~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/stack.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/stack.c (Version linux-6.12-rc7) and /fs/stack.c (Version linux-4.9.337)


  1 // SPDX-License-Identifier: GPL-2.0-only       << 
  2 #include <linux/export.h>                           1 #include <linux/export.h>
  3 #include <linux/fs.h>                               2 #include <linux/fs.h>
  4 #include <linux/fs_stack.h>                         3 #include <linux/fs_stack.h>
  5                                                     4 
  6 /* does _NOT_ require i_mutex to be held.           5 /* does _NOT_ require i_mutex to be held.
  7  *                                                  6  *
  8  * This function cannot be inlined since i_siz      7  * This function cannot be inlined since i_size_{read,write} is rather
  9  * heavy-weight on 32-bit systems                   8  * heavy-weight on 32-bit systems
 10  */                                                 9  */
 11 void fsstack_copy_inode_size(struct inode *dst     10 void fsstack_copy_inode_size(struct inode *dst, struct inode *src)
 12 {                                                  11 {
 13         loff_t i_size;                             12         loff_t i_size;
 14         blkcnt_t i_blocks;                         13         blkcnt_t i_blocks;
 15                                                    14 
 16         /*                                         15         /*
 17          * i_size_read() includes its own seql     16          * i_size_read() includes its own seqlocking and protection from
 18          * preemption (see include/linux/fs.h)     17          * preemption (see include/linux/fs.h): we need nothing extra for
 19          * that here, and prefer to avoid nest     18          * that here, and prefer to avoid nesting locks than attempt to keep
 20          * i_size and i_blocks in sync togethe     19          * i_size and i_blocks in sync together.
 21          */                                        20          */
 22         i_size = i_size_read(src);                 21         i_size = i_size_read(src);
 23                                                    22 
 24         /*                                         23         /*
 25          * But on 32-bit, we ought to make an  !!  24          * But if CONFIG_LBDAF (on 32-bit), we ought to make an effort to
 26          * i_blocks in sync despite SMP or PRE !!  25          * keep the two halves of i_blocks in sync despite SMP or PREEMPT -
 27          * generic_fillattr() doesn't bother,  !!  26          * though stat's generic_fillattr() doesn't bother, and we won't be
 28          * (where i_blocks does become importa !!  27          * applying quotas (where i_blocks does become important) at the
                                                   >>  28          * upper level.
 29          *                                         29          *
 30          * We don't actually know what locking     30          * We don't actually know what locking is used at the lower level;
 31          * but if it's a filesystem that suppo     31          * but if it's a filesystem that supports quotas, it will be using
 32          * i_lock as in inode_add_bytes().         32          * i_lock as in inode_add_bytes().
 33          */                                        33          */
 34         if (sizeof(i_blocks) > sizeof(long))       34         if (sizeof(i_blocks) > sizeof(long))
 35                 spin_lock(&src->i_lock);           35                 spin_lock(&src->i_lock);
 36         i_blocks = src->i_blocks;                  36         i_blocks = src->i_blocks;
 37         if (sizeof(i_blocks) > sizeof(long))       37         if (sizeof(i_blocks) > sizeof(long))
 38                 spin_unlock(&src->i_lock);         38                 spin_unlock(&src->i_lock);
 39                                                    39 
 40         /*                                         40         /*
 41          * If CONFIG_SMP or CONFIG_PREEMPTION  !!  41          * If CONFIG_SMP or CONFIG_PREEMPT on 32-bit, it's vital for
 42          * fsstack_copy_inode_size() to hold s     42          * fsstack_copy_inode_size() to hold some lock around
 43          * i_size_write(), otherwise i_size_re     43          * i_size_write(), otherwise i_size_read() may spin forever (see
 44          * include/linux/fs.h).  We don't nece     44          * include/linux/fs.h).  We don't necessarily hold i_mutex when this
 45          * is called, so take i_lock for that      45          * is called, so take i_lock for that case.
 46          *                                         46          *
 47          * And if on 32-bit, continue our effo !!  47          * And if CONFIG_LBDAF (on 32-bit), continue our effort to keep the
 48          * i_blocks in sync despite SMP or PRE !!  48          * two halves of i_blocks in sync despite SMP or PREEMPT: use i_lock
 49          * too, and do both at once by combini !!  49          * for that case too, and do both at once by combining the tests.
 50          *                                         50          *
 51          * There is none of this locking overh     51          * There is none of this locking overhead in the 64-bit case.
 52          */                                        52          */
 53         if (sizeof(i_size) > sizeof(long) || s     53         if (sizeof(i_size) > sizeof(long) || sizeof(i_blocks) > sizeof(long))
 54                 spin_lock(&dst->i_lock);           54                 spin_lock(&dst->i_lock);
 55         i_size_write(dst, i_size);                 55         i_size_write(dst, i_size);
 56         dst->i_blocks = i_blocks;                  56         dst->i_blocks = i_blocks;
 57         if (sizeof(i_size) > sizeof(long) || s     57         if (sizeof(i_size) > sizeof(long) || sizeof(i_blocks) > sizeof(long))
 58                 spin_unlock(&dst->i_lock);         58                 spin_unlock(&dst->i_lock);
 59 }                                                  59 }
 60 EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);        60 EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);
 61                                                    61 
 62 /* copy all attributes */                          62 /* copy all attributes */
 63 void fsstack_copy_attr_all(struct inode *dest,     63 void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
 64 {                                                  64 {
 65         dest->i_mode = src->i_mode;                65         dest->i_mode = src->i_mode;
 66         dest->i_uid = src->i_uid;                  66         dest->i_uid = src->i_uid;
 67         dest->i_gid = src->i_gid;                  67         dest->i_gid = src->i_gid;
 68         dest->i_rdev = src->i_rdev;                68         dest->i_rdev = src->i_rdev;
 69         inode_set_atime_to_ts(dest, inode_get_ !!  69         dest->i_atime = src->i_atime;
 70         inode_set_mtime_to_ts(dest, inode_get_ !!  70         dest->i_mtime = src->i_mtime;
 71         inode_set_ctime_to_ts(dest, inode_get_ !!  71         dest->i_ctime = src->i_ctime;
 72         dest->i_blkbits = src->i_blkbits;          72         dest->i_blkbits = src->i_blkbits;
 73         dest->i_flags = src->i_flags;              73         dest->i_flags = src->i_flags;
 74         set_nlink(dest, src->i_nlink);             74         set_nlink(dest, src->i_nlink);
 75 }                                                  75 }
 76 EXPORT_SYMBOL_GPL(fsstack_copy_attr_all);          76 EXPORT_SYMBOL_GPL(fsstack_copy_attr_all);
 77                                                    77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php