CC: l...@lists.linux.dev
CC: kbuild-...@lists.01.org
BCC: l...@intel.com
CC: linux-ker...@vger.kernel.org
TO: Allison Henderson <allison.hender...@oracle.com>
CC: Dave Chinner <dchin...@redhat.com>

tree:   https://github.com/allisonhenderson/xfs_work.git xfs-5.19-compose_pptrs
head:   74ecccf0e89a132c2490f3a63661c535974c6a08
commit: 7a5d447970de2d3b003b9015e2bce3bf0d15e3db [25/32] xfs: parent pointer 
attribute creation
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: x86_64-randconfig-c007 
(https://download.01.org/0day-ci/archive/20220511/202205110952.dfpq58iv-...@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
5e004fb787698440a387750db7f8028e7cb14cfc)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # 
https://github.com/allisonhenderson/xfs_work/commit/7a5d447970de2d3b003b9015e2bce3bf0d15e3db
        git remote add allisonhenderson-xfs-work 
https://github.com/allisonhenderson/xfs_work.git
        git fetch --no-tags allisonhenderson-xfs-work xfs-5.19-compose_pptrs
        git checkout 7a5d447970de2d3b003b9015e2bce3bf0d15e3db
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/xfs_ioctl.c:1744:2: warning: Call to function 'memset' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(label, 0, sizeof(label));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/xfs_ioctl.c:1744:2: note: Call to function 'memset' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memset_s' in case of C11
           memset(label, 0, sizeof(label));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/xfs_ioctl.c:1746:2: warning: Call to function 'strncpy' is insecure 
as it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'strncpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           strncpy(label, sbp->sb_fname, XFSLABEL_MAX);
           ^~~~~~~
   fs/xfs/xfs_ioctl.c:1746:2: note: Call to function 'strncpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'strncpy_s' in case of C11
           strncpy(label, sbp->sb_fname, XFSLABEL_MAX);
           ^~~~~~~
   fs/xfs/xfs_ioctl.c:1784:2: warning: Call to function 'memset' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(sbp->sb_fname, 0, sizeof(sbp->sb_fname));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/xfs_ioctl.c:1784:2: note: Call to function 'memset' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memset_s' in case of C11
           memset(sbp->sb_fname, 0, sizeof(sbp->sb_fname));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/xfs_ioctl.c:1785:2: warning: Call to function 'memcpy' is insecure as 
it does not provide security checks introduced in the C11 standard. Replace 
with analogous functions that support length arguments or provides boundary 
checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(sbp->sb_fname, label, len);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/xfs_ioctl.c:1785:2: note: Call to function 'memcpy' is insecure as it 
does not provide security checks introduced in the C11 standard. Replace with 
analogous functions that support length arguments or provides boundary checks 
such as 'memcpy_s' in case of C11
           memcpy(sbp->sb_fname, label, len);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   Suppressed 46 warnings (46 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   46 warnings generated.
   Suppressed 46 warnings (46 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   57 warnings generated.
   fs/xfs/libxfs/xfs_attr.c:495:2: warning: Value stored to 'error' is never 
read [clang-analyzer-deadcode.DeadStores]
           error = 0;
           ^       ~
   fs/xfs/libxfs/xfs_attr.c:495:2: note: Value stored to 'error' is never read
           error = 0;
           ^       ~
>> fs/xfs/libxfs/xfs_attr.c:556:21: warning: Value stored to 'dp' during its 
>> initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct xfs_inode                *dp = args->dp;
                                            ^~   ~~~~~~~~
   fs/xfs/libxfs/xfs_attr.c:556:21: note: Value stored to 'dp' during its 
initialization is never read
           struct xfs_inode                *dp = args->dp;
                                            ^~   ~~~~~~~~
>> fs/xfs/libxfs/xfs_attr.c:559:21: warning: Value stored to 'mp' during its 
>> initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct xfs_mount                *mp = args->dp->i_mount;
                                            ^~   ~~~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr.c:559:21: note: Value stored to 'mp' during its 
initialization is never read
           struct xfs_mount                *mp = args->dp->i_mount;
                                            ^~   ~~~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr.c:1402:2: warning: Value stored to 'error' is never 
read [clang-analyzer-deadcode.DeadStores]
           error = xfs_attr_node_removename(args, state);
           ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr.c:1402:2: note: Value stored to 'error' is never read
           error = xfs_attr_node_removename(args, state);
           ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 53 warnings (47 in non-user code, 6 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   83 warnings generated.
   fs/xfs/libxfs/xfs_attr_leaf.c:523:2: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(args->value, value, valuelen);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr_leaf.c:523:2: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
           memcpy(args->value, value, valuelen);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr_leaf.c:678:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(hdr, 0, sizeof(*hdr));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr_leaf.c:678:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(hdr, 0, sizeof(*hdr));
           ^
   include/linux/fortify-string.h:272:25: note: expanded from macro 'memset'
   #define memset(p, c, s) __fortify_memset_chk(p, c, s,                   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:265:2: note: expanded from macro 
'__fortify_memset_chk'
           __underlying_memset(p, c, __fortify_size);                      \
           ^~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:47:29: note: expanded from macro 
'__underlying_memset'
   #define __underlying_memset     __builtin_memset
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr_leaf.c:765:2: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(sfe->nameval, args->name, args->namelen);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr_leaf.c:765:2: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
           memcpy(sfe->nameval, args->name, args->namelen);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here
   include/linux/fortify-string.h:45:29: note: expanded from macro 
'__underlying_memcpy'
   #define __underlying_memcpy     __builtin_memcpy
                                   ^~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_attr_leaf.c:766:2: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen);
           ^
   include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy'
   #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/fortify-string.h:362:2: note: expanded from macro 
'__fortify_memcpy_chk'
           __underlying_##op(p, q, __fortify_size);                        \
           ^~~~~~~~~~~~~~~~~
   note: expanded from here

vim +/dp +556 fs/xfs/libxfs/xfs_attr.c

b8d9a2124c0193 Dave Chinner      2022-04-14  478  
b8d9a2124c0193 Dave Chinner      2022-04-14  479  /*
b8d9a2124c0193 Dave Chinner      2022-04-14  480   * Initial setup for 
xfs_attr_node_removename.  Make sure the attr is there and
b8d9a2124c0193 Dave Chinner      2022-04-14  481   * the blocks are valid.  
Attr keys with remote blocks will be marked
b8d9a2124c0193 Dave Chinner      2022-04-14  482   * incomplete.
b8d9a2124c0193 Dave Chinner      2022-04-14  483   */
b8d9a2124c0193 Dave Chinner      2022-04-14  484  static
b8d9a2124c0193 Dave Chinner      2022-04-14  485  int 
xfs_attr_node_removename_setup(
b8d9a2124c0193 Dave Chinner      2022-04-14  486        struct xfs_attr_item    
        *attr)
b8d9a2124c0193 Dave Chinner      2022-04-14  487  {
b8d9a2124c0193 Dave Chinner      2022-04-14  488        struct xfs_da_args      
        *args = attr->xattri_da_args;
b8d9a2124c0193 Dave Chinner      2022-04-14  489        struct xfs_da_state     
        **state = &attr->xattri_da_state;
b8d9a2124c0193 Dave Chinner      2022-04-14  490        int                     
        error;
b8d9a2124c0193 Dave Chinner      2022-04-14  491  
b8d9a2124c0193 Dave Chinner      2022-04-14  492        error = 
xfs_attr_node_hasname(args, state);
b8d9a2124c0193 Dave Chinner      2022-04-14  493        if (error != -EEXIST)
b8d9a2124c0193 Dave Chinner      2022-04-14  494                goto out;
b8d9a2124c0193 Dave Chinner      2022-04-14 @495        error = 0;
b8d9a2124c0193 Dave Chinner      2022-04-14  496  
b8d9a2124c0193 Dave Chinner      2022-04-14  497        
ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL);
b8d9a2124c0193 Dave Chinner      2022-04-14  498        
ASSERT((*state)->path.blk[(*state)->path.active - 1].magic ==
b8d9a2124c0193 Dave Chinner      2022-04-14  499                
XFS_ATTR_LEAF_MAGIC);
b8d9a2124c0193 Dave Chinner      2022-04-14  500  
b8d9a2124c0193 Dave Chinner      2022-04-14  501        error = 
xfs_attr_leaf_mark_incomplete(args, *state);
b8d9a2124c0193 Dave Chinner      2022-04-14  502        if (error)
b8d9a2124c0193 Dave Chinner      2022-04-14  503                goto out;
26b33e76e2c392 Dave Chinner      2022-04-14  504        if (args->rmtblkno > 0)
b8d9a2124c0193 Dave Chinner      2022-04-14  505                error = 
xfs_attr_rmtval_invalidate(args);
b8d9a2124c0193 Dave Chinner      2022-04-14  506  out:
b8d9a2124c0193 Dave Chinner      2022-04-14  507        if (error)
b8d9a2124c0193 Dave Chinner      2022-04-14  508                
xfs_da_state_free(*state);
b8d9a2124c0193 Dave Chinner      2022-04-14  509  
b8d9a2124c0193 Dave Chinner      2022-04-14  510        return error;
b8d9a2124c0193 Dave Chinner      2022-04-14  511  }
b8d9a2124c0193 Dave Chinner      2022-04-14  512  
e683cdbb8baf82 Dave Chinner      2022-04-14  513  /*
e683cdbb8baf82 Dave Chinner      2022-04-14  514   * Remove the original attr 
we have just replaced. This is dependent on the
e683cdbb8baf82 Dave Chinner      2022-04-14  515   * original lookup and insert 
placing the old attr in args->blkno/args->index
e683cdbb8baf82 Dave Chinner      2022-04-14  516   * and the new attr in 
args->blkno2/args->index2.
e683cdbb8baf82 Dave Chinner      2022-04-14  517   */
e683cdbb8baf82 Dave Chinner      2022-04-14  518  static int
e683cdbb8baf82 Dave Chinner      2022-04-14  519  xfs_attr_leaf_remove_attr(
e683cdbb8baf82 Dave Chinner      2022-04-14  520        struct xfs_attr_item    
        *attr)
e683cdbb8baf82 Dave Chinner      2022-04-14  521  {
e683cdbb8baf82 Dave Chinner      2022-04-14  522        struct xfs_da_args      
        *args = attr->xattri_da_args;
e683cdbb8baf82 Dave Chinner      2022-04-14  523        struct xfs_inode        
        *dp = args->dp;
e683cdbb8baf82 Dave Chinner      2022-04-14  524        struct xfs_buf          
        *bp = NULL;
e683cdbb8baf82 Dave Chinner      2022-04-14  525        int                     
        forkoff;
e683cdbb8baf82 Dave Chinner      2022-04-14  526        int                     
        error;
e683cdbb8baf82 Dave Chinner      2022-04-14  527  
e683cdbb8baf82 Dave Chinner      2022-04-14  528        error = 
xfs_attr3_leaf_read(args->trans, args->dp, args->blkno,
e683cdbb8baf82 Dave Chinner      2022-04-14  529                                
   &bp);
e683cdbb8baf82 Dave Chinner      2022-04-14  530        if (error)
e683cdbb8baf82 Dave Chinner      2022-04-14  531                return error;
e683cdbb8baf82 Dave Chinner      2022-04-14  532  
e683cdbb8baf82 Dave Chinner      2022-04-14  533        
xfs_attr3_leaf_remove(bp, args);
e683cdbb8baf82 Dave Chinner      2022-04-14  534  
e683cdbb8baf82 Dave Chinner      2022-04-14  535        forkoff = 
xfs_attr_shortform_allfit(bp, dp);
e683cdbb8baf82 Dave Chinner      2022-04-14  536        if (forkoff)
e683cdbb8baf82 Dave Chinner      2022-04-14  537                error = 
xfs_attr3_leaf_to_shortform(bp, args, forkoff);
e683cdbb8baf82 Dave Chinner      2022-04-14  538                /* bp is gone 
due to xfs_da_shrink_inode */
e683cdbb8baf82 Dave Chinner      2022-04-14  539  
e683cdbb8baf82 Dave Chinner      2022-04-14  540        return error;
e683cdbb8baf82 Dave Chinner      2022-04-14  541  }
e683cdbb8baf82 Dave Chinner      2022-04-14  542  
db1a28cc591c1a Allison Collins   2020-07-20  543  /*
d56c93997e96ed Dave Chinner      2022-04-14  544   * Run the attribute 
operation specified in @attr.
d56c93997e96ed Dave Chinner      2022-04-14  545   *
d56c93997e96ed Dave Chinner      2022-04-14  546   * This routine is meant to 
function as a delayed operation and will set the
d56c93997e96ed Dave Chinner      2022-04-14  547   * state to XFS_DAS_DONE when 
the operation is complete.  Calling functions will
d56c93997e96ed Dave Chinner      2022-04-14  548   * need to handle this, and 
recall the function until either an error or
d56c93997e96ed Dave Chinner      2022-04-14  549   * XFS_DAS_DONE is detected.
db1a28cc591c1a Allison Collins   2020-07-20  550   */
db1a28cc591c1a Allison Collins   2020-07-20  551  int
8f502a4009822a Allison Henderson 2021-05-21  552  xfs_attr_set_iter(
133b4f4350cc51 Allison Henderson 2022-04-11  553        struct xfs_attr_item    
        *attr)
db1a28cc591c1a Allison Collins   2020-07-20  554  {
133b4f4350cc51 Allison Henderson 2022-04-11  555        struct xfs_da_args      
        *args = attr->xattri_da_args;
7a5d447970de2d Allison Henderson 2022-03-22 @556        struct xfs_inode        
        *dp = args->dp;
7a5d447970de2d Allison Henderson 2022-03-22  557        struct xfs_buf          
        *bp = NULL;
7a5d447970de2d Allison Henderson 2022-03-22  558        int                     
        sf_size, forkoff, error = 0;
7a5d447970de2d Allison Henderson 2022-03-22 @559        struct xfs_mount        
        *mp = args->dp->i_mount;
7a5d447970de2d Allison Henderson 2022-03-22  560  
db1a28cc591c1a Allison Collins   2020-07-20  561  
8f502a4009822a Allison Henderson 2021-05-21  562        /* State machine switch 
*/
100ba63970eed9 Dave Chinner      2022-04-14  563  next_state:
133b4f4350cc51 Allison Henderson 2022-04-11  564        switch 
(attr->xattri_dela_state) {
8f502a4009822a Allison Henderson 2021-05-21  565        case XFS_DAS_UNINIT:
7a5d447970de2d Allison Henderson 2022-03-22  566                sf_size = 
sizeof(struct xfs_attr_sf_hdr) +
7a5d447970de2d Allison Henderson 2022-03-22  567                          
xfs_attr_sf_entsize_byname(args->namelen,
7a5d447970de2d Allison Henderson 2022-03-22  568                                
                             args->valuelen);
7a5d447970de2d Allison Henderson 2022-03-22  569                
xfs_bmap_set_attrforkoff(args->dp, sf_size, NULL);
7a5d447970de2d Allison Henderson 2022-03-22  570                args->dp->i_afp 
= kmem_cache_zalloc(xfs_ifork_cache, 0);
7a5d447970de2d Allison Henderson 2022-03-22  571                
args->dp->i_afp->if_format = XFS_DINODE_FMT_EXTENTS;
5a7bf541843b13 Dave Chinner      2022-04-14  572        case XFS_DAS_SF_ADD:
133b4f4350cc51 Allison Henderson 2022-04-11  573                return 
xfs_attr_sf_addname(attr);
5a7bf541843b13 Dave Chinner      2022-04-14  574        case XFS_DAS_LEAF_ADD:
133b4f4350cc51 Allison Henderson 2022-04-11  575                return 
xfs_attr_leaf_addname(attr);
5a7bf541843b13 Dave Chinner      2022-04-14  576        case XFS_DAS_NODE_ADD:
5a7bf541843b13 Dave Chinner      2022-04-14  577                return 
xfs_attr_node_addname(attr);
3f562d092bb1ed Allison Henderson 2021-02-12  578  
b8d9a2124c0193 Dave Chinner      2022-04-14  579        case XFS_DAS_SF_REMOVE:
f589c4f3a7a7d6 Dave Chinner      2022-04-14  580                error = 
xfs_attr_sf_removename(args);
f589c4f3a7a7d6 Dave Chinner      2022-04-14  581                
attr->xattri_dela_state = xfs_attr_complete_op(attr,
f589c4f3a7a7d6 Dave Chinner      2022-04-14  582                                
                xfs_attr_init_add_state(args));
f589c4f3a7a7d6 Dave Chinner      2022-04-14  583                break;
b8d9a2124c0193 Dave Chinner      2022-04-14  584        case 
XFS_DAS_LEAF_REMOVE:
f589c4f3a7a7d6 Dave Chinner      2022-04-14  585                error = 
xfs_attr_leaf_removename(args);
f589c4f3a7a7d6 Dave Chinner      2022-04-14  586                
attr->xattri_dela_state = xfs_attr_complete_op(attr,
f589c4f3a7a7d6 Dave Chinner      2022-04-14  587                                
                xfs_attr_init_add_state(args));
f589c4f3a7a7d6 Dave Chinner      2022-04-14  588                break;
b8d9a2124c0193 Dave Chinner      2022-04-14  589        case 
XFS_DAS_NODE_REMOVE:
b8d9a2124c0193 Dave Chinner      2022-04-14  590                error = 
xfs_attr_node_removename_setup(attr);
b8d9a2124c0193 Dave Chinner      2022-04-14  591                if (error)
b8d9a2124c0193 Dave Chinner      2022-04-14  592                        return 
error;
b8d9a2124c0193 Dave Chinner      2022-04-14  593                
attr->xattri_dela_state = XFS_DAS_NODE_REMOVE_RMT;
b8d9a2124c0193 Dave Chinner      2022-04-14  594                if 
(args->rmtblkno == 0)
b8d9a2124c0193 Dave Chinner      2022-04-14  595                        
attr->xattri_dela_state++;
b8d9a2124c0193 Dave Chinner      2022-04-14  596                break;
b8d9a2124c0193 Dave Chinner      2022-04-14  597  
020dee1bf99e76 Dave Chinner      2022-04-14  598        case 
XFS_DAS_LEAF_SET_RMT:
020dee1bf99e76 Dave Chinner      2022-04-14  599        case 
XFS_DAS_NODE_SET_RMT:
37e7bb8434f8b2 Allison Henderson 2022-04-11  600                error = 
xfs_attr_rmtval_find_space(attr);
83c6e70789ff37 Allison Henderson 2021-04-19  601                if (error)
83c6e70789ff37 Allison Henderson 2021-04-19  602                        return 
error;
100ba63970eed9 Dave Chinner      2022-04-14  603                
attr->xattri_dela_state++;
f1fdd499537724 Dave Chinner      2022-04-14  604                fallthrough;
020dee1bf99e76 Dave Chinner      2022-04-14  605  
f1fdd499537724 Dave Chinner      2022-04-14  606        case 
XFS_DAS_LEAF_ALLOC_RMT:
100ba63970eed9 Dave Chinner      2022-04-14  607        case 
XFS_DAS_NODE_ALLOC_RMT:
020dee1bf99e76 Dave Chinner      2022-04-14  608                error = 
xfs_attr_rmtval_alloc(attr);
8f502a4009822a Allison Henderson 2021-05-21  609                if (error)
8f502a4009822a Allison Henderson 2021-05-21  610                        return 
error;
f027184d93cf76 Dave Chinner      2022-04-14  611                /*
f027184d93cf76 Dave Chinner      2022-04-14  612                 * If there is 
still more to allocate we need to roll the
f027184d93cf76 Dave Chinner      2022-04-14  613                 * transaction 
so we have a full transaction reservation for
f027184d93cf76 Dave Chinner      2022-04-14  614                 * the next 
allocation.
f027184d93cf76 Dave Chinner      2022-04-14  615                 */
f027184d93cf76 Dave Chinner      2022-04-14  616                if 
(attr->xattri_blkcnt > 0)
f027184d93cf76 Dave Chinner      2022-04-14  617                        break;
020dee1bf99e76 Dave Chinner      2022-04-14  618                if 
(attr->xattri_dela_state == XFS_DAS_DONE)
020dee1bf99e76 Dave Chinner      2022-04-14  619                        break;
f027184d93cf76 Dave Chinner      2022-04-14  620  
f027184d93cf76 Dave Chinner      2022-04-14  621                goto next_state;
83c6e70789ff37 Allison Henderson 2021-04-19  622  
020dee1bf99e76 Dave Chinner      2022-04-14  623        case 
XFS_DAS_LEAF_REPLACE:
020dee1bf99e76 Dave Chinner      2022-04-14  624        case 
XFS_DAS_NODE_REPLACE:
83c6e70789ff37 Allison Henderson 2021-04-19  625                /*
f027184d93cf76 Dave Chinner      2022-04-14  626                 * We must 
"flip" the incomplete flags on the "new" and "old"
f027184d93cf76 Dave Chinner      2022-04-14  627                 * 
attribute/value pairs so that one disappears and one appears
6e971e92677394 Dave Chinner      2022-04-14  628                 * atomically.
83c6e70789ff37 Allison Henderson 2021-04-19  629                 */
83c6e70789ff37 Allison Henderson 2021-04-19  630                error = 
xfs_attr3_leaf_flipflags(args);
83c6e70789ff37 Allison Henderson 2021-04-19  631                if (error)
83c6e70789ff37 Allison Henderson 2021-04-19  632                        return 
error;
83c6e70789ff37 Allison Henderson 2021-04-19  633                /*
6e971e92677394 Dave Chinner      2022-04-14  634                 * We must 
commit the flag value change now to make it atomic
6e971e92677394 Dave Chinner      2022-04-14  635                 * and then we 
can start the next trans in series at REMOVE_OLD.
83c6e70789ff37 Allison Henderson 2021-04-19  636                 */
100ba63970eed9 Dave Chinner      2022-04-14  637                
attr->xattri_dela_state++;
020dee1bf99e76 Dave Chinner      2022-04-14  638                break;
f2d5674061121e Allison Henderson 2022-04-11  639  
f027184d93cf76 Dave Chinner      2022-04-14  640        case 
XFS_DAS_LEAF_REMOVE_OLD:
f027184d93cf76 Dave Chinner      2022-04-14  641        case 
XFS_DAS_NODE_REMOVE_OLD:
83c6e70789ff37 Allison Henderson 2021-04-19  642                /*
6e971e92677394 Dave Chinner      2022-04-14  643                 * If we have a 
remote attr, start the process of removing it
6e971e92677394 Dave Chinner      2022-04-14  644                 * by 
invalidating any cached buffers.
6e971e92677394 Dave Chinner      2022-04-14  645                 *
6e971e92677394 Dave Chinner      2022-04-14  646                 * If we don't 
have a remote attr, we skip the remote block
6e971e92677394 Dave Chinner      2022-04-14  647                 * removal 
state altogether with a second state increment.
83c6e70789ff37 Allison Henderson 2021-04-19  648                 */
83c6e70789ff37 Allison Henderson 2021-04-19  649                
xfs_attr_restore_rmt_blk(args);
6e971e92677394 Dave Chinner      2022-04-14  650                if 
(args->rmtblkno) {
83c6e70789ff37 Allison Henderson 2021-04-19  651                        error = 
xfs_attr_rmtval_invalidate(args);
83c6e70789ff37 Allison Henderson 2021-04-19  652                        if 
(error)
83c6e70789ff37 Allison Henderson 2021-04-19  653                                
return error;
6e971e92677394 Dave Chinner      2022-04-14  654                } else {
6e971e92677394 Dave Chinner      2022-04-14  655                        
attr->xattri_dela_state++;
6e971e92677394 Dave Chinner      2022-04-14  656                }
83c6e70789ff37 Allison Henderson 2021-04-19  657  
100ba63970eed9 Dave Chinner      2022-04-14  658                
attr->xattri_dela_state++;
6e971e92677394 Dave Chinner      2022-04-14  659                goto next_state;
6e971e92677394 Dave Chinner      2022-04-14  660  
6e971e92677394 Dave Chinner      2022-04-14  661        case 
XFS_DAS_LEAF_REMOVE_RMT:
6e971e92677394 Dave Chinner      2022-04-14  662        case 
XFS_DAS_NODE_REMOVE_RMT:
37e7bb8434f8b2 Allison Henderson 2022-04-11  663                error = 
xfs_attr_rmtval_remove(attr);
d56c93997e96ed Dave Chinner      2022-04-14  664                if (error == 
-EAGAIN) {
d56c93997e96ed Dave Chinner      2022-04-14  665                        error = 
0;
6e971e92677394 Dave Chinner      2022-04-14  666                        break;
d56c93997e96ed Dave Chinner      2022-04-14  667                }
83c6e70789ff37 Allison Henderson 2021-04-19  668                if (error)
83c6e70789ff37 Allison Henderson 2021-04-19  669                        return 
error;
8f502a4009822a Allison Henderson 2021-05-21  670  
100ba63970eed9 Dave Chinner      2022-04-14  671                /*
6e971e92677394 Dave Chinner      2022-04-14  672                 * We've 
finished removing the remote attr blocks, so commit the
6e971e92677394 Dave Chinner      2022-04-14  673                 * transaction 
and move on to removing the attr name from the
6e971e92677394 Dave Chinner      2022-04-14  674                 * leaf/node 
block. Removing the attr might require a full
6e971e92677394 Dave Chinner      2022-04-14  675                 * transaction 
reservation for btree block freeing, so we
6e971e92677394 Dave Chinner      2022-04-14  676                 * can't do 
that in the same transaction where we removed the
6e971e92677394 Dave Chinner      2022-04-14  677                 * remote attr 
blocks.
100ba63970eed9 Dave Chinner      2022-04-14  678                 */
100ba63970eed9 Dave Chinner      2022-04-14  679                
attr->xattri_dela_state++;
6e971e92677394 Dave Chinner      2022-04-14  680                break;
100ba63970eed9 Dave Chinner      2022-04-14  681  
e683cdbb8baf82 Dave Chinner      2022-04-14  682        case 
XFS_DAS_LEAF_REMOVE_ATTR:
e683cdbb8baf82 Dave Chinner      2022-04-14  683                error = 
xfs_attr_leaf_remove_attr(attr);
f589c4f3a7a7d6 Dave Chinner      2022-04-14  684                
attr->xattri_dela_state = xfs_attr_complete_op(attr,
f589c4f3a7a7d6 Dave Chinner      2022-04-14  685                                
                xfs_attr_init_add_state(args));
e683cdbb8baf82 Dave Chinner      2022-04-14  686                break;
5d954cc09f6bae Allison Henderson 2021-04-26  687  
e683cdbb8baf82 Dave Chinner      2022-04-14  688        case 
XFS_DAS_NODE_REMOVE_ATTR:
e683cdbb8baf82 Dave Chinner      2022-04-14  689                error = 
xfs_attr_node_remove_attr(attr);
f589c4f3a7a7d6 Dave Chinner      2022-04-14  690                
attr->xattri_dela_state = xfs_attr_complete_op(attr,
f589c4f3a7a7d6 Dave Chinner      2022-04-14  691                                
                xfs_attr_init_add_state(args));
8f502a4009822a Allison Henderson 2021-05-21  692                break;
8f502a4009822a Allison Henderson 2021-05-21  693        default:
4a4957c16dc674 Allison Henderson 2021-05-21  694                ASSERT(0);
8f502a4009822a Allison Henderson 2021-05-21  695                break;
8f502a4009822a Allison Henderson 2021-05-21  696        }
020dee1bf99e76 Dave Chinner      2022-04-14  697  
020dee1bf99e76 Dave Chinner      2022-04-14  698        
trace_xfs_attr_set_iter_return(attr->xattri_dela_state, args->dp);
6ca5a4a1f52952 Allison Henderson 2021-04-12  699        return error;
2f3cd809196381 Allison Henderson 2018-10-18  700  }
2f3cd809196381 Allison Henderson 2018-10-18  701  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to