vfs: pass 'struct file *' as parameter to ->check_flags() methods
Subsystems (6)
PATCH 1/2 vfs: pass 'struct file *' as parameter to ->check_flags() methods
Along with corresponding changes in -
- Documentation/
- nfs
- bad_inodes.c
- fcntl.c
--- Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- fs/bad_inode.c | 2 +- fs/fcntl.c | 2 +- fs/nfs/file.c | 6 +++--- include/linux/fs.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
Documentation/filesystems/Locking +1 -1
@@ -426,7 +426,7 @@ prototypes: loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); - int (*check_flags)(int); + int (*check_flags)(struct file *, int); int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
Documentation/filesystems/vfs.txt +1 -1
@@ -764,7 +764,7 @@ struct file_operations { ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *); ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); - int (*check_flags)(int); + int (*check_flags)(struct file *, int); int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);
fs/bad_inode.c +1 -1
@@ -120,7 +120,7 @@ static unsigned long bad_file_get_unmapped_area(struct file *file,return -EIO ; } -static int bad_file_check_flags (int flags) +static int bad_file_check_flags (struct file *filp,int flags) {return -EIO ; }
fs/fcntl.c +1 -1
@@ -174,7 +174,7 @@ static int setfl(int fd, struct file * filp, unsigned long arg) }if (filp->f_op && filp->f_op->check_flags) - error = filp->f_op->check_flags (arg); + error = filp->f_op->check_flags (filp, arg);if (error)return error;
fs/nfs/file.c +3 -3
@@ -56,7 +56,7 @@ static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, unsigned long nr_segs, loff_t pos);static int nfs_file_flush (struct file *,fl_owner_t id);static int nfs_file_fsync (struct file *,int datasync); -static int nfs_check_flags (int flags); +static int nfs_check_flags (struct file *,int flags);static int nfs_lock (struct file *filp,int cmd,struct file_lock *fl);static int nfs_flock (struct file *filp,int cmd,struct file_lock *fl);static int nfs_setlease (struct file *file,long arg,struct file_lock **fl);
@@ -105,7 +105,7 @@ const struct inode_operations nfs3_file_inode_operations = {# define IS_SWAPFILE (inode) (0)#endif -static int nfs_check_flags (int flags) +static int nfs_check_flags (struct file *filp,int flags) {if ((flags & (O_APPEND |O_DIRECT )) == (O_APPEND |O_DIRECT ))return -EINVAL ;
@@ -126,7 +126,7 @@ nfs_file_open(struct inode *inode, struct file *filp) filp->f_path.dentry->d_name.name);nfs_inc_stats (inode,NFSIOS_VFSOPEN ); - res =nfs_check_flags (filp->f_flags); + res =nfs_check_flags (filp, filp->f_flags);if (res)return res;
include/linux/fs.h +1 -1
@@ -1564,7 +1564,7 @@ struct file_operations {int (*lock) (struct file *,int ,struct file_lock *);ssize_t (*sendpage) (struct file *,struct page *,int ,size_t ,loff_t *,int );unsigned long (*get_unmapped_area)(struct file *,unsigned long ,unsigned long ,unsigned long ,unsigned long ); -int (*check_flags)(int ); +int (*check_flags)(struct file *,int );int (*flock) (struct file *,int ,struct file_lock *);ssize_t (*splice_write)(struct pipe_inode_info *,struct file *,loff_t *,size_t ,unsigned int );ssize_t (*splice_read)(struct file *,loff_t *,struct pipe_inode_info *,size_t ,unsigned int );
Signature · 9 lines
1.7.4.4 ------------------------------------------------------------------------------ 10 Tips for Better Web Security Learn 10 ways to better secure your business today. Topics covered include: Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, security Microsoft Exchange, secure Instant Messaging, and much more. http://www.accelacomm.com/jaw/sfnl/114/51426210/
PATCH 2/2 fuse: permit O_DIRECT flag in open()
In reply to a message not in the archivebut do not permit setting of O_DIRECT flag via fcntl() (or unsetting)
--- fs/fuse/file.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)
fs/fuse/file.c +23 -4
@@ -154,6 +154,18 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,return err; } +if (file->f_flags &O_DIRECT ) { +/* set fuse_direct_io_file_operations as fops in +fuse_finish_open as though the FS enforced direct_io +*/ + outarg.open_flags |=FOPEN_DIRECT_IO ; + +/* make VFS believe we don't support O_DIRECT till we +implement a_ops->direct_IO +*/ + file->f_flags &= ~O_DIRECT ; + } +if (isdir) outarg.open_flags &= ~FOPEN_DIRECT_IO ;
@@ -193,10 +205,6 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)struct fuse_conn *fc =get_fuse_conn (inode);int err; -/* VFS checks this, but only _after_ ->open() */ -if (file->f_flags &O_DIRECT ) -return -EINVAL ; - err =generic_file_open (inode, file);if (err)return err;
@@ -2132,6 +2140,15 @@ int fuse_notify_poll_wakeup(struct fuse_conn *fc,return 0 ; } + +static int fuse_check_flags (struct file *filp,int flags) +{ +if ((filp->f_flags ^ flags) &O_DIRECT ) +return -EINVAL ; +return 0 ; +} + +static const struct file_operations fuse_file_operations = { .llseek = fuse_file_llseek, .read = do_sync_read,
@@ -2149,6 +2166,7 @@ static const struct file_operations fuse_file_operations = { .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, .poll = fuse_file_poll, + .check_flags = fuse_check_flags, };static const struct file_operations fuse_direct_io_file_operations = {
@@ -2165,6 +2183,7 @@ static const struct file_operations fuse_direct_io_file_operations = { .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, .poll = fuse_file_poll, + .check_flags = fuse_check_flags,/* no splice_read */ };
Signature · 9 lines
1.7.4.4 ------------------------------------------------------------------------------ 10 Tips for Better Web Security Learn 10 ways to better secure your business today. Topics covered include: Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, security Microsoft Exchange, secure Instant Messaging, and much more. http://www.accelacomm.com/jaw/sfnl/114/51426210/
Quoted 6 lines · Anand Avati
Along with corresponding changes in -
-
Documentation/
- nfs
-bad_inodes.c
-fcntl.c
Patch looks good to me.
You should add some better description to the patch. Listing the changed files isn't needed, it's apparent from the diffstat below. Rather you should describe why this is needed.
You should also add a "Signed-off-by:" line.
Thanks,
Miklos
Quoted 105 lines
--- Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- fs/bad_inode.c | 2 +- fs/fcntl.c | 2 +- fs/nfs/file.c | 6 +++--- include/linux/fs.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)Documentation/filesystems/Locking +1
-1@@ -426,7 +426,7 @@ prototypes: loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); - int (*check_flags)(int); + int (*check_flags)(struct file *, int); int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);Documentation/filesystems/vfs.txt +1
-1@@ -764,7 +764,7 @@ struct file_operations { ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *); ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); - int (*check_flags)(int); + int (*check_flags)(struct file *, int); int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);fs/bad_inode.c +1
-1@@ -120,7 +120,7 @@ static unsigned long bad_file_get_unmapped_area(struct file *file,return -EIO ; } -static int bad_file_check_flags (int flags) +static int bad_file_check_flags (struct file *filp,int flags) {return -EIO ; }fs/fcntl.c +1
-1@@ -174,7 +174,7 @@ static int setfl(int fd, struct file * filp, unsigned long arg) }if (filp->f_op && filp->f_op->check_flags) - error = filp->f_op->check_flags (arg); + error = filp->f_op->check_flags (filp, arg);if (error)return error;fs/nfs/file.c +3
-3@@ -56,7 +56,7 @@ static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, unsigned long nr_segs, loff_t pos);static int nfs_file_flush (struct file *,fl_owner_t id);static int nfs_file_fsync (struct file *,int datasync); -static int nfs_check_flags (int flags); +static int nfs_check_flags (struct file *,int flags);static int nfs_lock (struct file *filp,int cmd,struct file_lock *fl);static int nfs_flock (struct file *filp,int cmd,struct file_lock *fl);static int nfs_setlease (struct file *file,long arg,struct file_lock **fl);@@ -105,7 +105,7 @@ const struct inode_operations nfs3_file_inode_operations = {# define IS_SWAPFILE (inode) (0)#endif -static int nfs_check_flags (int flags) +static int nfs_check_flags (struct file *filp,int flags) {if ((flags & (O_APPEND |O_DIRECT )) == (O_APPEND |O_DIRECT ))return -EINVAL ;@@ -126,7 +126,7 @@ nfs_file_open(struct inode *inode, struct file *filp) filp->f_path.dentry->d_name.name);nfs_inc_stats (inode,NFSIOS_VFSOPEN ); - res =nfs_check_flags (filp->f_flags); + res =nfs_check_flags (filp, filp->f_flags);if (res)return res;include/linux/fs.h +1
-1@@ -1564,7 +1564,7 @@ struct file_operations {int (*lock) (struct file *,int ,struct file_lock *);ssize_t (*sendpage) (struct file *,struct page *,int ,size_t ,loff_t *,int );unsigned long (*get_unmapped_area)(struct file *,unsigned long ,unsigned long ,unsigned long ,unsigned long ); -int (*check_flags)(int ); +int (*check_flags)(struct file *,int );int (*flock) (struct file *,int ,struct file_lock *);ssize_t (*splice_write)(struct pipe_inode_info *,struct file *,loff_t *,size_t ,unsigned int );ssize_t (*splice_read)(struct file *,loff_t *,struct pipe_inode_info *,size_t ,unsigned int );
Miklos Szeredi
maintainerRe: [PATCH 2/2] fuse: permit O_DIRECT flag in open()
In reply to Anand AvatiQuoted 1 line · Anand Avati
but do not permit setting of
O_DIRECTflag viafcntl()(or unsetting)
Again, some more verbose description would be good, as well as a Signed-off-by.
fs/fuse/file.c int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, · line 157
Quoted 13 lines
--- fs/fuse/file.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)fs/fuse/file.c +1
-0@@ -154,6 +154,18 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,return err; } +if (file->f_flags &O_DIRECT ) {
Please use tabs, not spaces.
Before submission you should run your patch through scripts/checkpatch.pl to filter out such problems.
fs/fuse/file.c int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, · line 161
Quoted 4 lines
fs/fuse/file.c +4
-0+/* set fuse_direct_io_file_operations as fops in +fuse_finish_open as though the FS enforced direct_io +*/ + outarg.open_flags |=FOPEN_DIRECT_IO ;
As I said earlier, I don't like this. Rather the userspace filesystem should set FOPEN_DIRECT_IO on O_DIRECT if it wants to.
And if the userspace filesystem has not set FOPEN_DIRECT_IO and O_DIRECT is set then we should return -EINVAL.
Thanks,
Miklos
Quoted 52 lines
fs/fuse/file.c +18
-4+ +/* make VFS believe we don't support O_DIRECT till we +implement a_ops->direct_IO +*/ + file->f_flags &= ~O_DIRECT ; + } +if (isdir) outarg.open_flags &= ~FOPEN_DIRECT_IO ;@@ -193,10 +205,6 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)struct fuse_conn *fc =get_fuse_conn (inode);int err; -/* VFS checks this, but only _after_ ->open() */ -if (file->f_flags &O_DIRECT ) -return -EINVAL ; - err =generic_file_open (inode, file);if (err)return err;@@ -2132,6 +2140,15 @@ int fuse_notify_poll_wakeup(struct fuse_conn *fc,return 0 ; } + +static int fuse_check_flags (struct file *filp,int flags) +{ +if ((filp->f_flags ^ flags) &O_DIRECT ) +return -EINVAL ; +return 0 ; +} + +static const struct file_operations fuse_file_operations = { .llseek = fuse_file_llseek, .read = do_sync_read,@@ -2149,6 +2166,7 @@ static const struct file_operations fuse_file_operations = { .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, .poll = fuse_file_poll, + .check_flags = fuse_check_flags, };static const struct file_operations fuse_direct_io_file_operations = {@@ -2165,6 +2183,7 @@ static const struct file_operations fuse_direct_io_file_operations = { .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, .poll = fuse_file_poll, + .check_flags = fuse_check_flags,/* no splice_read */ };
Re: [PATCH 2/2] fuse: permit O_DIRECT flag in open()
In reply to a message not in the archiveI do not like it. Setting O_DIRECT to the flags is an option which should be set in the filesystem, not in the general library.
I'm working on a overlay fs with various backends, like a normal (part of) partition on a ATA harddisk, a USB stick, a Cdrom, a mounted SMB share.... and it is able to set the O_DIRECT flag, but always per backend.
Stef
2011/7/22 Miklos Szeredi <[email protected]>:
Quoted 5 lines
Quoted 1 line · Anand Avati
but do not permit setting of
O_DIRECTflag viafcntl()(or unsetting)Again, some more verbose description would be good, as well as a
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html