Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull misc vfs updates from Al Viro:
 "No common topic whatsoever in those, sorry"

* 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs: define inode flags using bit numbers
  iov_iter: Move unnecessary inclusion of crypto/hash.h
  dlmfs: clean up dlmfs_file_{read,write}() a bit
This commit is contained in:
Linus Torvalds 2020-08-07 21:14:30 -07:00
commit b79675e15a
18 changed files with 45 additions and 75 deletions

View File

@ -9,6 +9,7 @@
#include <linux/kallsyms.h> #include <linux/kallsyms.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/kprobes.h> #include <linux/kprobes.h>
#include <linux/wait.h> #include <linux/wait.h>

View File

@ -20,6 +20,7 @@
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/slab.h>
#include "sf-pdma.h" #include "sf-pdma.h"

View File

@ -15,6 +15,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/remoteproc.h> #include <linux/remoteproc.h>
#include <linux/slab.h>
#include "st_fdma.h" #include "st_fdma.h"

View File

@ -12,6 +12,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_dma.h> #include <linux/of_dma.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h>
#include "dmaengine.h" #include "dmaengine.h"
#include "virt-dma.h" #include "virt-dma.h"

View File

@ -4,6 +4,7 @@
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/slab.h>
#include <linux/uacce.h> #include <linux/uacce.h>
static struct class *uacce_class; static struct class *uacce_class;

View File

