Lines Matching +full:tp +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
68 * ASCII case-insensitive (ie. A-Z) support for directories that was
78 for (i = 0, hash = 0; i < name->len; i++) in xfs_ascii_ci_hashname()
79 hash = xfs_ascii_ci_xfrm(name->name[i]) ^ rol32(hash, 7); in xfs_ascii_ci_hashname()
93 if (args->namelen != len) in xfs_ascii_ci_compname()
98 if (args->name[i] == name[i]) in xfs_ascii_ci_compname()
100 if (xfs_ascii_ci_xfrm(args->name[i]) != in xfs_ascii_ci_compname()
116 ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT); in xfs_da_mount()
117 ASSERT(xfs_dir2_dirblock_bytes(&mp->m_sb) <= XFS_MAX_BLOCKSIZE); in xfs_da_mount()
119 mp->m_dir_geo = kzalloc(sizeof(struct xfs_da_geometry), in xfs_da_mount()
121 mp->m_attr_geo = kzalloc(sizeof(struct xfs_da_geometry), in xfs_da_mount()
123 if (!mp->m_dir_geo || !mp->m_attr_geo) { in xfs_da_mount()
124 kfree(mp->m_dir_geo); in xfs_da_mount()
125 kfree(mp->m_attr_geo); in xfs_da_mount()
126 return -ENOMEM; in xfs_da_mount()
130 dageo = mp->m_dir_geo; in xfs_da_mount()
131 dageo->blklog = mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog; in xfs_da_mount()
132 dageo->fsblog = mp->m_sb.sb_blocklog; in xfs_da_mount()
133 dageo->blksize = xfs_dir2_dirblock_bytes(&mp->m_sb); in xfs_da_mount()
134 dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog; in xfs_da_mount()
136 dageo->node_hdr_size = sizeof(struct xfs_da3_node_hdr); in xfs_da_mount()
137 dageo->leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr); in xfs_da_mount()
138 dageo->free_hdr_size = sizeof(struct xfs_dir3_free_hdr); in xfs_da_mount()
139 dageo->data_entry_offset = in xfs_da_mount()
142 dageo->node_hdr_size = sizeof(struct xfs_da_node_hdr); in xfs_da_mount()
143 dageo->leaf_hdr_size = sizeof(struct xfs_dir2_leaf_hdr); in xfs_da_mount()
144 dageo->free_hdr_size = sizeof(struct xfs_dir2_free_hdr); in xfs_da_mount()
145 dageo->data_entry_offset = in xfs_da_mount()
148 dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) / in xfs_da_mount()
150 dageo->free_max_bests = (dageo->blksize - dageo->free_hdr_size) / in xfs_da_mount()
153 dageo->data_first_offset = dageo->data_entry_offset + in xfs_da_mount()
161 dageo->datablk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_DATA_OFFSET); in xfs_da_mount()
162 dageo->leafblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_LEAF_OFFSET); in xfs_da_mount()
163 dageo->freeblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_FREE_OFFSET); in xfs_da_mount()
164 dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / in xfs_da_mount()
166 dageo->max_extents = (XFS_DIR2_MAX_SPACES * XFS_DIR2_SPACE_SIZE) >> in xfs_da_mount()
167 mp->m_sb.sb_blocklog; in xfs_da_mount()
168 dageo->magicpct = (dageo->blksize * 37) / 100; in xfs_da_mount()
170 /* set up attribute geometry - single fsb only */ in xfs_da_mount()
171 dageo = mp->m_attr_geo; in xfs_da_mount()
172 dageo->blklog = mp->m_sb.sb_blocklog; in xfs_da_mount()
173 dageo->fsblog = mp->m_sb.sb_blocklog; in xfs_da_mount()
174 dageo->blksize = 1 << dageo->blklog; in xfs_da_mount()
175 dageo->fsbcount = 1; in xfs_da_mount()
176 dageo->node_hdr_size = mp->m_dir_geo->node_hdr_size; in xfs_da_mount()
177 dageo->node_ents = (dageo->blksize - dageo->node_hdr_size) / in xfs_da_mount()
181 dageo->max_extents = XFS_MAX_EXTCNT_ATTR_FORK_LARGE; in xfs_da_mount()
183 dageo->max_extents = XFS_MAX_EXTCNT_ATTR_FORK_SMALL; in xfs_da_mount()
185 dageo->magicpct = (dageo->blksize * 37) / 100; in xfs_da_mount()
193 kfree(mp->m_dir_geo); in xfs_da_unmount()
194 kfree(mp->m_attr_geo); in xfs_da_unmount()
206 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); in xfs_dir_isempty()
207 if (dp->i_disk_size == 0) /* might happen during shutdown. */ in xfs_dir_isempty()
209 if (dp->i_disk_size > xfs_inode_data_fork_size(dp)) in xfs_dir_isempty()
211 sfp = dp->i_df.if_data; in xfs_dir_isempty()
212 return !sfp->count; in xfs_dir_isempty()
229 return -EFSCORRUPTED; in xfs_dir_ino_validate()
239 xfs_trans_t *tp, in xfs_dir_init() argument
246 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); in xfs_dir_init()
247 error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino); in xfs_dir_init()
253 return -ENOMEM; in xfs_dir_init()
255 args->geo = dp->i_mount->m_dir_geo; in xfs_dir_init()
256 args->dp = dp; in xfs_dir_init()
257 args->trans = tp; in xfs_dir_init()
258 args->owner = dp->i_ino; in xfs_dir_init()
259 error = xfs_dir2_sf_create(args, pdp->i_ino); in xfs_dir_init()
269 struct xfs_inode *dp = args->dp; in xfs_dir2_format()
270 struct xfs_mount *mp = dp->i_mount; in xfs_dir2_format()
271 struct xfs_da_geometry *geo = mp->m_dir_geo; in xfs_dir2_format()
277 if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL) in xfs_dir2_format()
284 if (eof == XFS_B_TO_FSB(mp, geo->blksize)) { in xfs_dir2_format()
285 if (XFS_IS_CORRUPT(mp, dp->i_disk_size != geo->blksize)) { in xfs_dir2_format()
287 *error = -EFSCORRUPTED; in xfs_dir2_format()
292 if (eof == geo->leafblk + geo->fsbcount) in xfs_dir2_format()
303 if (!args->inumber) in xfs_dir_createname_args()
304 args->op_flags |= XFS_DA_OP_JUSTCHECK; in xfs_dir_createname_args()
326 struct xfs_trans *tp, in xfs_dir_createname() argument
335 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); in xfs_dir_createname()
338 rval = xfs_dir_ino_validate(tp->t_mountp, inum); in xfs_dir_createname()
341 XFS_STATS_INC(dp->i_mount, xs_dir_create); in xfs_dir_createname()
346 return -ENOMEM; in xfs_dir_createname()
348 args->geo = dp->i_mount->m_dir_geo; in xfs_dir_createname()
349 args->name = name->name; in xfs_dir_createname()
350 args->namelen = name->len; in xfs_dir_createname()
351 args->filetype = name->type; in xfs_dir_createname()
352 args->hashval = xfs_dir2_hashname(dp->i_mount, name); in xfs_dir_createname()
353 args->inumber = inum; in xfs_dir_createname()
354 args->dp = dp; in xfs_dir_createname()
355 args->total = total; in xfs_dir_createname()
356 args->whichfork = XFS_DATA_FORK; in xfs_dir_createname()
357 args->trans = tp; in xfs_dir_createname()
358 args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; in xfs_dir_createname()
359 args->owner = dp->i_ino; in xfs_dir_createname()
367 * If doing a CI lookup and case-insensitive match, dup actual name into
376 if (args->cmpresult == XFS_CMP_DIFFERENT) in xfs_dir_cilookup_result()
377 return -ENOENT; in xfs_dir_cilookup_result()
378 if (args->cmpresult != XFS_CMP_CASE || in xfs_dir_cilookup_result()
379 !(args->op_flags & XFS_DA_OP_CILOOKUP)) in xfs_dir_cilookup_result()
380 return -EEXIST; in xfs_dir_cilookup_result()
382 args->value = kmalloc(len, in xfs_dir_cilookup_result()
384 if (!args->value) in xfs_dir_cilookup_result()
385 return -ENOMEM; in xfs_dir_cilookup_result()
387 memcpy(args->value, name, len); in xfs_dir_cilookup_result()
388 args->valuelen = len; in xfs_dir_cilookup_result()
389 return -EEXIST; in xfs_dir_cilookup_result()
415 if (error != -EEXIST) in xfs_dir_lookup_args()
423 * to name, or ci_name->name is set to NULL for an exact match.
428 struct xfs_trans *tp, in xfs_dir_lookup() argument
438 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); in xfs_dir_lookup()
439 XFS_STATS_INC(dp->i_mount, xs_dir_lookup); in xfs_dir_lookup()
443 args->geo = dp->i_mount->m_dir_geo; in xfs_dir_lookup()
444 args->name = name->name; in xfs_dir_lookup()
445 args->namelen = name->len; in xfs_dir_lookup()
446 args->filetype = name->type; in xfs_dir_lookup()
447 args->hashval = xfs_dir2_hashname(dp->i_mount, name); in xfs_dir_lookup()
448 args->dp = dp; in xfs_dir_lookup()
449 args->whichfork = XFS_DATA_FORK; in xfs_dir_lookup()
450 args->trans = tp; in xfs_dir_lookup()
451 args->op_flags = XFS_DA_OP_OKNOENT; in xfs_dir_lookup()
452 args->owner = dp->i_ino; in xfs_dir_lookup()
454 args->op_flags |= XFS_DA_OP_CILOOKUP; in xfs_dir_lookup()
459 *inum = args->inumber; in xfs_dir_lookup()
461 ci_name->name = args->value; in xfs_dir_lookup()
462 ci_name->len = args->valuelen; in xfs_dir_lookup()
495 struct xfs_trans *tp, in xfs_dir_removename() argument
504 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); in xfs_dir_removename()
505 XFS_STATS_INC(dp->i_mount, xs_dir_remove); in xfs_dir_removename()
509 return -ENOMEM; in xfs_dir_removename()
511 args->geo = dp->i_mount->m_dir_geo; in xfs_dir_removename()
512 args->name = name->name; in xfs_dir_removename()
513 args->namelen = name->len; in xfs_dir_removename()
514 args->filetype = name->type; in xfs_dir_removename()
515 args->hashval = xfs_dir2_hashname(dp->i_mount, name); in xfs_dir_removename()
516 args->inumber = ino; in xfs_dir_removename()
517 args->dp = dp; in xfs_dir_removename()
518 args->total = total; in xfs_dir_removename()
519 args->whichfork = XFS_DATA_FORK; in xfs_dir_removename()
520 args->trans = tp; in xfs_dir_removename()
521 args->owner = dp->i_ino; in xfs_dir_removename()
552 struct xfs_trans *tp, in xfs_dir_replace() argument
561 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); in xfs_dir_replace()
563 rval = xfs_dir_ino_validate(tp->t_mountp, inum); in xfs_dir_replace()
569 return -ENOMEM; in xfs_dir_replace()
571 args->geo = dp->i_mount->m_dir_geo; in xfs_dir_replace()
572 args->name = name->name; in xfs_dir_replace()
573 args->namelen = name->len; in xfs_dir_replace()
574 args->filetype = name->type; in xfs_dir_replace()
575 args->hashval = xfs_dir2_hashname(dp->i_mount, name); in xfs_dir_replace()
576 args->inumber = inum; in xfs_dir_replace()
577 args->dp = dp; in xfs_dir_replace()
578 args->total = total; in xfs_dir_replace()
579 args->whichfork = XFS_DATA_FORK; in xfs_dir_replace()
580 args->trans = tp; in xfs_dir_replace()
581 args->owner = dp->i_ino; in xfs_dir_replace()
592 struct xfs_trans *tp, in xfs_dir_canenter() argument
596 return xfs_dir_createname(tp, dp, name, 0, 0); in xfs_dir_canenter()
615 struct xfs_inode *dp = args->dp; in xfs_dir2_grow_inode()
616 struct xfs_mount *mp = dp->i_mount; in xfs_dir2_grow_inode()
627 count = args->geo->fsbcount; in xfs_dir2_grow_inode()
633 *dbp = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)bno); in xfs_dir2_grow_inode()
642 if (size > dp->i_disk_size) { in xfs_dir2_grow_inode()
643 dp->i_disk_size = size; in xfs_dir2_grow_inode()
644 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE); in xfs_dir2_grow_inode()
667 struct xfs_trans *tp; in xfs_dir2_shrink_inode() local
671 dp = args->dp; in xfs_dir2_shrink_inode()
672 mp = dp->i_mount; in xfs_dir2_shrink_inode()
673 tp = args->trans; in xfs_dir2_shrink_inode()
674 da = xfs_dir2_db_to_da(args->geo, db); in xfs_dir2_shrink_inode()
677 error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, &done); in xfs_dir2_shrink_inode()
683 * This can only happen for un-fragmented directory blocks, in xfs_dir2_shrink_inode()
697 xfs_trans_binval(tp, bp); in xfs_dir2_shrink_inode()
701 if (db >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET)) in xfs_dir2_shrink_inode()
706 if (dp->i_disk_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0)) in xfs_dir2_shrink_inode()
709 if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) { in xfs_dir2_shrink_inode()
715 if (db == args->geo->datablk) in xfs_dir2_shrink_inode()
722 dp->i_disk_size = XFS_FSB_TO_B(mp, bno); in xfs_dir2_shrink_inode()
723 xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); in xfs_dir2_shrink_inode()
751 return xfs_da_hashname(name->name, name->len); in xfs_dir2_hashname()
760 if (unlikely(xfs_has_asciici(args->dp->i_mount))) in xfs_dir2_compname()
806 struct xfs_mount *mp = ip->i_mount; in xfs_dir_update_hook()
808 xfs_hooks_call(&mp->m_dir_update_hooks, 0, &p); in xfs_dir_update_hook()
818 return xfs_hooks_add(&mp->m_dir_update_hooks, &hook->dirent_hook); in xfs_dir_hook_add()
827 xfs_hooks_del(&mp->m_dir_update_hooks, &hook->dirent_hook); in xfs_dir_hook_del()
836 xfs_hook_setup(&hook->dirent_hook, mod_fn); in xfs_dir_hook_setup()
841 * Given a directory @dp, a newly allocated inode @ip, and a @name, link @ip
848 struct xfs_trans *tp, in xfs_dir_create_child() argument
852 struct xfs_inode *dp = du->dp; in xfs_dir_create_child()
853 const struct xfs_name *name = du->name; in xfs_dir_create_child()
854 struct xfs_inode *ip = du->ip; in xfs_dir_create_child()
860 error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks); in xfs_dir_create_child()
862 ASSERT(error != -ENOSPC); in xfs_dir_create_child()
866 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); in xfs_dir_create_child()
867 xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); in xfs_dir_create_child()
869 if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_dir_create_child()
870 error = xfs_dir_init(tp, ip, dp); in xfs_dir_create_child()
874 xfs_bumplink(tp, dp); in xfs_dir_create_child()
881 if (du->ppargs) { in xfs_dir_create_child()
882 error = xfs_parent_addname(tp, du->ppargs, dp, name, ip); in xfs_dir_create_child()
892 * Given a directory @dp, an existing non-directory inode @ip, and a @name,
893 * link @ip into @dp under the given @name. Both inodes must have the ILOCK
898 struct xfs_trans *tp, in xfs_dir_add_child() argument
902 struct xfs_inode *dp = du->dp; in xfs_dir_add_child()
903 const struct xfs_name *name = du->name; in xfs_dir_add_child()
904 struct xfs_inode *ip = du->ip; in xfs_dir_add_child()
905 struct xfs_mount *mp = tp->t_mountp; in xfs_dir_add_child()
910 ASSERT(!S_ISDIR(VFS_I(ip)->i_mode)); in xfs_dir_add_child()
913 error = xfs_dir_canenter(tp, dp, name); in xfs_dir_add_child()
919 * Handle initial link state of O_TMPFILE inode in xfs_dir_add_child()
921 if (VFS_I(ip)->i_nlink == 0) { in xfs_dir_add_child()
924 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_dir_add_child()
925 error = xfs_iunlink_remove(tp, pag, ip); in xfs_dir_add_child()
931 error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks); in xfs_dir_add_child()
935 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); in xfs_dir_add_child()
936 xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); in xfs_dir_add_child()
938 xfs_bumplink(tp, ip); in xfs_dir_add_child()
946 if (du->ppargs) { in xfs_dir_add_child()
947 error = xfs_parent_addname(tp, du->ppargs, dp, name, ip); in xfs_dir_add_child()
962 struct xfs_trans *tp, in xfs_dir_remove_child() argument
966 struct xfs_inode *dp = du->dp; in xfs_dir_remove_child()
967 const struct xfs_name *name = du->name; in xfs_dir_remove_child()
968 struct xfs_inode *ip = du->ip; in xfs_dir_remove_child()
977 if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_dir_remove_child()
978 ASSERT(VFS_I(ip)->i_nlink >= 2); in xfs_dir_remove_child()
979 if (VFS_I(ip)->i_nlink != 2) in xfs_dir_remove_child()
980 return -ENOTEMPTY; in xfs_dir_remove_child()
982 return -ENOTEMPTY; in xfs_dir_remove_child()
984 /* Drop the link from ip's "..". */ in xfs_dir_remove_child()
985 error = xfs_droplink(tp, dp); in xfs_dir_remove_child()
989 /* Drop the "." link from ip to self. */ in xfs_dir_remove_child()
990 error = xfs_droplink(tp, ip); in xfs_dir_remove_child()
996 * directory to eliminate back-references to inodes that may in xfs_dir_remove_child()
1000 if (dp->i_ino != tp->t_mountp->m_sb.sb_rootino) { in xfs_dir_remove_child()
1001 error = xfs_dir_replace(tp, ip, &xfs_name_dotdot, in xfs_dir_remove_child()
1002 tp->t_mountp->m_sb.sb_rootino, 0); in xfs_dir_remove_child()
1008 * When removing a non-directory we need to log the parent in xfs_dir_remove_child()
1012 xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); in xfs_dir_remove_child()
1014 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); in xfs_dir_remove_child()
1016 /* Drop the link from dp to ip. */ in xfs_dir_remove_child()
1017 error = xfs_droplink(tp, ip); in xfs_dir_remove_child()
1021 error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); in xfs_dir_remove_child()
1023 ASSERT(error != -ENOENT); in xfs_dir_remove_child()
1028 if (du->ppargs) { in xfs_dir_remove_child()
1029 error = xfs_parent_removename(tp, du->ppargs, dp, name, ip); in xfs_dir_remove_child()
1034 xfs_dir_update_hook(dp, ip, -1, name); in xfs_dir_remove_child()
1047 struct xfs_trans *tp, in xfs_dir_exchange_children() argument
1052 struct xfs_inode *dp1 = du1->dp; in xfs_dir_exchange_children()
1053 const struct xfs_name *name1 = du1->name; in xfs_dir_exchange_children()
1054 struct xfs_inode *ip1 = du1->ip; in xfs_dir_exchange_children()
1055 struct xfs_inode *dp2 = du2->dp; in xfs_dir_exchange_children()
1056 const struct xfs_name *name2 = du2->name; in xfs_dir_exchange_children()
1057 struct xfs_inode *ip2 = du2->ip; in xfs_dir_exchange_children()
1064 error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); in xfs_dir_exchange_children()
1069 error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); in xfs_dir_exchange_children()
1075 * update the respective ".." entries (and link counts) to match the new in xfs_dir_exchange_children()
1081 if (S_ISDIR(VFS_I(ip2)->i_mode)) { in xfs_dir_exchange_children()
1082 error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, in xfs_dir_exchange_children()
1083 dp1->i_ino, spaceres); in xfs_dir_exchange_children()
1088 if (!S_ISDIR(VFS_I(ip1)->i_mode)) { in xfs_dir_exchange_children()
1089 error = xfs_droplink(tp, dp2); in xfs_dir_exchange_children()
1092 xfs_bumplink(tp, dp1); in xfs_dir_exchange_children()
1105 if (S_ISDIR(VFS_I(ip1)->i_mode)) { in xfs_dir_exchange_children()
1106 error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, in xfs_dir_exchange_children()
1107 dp2->i_ino, spaceres); in xfs_dir_exchange_children()
1112 if (!S_ISDIR(VFS_I(ip2)->i_mode)) { in xfs_dir_exchange_children()
1113 error = xfs_droplink(tp, dp1); in xfs_dir_exchange_children()
1116 xfs_bumplink(tp, dp2); in xfs_dir_exchange_children()
1131 xfs_trans_ichgtime(tp, ip1, ip1_flags); in xfs_dir_exchange_children()
1132 xfs_trans_log_inode(tp, ip1, XFS_ILOG_CORE); in xfs_dir_exchange_children()
1135 xfs_trans_ichgtime(tp, ip2, ip2_flags); in xfs_dir_exchange_children()
1136 xfs_trans_log_inode(tp, ip2, XFS_ILOG_CORE); in xfs_dir_exchange_children()
1139 xfs_trans_ichgtime(tp, dp2, dp2_flags); in xfs_dir_exchange_children()
1140 xfs_trans_log_inode(tp, dp2, XFS_ILOG_CORE); in xfs_dir_exchange_children()
1142 xfs_trans_ichgtime(tp, dp1, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); in xfs_dir_exchange_children()
1143 xfs_trans_log_inode(tp, dp1, XFS_ILOG_CORE); in xfs_dir_exchange_children()
1146 if (du1->ppargs) { in xfs_dir_exchange_children()
1147 error = xfs_parent_replacename(tp, du1->ppargs, dp1, name1, in xfs_dir_exchange_children()
1153 if (du2->ppargs) { in xfs_dir_exchange_children()
1154 error = xfs_parent_replacename(tp, du2->ppargs, dp2, name2, in xfs_dir_exchange_children()
1168 xfs_dir_update_hook(dp1, ip1, -1, name1); in xfs_dir_exchange_children()
1169 xfs_dir_update_hook(dp2, ip2, -1, name2); in xfs_dir_exchange_children()
1180 * Cleanup involves dropping a link count on @target_ip, and either removing
1190 struct xfs_trans *tp, in xfs_dir_rename_children() argument
1196 struct xfs_mount *mp = tp->t_mountp; in xfs_dir_rename_children()
1197 struct xfs_inode *src_dp = du_src->dp; in xfs_dir_rename_children()
1198 const struct xfs_name *src_name = du_src->name; in xfs_dir_rename_children()
1199 struct xfs_inode *src_ip = du_src->ip; in xfs_dir_rename_children()
1200 struct xfs_inode *target_dp = du_tgt->dp; in xfs_dir_rename_children()
1201 const struct xfs_name *target_name = du_tgt->name; in xfs_dir_rename_children()
1202 struct xfs_inode *target_ip = du_tgt->ip; in xfs_dir_rename_children()
1207 src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode); in xfs_dir_rename_children()
1219 error = xfs_dir_canenter(tp, target_dp, target_name); in xfs_dir_rename_children()
1228 if (S_ISDIR(VFS_I(target_ip)->i_mode) && in xfs_dir_rename_children()
1230 (VFS_I(target_ip)->i_nlink > 2))) in xfs_dir_rename_children()
1231 return -EEXIST; in xfs_dir_rename_children()
1241 * For whiteouts, we need to bump the link count on the whiteout in xfs_dir_rename_children()
1242 * inode. After this point, we have a real link, clear the tmpfile in xfs_dir_rename_children()
1246 if (du_wip->ip) { in xfs_dir_rename_children()
1249 ASSERT(VFS_I(du_wip->ip)->i_nlink == 0); in xfs_dir_rename_children()
1251 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, du_wip->ip->i_ino)); in xfs_dir_rename_children()
1252 error = xfs_iunlink_remove(tp, pag, du_wip->ip); in xfs_dir_rename_children()
1257 xfs_bumplink(tp, du_wip->ip); in xfs_dir_rename_children()
1266 * directories, adjust the target directory link count in xfs_dir_rename_children()
1269 error = xfs_dir_createname(tp, target_dp, target_name, in xfs_dir_rename_children()
1270 src_ip->i_ino, spaceres); in xfs_dir_rename_children()
1274 xfs_trans_ichgtime(tp, target_dp, in xfs_dir_rename_children()
1278 xfs_bumplink(tp, target_dp); in xfs_dir_rename_children()
1282 * Link the source inode under the target name. in xfs_dir_rename_children()
1290 error = xfs_dir_replace(tp, target_dp, target_name, in xfs_dir_rename_children()
1291 src_ip->i_ino, spaceres); in xfs_dir_rename_children()
1295 xfs_trans_ichgtime(tp, target_dp, in xfs_dir_rename_children()
1299 * Decrement the link count on the target since the target in xfs_dir_rename_children()
1302 error = xfs_droplink(tp, target_ip); in xfs_dir_rename_children()
1308 * Drop the link from the old "." entry. in xfs_dir_rename_children()
1310 error = xfs_droplink(tp, target_ip); in xfs_dir_rename_children()
1324 error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, in xfs_dir_rename_children()
1325 target_dp->i_ino, spaceres); in xfs_dir_rename_children()
1326 ASSERT(error != -EEXIST); in xfs_dir_rename_children()
1338 xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG); in xfs_dir_rename_children()
1339 xfs_trans_log_inode(tp, src_ip, XFS_ILOG_CORE); in xfs_dir_rename_children()
1342 * Adjust the link count on src_dp. This is necessary when in xfs_dir_rename_children()
1349 * Decrement link count on src_directory since the in xfs_dir_rename_children()
1352 error = xfs_droplink(tp, src_dp); in xfs_dir_rename_children()
1362 if (du_wip->ip) in xfs_dir_rename_children()
1363 error = xfs_dir_replace(tp, src_dp, src_name, du_wip->ip->i_ino, in xfs_dir_rename_children()
1366 error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, in xfs_dir_rename_children()
1371 xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); in xfs_dir_rename_children()
1372 xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE); in xfs_dir_rename_children()
1374 xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); in xfs_dir_rename_children()
1377 if (du_wip->ppargs) { in xfs_dir_rename_children()
1378 error = xfs_parent_addname(tp, du_wip->ppargs, src_dp, in xfs_dir_rename_children()
1379 src_name, du_wip->ip); in xfs_dir_rename_children()
1384 if (du_src->ppargs) { in xfs_dir_rename_children()
1385 error = xfs_parent_replacename(tp, du_src->ppargs, src_dp, in xfs_dir_rename_children()
1391 if (du_tgt->ppargs) { in xfs_dir_rename_children()
1392 error = xfs_parent_removename(tp, du_tgt->ppargs, target_dp, in xfs_dir_rename_children()
1407 xfs_dir_update_hook(target_dp, target_ip, -1, target_name); in xfs_dir_rename_children()
1408 xfs_dir_update_hook(src_dp, src_ip, -1, src_name); in xfs_dir_rename_children()
1410 if (du_wip->ip) in xfs_dir_rename_children()
1411 xfs_dir_update_hook(src_dp, du_wip->ip, 1, src_name); in xfs_dir_rename_children()