fs: drop the fl_owner_t argument from ->flush
Subsystems (19)
RFC PATCH 1/1 fs: drop the fl_owner_t argument from ->flush
We have a long-term goal to deprecate use the fl_owner_t, and instead use something like an unsigned long to represent a filelock owner.
None of flush file_operations for kernel-based filesystems do anything with their fl_owner_t argument. ecryptfs and overlayfs just pass the argument through to the lower filesystem, and most just ignore it.
The exception here is FUSE, which coverts and passes this value to userland. For now, this patch just universally sets the lock_owner field to 0.
--- arch/powerpc/platforms/cell/spufs/file.c | 4 ++-- drivers/android/binder.c | 2 +- drivers/char/ps3flash.c | 2 +- drivers/char/xillybus/xillybus_core.c | 2 +- drivers/char/xillybus/xillyusb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- drivers/scsi/st.c | 2 +- drivers/usb/class/cdc-wdm.c | 2 +- drivers/usb/class/usbtmc.c | 2 +- drivers/usb/usb-skeleton.c | 2 +- fs/cifs/cifsfs.h | 2 +- fs/cifs/file.c | 2 +- fs/ecryptfs/file.c | 4 ++-- fs/f2fs/file.c | 2 +- fs/fuse/file.c | 4 ++-- fs/nfs/file.c | 2 +- fs/nfs/nfs4file.c | 2 +- fs/open.c | 2 +- fs/orangefs/file.c | 2 +- fs/overlayfs/file.c | 4 ++-- include/linux/fs.h | 2 +- ipc/mqueue.c | 2 +- kernel/acct.c | 2 +- 23 files changed, 27 insertions(+), 27 deletions(-)
It would be nice to do this, but the FUSE thing may make it impossible.
Is there a way to audit the various flush operations in userland FUSE filesystems and see whether they do anything with the lock_owner? I did take a peek at ceph-fuse and it doesn't care about the lock_owner in its flush op. I'm at a loss as to how to check this more broadly.
If we can't do this right away, then perhaps we could try to change this as part of the FUSE userland API first, and follow up with a change like this later.
Thoughts?
arch/powerpc/platforms/cell/spufs/file.c +2 -2
@@ -1697,7 +1697,7 @@ static __poll_t spufs_mfc_poll(struct file *file,poll_table *wait)return mask; } -static int spufs_mfc_flush (struct file *file,fl_owner_t id) +static int spufs_mfc_flush (struct file *file) {struct spu_context *ctx = file->private_data;int ret;
@@ -1729,7 +1729,7 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int dataint err =file_write_and_wait_range (file, start, end);if (!err) {inode_lock (inode); - err =spufs_mfc_flush (file,NULL ); + err =spufs_mfc_flush (file);inode_unlock (inode); }return err;
drivers/android/binder.c +1 -1
@@ -5675,7 +5675,7 @@ static int binder_open(struct inode *nodp, struct file *filp)return 0 ; } -static int binder_flush (struct file *filp,fl_owner_t id) +static int binder_flush (struct file *filp) {struct binder_proc *proc = filp->private_data;
drivers/char/ps3flash.c +1 -1
@@ -269,7 +269,7 @@ static ssize_t ps3flash_kernel_write(const void *buf, size_t count,return res; } -static int ps3flash_flush (struct file *file,fl_owner_t id) +static int ps3flash_flush (struct file *file) {return ps3flash_writeback (ps3flash_dev); }
drivers/char/xillybus/xillybus_core.c +1 -1
@@ -1174,7 +1174,7 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout)return rc; } -static int xillybus_flush (struct file *filp,fl_owner_t id) +static int xillybus_flush (struct file *filp) {if (!(filp->f_mode &FMODE_WRITE ))return 0 ;
drivers/char/xillybus/xillyusb.c +1 -1
@@ -1592,7 +1592,7 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,return rc; } -static int xillyusb_flush (struct file *filp,fl_owner_t id) +static int xillyusb_flush (struct file *filp) {struct xillyusb_channel *chan = filp->private_data;int rc;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -2675,7 +2675,7 @@ static const struct dev_pm_ops amdgpu_pm_ops = { .runtime_idle = amdgpu_pmops_runtime_idle, }; -static int amdgpu_flush (struct file *f,fl_owner_t id) +static int amdgpu_flush (struct file *f) {struct drm_file *file_priv = f->private_data;struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
drivers/scsi/st.c +1 -1
@@ -1338,7 +1338,7 @@ static int st_open(struct inode *inode, struct file *filp)/* Flush the tape buffer before close */ -static int st_flush (struct file *filp,fl_owner_t id) +static int st_flush (struct file *filp) {int result =0 , result2;unsigned char cmd[MAX_COMMAND_SIZE ];
drivers/usb/class/cdc-wdm.c +1 -1
@@ -674,7 +674,7 @@ static int wdm_fsync(struct file *file, loff_t start, loff_t end, int datasync)* malicious or defective hardware which ceased communication after close() was * implicitly called due to process termination. */ -static int wdm_flush (struct file *file,fl_owner_t id) +static int wdm_flush (struct file *file) {return wdm_wait_for_response (file,WDM_FLUSH_TIMEOUT ); }
drivers/usb/class/usbtmc.c +1 -1
@@ -212,7 +212,7 @@ static int usbtmc_open(struct inode *inode, struct file *filp)/* * usbtmc_flush - called before file handle is closed */ -static int usbtmc_flush (struct file *file,fl_owner_t id) +static int usbtmc_flush (struct file *file) {struct usbtmc_file_data *file_data;struct usbtmc_device_data *data;
drivers/usb/usb-skeleton.c +1 -1
@@ -133,7 +133,7 @@ static int skel_release(struct inode *inode, struct file *file)return 0 ; } -static int skel_flush (struct file *file,fl_owner_t id) +static int skel_flush (struct file *file) {struct usb_skel *dev;int res;
fs/cifs/cifsfs.h +1 -1
@@ -104,7 +104,7 @@ extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock);extern int cifs_lock (struct file *,int ,struct file_lock *);extern int cifs_fsync (struct file *,loff_t ,loff_t ,int );extern int cifs_strict_fsync (struct file *,loff_t ,loff_t ,int ); -extern int cifs_flush (struct file *,fl_owner_t id); +extern int cifs_flush (struct file *);extern int cifs_file_mmap (struct file * ,struct vm_area_struct *);extern int cifs_file_strict_mmap (struct file * ,struct vm_area_struct *);extern const struct file_operations cifs_dir_ops;
fs/cifs/file.c +1 -1
@@ -3028,7 +3028,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)* As file closes, flush all cached write data for this inode checking * for write behind errors. */ -int cifs_flush (struct file *file,fl_owner_t id) +int cifs_flush (struct file *file) {struct inode *inode =file_inode (file);int rc =0 ;
fs/ecryptfs/file.c +2 -2
@@ -281,13 +281,13 @@ static int ecryptfs_dir_open(struct inode *inode, struct file *file)return 0 ; } -static int ecryptfs_flush (struct file *file,fl_owner_t td) +static int ecryptfs_flush (struct file *file) {struct file *lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->flush) {filemap_write_and_wait (file->f_mapping); -return lower_file->f_op->flush (lower_file, td); +return lower_file->f_op->flush (lower_file); }return 0 ;
fs/f2fs/file.c +1 -1
@@ -1869,7 +1869,7 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)return 0 ; } -static int f2fs_file_flush (struct file *file,fl_owner_t id) +static int f2fs_file_flush (struct file *file) {struct inode *inode =file_inode (file);
fs/fuse/file.c +2 -2
@@ -478,7 +478,7 @@ static void fuse_sync_writes(struct inode *inode)fuse_release_nowrite (inode); } -static int fuse_flush (struct file *file,fl_owner_t id) +static int fuse_flush (struct file *file) {struct inode *inode =file_inode (file);struct fuse_mount *fm =get_fuse_mount (inode);
@@ -511,7 +511,7 @@ static int fuse_flush(struct file *file, fl_owner_t id)memset (&inarg,0 ,sizeof (inarg)); inarg.fh = ff->fh; - inarg.lock_owner =fuse_lock_owner_id (fm->fc, id); + inarg.lock_owner =fuse_lock_owner_id (fm->fc,0 ); args.opcode =FUSE_FLUSH ; args.nodeid =get_node_id (inode); args.in_numargs =1 ;
fs/nfs/file.c +1 -1
@@ -136,7 +136,7 @@ EXPORT_SYMBOL_GPL(nfs_file_llseek);* Flush all dirty pages, and check for write errors. */ static int -nfs_file_flush (struct file *file,fl_owner_t id) +nfs_file_flush (struct file *file) {struct inode *inode =file_inode (file);errseq_t since;
fs/nfs/nfs4file.c +1 -1
@@ -111,7 +111,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)* Flush all dirty pages, and check for write errors. */ static int -nfs4_file_flush (struct file *file,fl_owner_t id) +nfs4_file_flush (struct file *file) {struct inode *inode =file_inode (file);errseq_t since;
fs/open.c +1 -1
@@ -1418,7 +1418,7 @@ int filp_close(struct file *filp, fl_owner_t id) }if (filp->f_op->flush) - retval = filp->f_op->flush (filp, id); + retval = filp->f_op->flush (filp);if (likely (!(filp->f_mode &FMODE_PATH ))) {dnotify_flush (filp, id);
fs/orangefs/file.c +1 -1
@@ -531,7 +531,7 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)return rc; } -static int orangefs_flush (struct file *file,fl_owner_t id) +static int orangefs_flush (struct file *file) {/* * This is vfs_fsync_range(file, 0, LLONG_MAX, 0) without the
fs/overlayfs/file.c +2 -2
@@ -641,7 +641,7 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, remap_flags, op); } -static int ovl_flush (struct file *file,fl_owner_t id) +static int ovl_flush (struct file *file) {struct fd real;const struct cred *old_cred;
@@ -653,7 +653,7 @@ static int ovl_flush(struct file *file, fl_owner_t id)if (real.file->f_op->flush) { old_cred =ovl_override_creds (file_inode (file)->i_sb); - err = real.file->f_op->flush (real.file, id); + err = real.file->f_op->flush (real.file);revert_creds (old_cred); }fdput (real);
include/linux/fs.h +1 -1
@@ -1793,7 +1793,7 @@ struct file_operations {int (*mmap) (struct file *,struct vm_area_struct *);unsigned long mmap_supported_flags;int (*open) (struct inode *,struct file *); -int (*flush) (struct file *,fl_owner_t id); +int (*flush) (struct file *);int (*release) (struct inode *,struct file *);int (*fsync) (struct file *,loff_t ,loff_t ,int datasync);int (*fasync) (int ,struct file *,int );
ipc/mqueue.c +1 -1
@@ -660,7 +660,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,return ret; } -static int mqueue_flush_file (struct file *filp,fl_owner_t id) +static int mqueue_flush_file (struct file *filp) {struct mqueue_inode_info *info =MQUEUE_I (file_inode (filp));
kernel/acct.c +1 -1
@@ -204,7 +204,7 @@ static void close_work(struct work_struct *work) struct bsd_acct_struct *acct = container_of(work, struct bsd_acct_struct, work);struct file *file = acct->file;if (file->f_op->flush) - file->f_op->flush (file,NULL ); + file->f_op->flush (file);__fput_sync (file);complete (&acct->done); }
Signature · 1 line
2.38.1
RFC PATCH 1/1 fs: drop the fl_owner_t argument from ->flush
We have a long-term goal to deprecate use the fl_owner_t, and instead use something like an unsigned long to represent a filelock owner.
None of flush file_operations for kernel-based filesystems do anything with their fl_owner_t argument. ecryptfs and overlayfs just pass the argument through to the lower filesystem, and most just ignore it.
The exception here is FUSE, which coverts and passes this value to userland. For now, this patch just universally sets the lock_owner field to 0.
--- arch/powerpc/platforms/cell/spufs/file.c | 4 ++-- drivers/android/binder.c | 2 +- drivers/char/ps3flash.c | 2 +- drivers/char/xillybus/xillybus_core.c | 2 +- drivers/char/xillybus/xillyusb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- drivers/scsi/st.c | 2 +- drivers/usb/class/cdc-wdm.c | 2 +- drivers/usb/class/usbtmc.c | 2 +- drivers/usb/usb-skeleton.c | 2 +- fs/cifs/cifsfs.h | 2 +- fs/cifs/file.c | 2 +- fs/ecryptfs/file.c | 4 ++-- fs/f2fs/file.c | 2 +- fs/fuse/file.c | 4 ++-- fs/nfs/file.c | 2 +- fs/nfs/nfs4file.c | 2 +- fs/open.c | 2 +- fs/orangefs/file.c | 2 +- fs/overlayfs/file.c | 4 ++-- include/linux/fs.h | 2 +- ipc/mqueue.c | 2 +- kernel/acct.c | 2 +- 23 files changed, 27 insertions(+), 27 deletions(-)
It would be nice to do this, but the FUSE thing may make it impossible.
Is there a way to audit the various flush operations in userland FUSE filesystems and see whether they do anything with the lock_owner? I did take a peek at ceph-fuse and it doesn't care about the lock_owner in its flush op. I'm at a loss as to how to check this more broadly.
If we can't do this right away, then perhaps we could try to change this as part of the FUSE userland API first, and follow up with a change like this later.
Thoughts?
arch/powerpc/platforms/cell/spufs/file.c +2 -2
@@ -1697,7 +1697,7 @@ static __poll_t spufs_mfc_poll(struct file *file,poll_table *wait)return mask; } -static int spufs_mfc_flush (struct file *file,fl_owner_t id) +static int spufs_mfc_flush (struct file *file) {struct spu_context *ctx = file->private_data;int ret;
@@ -1729,7 +1729,7 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int dataint err =file_write_and_wait_range (file, start, end);if (!err) {inode_lock (inode); - err =spufs_mfc_flush (file,NULL ); + err =spufs_mfc_flush (file);inode_unlock (inode); }return err;
drivers/android/binder.c +1 -1
@@ -5675,7 +5675,7 @@ static int binder_open(struct inode *nodp, struct file *filp)return 0 ; } -static int binder_flush (struct file *filp,fl_owner_t id) +static int binder_flush (struct file *filp) {struct binder_proc *proc = filp->private_data;
drivers/char/ps3flash.c +1 -1
@@ -269,7 +269,7 @@ static ssize_t ps3flash_kernel_write(const void *buf, size_t count,return res; } -static int ps3flash_flush (struct file *file,fl_owner_t id) +static int ps3flash_flush (struct file *file) {return ps3flash_writeback (ps3flash_dev); }
drivers/char/xillybus/xillybus_core.c +1 -1
@@ -1174,7 +1174,7 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout)return rc; } -static int xillybus_flush (struct file *filp,fl_owner_t id) +static int xillybus_flush (struct file *filp) {if (!(filp->f_mode &FMODE_WRITE ))return 0 ;
drivers/char/xillybus/xillyusb.c +1 -1
@@ -1592,7 +1592,7 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,return rc; } -static int xillyusb_flush (struct file *filp,fl_owner_t id) +static int xillyusb_flush (struct file *filp) {struct xillyusb_channel *chan = filp->private_data;int rc;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -2675,7 +2675,7 @@ static const struct dev_pm_ops amdgpu_pm_ops = { .runtime_idle = amdgpu_pmops_runtime_idle, }; -static int amdgpu_flush (struct file *f,fl_owner_t id) +static int amdgpu_flush (struct file *f) {struct drm_file *file_priv = f->private_data;struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
drivers/scsi/st.c +1 -1
@@ -1338,7 +1338,7 @@ static int st_open(struct inode *inode, struct file *filp)/* Flush the tape buffer before close */ -static int st_flush (struct file *filp,fl_owner_t id) +static int st_flush (struct file *filp) {int result =0 , result2;unsigned char cmd[MAX_COMMAND_SIZE ];
drivers/usb/class/cdc-wdm.c +1 -1
@@ -674,7 +674,7 @@ static int wdm_fsync(struct file *file, loff_t start, loff_t end, int datasync)* malicious or defective hardware which ceased communication after close() was * implicitly called due to process termination. */ -static int wdm_flush (struct file *file,fl_owner_t id) +static int wdm_flush (struct file *file) {return wdm_wait_for_response (file,WDM_FLUSH_TIMEOUT ); }
drivers/usb/class/usbtmc.c +1 -1
@@ -212,7 +212,7 @@ static int usbtmc_open(struct inode *inode, struct file *filp)/* * usbtmc_flush - called before file handle is closed */ -static int usbtmc_flush (struct file *file,fl_owner_t id) +static int usbtmc_flush (struct file *file) {struct usbtmc_file_data *file_data;struct usbtmc_device_data *data;
drivers/usb/usb-skeleton.c +1 -1
@@ -133,7 +133,7 @@ static int skel_release(struct inode *inode, struct file *file)return 0 ; } -static int skel_flush (struct file *file,fl_owner_t id) +static int skel_flush (struct file *file) {struct usb_skel *dev;int res;
fs/cifs/cifsfs.h +1 -1
@@ -104,7 +104,7 @@ extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock);extern int cifs_lock (struct file *,int ,struct file_lock *);extern int cifs_fsync (struct file *,loff_t ,loff_t ,int );extern int cifs_strict_fsync (struct file *,loff_t ,loff_t ,int ); -extern int cifs_flush (struct file *,fl_owner_t id); +extern int cifs_flush (struct file *);extern int cifs_file_mmap (struct file * ,struct vm_area_struct *);extern int cifs_file_strict_mmap (struct file * ,struct vm_area_struct *);extern const struct file_operations cifs_dir_ops;
fs/cifs/file.c +1 -1
@@ -3028,7 +3028,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)* As file closes, flush all cached write data for this inode checking * for write behind errors. */ -int cifs_flush (struct file *file,fl_owner_t id) +int cifs_flush (struct file *file) {struct inode *inode =file_inode (file);int rc =0 ;
fs/ecryptfs/file.c +2 -2
@@ -281,13 +281,13 @@ static int ecryptfs_dir_open(struct inode *inode, struct file *file)return 0 ; } -static int ecryptfs_flush (struct file *file,fl_owner_t td) +static int ecryptfs_flush (struct file *file) {struct file *lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->flush) {filemap_write_and_wait (file->f_mapping); -return lower_file->f_op->flush (lower_file, td); +return lower_file->f_op->flush (lower_file); }return 0 ;
fs/f2fs/file.c +1 -1
@@ -1869,7 +1869,7 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)return 0 ; } -static int f2fs_file_flush (struct file *file,fl_owner_t id) +static int f2fs_file_flush (struct file *file) {struct inode *inode =file_inode (file);
fs/fuse/file.c +2 -2
@@ -478,7 +478,7 @@ static void fuse_sync_writes(struct inode *inode)fuse_release_nowrite (inode); } -static int fuse_flush (struct file *file,fl_owner_t id) +static int fuse_flush (struct file *file) {struct inode *inode =file_inode (file);struct fuse_mount *fm =get_fuse_mount (inode);
@@ -511,7 +511,7 @@ static int fuse_flush(struct file *file, fl_owner_t id)memset (&inarg,0 ,sizeof (inarg)); inarg.fh = ff->fh; - inarg.lock_owner =fuse_lock_owner_id (fm->fc, id); + inarg.lock_owner =fuse_lock_owner_id (fm->fc,0 ); args.opcode =FUSE_FLUSH ; args.nodeid =get_node_id (inode); args.in_numargs =1 ;
fs/nfs/file.c +1 -1
@@ -136,7 +136,7 @@ EXPORT_SYMBOL_GPL(nfs_file_llseek);* Flush all dirty pages, and check for write errors. */ static int -nfs_file_flush (struct file *file,fl_owner_t id) +nfs_file_flush (struct file *file) {struct inode *inode =file_inode (file);errseq_t since;
fs/nfs/nfs4file.c +1 -1
@@ -111,7 +111,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)* Flush all dirty pages, and check for write errors. */ static int -nfs4_file_flush (struct file *file,fl_owner_t id) +nfs4_file_flush (struct file *file) {struct inode *inode =file_inode (file);errseq_t since;
fs/open.c +1 -1
@@ -1418,7 +1418,7 @@ int filp_close(struct file *filp, fl_owner_t id) }if (filp->f_op->flush) - retval = filp->f_op->flush (filp, id); + retval = filp->f_op->flush (filp);if (likely (!(filp->f_mode &FMODE_PATH ))) {dnotify_flush (filp, id);
fs/orangefs/file.c +1 -1
@@ -531,7 +531,7 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)return rc; } -static int orangefs_flush (struct file *file,fl_owner_t id) +static int orangefs_flush (struct file *file) {/* * This is vfs_fsync_range(file, 0, LLONG_MAX, 0) without the
fs/overlayfs/file.c +2 -2
@@ -641,7 +641,7 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, remap_flags, op); } -static int ovl_flush (struct file *file,fl_owner_t id) +static int ovl_flush (struct file *file) {struct fd real;const struct cred *old_cred;
@@ -653,7 +653,7 @@ static int ovl_flush(struct file *file, fl_owner_t id)if (real.file->f_op->flush) { old_cred =ovl_override_creds (file_inode (file)->i_sb); - err = real.file->f_op->flush (real.file, id); + err = real.file->f_op->flush (real.file);revert_creds (old_cred); }fdput (real);
include/linux/fs.h +1 -1
@@ -1793,7 +1793,7 @@ struct file_operations {int (*mmap) (struct file *,struct vm_area_struct *);unsigned long mmap_supported_flags;int (*open) (struct inode *,struct file *); -int (*flush) (struct file *,fl_owner_t id); +int (*flush) (struct file *);int (*release) (struct inode *,struct file *);int (*fsync) (struct file *,loff_t ,loff_t ,int datasync);int (*fasync) (int ,struct file *,int );
ipc/mqueue.c +1 -1
@@ -660,7 +660,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,return ret; } -static int mqueue_flush_file (struct file *filp,fl_owner_t id) +static int mqueue_flush_file (struct file *filp) {struct mqueue_inode_info *info =MQUEUE_I (file_inode (filp));
kernel/acct.c +1 -1
@@ -204,7 +204,7 @@ static void close_work(struct work_struct *work) struct bsd_acct_struct *acct = container_of(work, struct bsd_acct_struct, work);struct file *file = acct->file;if (file->f_op->flush) - file->f_op->flush (file,NULL ); + file->f_op->flush (file);__fput_sync (file);complete (&acct->done); }
Signature · 1 line
2.38.1
Miklos Szeredi
maintainerQuoted 7 lines · Jeff Layton
It would be nice to do this, but the FUSE thing may make it impossible.
Is there a way to audit the various flush operations in userland FUSE filesystems and see whether they do anything with the
lock_owner? I did take a peek at ceph-fuse and it doesn't care about thelock_ownerin its flush op. I'm at a loss as to how to check this more broadly.
Quoted 5 lines
If we can't do this right away, then perhaps we could try to change this as part of the FUSE userland API first, and follow up with a change like this later.
Thoughts?
So fuse is alone in trying to support remote POSIX locks?
There's a feature flag in fuse: FUSE_POSIX_LOCKS. In theory it's okay to remove this feature from the INIT flags, which tells the server that the client doesn't support remote POSIX locks. At that point flush wouldn't need the lock owner.
I'm not sure if there are any users of this feature, and whether they check the feature flag.
So it's not easy to deprecate, but maybe we could start by adding a CONFIG_FUSE_REMOTE_POSIX_LOCKS with an appropriate notice.
Thanks,
Miklos
Quoted 338 lines
arch/powerpc/platforms/cell/spufs/file.c +2
-2@@ -1697,7 +1697,7 @@ static __poll_t spufs_mfc_poll(struct file *file,poll_table *wait)return mask; } -static int spufs_mfc_flush (struct file *file,fl_owner_t id) +static int spufs_mfc_flush (struct file *file) {struct spu_context *ctx = file->private_data;int ret;@@ -1729,7 +1729,7 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int dataint err =file_write_and_wait_range (file, start, end);if (!err) {inode_lock (inode); - err =spufs_mfc_flush (file,NULL ); + err =spufs_mfc_flush (file);inode_unlock (inode); }return err;drivers/android/binder.c +1
-1@@ -5675,7 +5675,7 @@ static int binder_open(struct inode *nodp, struct file *filp)return 0 ; } -static int binder_flush (struct file *filp,fl_owner_t id) +static int binder_flush (struct file *filp) {struct binder_proc *proc = filp->private_data;drivers/char/ps3flash.c +1
-1@@ -269,7 +269,7 @@ static ssize_t ps3flash_kernel_write(const void *buf, size_t count,return res; } -static int ps3flash_flush (struct file *file,fl_owner_t id) +static int ps3flash_flush (struct file *file) {return ps3flash_writeback (ps3flash_dev); }drivers/char/xillybus/xillybus_core.c +1
-1@@ -1174,7 +1174,7 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout)return rc; } -static int xillybus_flush (struct file *filp,fl_owner_t id) +static int xillybus_flush (struct file *filp) {if (!(filp->f_mode &FMODE_WRITE ))return 0 ;drivers/char/xillybus/xillyusb.c +1
-1@@ -1592,7 +1592,7 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,return rc; } -static int xillyusb_flush (struct file *filp,fl_owner_t id) +static int xillyusb_flush (struct file *filp) {struct xillyusb_channel *chan = filp->private_data;int rc;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1@@ -2675,7 +2675,7 @@ static const struct dev_pm_ops amdgpu_pm_ops = { .runtime_idle = amdgpu_pmops_runtime_idle, }; -static int amdgpu_flush (struct file *f,fl_owner_t id) +static int amdgpu_flush (struct file *f) {struct drm_file *file_priv = f->private_data;struct amdgpu_fpriv *fpriv = file_priv->driver_priv;drivers/scsi/st.c +1
-1@@ -1338,7 +1338,7 @@ static int st_open(struct inode *inode, struct file *filp)/* Flush the tape buffer before close */ -static int st_flush (struct file *filp,fl_owner_t id) +static int st_flush (struct file *filp) {int result =0 , result2;unsigned char cmd[MAX_COMMAND_SIZE ];drivers/usb/class/cdc-wdm.c +1
-1@@ -674,7 +674,7 @@ static int wdm_fsync(struct file *file, loff_t start, loff_t end, int datasync)* malicious or defective hardware which ceased communication after close() was * implicitly called due to process termination. */ -static int wdm_flush (struct file *file,fl_owner_t id) +static int wdm_flush (struct file *file) {return wdm_wait_for_response (file,WDM_FLUSH_TIMEOUT ); }drivers/usb/class/usbtmc.c +1
-1@@ -212,7 +212,7 @@ static int usbtmc_open(struct inode *inode, struct file *filp)/* * usbtmc_flush - called before file handle is closed */ -static int usbtmc_flush (struct file *file,fl_owner_t id) +static int usbtmc_flush (struct file *file) {struct usbtmc_file_data *file_data;struct usbtmc_device_data *data;drivers/usb/usb-skeleton.c +1
-1@@ -133,7 +133,7 @@ static int skel_release(struct inode *inode, struct file *file)return 0 ; } -static int skel_flush (struct file *file,fl_owner_t id) +static int skel_flush (struct file *file) {struct usb_skel *dev;int res;fs/cifs/cifsfs.h +1
-1@@ -104,7 +104,7 @@ extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock);extern int cifs_lock (struct file *,int ,struct file_lock *);extern int cifs_fsync (struct file *,loff_t ,loff_t ,int );extern int cifs_strict_fsync (struct file *,loff_t ,loff_t ,int ); -extern int cifs_flush (struct file *,fl_owner_t id); +extern int cifs_flush (struct file *);extern int cifs_file_mmap (struct file * ,struct vm_area_struct *);extern int cifs_file_strict_mmap (struct file * ,struct vm_area_struct *);extern const struct file_operations cifs_dir_ops;fs/cifs/file.c +1
-1@@ -3028,7 +3028,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)* As file closes, flush all cached write data for this inode checking * for write behind errors. */ -int cifs_flush (struct file *file,fl_owner_t id) +int cifs_flush (struct file *file) {struct inode *inode =file_inode (file);int rc =0 ;fs/ecryptfs/file.c +2
-2@@ -281,13 +281,13 @@ static int ecryptfs_dir_open(struct inode *inode, struct file *file)return 0 ; } -static int ecryptfs_flush (struct file *file,fl_owner_t td) +static int ecryptfs_flush (struct file *file) {struct file *lower_file =ecryptfs_file_to_lower (file);if (lower_file->f_op->flush) {filemap_write_and_wait (file->f_mapping); -return lower_file->f_op->flush (lower_file, td); +return lower_file->f_op->flush (lower_file); }return 0 ;fs/f2fs/file.c +1
-1@@ -1869,7 +1869,7 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)return 0 ; } -static int f2fs_file_flush (struct file *file,fl_owner_t id) +static int f2fs_file_flush (struct file *file) {struct inode *inode =file_inode (file);fs/fuse/file.c +2
-2@@ -478,7 +478,7 @@ static void fuse_sync_writes(struct inode *inode)fuse_release_nowrite (inode); } -static int fuse_flush (struct file *file,fl_owner_t id) +static int fuse_flush (struct file *file) {struct inode *inode =file_inode (file);struct fuse_mount *fm =get_fuse_mount (inode);@@ -511,7 +511,7 @@ static int fuse_flush(struct file *file, fl_owner_t id)memset (&inarg,0 ,sizeof (inarg)); inarg.fh = ff->fh; - inarg.lock_owner =fuse_lock_owner_id (fm->fc, id); + inarg.lock_owner =fuse_lock_owner_id (fm->fc,0 ); args.opcode =FUSE_FLUSH ; args.nodeid =get_node_id (inode); args.in_numargs =1 ;fs/nfs/file.c +1
-1@@ -136,7 +136,7 @@ EXPORT_SYMBOL_GPL(nfs_file_llseek);* Flush all dirty pages, and check for write errors. */ static int -nfs_file_flush (struct file *file,fl_owner_t id) +nfs_file_flush (struct file *file) {struct inode *inode =file_inode (file);errseq_t since;fs/nfs/nfs4file.c +1
-1@@ -111,7 +111,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)* Flush all dirty pages, and check for write errors. */ static int -nfs4_file_flush (struct file *file,fl_owner_t id) +nfs4_file_flush (struct file *file) {struct inode *inode =file_inode (file);errseq_t since;fs/open.c +1
-1@@ -1418,7 +1418,7 @@ int filp_close(struct file *filp, fl_owner_t id) }if (filp->f_op->flush) - retval = filp->f_op->flush (filp, id); + retval = filp->f_op->flush (filp);if (likely (!(filp->f_mode &FMODE_PATH ))) {dnotify_flush (filp, id);fs/orangefs/file.c +1
-1@@ -531,7 +531,7 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)return rc; } -static int orangefs_flush (struct file *file,fl_owner_t id) +static int orangefs_flush (struct file *file) {/* * This is vfs_fsync_range(file, 0, LLONG_MAX, 0) without the fs/overlayfs/file.c +2
-2@@ -641,7 +641,7 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, remap_flags, op); } -static int ovl_flush (struct file *file,fl_owner_t id) +static int ovl_flush (struct file *file) {struct fd real;const struct cred *old_cred;@@ -653,7 +653,7 @@ static int ovl_flush(struct file *file, fl_owner_t id)if (real.file->f_op->flush) { old_cred =ovl_override_creds (file_inode (file)->i_sb); - err = real.file->f_op->flush (real.file, id); + err = real.file->f_op->flush (real.file);revert_creds (old_cred); }fdput (real);include/linux/fs.h +1
-1@@ -1793,7 +1793,7 @@ struct file_operations {int (*mmap) (struct file *,struct vm_area_struct *);unsigned long mmap_supported_flags;int (*open) (struct inode *,struct file *); -int (*flush) (struct file *,fl_owner_t id); +int (*flush) (struct file *);int (*release) (struct inode *,struct file *);int (*fsync) (struct file *,loff_t ,loff_t ,int datasync);int (*fasync) (int ,struct file *,int );ipc/mqueue.c +1
-1@@ -660,7 +660,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,return ret; } -static int mqueue_flush_file (struct file *filp,fl_owner_t id) +static int mqueue_flush_file (struct file *filp) {struct mqueue_inode_info *info =MQUEUE_I (file_inode (filp));kernel/acct.c +1
-2@@ -204,7 +204,7 @@ static void close_work(struct work_struct *work) struct bsd_acct_struct *acct = container_of(work, struct bsd_acct_struct, work);struct file *file = acct->file;if (file->f_op->flush) - file->f_op->flush (file,NULL ); + file->f_op->flush (file);__fput_sync (file);complete (&acct->done); } --2.38.1
Quoted 9 lines · Miklos Szeredi
Quoted 7 lines · Jeff Layton
It would be nice to do this, but the FUSE thing may make it impossible.
Is there a way to audit the various flush operations in userland FUSE filesystems and see whether they do anything with the
lock_owner? I did take a peek at ceph-fuse and it doesn't care about thelock_ownerin its flush op. I'm at a loss as to how to check this more broadly.
Quoted 8 lines
Quoted 5 lines
If we can't do this right away, then perhaps we could try to change this as part of the FUSE userland API first, and follow up with a change like this later.
Thoughts?
So fuse is alone in trying to support remote POSIX locks?
No. Several network filesystems support POSIX locking. This is about the ->flush file_operation. That op is called from filp_close, just before we remove POSIX locks:
-------------8<-----------------
int filp_close(struct file *filp, fl_owner_t id)
{
int retval = 0;
if (!file_count(filp)) {
printk(KERN_ERR "VFS: Close: file count is 0\n");
return 0;
}
if (filp->f_op->flush)
retval = filp->f_op->flush(filp, id);
if (likely(!(filp->f_mode & FMODE_PATH))) {
dnotify_flush(filp, id);
locks_remove_posix(filp, id);
}
fput(filp);
return retval;
}-------------8<-----------------
None of the in-kernel filesystems that define a ->flush operation do anything with the fl_owner_t arg, aside from FUSE which just passes it along.
ceph-fuse also seems to ignore the lock_owner in its ->flush (not that it's necessarily a representative sample, but it does support file locking). My suspicion is that most, if not all FUSE filesystems don't pay attention to the lock_owner in their ->flush ops.
To be clear, fuse_common.h has this in struct fuse_file_info:
/** Lock owner id. Available in locking operations and flush */
uint64_t lock_owner;After the proposed change, we'd just change the comment to say:
/** Lock owner id. Available in locking operations */
The big question is whether this would negatively affect any FUSE filesystems in the field.
Quoted 11 lines
There's a feature flag in fuse:
FUSE_POSIX_LOCKS. In theory it's okay to remove this feature from the INIT flags, which tells the server that the client doesn't support remote POSIX locks. At that point flush wouldn't need the lock owner.I'm not sure if there are any users of this feature, and whether they check the feature flag.
So it's not easy to deprecate, but maybe we could start by adding a
CONFIG_FUSE_REMOTE_POSIX_LOCKSwith an appropriate notice.
This wouldn't obviate FUSE's support for POSIX locks, but I do see a problem for FUSE here. It looks like FUSE doesn't record POSIX locks in the local inode. Without that, it'd never unlock due to the optimization at the start of locks_remove_posix.
That'd be pretty simple to fix though. We could add a fstype flag that just says "don't trust that list_empty check and always unlock". We'd set that for FUSE and you'd still get the whole-file unlock call down to the fs for any inode with a file_lock_context.
Signature · 1 line
Jeff Layton <[email protected]>
Miklos Szeredi
maintainerQuoted 4 lines · Jeff Layton
This wouldn't obviate FUSE's support for POSIX locks, but I do see a problem for FUSE here. It looks like FUSE doesn't record POSIX locks in the local inode. Without that, it'd never unlock due to the optimization at the start of
locks_remove_posix.
Indeed.
Quoted 4 lines
That'd be pretty simple to fix though. We could add a fstype flag that just says "don't trust that
list_emptycheck and always unlock". We'd set that for FUSE and you'd still get the whole-file unlock call down to the fs for any inode with afile_lock_context.
FUSE took that path, because it seemed impossible or impractical to keep the kernel's locking state in sync with the filesystem's locking state. It was a long time ago and I don't remember the details. Unfortunately the commit message doesn't help to explain either...
commit 7142125937e1482ad3ae4366594c6586153dfc86
Author: Miklos Szeredi <[email protected]> Date: Sun Jun 25 05:48:52 2006 -0700
[PATCH] fuse: add POSIX file locking support
This patch adds POSIX file locking support to the fuse interface.
This implementation doesn't keep any locking state in kernel. Unlocking on close() is handled by the FLUSH message, which now contains the
lock owner id.
Mandatory locking is not supported. The filesystem may enfoce mandatory locking in userspace if needed.
Thanks,
Miklos