Skip to content

Commit 674eb54

Browse files
allisonhendersondjwong
authored andcommitted
xfs: Add helper function xfs_attr_node_removename_setup
This patch adds a new helper function xfs_attr_node_removename_setup. This will help modularize xfs_attr_node_removename when we add delay ready attributes later. Signed-off-by: Allison Collins <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Chandan Rajendra <[email protected]> [darrick: fix unused variable complaints by 0day robot] Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Acked-by: Dave Chinner <[email protected]> Reported-by: kernel test robot <[email protected]>
1 parent 410c198 commit 674eb54

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,37 @@ xfs_attr_leaf_mark_incomplete(
11671167
return xfs_attr3_leaf_setflag(args);
11681168
}
11691169

1170+
/*
1171+
* Initial setup for xfs_attr_node_removename. Make sure the attr is there and
1172+
* the blocks are valid. Attr keys with remote blocks will be marked
1173+
* incomplete.
1174+
*/
1175+
STATIC
1176+
int xfs_attr_node_removename_setup(
1177+
struct xfs_da_args *args,
1178+
struct xfs_da_state **state)
1179+
{
1180+
int error;
1181+
1182+
error = xfs_attr_node_hasname(args, state);
1183+
if (error != -EEXIST)
1184+
return error;
1185+
1186+
ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL);
1187+
ASSERT((*state)->path.blk[(*state)->path.active - 1].magic ==
1188+
XFS_ATTR_LEAF_MAGIC);
1189+
1190+
if (args->rmtblkno > 0) {
1191+
error = xfs_attr_leaf_mark_incomplete(args, *state);
1192+
if (error)
1193+
return error;
1194+
1195+
return xfs_attr_rmtval_invalidate(args);
1196+
}
1197+
1198+
return 0;
1199+
}
1200+
11701201
/*
11711202
* Remove a name from a B-tree attribute list.
11721203
*
@@ -1185,27 +1216,16 @@ xfs_attr_node_removename(
11851216

11861217
trace_xfs_attr_node_removename(args);
11871218

1188-
error = xfs_attr_node_hasname(args, &state);
1189-
if (error != -EEXIST)
1219+
error = xfs_attr_node_removename_setup(args, &state);
1220+
if (error)
11901221
goto out;
11911222

11921223
/*
11931224
* If there is an out-of-line value, de-allocate the blocks.
11941225
* This is done before we remove the attribute so that we don't
11951226
* overflow the maximum size of a transaction and/or hit a deadlock.
11961227
*/
1197-
blk = &state->path.blk[ state->path.active-1 ];
1198-
ASSERT(blk->bp != NULL);
1199-
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
12001228
if (args->rmtblkno > 0) {
1201-
error = xfs_attr_leaf_mark_incomplete(args, state);
1202-
if (error)
1203-
goto out;
1204-
1205-
error = xfs_attr_rmtval_invalidate(args);
1206-
if (error)
1207-
return error;
1208-
12091229
error = xfs_attr_rmtval_remove(args);
12101230
if (error)
12111231
goto out;

0 commit comments

Comments
 (0)