]> Git Repo - J-linux.git/commitdiff
Merge tag 'locks-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux
authorLinus Torvalds <[email protected]>
Mon, 12 Dec 2022 16:52:53 +0000 (08:52 -0800)
committerLinus Torvalds <[email protected]>
Mon, 12 Dec 2022 16:52:53 +0000 (08:52 -0800)
Pull file locking updates from Jeff Layton:
 "The main change here is to add the new locks_inode_context helper, and
  convert all of the places that dereference inode->i_flctx directly to
  use that instead.

  There is a new helper to indicate whether any locks are held on an
  inode. This is mostly for Ceph but may be usable elsewhere too.

  Andi Kleen requested that we print the PID when the LOCK_MAND warning
  fires, to help track down applications trying to use it.

  Finally, we added some new warnings to some of the file locking
  functions that fire when the ->fl_file and filp arguments differ. This
  helped us find some long-standing bugs in lockd. Patches for those are
  in Chuck Lever's tree and should be in his v6.2 PR. After that patch,
  people using NFSv2/v3 locking may see some warnings fire until those
  go in.

  Happy Holidays!"

* tag 'locks-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux:
  Add process name and pid to locks warning
  nfsd: use locks_inode_context helper
  nfs: use locks_inode_context helper
  lockd: use locks_inode_context helper
  ksmbd: use locks_inode_context helper
  cifs: use locks_inode_context helper
  ceph: use locks_inode_context helper
  filelock: add a new locks_inode_context accessor function
  filelock: new helper: vfs_inode_has_locks
  filelock: WARN_ON_ONCE when ->fl_file and filp don't match

1  2 
fs/ksmbd/vfs.c
include/linux/fs.h

diff --combined fs/ksmbd/vfs.c
index 94b8ed4ef8707c1476405ccc2e825b94952603cf,f9e85d6a160eb36c79eded43d7f854ad245de422..72e981c9a572c704d64c4d8b47be50d0eb401702
@@@ -321,7 -321,7 +321,7 @@@ static int check_lock_range(struct fil
                            unsigned char type)
  {
        struct file_lock *flock;
-       struct file_lock_context *ctx = file_inode(filp)->i_flctx;
+       struct file_lock_context *ctx = locks_inode_context(file_inode(filp));
        int error = 0;
  
        if (!ctx || list_empty_careful(&ctx->flc_posix))
@@@ -1794,9 -1794,9 +1794,9 @@@ int ksmbd_vfs_copy_file_ranges(struct k
                ret = vfs_copy_file_range(src_fp->filp, src_off,
                                          dst_fp->filp, dst_off, len, 0);
                if (ret == -EOPNOTSUPP || ret == -EXDEV)
 -                      ret = generic_copy_file_range(src_fp->filp, src_off,
 -                                                    dst_fp->filp, dst_off,
 -                                                    len, 0);
 +                      ret = vfs_copy_file_range(src_fp->filp, src_off,
 +                                                dst_fp->filp, dst_off, len,
 +                                                COPY_FILE_SPLICE);
                if (ret < 0)
                        return ret;
  
diff --combined include/linux/fs.h
index 59ae95ddb6793588b1be1ae9af3ab07c8f762ffa,fd0a79511fd8e2bea8586fc36b79f43eb84bc66d..71b5c24b55ce8a81fc9e2f446e9e5d7ca931e8e8
@@@ -1170,6 -1170,7 +1170,7 @@@ extern int locks_delete_block(struct fi
  extern int vfs_test_lock(struct file *, struct file_lock *);
  extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
  extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
+ bool vfs_inode_has_locks(struct inode *inode);
  extern int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
  extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
  extern void lease_get_mtime(struct inode *, struct timespec64 *time);
@@@ -1186,6 -1187,13 +1187,13 @@@ extern void show_fd_locks(struct seq_fi
                         struct file *filp, struct files_struct *files);
  extern bool locks_owner_has_blockers(struct file_lock_context *flctx,
                        fl_owner_t owner);
+ static inline struct file_lock_context *
+ locks_inode_context(const struct inode *inode)
+ {
+       return smp_load_acquire(&inode->i_flctx);
+ }
  #else /* !CONFIG_FILE_LOCKING */
  static inline int fcntl_getlk(struct file *file, unsigned int cmd,
                              struct flock __user *user)
@@@ -1284,6 -1292,11 +1292,11 @@@ static inline int vfs_cancel_lock(struc
        return 0;
  }
  
+ static inline bool vfs_inode_has_locks(struct inode *inode)
+ {
+       return false;
+ }
  static inline int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl)
  {
        return -ENOLCK;
@@@ -1326,6 -1339,13 +1339,13 @@@ static inline bool locks_owner_has_bloc
  {
        return false;
  }
+ static inline struct file_lock_context *
+ locks_inode_context(const struct inode *inode)
+ {
+       return NULL;
+ }
  #endif /* !CONFIG_FILE_LOCKING */
  
  static inline struct inode *file_inode(const struct file *f)
@@@ -2089,14 -2109,6 +2109,14 @@@ struct dir_context 
   */
  #define REMAP_FILE_ADVISORY           (REMAP_FILE_CAN_SHORTEN)
  
 +/*
 + * These flags control the behavior of vfs_copy_file_range().
 + * They are not available to the user via syscall.
 + *
 + * COPY_FILE_SPLICE: call splice direct instead of fs clone/copy ops
 + */
 +#define COPY_FILE_SPLICE              (1 << 0)
 +
  struct iov_iter;
  struct io_uring_cmd;
  
This page took 0.065215 seconds and 4 git commands to generate.