CC: [email protected] CC: [email protected] BCC: [email protected] CC: [email protected] TO: Allison Henderson <[email protected]>
tree: https://github.com/allisonhenderson/xfs_work.git xfs-5.19-compose_pptrs head: 74ecccf0e89a132c2490f3a63661c535974c6a08 commit: 5e63097b3f9723c46738f7a739cb982675803434 [28/32] xfs: Add parent pointers to rename :::::: branch date: 6 days ago :::::: commit date: 6 days ago config: x86_64-randconfig-c007 (https://download.01.org/0day-ci/archive/20220512/[email protected]/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/5e63097b3f9723c46738f7a739cb982675803434 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 5e63097b3f9723c46738f7a739cb982675803434 # 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 <[email protected]> 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 ^~~~~~~~~~~~~~~~ drivers/input/keyboard/sunkbd.c:293: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(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); ^ 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 34 warnings (34 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. 79 warnings generated. drivers/net/wireless/ti/wl1251/rx.c:40: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(status, 0, sizeof(struct ieee80211_rx_status)); ^ 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 ^~~~~~~~~~~~~~~~ drivers/net/wireless/ti/wl1251/rx.c:40: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(status, 0, sizeof(struct ieee80211_rx_status)); ^ 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 ^~~~~~~~~~~~~~~~ drivers/net/wireless/ti/wl1251/rx.c:181: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(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); ^ 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 ^~~~~~~~~~~~~~~~ drivers/net/wireless/ti/wl1251/rx.c:181: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(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); ^ 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 77 warnings (77 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. 50 warnings generated. fs/xfs/xfs_inode.c:3003: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(i_tab, 0, *num_inodes * sizeof(struct xfs_inode *)); ^ 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_inode.c:3003: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(i_tab, 0, *num_inodes * sizeof(struct xfs_inode *)); ^ 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_inode.c:3329:3: warning: Value stored to 'error' is never read >> [clang-analyzer-deadcode.DeadStores] error = xfs_cross_rename(tp, src_dp, src_name, src_ip, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/xfs/xfs_inode.c:3329:3: note: Value stored to 'error' is never read error = xfs_cross_rename(tp, src_dp, src_name, src_ip, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 48 warnings (48 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. 48 warnings generated. fs/xfs/xfs_itable.c:320: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(bs1, 0, sizeof(struct xfs_bstat)); ^ 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_itable.c:320: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(bs1, 0, sizeof(struct xfs_bstat)); ^ 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_itable.c:448: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(ig1, 0, sizeof(struct xfs_inogrp)); ^ 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_itable.c:448: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(ig1, 0, sizeof(struct xfs_inogrp)); ^ 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 ^~~~~~~~~~~~~~~~ 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. 59 warnings generated. fs/fat/dir.c:45:18: warning: Access to field 'b_blocknr' results in a dereference of a null pointer (loaded from variable 'bh') [clang-analyzer-core.NullDereference] return ((loff_t)bh->b_blocknr << MSDOS_SB(sb)->dir_per_block_bits) ^ fs/fat/dir.c:1298:9: note: Calling 'fat_get_entry' while (fat_get_entry(dir, &pos, &bh, &de) > -1) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/fat/dir.c:121:10: note: Left side of '&&' is false if (*bh && *de && ^ fs/fat/dir.c:128:9: note: Calling 'fat__get_entry' return fat__get_entry(dir, pos, bh, de); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/fat/dir.c:95:6: note: Assuming 'err' is 0 if (err || !phys) ^~~ fs/fat/dir.c:95:6: note: Left side of '||' is false fs/fat/dir.c:95:13: note: Assuming 'phys' is not equal to 0 if (err || !phys) ^~~~~ fs/fat/dir.c:95:2: note: Taking false branch if (err || !phys) ^ fs/fat/dir.c:101:6: note: Assuming the condition is false if (*bh == NULL) { ^~~~~~~~~~~ fs/fat/dir.c:101:2: note: Taking false branch if (*bh == NULL) { ^ fs/fat/dir.c:128:9: note: Returning from 'fat__get_entry' return fat__get_entry(dir, pos, bh, de); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/fat/dir.c:1298:9: note: Returning from 'fat_get_entry' while (fat_get_entry(dir, &pos, &bh, &de) > -1) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/fat/dir.c:1298:2: note: Loop condition is true. Entering loop body while (fat_get_entry(dir, &pos, &bh, &de) > -1) { ^ fs/fat/dir.c:1300:3: note: Taking false branch if (pos >= FAT_MAX_DIR_SIZE) ^ fs/fat/dir.c:1303:7: note: Assuming the condition is false vim +/error +3329 fs/xfs/xfs_inode.c 7dcf5c3e4527cf Dave Chinner 2015-03-25 3194 f6bba2017afb3b Dave Chinner 2013-08-12 3195 /* f6bba2017afb3b Dave Chinner 2013-08-12 3196 * xfs_rename f6bba2017afb3b Dave Chinner 2013-08-12 3197 */ f6bba2017afb3b Dave Chinner 2013-08-12 3198 int f6bba2017afb3b Dave Chinner 2013-08-12 3199 xfs_rename( f736d93d76d3e9 Christoph Hellwig 2021-01-21 3200 struct user_namespace *mnt_userns, 7dcf5c3e4527cf Dave Chinner 2015-03-25 3201 struct xfs_inode *src_dp, f6bba2017afb3b Dave Chinner 2013-08-12 3202 struct xfs_name *src_name, 7dcf5c3e4527cf Dave Chinner 2015-03-25 3203 struct xfs_inode *src_ip, 7dcf5c3e4527cf Dave Chinner 2015-03-25 3204 struct xfs_inode *target_dp, f6bba2017afb3b Dave Chinner 2013-08-12 3205 struct xfs_name *target_name, 7dcf5c3e4527cf Dave Chinner 2015-03-25 3206 struct xfs_inode *target_ip, d31a1825450062 Carlos Maiolino 2014-12-24 3207 unsigned int flags) f6bba2017afb3b Dave Chinner 2013-08-12 3208 { 7dcf5c3e4527cf Dave Chinner 2015-03-25 3209 struct xfs_mount *mp = src_dp->i_mount; 7dcf5c3e4527cf Dave Chinner 2015-03-25 3210 struct xfs_trans *tp; 7dcf5c3e4527cf Dave Chinner 2015-03-25 3211 struct xfs_inode *wip = NULL; /* whiteout inode */ 7dcf5c3e4527cf Dave Chinner 2015-03-25 3212 struct xfs_inode *inodes[__XFS_SORT_INODES]; 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3213 int i; 95afcf5c7bca93 Dave Chinner 2015-03-25 3214 int num_inodes = __XFS_SORT_INODES; 2b93681f593577 Dave Chinner 2015-03-25 3215 bool new_parent = (src_dp != target_dp); c19b3b05ae440d Dave Chinner 2016-02-09 3216 bool src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode); f6bba2017afb3b Dave Chinner 2013-08-12 3217 int spaceres; 41667260bc84db Darrick J. Wong 2022-03-09 3218 bool retried = false; 41667260bc84db Darrick J. Wong 2022-03-09 3219 int error, nospace_error = 0; 5e63097b3f9723 Allison Henderson 2022-03-22 3220 struct xfs_parent_name_rec new_rec; 5e63097b3f9723 Allison Henderson 2022-03-22 3221 struct xfs_parent_name_rec old_rec; 5e63097b3f9723 Allison Henderson 2022-03-22 3222 xfs_dir2_dataptr_t new_diroffset; 5e63097b3f9723 Allison Henderson 2022-03-22 3223 xfs_dir2_dataptr_t old_diroffset; 5e63097b3f9723 Allison Henderson 2022-03-22 3224 struct xfs_da_args new_args = { 5e63097b3f9723 Allison Henderson 2022-03-22 3225 .dp = src_ip, 5e63097b3f9723 Allison Henderson 2022-03-22 3226 .geo = mp->m_attr_geo, 5e63097b3f9723 Allison Henderson 2022-03-22 3227 .whichfork = XFS_ATTR_FORK, 5e63097b3f9723 Allison Henderson 2022-03-22 3228 .attr_filter = XFS_ATTR_PARENT, 5e63097b3f9723 Allison Henderson 2022-03-22 3229 .op_flags = XFS_DA_OP_OKNOENT, 5e63097b3f9723 Allison Henderson 2022-03-22 3230 .name = (const uint8_t *)&new_rec, 5e63097b3f9723 Allison Henderson 2022-03-22 3231 .namelen = sizeof(new_rec), 5e63097b3f9723 Allison Henderson 2022-03-22 3232 .value = (void *)target_name->name, 5e63097b3f9723 Allison Henderson 2022-03-22 3233 .valuelen = target_name->len, 5e63097b3f9723 Allison Henderson 2022-03-22 3234 }; 5e63097b3f9723 Allison Henderson 2022-03-22 3235 struct xfs_da_args old_args = { 5e63097b3f9723 Allison Henderson 2022-03-22 3236 .dp = src_ip, 5e63097b3f9723 Allison Henderson 2022-03-22 3237 .geo = mp->m_attr_geo, 5e63097b3f9723 Allison Henderson 2022-03-22 3238 .whichfork = XFS_ATTR_FORK, 5e63097b3f9723 Allison Henderson 2022-03-22 3239 .attr_filter = XFS_ATTR_PARENT, 5e63097b3f9723 Allison Henderson 2022-03-22 3240 .op_flags = XFS_DA_OP_OKNOENT, 5e63097b3f9723 Allison Henderson 2022-03-22 3241 .name = (const uint8_t *)&old_rec, 5e63097b3f9723 Allison Henderson 2022-03-22 3242 .namelen = sizeof(old_rec), 5e63097b3f9723 Allison Henderson 2022-03-22 3243 .value = NULL, 5e63097b3f9723 Allison Henderson 2022-03-22 3244 .valuelen = 0, 5e63097b3f9723 Allison Henderson 2022-03-22 3245 }; f6bba2017afb3b Dave Chinner 2013-08-12 3246 f6bba2017afb3b Dave Chinner 2013-08-12 3247 trace_xfs_rename(src_dp, target_dp, src_name, target_name); f6bba2017afb3b Dave Chinner 2013-08-12 3248 eeacd3217b8fa8 Dave Chinner 2015-03-25 3249 if ((flags & RENAME_EXCHANGE) && !target_ip) eeacd3217b8fa8 Dave Chinner 2015-03-25 3250 return -EINVAL; eeacd3217b8fa8 Dave Chinner 2015-03-25 3251 7dcf5c3e4527cf Dave Chinner 2015-03-25 3252 /* 7dcf5c3e4527cf Dave Chinner 2015-03-25 3253 * If we are doing a whiteout operation, allocate the whiteout inode 7dcf5c3e4527cf Dave Chinner 2015-03-25 3254 * we will be placing at the target and ensure the type is set 7dcf5c3e4527cf Dave Chinner 2015-03-25 3255 * appropriately. 7dcf5c3e4527cf Dave Chinner 2015-03-25 3256 */ 7dcf5c3e4527cf Dave Chinner 2015-03-25 3257 if (flags & RENAME_WHITEOUT) { f736d93d76d3e9 Christoph Hellwig 2021-01-21 3258 error = xfs_rename_alloc_whiteout(mnt_userns, target_dp, &wip); 7dcf5c3e4527cf Dave Chinner 2015-03-25 3259 if (error) 7dcf5c3e4527cf Dave Chinner 2015-03-25 3260 return error; f6bba2017afb3b Dave Chinner 2013-08-12 3261 7dcf5c3e4527cf Dave Chinner 2015-03-25 3262 /* setup target dirent info as whiteout */ 7dcf5c3e4527cf Dave Chinner 2015-03-25 3263 src_name->type = XFS_DIR3_FT_CHRDEV; 7dcf5c3e4527cf Dave Chinner 2015-03-25 3264 } f6bba2017afb3b Dave Chinner 2013-08-12 3265 7dcf5c3e4527cf Dave Chinner 2015-03-25 3266 xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip, wip, f6bba2017afb3b Dave Chinner 2013-08-12 3267 inodes, &num_inodes); 5e63097b3f9723 Allison Henderson 2022-03-22 3268 if (xfs_has_larp(mp)) { 5e63097b3f9723 Allison Henderson 2022-03-22 3269 error = xfs_attr_use_log_assist(mp); 5e63097b3f9723 Allison Henderson 2022-03-22 3270 if (error) 5e63097b3f9723 Allison Henderson 2022-03-22 3271 goto out_release_wip; 5e63097b3f9723 Allison Henderson 2022-03-22 3272 } f6bba2017afb3b Dave Chinner 2013-08-12 3273 41667260bc84db Darrick J. Wong 2022-03-09 3274 retry: 41667260bc84db Darrick J. Wong 2022-03-09 3275 nospace_error = 0; f6bba2017afb3b Dave Chinner 2013-08-12 3276 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); 253f4911f297b8 Christoph Hellwig 2016-04-06 3277 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, spaceres, 0, 0, &tp); 2451337dd04390 Dave Chinner 2014-06-25 3278 if (error == -ENOSPC) { 41667260bc84db Darrick J. Wong 2022-03-09 3279 nospace_error = error; f6bba2017afb3b Dave Chinner 2013-08-12 3280 spaceres = 0; 253f4911f297b8 Christoph Hellwig 2016-04-06 3281 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, 0, 0, 0, 253f4911f297b8 Christoph Hellwig 2016-04-06 3282 &tp); f6bba2017afb3b Dave Chinner 2013-08-12 3283 } 445883e8133975 Dave Chinner 2015-03-25 3284 if (error) 5e63097b3f9723 Allison Henderson 2022-03-22 3285 goto drop_incompat; f6bba2017afb3b Dave Chinner 2013-08-12 3286 f6bba2017afb3b Dave Chinner 2013-08-12 3287 /* f6bba2017afb3b Dave Chinner 2013-08-12 3288 * Attach the dquots to the inodes f6bba2017afb3b Dave Chinner 2013-08-12 3289 */ f6bba2017afb3b Dave Chinner 2013-08-12 3290 error = xfs_qm_vop_rename_dqattach(inodes); 445883e8133975 Dave Chinner 2015-03-25 3291 if (error) 445883e8133975 Dave Chinner 2015-03-25 3292 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3293 f6bba2017afb3b Dave Chinner 2013-08-12 3294 /* f6bba2017afb3b Dave Chinner 2013-08-12 3295 * Lock all the participating inodes. Depending upon whether f6bba2017afb3b Dave Chinner 2013-08-12 3296 * the target_name exists in the target directory, and f6bba2017afb3b Dave Chinner 2013-08-12 3297 * whether the target directory is the same as the source f6bba2017afb3b Dave Chinner 2013-08-12 3298 * directory, we can lock from 2 to 4 inodes. f6bba2017afb3b Dave Chinner 2013-08-12 3299 */ f6bba2017afb3b Dave Chinner 2013-08-12 3300 xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); f6bba2017afb3b Dave Chinner 2013-08-12 3301 f6bba2017afb3b Dave Chinner 2013-08-12 3302 /* f6bba2017afb3b Dave Chinner 2013-08-12 3303 * Join all the inodes to the transaction. From this point on, f6bba2017afb3b Dave Chinner 2013-08-12 3304 * we can rely on either trans_commit or trans_cancel to unlock f6bba2017afb3b Dave Chinner 2013-08-12 3305 * them. f6bba2017afb3b Dave Chinner 2013-08-12 3306 */ 5e63097b3f9723 Allison Henderson 2022-03-22 3307 xfs_trans_ijoin(tp, src_dp, 0); f6bba2017afb3b Dave Chinner 2013-08-12 3308 if (new_parent) 5e63097b3f9723 Allison Henderson 2022-03-22 3309 xfs_trans_ijoin(tp, target_dp, 0); 5e63097b3f9723 Allison Henderson 2022-03-22 3310 xfs_trans_ijoin(tp, src_ip, 0); f6bba2017afb3b Dave Chinner 2013-08-12 3311 if (target_ip) 5e63097b3f9723 Allison Henderson 2022-03-22 3312 xfs_trans_ijoin(tp, target_ip, 0); 7dcf5c3e4527cf Dave Chinner 2015-03-25 3313 if (wip) 5e63097b3f9723 Allison Henderson 2022-03-22 3314 xfs_trans_ijoin(tp, wip, 0); f6bba2017afb3b Dave Chinner 2013-08-12 3315 f6bba2017afb3b Dave Chinner 2013-08-12 3316 /* f6bba2017afb3b Dave Chinner 2013-08-12 3317 * If we are using project inheritance, we only allow renames f6bba2017afb3b Dave Chinner 2013-08-12 3318 * into our tree when the project IDs are the same; else the f6bba2017afb3b Dave Chinner 2013-08-12 3319 * tree quota mechanism would be circumvented. f6bba2017afb3b Dave Chinner 2013-08-12 3320 */ db07349da2f564 Christoph Hellwig 2021-03-29 3321 if (unlikely((target_dp->i_diflags & XFS_DIFLAG_PROJINHERIT) && ceaf603c7024d3 Christoph Hellwig 2021-03-29 3322 target_dp->i_projid != src_ip->i_projid)) { 2451337dd04390 Dave Chinner 2014-06-25 3323 error = -EXDEV; 5e63097b3f9723 Allison Henderson 2022-03-22 3324 goto out_unlock; f6bba2017afb3b Dave Chinner 2013-08-12 3325 } f6bba2017afb3b Dave Chinner 2013-08-12 3326 eeacd3217b8fa8 Dave Chinner 2015-03-25 3327 /* RENAME_EXCHANGE is unique from here on. */ 5e63097b3f9723 Allison Henderson 2022-03-22 3328 if (flags & RENAME_EXCHANGE) { 5e63097b3f9723 Allison Henderson 2022-03-22 @3329 error = xfs_cross_rename(tp, src_dp, src_name, src_ip, d31a1825450062 Carlos Maiolino 2014-12-24 3330 target_dp, target_name, target_ip, f16dea54b789aa Brian Foster 2018-07-11 3331 spaceres); 5e63097b3f9723 Allison Henderson 2022-03-22 3332 goto out_pptr; 5e63097b3f9723 Allison Henderson 2022-03-22 3333 } 41667260bc84db Darrick J. Wong 2022-03-09 3334 /* 41667260bc84db Darrick J. Wong 2022-03-09 3335 * Try to reserve quota to handle an expansion of the target directory. 41667260bc84db Darrick J. Wong 2022-03-09 3336 * We'll allow the rename to continue in reservationless mode if we hit 41667260bc84db Darrick J. Wong 2022-03-09 3337 * a space usage constraint. If we trigger reservationless mode, save 41667260bc84db Darrick J. Wong 2022-03-09 3338 * the errno if there isn't any free space in the target directory. 41667260bc84db Darrick J. Wong 2022-03-09 3339 */ 41667260bc84db Darrick J. Wong 2022-03-09 3340 if (spaceres != 0) { 41667260bc84db Darrick J. Wong 2022-03-09 3341 error = xfs_trans_reserve_quota_nblks(tp, target_dp, spaceres, 41667260bc84db Darrick J. Wong 2022-03-09 3342 0, false); 41667260bc84db Darrick J. Wong 2022-03-09 3343 if (error == -EDQUOT || error == -ENOSPC) { 41667260bc84db Darrick J. Wong 2022-03-09 3344 if (!retried) { 41667260bc84db Darrick J. Wong 2022-03-09 3345 xfs_trans_cancel(tp); 41667260bc84db Darrick J. Wong 2022-03-09 3346 xfs_blockgc_free_quota(target_dp, 0); 41667260bc84db Darrick J. Wong 2022-03-09 3347 retried = true; 41667260bc84db Darrick J. Wong 2022-03-09 3348 goto retry; 41667260bc84db Darrick J. Wong 2022-03-09 3349 } 41667260bc84db Darrick J. Wong 2022-03-09 3350 41667260bc84db Darrick J. Wong 2022-03-09 3351 nospace_error = error; 41667260bc84db Darrick J. Wong 2022-03-09 3352 spaceres = 0; 41667260bc84db Darrick J. Wong 2022-03-09 3353 error = 0; 41667260bc84db Darrick J. Wong 2022-03-09 3354 } 41667260bc84db Darrick J. Wong 2022-03-09 3355 if (error) 41667260bc84db Darrick J. Wong 2022-03-09 3356 goto out_trans_cancel; 41667260bc84db Darrick J. Wong 2022-03-09 3357 } 41667260bc84db Darrick J. Wong 2022-03-09 3358 f6bba2017afb3b Dave Chinner 2013-08-12 3359 /* bc56ad8c74b858 kaixuxia 2019-09-03 3360 * Check for expected errors before we dirty the transaction bc56ad8c74b858 kaixuxia 2019-09-03 3361 * so we can return an error without a transaction abort. f6bba2017afb3b Dave Chinner 2013-08-12 3362 */ f6bba2017afb3b Dave Chinner 2013-08-12 3363 if (target_ip == NULL) { f6bba2017afb3b Dave Chinner 2013-08-12 3364 /* f6bba2017afb3b Dave Chinner 2013-08-12 3365 * If there's no space reservation, check the entry will f6bba2017afb3b Dave Chinner 2013-08-12 3366 * fit before actually inserting it. f6bba2017afb3b Dave Chinner 2013-08-12 3367 */ 94f3cad555d660 Eric Sandeen 2014-09-09 3368 if (!spaceres) { 94f3cad555d660 Eric Sandeen 2014-09-09 3369 error = xfs_dir_canenter(tp, target_dp, target_name); f6bba2017afb3b Dave Chinner 2013-08-12 3370 if (error) 445883e8133975 Dave Chinner 2015-03-25 3371 goto out_trans_cancel; 94f3cad555d660 Eric Sandeen 2014-09-09 3372 } bc56ad8c74b858 kaixuxia 2019-09-03 3373 } else { bc56ad8c74b858 kaixuxia 2019-09-03 3374 /* bc56ad8c74b858 kaixuxia 2019-09-03 3375 * If target exists and it's a directory, check that whether bc56ad8c74b858 kaixuxia 2019-09-03 3376 * it can be destroyed. bc56ad8c74b858 kaixuxia 2019-09-03 3377 */ bc56ad8c74b858 kaixuxia 2019-09-03 3378 if (S_ISDIR(VFS_I(target_ip)->i_mode) && bc56ad8c74b858 kaixuxia 2019-09-03 3379 (!xfs_dir_isempty(target_ip) || bc56ad8c74b858 kaixuxia 2019-09-03 3380 (VFS_I(target_ip)->i_nlink > 2))) { bc56ad8c74b858 kaixuxia 2019-09-03 3381 error = -EEXIST; bc56ad8c74b858 kaixuxia 2019-09-03 3382 goto out_trans_cancel; bc56ad8c74b858 kaixuxia 2019-09-03 3383 } bc56ad8c74b858 kaixuxia 2019-09-03 3384 } bc56ad8c74b858 kaixuxia 2019-09-03 3385 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3386 /* 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3387 * Lock the AGI buffers we need to handle bumping the nlink of the 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3388 * whiteout inode off the unlinked list and to handle dropping the 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3389 * nlink of the target inode. Per locking order rules, do this in 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3390 * increasing AG order and before directory block allocation tries to 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3391 * grab AGFs because we grab AGIs before AGFs. 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3392 * 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3393 * The (vfs) caller must ensure that if src is a directory then 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3394 * target_ip is either null or an empty directory. 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3395 */ 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3396 for (i = 0; i < num_inodes && inodes[i] != NULL; i++) { 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3397 if (inodes[i] == wip || 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3398 (inodes[i] == target_ip && 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3399 (VFS_I(target_ip)->i_nlink == 1 || src_is_directory))) { 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3400 struct xfs_buf *bp; 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3401 xfs_agnumber_t agno; 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3402 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3403 agno = XFS_INO_TO_AGNO(mp, inodes[i]->i_ino); 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3404 error = xfs_read_agi(mp, tp, agno, &bp); 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3405 if (error) 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3406 goto out_trans_cancel; 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3407 } 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3408 } 6da1b4b1ab36d8 Darrick J. Wong 2021-01-22 3409 bc56ad8c74b858 kaixuxia 2019-09-03 3410 /* bc56ad8c74b858 kaixuxia 2019-09-03 3411 * Directory entry creation below may acquire the AGF. Remove bc56ad8c74b858 kaixuxia 2019-09-03 3412 * the whiteout from the unlinked list first to preserve correct bc56ad8c74b858 kaixuxia 2019-09-03 3413 * AGI/AGF locking order. This dirties the transaction so failures bc56ad8c74b858 kaixuxia 2019-09-03 3414 * after this point will abort and log recovery will clean up the bc56ad8c74b858 kaixuxia 2019-09-03 3415 * mess. bc56ad8c74b858 kaixuxia 2019-09-03 3416 * bc56ad8c74b858 kaixuxia 2019-09-03 3417 * For whiteouts, we need to bump the link count on the whiteout bc56ad8c74b858 kaixuxia 2019-09-03 3418 * inode. After this point, we have a real link, clear the tmpfile bc56ad8c74b858 kaixuxia 2019-09-03 3419 * state flag from the inode so it doesn't accidentally get misused bc56ad8c74b858 kaixuxia 2019-09-03 3420 * in future. bc56ad8c74b858 kaixuxia 2019-09-03 3421 */ bc56ad8c74b858 kaixuxia 2019-09-03 3422 if (wip) { f40aadb2bb64fe Dave Chinner 2021-06-02 3423 struct xfs_perag *pag; f40aadb2bb64fe Dave Chinner 2021-06-02 3424 bc56ad8c74b858 kaixuxia 2019-09-03 3425 ASSERT(VFS_I(wip)->i_nlink == 0); f40aadb2bb64fe Dave Chinner 2021-06-02 3426 f40aadb2bb64fe Dave Chinner 2021-06-02 3427 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, wip->i_ino)); f40aadb2bb64fe Dave Chinner 2021-06-02 3428 error = xfs_iunlink_remove(tp, pag, wip); f40aadb2bb64fe Dave Chinner 2021-06-02 3429 xfs_perag_put(pag); bc56ad8c74b858 kaixuxia 2019-09-03 3430 if (error) bc56ad8c74b858 kaixuxia 2019-09-03 3431 goto out_trans_cancel; bc56ad8c74b858 kaixuxia 2019-09-03 3432 bc56ad8c74b858 kaixuxia 2019-09-03 3433 xfs_bumplink(tp, wip); bc56ad8c74b858 kaixuxia 2019-09-03 3434 VFS_I(wip)->i_state &= ~I_LINKABLE; bc56ad8c74b858 kaixuxia 2019-09-03 3435 } bc56ad8c74b858 kaixuxia 2019-09-03 3436 bc56ad8c74b858 kaixuxia 2019-09-03 3437 /* bc56ad8c74b858 kaixuxia 2019-09-03 3438 * Set up the target. bc56ad8c74b858 kaixuxia 2019-09-03 3439 */ bc56ad8c74b858 kaixuxia 2019-09-03 3440 if (target_ip == NULL) { f6bba2017afb3b Dave Chinner 2013-08-12 3441 /* f6bba2017afb3b Dave Chinner 2013-08-12 3442 * If target does not exist and the rename crosses f6bba2017afb3b Dave Chinner 2013-08-12 3443 * directories, adjust the target directory link count f6bba2017afb3b Dave Chinner 2013-08-12 3444 * to account for the ".." reference from the new entry. f6bba2017afb3b Dave Chinner 2013-08-12 3445 */ f6bba2017afb3b Dave Chinner 2013-08-12 3446 error = xfs_dir_createname(tp, target_dp, target_name, 5e63097b3f9723 Allison Henderson 2022-03-22 3447 src_ip->i_ino, spaceres, &new_diroffset); f6bba2017afb3b Dave Chinner 2013-08-12 3448 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3449 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3450 f6bba2017afb3b Dave Chinner 2013-08-12 3451 xfs_trans_ichgtime(tp, target_dp, f6bba2017afb3b Dave Chinner 2013-08-12 3452 XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); f6bba2017afb3b Dave Chinner 2013-08-12 3453 f6bba2017afb3b Dave Chinner 2013-08-12 3454 if (new_parent && src_is_directory) { 910832697cf855 Eric Sandeen 2019-05-01 3455 xfs_bumplink(tp, target_dp); f6bba2017afb3b Dave Chinner 2013-08-12 3456 } f6bba2017afb3b Dave Chinner 2013-08-12 3457 } else { /* target_ip != NULL */ f6bba2017afb3b Dave Chinner 2013-08-12 3458 /* f6bba2017afb3b Dave Chinner 2013-08-12 3459 * Link the source inode under the target name. f6bba2017afb3b Dave Chinner 2013-08-12 3460 * If the source inode is a directory and we are moving f6bba2017afb3b Dave Chinner 2013-08-12 3461 * it across directories, its ".." entry will be f6bba2017afb3b Dave Chinner 2013-08-12 3462 * inconsistent until we replace that down below. f6bba2017afb3b Dave Chinner 2013-08-12 3463 * f6bba2017afb3b Dave Chinner 2013-08-12 3464 * In case there is already an entry with the same f6bba2017afb3b Dave Chinner 2013-08-12 3465 * name at the destination directory, remove it first. f6bba2017afb3b Dave Chinner 2013-08-12 3466 */ f6bba2017afb3b Dave Chinner 2013-08-12 3467 error = xfs_dir_replace(tp, target_dp, target_name, 5e63097b3f9723 Allison Henderson 2022-03-22 3468 src_ip->i_ino, spaceres, &new_diroffset); f6bba2017afb3b Dave Chinner 2013-08-12 3469 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3470 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3471 f6bba2017afb3b Dave Chinner 2013-08-12 3472 xfs_trans_ichgtime(tp, target_dp, f6bba2017afb3b Dave Chinner 2013-08-12 3473 XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); f6bba2017afb3b Dave Chinner 2013-08-12 3474 f6bba2017afb3b Dave Chinner 2013-08-12 3475 /* f6bba2017afb3b Dave Chinner 2013-08-12 3476 * Decrement the link count on the target since the target f6bba2017afb3b Dave Chinner 2013-08-12 3477 * dir no longer points to it. f6bba2017afb3b Dave Chinner 2013-08-12 3478 */ f6bba2017afb3b Dave Chinner 2013-08-12 3479 error = xfs_droplink(tp, target_ip); f6bba2017afb3b Dave Chinner 2013-08-12 3480 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3481 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3482 f6bba2017afb3b Dave Chinner 2013-08-12 3483 if (src_is_directory) { f6bba2017afb3b Dave Chinner 2013-08-12 3484 /* f6bba2017afb3b Dave Chinner 2013-08-12 3485 * Drop the link from the old "." entry. f6bba2017afb3b Dave Chinner 2013-08-12 3486 */ f6bba2017afb3b Dave Chinner 2013-08-12 3487 error = xfs_droplink(tp, target_ip); f6bba2017afb3b Dave Chinner 2013-08-12 3488 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3489 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3490 } f6bba2017afb3b Dave Chinner 2013-08-12 3491 } /* target_ip != NULL */ f6bba2017afb3b Dave Chinner 2013-08-12 3492 f6bba2017afb3b Dave Chinner 2013-08-12 3493 /* f6bba2017afb3b Dave Chinner 2013-08-12 3494 * Remove the source. f6bba2017afb3b Dave Chinner 2013-08-12 3495 */ f6bba2017afb3b Dave Chinner 2013-08-12 3496 if (new_parent && src_is_directory) { f6bba2017afb3b Dave Chinner 2013-08-12 3497 /* f6bba2017afb3b Dave Chinner 2013-08-12 3498 * Rewrite the ".." entry to point to the new f6bba2017afb3b Dave Chinner 2013-08-12 3499 * directory. f6bba2017afb3b Dave Chinner 2013-08-12 3500 */ f6bba2017afb3b Dave Chinner 2013-08-12 3501 error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, 5e63097b3f9723 Allison Henderson 2022-03-22 3502 target_dp->i_ino, spaceres, &new_diroffset); 2451337dd04390 Dave Chinner 2014-06-25 3503 ASSERT(error != -EEXIST); f6bba2017afb3b Dave Chinner 2013-08-12 3504 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3505 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3506 } f6bba2017afb3b Dave Chinner 2013-08-12 3507 f6bba2017afb3b Dave Chinner 2013-08-12 3508 /* f6bba2017afb3b Dave Chinner 2013-08-12 3509 * We always want to hit the ctime on the source inode. f6bba2017afb3b Dave Chinner 2013-08-12 3510 * f6bba2017afb3b Dave Chinner 2013-08-12 3511 * This isn't strictly required by the standards since the source f6bba2017afb3b Dave Chinner 2013-08-12 3512 * inode isn't really being changed, but old unix file systems did f6bba2017afb3b Dave Chinner 2013-08-12 3513 * it and some incremental backup programs won't work without it. f6bba2017afb3b Dave Chinner 2013-08-12 3514 */ f6bba2017afb3b Dave Chinner 2013-08-12 3515 xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG); f6bba2017afb3b Dave Chinner 2013-08-12 3516 xfs_trans_log_inode(tp, src_ip, XFS_ILOG_CORE); f6bba2017afb3b Dave Chinner 2013-08-12 3517 f6bba2017afb3b Dave Chinner 2013-08-12 3518 /* f6bba2017afb3b Dave Chinner 2013-08-12 3519 * Adjust the link count on src_dp. This is necessary when f6bba2017afb3b Dave Chinner 2013-08-12 3520 * renaming a directory, either within one parent when f6bba2017afb3b Dave Chinner 2013-08-12 3521 * the target existed, or across two parent directories. f6bba2017afb3b Dave Chinner 2013-08-12 3522 */ f6bba2017afb3b Dave Chinner 2013-08-12 3523 if (src_is_directory && (new_parent || target_ip != NULL)) { f6bba2017afb3b Dave Chinner 2013-08-12 3524 f6bba2017afb3b Dave Chinner 2013-08-12 3525 /* f6bba2017afb3b Dave Chinner 2013-08-12 3526 * Decrement link count on src_directory since the f6bba2017afb3b Dave Chinner 2013-08-12 3527 * entry that's moved no longer points to it. f6bba2017afb3b Dave Chinner 2013-08-12 3528 */ f6bba2017afb3b Dave Chinner 2013-08-12 3529 error = xfs_droplink(tp, src_dp); f6bba2017afb3b Dave Chinner 2013-08-12 3530 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3531 goto out_trans_cancel; f6bba2017afb3b Dave Chinner 2013-08-12 3532 } f6bba2017afb3b Dave Chinner 2013-08-12 3533 7dcf5c3e4527cf Dave Chinner 2015-03-25 3534 /* 7dcf5c3e4527cf Dave Chinner 2015-03-25 3535 * For whiteouts, we only need to update the source dirent with the 7dcf5c3e4527cf Dave Chinner 2015-03-25 3536 * inode number of the whiteout inode rather than removing it 7dcf5c3e4527cf Dave Chinner 2015-03-25 3537 * altogether. 7dcf5c3e4527cf Dave Chinner 2015-03-25 3538 */ 49076df67754f5 Chandan Babu R 2022-04-11 3539 if (wip) 7dcf5c3e4527cf Dave Chinner 2015-03-25 3540 error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, 5e63097b3f9723 Allison Henderson 2022-03-22 3541 spaceres, &old_diroffset); 49076df67754f5 Chandan Babu R 2022-04-11 3542 else f6bba2017afb3b Dave Chinner 2013-08-12 3543 error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, 5e63097b3f9723 Allison Henderson 2022-03-22 3544 spaceres, &old_diroffset); 5e63097b3f9723 Allison Henderson 2022-03-22 3545 5e63097b3f9723 Allison Henderson 2022-03-22 3546 if (error) 5e63097b3f9723 Allison Henderson 2022-03-22 3547 goto out_trans_cancel; 5e63097b3f9723 Allison Henderson 2022-03-22 3548 5e63097b3f9723 Allison Henderson 2022-03-22 3549 out_pptr: 5e63097b3f9723 Allison Henderson 2022-03-22 3550 if (xfs_sb_version_hasparent(&mp->m_sb)) { 5e63097b3f9723 Allison Henderson 2022-03-22 3551 new_args.trans = tp; 5e63097b3f9723 Allison Henderson 2022-03-22 3552 xfs_init_parent_name_rec(&new_rec, target_dp, new_diroffset); 5e63097b3f9723 Allison Henderson 2022-03-22 3553 new_args.hashval = xfs_da_hashname(new_args.name, 5e63097b3f9723 Allison Henderson 2022-03-22 3554 new_args.namelen); 5e63097b3f9723 Allison Henderson 2022-03-22 3555 error = xfs_attr_defer_add(&new_args); 5e63097b3f9723 Allison Henderson 2022-03-22 3556 if (error) 5e63097b3f9723 Allison Henderson 2022-03-22 3557 goto out_trans_cancel; 02092a2f034fde Chandan Babu R 2021-01-22 3558 5e63097b3f9723 Allison Henderson 2022-03-22 3559 old_args.trans = tp; 5e63097b3f9723 Allison Henderson 2022-03-22 3560 xfs_init_parent_name_rec(&old_rec, src_dp, old_diroffset); 5e63097b3f9723 Allison Henderson 2022-03-22 3561 old_args.hashval = xfs_da_hashname(old_args.name, 5e63097b3f9723 Allison Henderson 2022-03-22 3562 old_args.namelen); 5e63097b3f9723 Allison Henderson 2022-03-22 3563 error = xfs_attr_defer_remove(&old_args); f6bba2017afb3b Dave Chinner 2013-08-12 3564 if (error) c8eac49ef798a7 Brian Foster 2018-07-24 3565 goto out_trans_cancel; 5e63097b3f9723 Allison Henderson 2022-03-22 3566 } f6bba2017afb3b Dave Chinner 2013-08-12 3567 f6bba2017afb3b Dave Chinner 2013-08-12 3568 xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); f6bba2017afb3b Dave Chinner 2013-08-12 3569 xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE); f6bba2017afb3b Dave Chinner 2013-08-12 3570 if (new_parent) f6bba2017afb3b Dave Chinner 2013-08-12 3571 xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); f6bba2017afb3b Dave Chinner 2013-08-12 3572 c9cfdb38117217 Brian Foster 2018-07-11 3573 error = xfs_finish_rename(tp); 5e63097b3f9723 Allison Henderson 2022-03-22 3574 5e63097b3f9723 Allison Henderson 2022-03-22 3575 out_unlock: 7dcf5c3e4527cf Dave Chinner 2015-03-25 3576 if (wip) 44a8736bd20a08 Darrick J. Wong 2018-07-25 3577 xfs_irele(wip); 5e63097b3f9723 Allison Henderson 2022-03-22 3578 if (wip) 5e63097b3f9723 Allison Henderson 2022-03-22 3579 xfs_iunlock(wip, XFS_ILOCK_EXCL); 5e63097b3f9723 Allison Henderson 2022-03-22 3580 if (target_ip) 5e63097b3f9723 Allison Henderson 2022-03-22 3581 xfs_iunlock(target_ip, XFS_ILOCK_EXCL); 5e63097b3f9723 Allison Henderson 2022-03-22 3582 xfs_iunlock(src_ip, XFS_ILOCK_EXCL); 5e63097b3f9723 Allison Henderson 2022-03-22 3583 if (new_parent) 5e63097b3f9723 Allison Henderson 2022-03-22 3584 xfs_iunlock(target_dp, XFS_ILOCK_EXCL); 5e63097b3f9723 Allison Henderson 2022-03-22 3585 xfs_iunlock(src_dp, XFS_ILOCK_EXCL); 5e63097b3f9723 Allison Henderson 2022-03-22 3586 7dcf5c3e4527cf Dave Chinner 2015-03-25 3587 return error; f6bba2017afb3b Dave Chinner 2013-08-12 3588 445883e8133975 Dave Chinner 2015-03-25 3589 out_trans_cancel: 4906e21545814e Christoph Hellwig 2015-06-04 3590 xfs_trans_cancel(tp); 5e63097b3f9723 Allison Henderson 2022-03-22 3591 drop_incompat: 5e63097b3f9723 Allison Henderson 2022-03-22 3592 if (xfs_has_larp(mp)) 5e63097b3f9723 Allison Henderson 2022-03-22 3593 xlog_drop_incompat_feat(mp->m_log); 253f4911f297b8 Christoph Hellwig 2016-04-06 3594 out_release_wip: 7dcf5c3e4527cf Dave Chinner 2015-03-25 3595 if (wip) 44a8736bd20a08 Darrick J. Wong 2018-07-25 3596 xfs_irele(wip); 41667260bc84db Darrick J. Wong 2022-03-09 3597 if (error == -ENOSPC && nospace_error) 41667260bc84db Darrick J. Wong 2022-03-09 3598 error = nospace_error; f6bba2017afb3b Dave Chinner 2013-08-12 3599 return error; f6bba2017afb3b Dave Chinner 2013-08-12 3600 } f6bba2017afb3b Dave Chinner 2013-08-12 3601 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
