summaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-04-25 15:17:01 +0200
committerChandan Babu R <chandanbabu@kernel.org>2024-04-26 07:49:04 +0200
commit3866e6e669e2c1b3eebf580b8779ea55838c3f5a (patch)
tree84c8f9088886f914cdf1212af6790512b3ee84d0 /fs/xfs
parentxfs: factor out a xfs_dir_createname_args helper (diff)
downloadlinux-3866e6e669e2c1b3eebf580b8779ea55838c3f5a.tar.xz
linux-3866e6e669e2c1b3eebf580b8779ea55838c3f5a.zip
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: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_dir2.c48
-rw-r--r--fs/xfs/libxfs/xfs_dir2.h1
-rw-r--r--fs/xfs/scrub/dir_repair.c20
3 files changed, 27 insertions, 42 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index e2727602d047..76aa11ade2e9 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -444,6 +444,30 @@ xfs_dir_lookup(
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.
*/
@@ -457,7 +481,6 @@ xfs_dir_removename(
{
struct xfs_da_args *args;
int rval;
- bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove);
@@ -477,28 +500,7 @@ xfs_dir_removename(
args->whichfork = XFS_DATA_FORK;
args->trans = tp;
args->owner = dp->i_ino;
-
- 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:
+ rval = xfs_dir_removename_args(args);
kfree(args);
return rval;
}
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index f5361dd7b90a..3db54801d69e 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -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_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.
diff --git a/fs/xfs/scrub/dir_repair.c b/fs/xfs/scrub/dir_repair.c
index a1e31b782788..98e4ed25cc23 100644
--- a/fs/xfs/scrub/dir_repair.c
+++ b/fs/xfs/scrub/dir_repair.c
@@ -712,8 +712,6 @@ xrep_dir_replay_removename(
xfs_extlen_t total)
{
struct xfs_inode *dp = rd->args.dp;
- bool is_block, is_leaf;
- int error;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
@@ -722,23 +720,7 @@ xrep_dir_replay_removename(
rd->args.total = total;
trace_xrep_dir_replay_removename(dp, name, 0);
-
- 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);
+ return xfs_dir_removename_args(&rd->args);
}
/*