]> Git Repo - J-linux.git/commitdiff
Merge tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <[email protected]>
Tue, 13 Dec 2022 02:38:47 +0000 (18:38 -0800)
committerLinus Torvalds <[email protected]>
Tue, 13 Dec 2022 02:38:47 +0000 (18:38 -0800)
Pull misc vfs updates from Al Viro:
 "misc pile"

* tag 'pull-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs: sysv: Fix sysv_nblocks() returns wrong value
  get rid of INT_LIMIT, use type_max() instead
  btrfs: replace INT_LIMIT(loff_t) with OFFSET_MAX
  fs: simplify vfs_get_super
  fs: drop useless condition from inode_needs_update_time

1  2 
fs/super.c
include/linux/fs.h

diff --combined fs/super.c
index 8d39e4f11cfa3c431d32952eb168bc7a7426ffc7,76f477c24c3d5f9f122568ac93017bbb81c36df4..12c08cb20405d50baa25c8b5664925c5117bc60b
@@@ -291,7 -291,6 +291,7 @@@ static void __put_super(struct super_bl
                WARN_ON(s->s_inode_lru.node);
                WARN_ON(!list_empty(&s->s_mounts));
                security_sb_free(s);
 +              fscrypt_destroy_keyring(s);
                put_user_ns(s->s_user_ns);
                kfree(s->s_subtype);
                call_rcu(&s->rcu, destroy_super_rcu);
@@@ -480,7 -479,7 +480,7 @@@ void generic_shutdown_super(struct supe
                evict_inodes(sb);
                /* only nonzero refcount inodes can have marks */
                fsnotify_sb_delete(sb);
 -              fscrypt_sb_delete(sb);
 +              fscrypt_destroy_keyring(sb);
                security_sb_delete(sb);
  
                if (sb->s_dio_done_wq) {
@@@ -1112,55 -1111,14 +1112,14 @@@ static int test_single_super(struct sup
        return 1;
  }
  
- /**
-  * vfs_get_super - Get a superblock with a search key set in s_fs_info.
-  * @fc: The filesystem context holding the parameters
-  * @keying: How to distinguish superblocks
-  * @fill_super: Helper to initialise a new superblock
-  *
-  * Search for a superblock and create a new one if not found.  The search
-  * criterion is controlled by @keying.  If the search fails, a new superblock
-  * is created and @fill_super() is called to initialise it.
-  *
-  * @keying can take one of a number of values:
-  *
-  * (1) vfs_get_single_super - Only one superblock of this type may exist on the
-  *     system.  This is typically used for special system filesystems.
-  *
-  * (2) vfs_get_keyed_super - Multiple superblocks may exist, but they must have
-  *     distinct keys (where the key is in s_fs_info).  Searching for the same
-  *     key again will turn up the superblock for that key.
-  *
-  * (3) vfs_get_independent_super - Multiple superblocks may exist and are
-  *     unkeyed.  Each call will get a new superblock.
-  *
-  * A permissions check is made by sget_fc() unless we're getting a superblock
-  * for a kernel-internal mount or a submount.
-  */
- int vfs_get_super(struct fs_context *fc,
-                 enum vfs_get_super_keying keying,
-                 int (*fill_super)(struct super_block *sb,
-                                   struct fs_context *fc))
+ static int vfs_get_super(struct fs_context *fc, bool reconf,
+               int (*test)(struct super_block *, struct fs_context *),
+               int (*fill_super)(struct super_block *sb,
+                                 struct fs_context *fc))
  {
-       int (*test)(struct super_block *, struct fs_context *);
        struct super_block *sb;
        int err;
  
-       switch (keying) {
-       case vfs_get_single_super:
-       case vfs_get_single_reconf_super:
-               test = test_single_super;
-               break;
-       case vfs_get_keyed_super:
-               test = test_keyed_super;
-               break;
-       case vfs_get_independent_super:
-               test = NULL;
-               break;
-       default:
-               BUG();
-       }
        sb = sget_fc(fc, test, set_anon_super_fc);
        if (IS_ERR(sb))
                return PTR_ERR(sb);
                fc->root = dget(sb->s_root);
        } else {
                fc->root = dget(sb->s_root);
-               if (keying == vfs_get_single_reconf_super) {
+               if (reconf) {
                        err = reconfigure_super(fc);
                        if (err < 0) {
                                dput(fc->root);
@@@ -1190,13 -1148,12 +1149,12 @@@ error
        deactivate_locked_super(sb);
        return err;
  }
- EXPORT_SYMBOL(vfs_get_super);
  
  int get_tree_nodev(struct fs_context *fc,
                  int (*fill_super)(struct super_block *sb,
                                    struct fs_context *fc))
  {
-       return vfs_get_super(fc, vfs_get_independent_super, fill_super);
+       return vfs_get_super(fc, false, NULL, fill_super);
  }
  EXPORT_SYMBOL(get_tree_nodev);
  
@@@ -1204,7 -1161,7 +1162,7 @@@ int get_tree_single(struct fs_context *
                  int (*fill_super)(struct super_block *sb,
                                    struct fs_context *fc))
  {
-       return vfs_get_super(fc, vfs_get_single_super, fill_super);
+       return vfs_get_super(fc, false, test_single_super, fill_super);
  }
  EXPORT_SYMBOL(get_tree_single);
  
@@@ -1212,7 -1169,7 +1170,7 @@@ int get_tree_single_reconf(struct fs_co
                  int (*fill_super)(struct super_block *sb,
                                    struct fs_context *fc))
  {
-       return vfs_get_super(fc, vfs_get_single_reconf_super, fill_super);
+       return vfs_get_super(fc, true, test_single_super, fill_super);
  }
  EXPORT_SYMBOL(get_tree_single_reconf);
  
@@@ -1222,7 -1179,7 +1180,7 @@@ int get_tree_keyed(struct fs_context *f
                void *key)
  {
        fc->s_fs_info = key;
-       return vfs_get_super(fc, vfs_get_keyed_super, fill_super);
+       return vfs_get_super(fc, false, test_keyed_super, fill_super);
  }
  EXPORT_SYMBOL(get_tree_keyed);
  
diff --combined include/linux/fs.h
index 6dd5f1d61fcf21f2f7ec6c2fbb50ea21d1be7cf3,a384741b1449457bf32499be225ea31ba79a3a69..1e469b8797878247ba88117a2cca6371295a70a9
@@@ -1131,9 -1131,8 +1131,8 @@@ struct file_lock_context 
  
  /* The following constant reflects the upper bound of the file/locking space */
  #ifndef OFFSET_MAX
- #define INT_LIMIT(x)  (~((x)1 << (sizeof(x)*8 - 1)))
- #define OFFSET_MAX    INT_LIMIT(loff_t)
- #define OFFT_OFFSET_MAX       INT_LIMIT(off_t)
+ #define OFFSET_MAX    type_max(loff_t)
+ #define OFFT_OFFSET_MAX       type_max(off_t)
  #endif
  
  extern void send_sigio(struct fown_struct *fown, int fd, int band);
@@@ -1170,7 -1169,6 +1169,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);
@@@ -1187,13 -1185,6 +1186,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)
@@@ -1292,11 -1283,6 +1291,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;
@@@ -1339,13 -1325,6 +1338,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)
@@@ -2109,14 -2088,6 +2108,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;
  
@@@ -3513,7 -3484,7 +3512,7 @@@ void simple_transaction_set(struct fil
   * All attributes contain a text representation of a numeric value
   * that are accessed with the get() and set() functions.
   */
 -#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)          \
 +#define DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed)     \
  static int __fops ## _open(struct inode *inode, struct file *file)    \
  {                                                                     \
        __simple_attr_check_format(__fmt, 0ull);                        \
@@@ -3524,16 -3495,10 +3523,16 @@@ static const struct file_operations __f
        .open    = __fops ## _open,                                     \
        .release = simple_attr_release,                                 \
        .read    = simple_attr_read,                                    \
 -      .write   = simple_attr_write,                                   \
 +      .write   = (__is_signed) ? simple_attr_write_signed : simple_attr_write,        \
        .llseek  = generic_file_llseek,                                 \
  }
  
 +#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)          \
 +      DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
 +
 +#define DEFINE_SIMPLE_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt)   \
 +      DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
 +
  static inline __printf(1, 2)
  void __simple_attr_check_format(const char *fmt, ...)
  {
@@@ -3548,8 -3513,6 +3547,8 @@@ ssize_t simple_attr_read(struct file *f
                         size_t len, loff_t *ppos);
  ssize_t simple_attr_write(struct file *file, const char __user *buf,
                          size_t len, loff_t *ppos);
 +ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
 +                               size_t len, loff_t *ppos);
  
  struct ctl_table;
  int __init list_bdev_fs_names(char *buf, size_t size);
This page took 0.073386 seconds and 4 git commands to generate.