@ -7,6 +7,7 @@
#include <linux/pstore_blk.h> #include <linux/pstore_blk.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/slab.h>
static struct mtdpstore_context { static struct mtdpstore_context {
int index; int index;

View File

@ -17,6 +17,7 @@
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/slab.h>
/* /*
* HPNFC can work in 3 modes: * HPNFC can work in 3 modes:

View File

@ -26,6 +26,7 @@
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/soc/qcom/mdt_loader.h> #include <linux/soc/qcom/mdt_loader.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/slab.h>
#include "remoteproc_internal.h" #include "remoteproc_internal.h"
#include "qcom_common.h" #include "qcom_common.h"

View File

@ -5,6 +5,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>

View File

@ -3,6 +3,7 @@
* Copyright (C) 2007 Oracle. All rights reserved. * Copyright (C) 2007 Oracle. All rights reserved.
*/ */
#include <crypto/hash.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>

View File

@ -221,47 +221,17 @@ static __poll_t dlmfs_file_poll(struct file *file, poll_table *wait)
return event; return event;
} }
static ssize_t dlmfs_file_read(struct file *filp, static ssize_t dlmfs_file_read(struct file *file,
char __user *buf, char __user *buf,
size_t count, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
int bytes_left; char lvb[DLM_LVB_LEN];
ssize_t got;
char *lvb_buf;
struct inode *inode = file_inode(filp);
mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", if (!user_dlm_read_lvb(file_inode(file), lvb))
inode->i_ino, count, *ppos);
if (*ppos >= i_size_read(inode))
return 0; return 0;
/* don't read past the lvb */ return simple_read_from_buffer(buf, count, ppos, lvb, sizeof(lvb));
if (count > i_size_read(inode) - *ppos)
count = i_size_read(inode) - *ppos;
if (!count)
return 0;
lvb_buf = kmalloc(count, GFP_NOFS);
if (!lvb_buf)
return -ENOMEM;
got = user_dlm_read_lvb(inode, lvb_buf, count);
if (got) {
BUG_ON(got != count);
bytes_left = copy_to_user(buf, lvb_buf, count);
count -= bytes_left;
} else
count = 0;
kfree(lvb_buf);
*ppos = *ppos + count;
mlog(0, "read %zu bytes\n", count);
return count;
} }
static ssize_t dlmfs_file_write(struct file *filp, static ssize_t dlmfs_file_write(struct file *filp,
@ -269,34 +239,28 @@ static ssize_t dlmfs_file_write(struct file *filp,
size_t count, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
char lvb_buf[DLM_LVB_LEN];
int bytes_left; int bytes_left;
char *lvb_buf;
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
inode->i_ino, count, *ppos); inode->i_ino, count, *ppos);
if (*ppos >= i_size_read(inode)) if (*ppos >= DLM_LVB_LEN)
return -ENOSPC; return -ENOSPC;
/* don't write past the lvb */ /* don't write past the lvb */
if (count > i_size_read(inode) - *ppos) if (count > DLM_LVB_LEN - *ppos)
count = i_size_read(inode) - *ppos; count = DLM_LVB_LEN - *ppos;
if (!count) if (!count)
return 0; return 0;
lvb_buf = kmalloc(count, GFP_NOFS);
if (!lvb_buf)
return -ENOMEM;
bytes_left = copy_from_user(lvb_buf, buf, count); bytes_left = copy_from_user(lvb_buf, buf, count);
count -= bytes_left; count -= bytes_left;
if (count) if (count)
user_dlm_write_lvb(inode, lvb_buf, count); user_dlm_write_lvb(inode, lvb_buf, count);
kfree(lvb_buf);
*ppos = *ppos + count; *ppos = *ppos + count;
mlog(0, "wrote %zu bytes\n", count); mlog(0, "wrote %zu bytes\n", count);
return count; return count;

View File

@ -547,24 +547,20 @@ void user_dlm_write_lvb(struct inode *inode,
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
} }
ssize_t user_dlm_read_lvb(struct inode *inode, bool user_dlm_read_lvb(struct inode *inode, char *val)
char *val,
unsigned int len)
{ {
struct user_lock_res *lockres = &DLMFS_I(inode)->ip_lockres; struct user_lock_res *lockres = &DLMFS_I(inode)->ip_lockres;
char *lvb; char *lvb;
ssize_t ret = len; bool ret = true;
BUG_ON(len > DLM_LVB_LEN);
spin_lock(&lockres->l_lock); spin_lock(&lockres->l_lock);
BUG_ON(lockres->l_level < DLM_LOCK_PR); BUG_ON(lockres->l_level < DLM_LOCK_PR);
if (ocfs2_dlm_lvb_valid(&lockres->l_lksb)) { if (ocfs2_dlm_lvb_valid(&lockres->l_lksb)) {
lvb = ocfs2_dlm_lvb(&lockres->l_lksb); lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
memcpy(val, lvb, len); memcpy(val, lvb, DLM_LVB_LEN);
} else } else
ret = 0; ret = false;
spin_unlock(&lockres->l_lock); spin_unlock(&lockres->l_lock);
return ret; return ret;

View File

@ -66,9 +66,7 @@ void user_dlm_cluster_unlock(struct user_lock_res *lockres,
void user_dlm_write_lvb(struct inode *inode, void user_dlm_write_lvb(struct inode *inode,
const char *val, const char *val,
unsigned int len); unsigned int len);
ssize_t user_dlm_read_lvb(struct inode *inode, bool user_dlm_read_lvb(struct inode *inode, char *val);
char *val,
unsigned int len);
struct ocfs2_cluster_connection *user_dlm_register(const struct qstr *name); struct ocfs2_cluster_connection *user_dlm_register(const struct qstr *name);
void user_dlm_unregister(struct ocfs2_cluster_connection *conn); void user_dlm_unregister(struct ocfs2_cluster_connection *conn);
void user_dlm_set_locking_protocol(void); void user_dlm_set_locking_protocol(void);

View File

@ -1946,27 +1946,27 @@ struct super_operations {
/* /*
* Inode flags - they have no relation to superblock flags now * Inode flags - they have no relation to superblock flags now
*/ */
#define S_SYNC 1 /* Writes are synced at once */ #define S_SYNC (1 << 0) /* Writes are synced at once */
#define S_NOATIME 2 /* Do not update access times */ #define S_NOATIME (1 << 1) /* Do not update access times */
#define S_APPEND 4 /* Append-only file */ #define S_APPEND (1 << 2) /* Append-only file */
#define S_IMMUTABLE 8 /* Immutable file */ #define S_IMMUTABLE (1 << 3) /* Immutable file */
#define S_DEAD 16 /* removed, but still open directory */ #define S_DEAD (1 << 4) /* removed, but still open directory */
#define S_NOQUOTA 32 /* Inode is not counted to quota */ #define S_NOQUOTA (1 << 5) /* Inode is not counted to quota */
#define S_DIRSYNC 64 /* Directory modifications are synchronous */ #define S_DIRSYNC (1 << 6) /* Directory modifications are synchronous */
#define S_NOCMTIME 128 /* Do not update file c/mtime */ #define S_NOCMTIME (1 << 7) /* Do not update file c/mtime */
#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ #define S_SWAPFILE (1 << 8) /* Do not truncate: swapon got its bmaps */
#define S_PRIVATE 512 /* Inode is fs-internal */ #define S_PRIVATE (1 << 9) /* Inode is fs-internal */
#define S_IMA 1024 /* Inode has an associated IMA struct */ #define S_IMA (1 << 10) /* Inode has an associated IMA struct */
#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ #define S_AUTOMOUNT (1 << 11) /* Automount/referral quasi-directory */
#define S_NOSEC 4096 /* no suid or xattr security attributes */ #define S_NOSEC (1 << 12) /* no suid or xattr security attributes */
#ifdef CONFIG_FS_DAX #ifdef CONFIG_FS_DAX
#define S_DAX 8192 /* Direct Access, avoiding the page cache */ #define S_DAX (1 << 13) /* Direct Access, avoiding the page cache */
#else #else
#define S_DAX 0 /* Make all the DAX code disappear */ #define S_DAX 0 /* Make all the DAX code disappear */
#endif #endif
#define S_ENCRYPTED 16384 /* Encrypted file (using fs/crypto/) */ #define S_ENCRYPTED (1 << 14) /* Encrypted file (using fs/crypto/) */
#define S_CASEFOLD 32768 /* Casefolded file */ #define S_CASEFOLD (1 << 15) /* Casefolded file */
#define S_VERITY 65536 /* Verity file (using fs/verity/) */ #define S_VERITY (1 << 16) /* Verity file (using fs/verity/) */
/* /*
* Note that nosuid etc flags are inode-specific: setting some file-system * Note that nosuid etc flags are inode-specific: setting some file-system

View File

@ -238,6 +238,7 @@
SKB_DATA_ALIGN(sizeof(struct sk_buff)) + \ SKB_DATA_ALIGN(sizeof(struct sk_buff)) + \
SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
struct ahash_request;
struct net_device; struct net_device;
struct scatterlist; struct scatterlist;
struct pipe_inode_info; struct pipe_inode_info;

View File

@ -10,6 +10,7 @@
#include <linux/compiler.h> /* __user */ #include <linux/compiler.h> /* __user */
#include <uapi/linux/socket.h> #include <uapi/linux/socket.h>
struct file;
struct pid; struct pid;
struct cred; struct cred;
struct socket; struct socket;

View File

@ -7,7 +7,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/thread_info.h> #include <linux/thread_info.h>
#include <crypto/hash.h>
#include <uapi/linux/uio.h> #include <uapi/linux/uio.h>
struct page; struct page;

View File

@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
#include <crypto/hash.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/bvec.h> #include <linux/bvec.h>
#include <linux/uio.h> #include <linux/uio.h>
@ -1567,7 +1568,7 @@ EXPORT_SYMBOL(csum_and_copy_to_iter);
size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
struct iov_iter *i) struct iov_iter *i)
{ {
#ifdef CONFIG_CRYPTO #ifdef CONFIG_CRYPTO_HASH
struct ahash_request *hash = hashp; struct ahash_request *hash = hashp;
struct scatterlist sg; struct scatterlist sg;
size_t copied; size_t copied;