Commit 3866e6e6 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: factor out a xfs_dir_removename_args helper

Add a helper to switch between the different directory formats for
removing a directory entry.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent 4d893a40
...@@ -444,6 +444,30 @@ xfs_dir_lookup( ...@@ -444,6 +444,30 @@ xfs_dir_lookup(
return rval; return rval;
} }
int
xfs_dir_removename_args(
struct xfs_da_args *args)
{
bool is_block, is_leaf;
int error;
if (args->dp->i_df.if_format == XFS_DINODE_FMT_LOCAL)
return xfs_dir2_sf_removename(args);
error = xfs_dir2_isblock(args, &is_block);
if (error)
return error;
if (is_block)
return xfs_dir2_block_removename(args);
error = xfs_dir2_isleaf(args, &is_leaf);
if (error)
return error;
if (is_leaf)
return xfs_dir2_leaf_removename(args);
return xfs_dir2_node_removename(args);
}
/* /*
* Remove an entry from a directory. * Remove an entry from a directory.
*/ */
...@@ -457,7 +481,6 @@ xfs_dir_removename( ...@@ -457,7 +481,6 @@ xfs_dir_removename(
{ {
struct xfs_da_args *args; struct xfs_da_args *args;
int rval; int rval;
bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove); XFS_STATS_INC(dp->i_mount, xs_dir_remove);
...@@ -477,28 +500,7 @@ xfs_dir_removename( ...@@ -477,28 +500,7 @@ xfs_dir_removename(
args->whichfork = XFS_DATA_FORK; args->whichfork = XFS_DATA_FORK;
args->trans = tp; args->trans = tp;
args->owner = dp->i_ino; args->owner = dp->i_ino;
rval = xfs_dir_removename_args(args);
if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL) {
rval = xfs_dir2_sf_removename(args);
goto out_free;
}
rval = xfs_dir2_isblock(args, &v);
if (rval)
goto out_free;
if (v) {
rval = xfs_dir2_block_removename(args);
goto out_free;
}
rval = xfs_dir2_isleaf(args, &v);
if (rval)
goto out_free;
if (v)
rval = xfs_dir2_leaf_removename(args);
else
rval = xfs_dir2_node_removename(args);
out_free:
kfree(args); kfree(args);
return rval; return rval;
} }
......
...@@ -68,6 +68,7 @@ extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, ...@@ -68,6 +68,7 @@ extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
int xfs_dir_lookup_args(struct xfs_da_args *args); int xfs_dir_lookup_args(struct xfs_da_args *args);
int xfs_dir_createname_args(struct xfs_da_args *args); int xfs_dir_createname_args(struct xfs_da_args *args);
int xfs_dir_removename_args(struct xfs_da_args *args);
/* /*
* Direct call from the bmap code, bypassing the generic directory layer. * Direct call from the bmap code, bypassing the generic directory layer.
......
...@@ -712,8 +712,6 @@ xrep_dir_replay_removename( ...@@ -712,8 +712,6 @@ xrep_dir_replay_removename(
xfs_extlen_t total) xfs_extlen_t total)
{ {
struct xfs_inode *dp = rd->args.dp; struct xfs_inode *dp = rd->args.dp;
bool is_block, is_leaf;
int error;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
...@@ -722,23 +720,7 @@ xrep_dir_replay_removename( ...@@ -722,23 +720,7 @@ xrep_dir_replay_removename(
rd->args.total = total; rd->args.total = total;
trace_xrep_dir_replay_removename(dp, name, 0); trace_xrep_dir_replay_removename(dp, name, 0);
return xfs_dir_removename_args(&rd->args);
if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL)
return xfs_dir2_sf_removename(&rd->args);
error = xfs_dir2_isblock(&rd->args, &is_block);
if (error)
return error;
if (is_block)
return xfs_dir2_block_removename(&rd->args);
error = xfs_dir2_isleaf(&rd->args, &is_leaf);
if (error)
return error;
if (is_leaf)
return xfs_dir2_leaf_removename(&rd->args);
return xfs_dir2_node_removename(&rd->args);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment