mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
xfs: refactor dir format helpers
Add a new enum and a xfs_dir2_format helper that returns it to allow the code to switch on the format of a directory in a single operation and switch all helpers of xfs_dir2_isblock and xfs_dir2_isleaf to it. This also removes the explicit xfs_iread_extents call in a few of the call sites given that xfs_bmap_last_offset already takes care of it underneath. 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>
This commit is contained in:
committed by
Chandan Babu R
parent
dfe5febe2b
commit
e58ac1770d
@@ -516,7 +516,6 @@ xfs_readdir(
|
||||
{
|
||||
struct xfs_da_args args = { NULL };
|
||||
unsigned int lock_mode;
|
||||
bool isblock;
|
||||
int error;
|
||||
|
||||
trace_xfs_readdir(dp);
|
||||
@@ -539,18 +538,18 @@ xfs_readdir(
|
||||
return xfs_dir2_sf_getdents(&args, ctx);
|
||||
|
||||
lock_mode = xfs_ilock_data_map_shared(dp);
|
||||
error = xfs_dir2_isblock(&args, &isblock);
|
||||
if (error)
|
||||
goto out_unlock;
|
||||
|
||||
if (isblock) {
|
||||
switch (xfs_dir2_format(&args, &error)) {
|
||||
case XFS_DIR2_FMT_BLOCK:
|
||||
error = xfs_dir2_block_getdents(&args, ctx, &lock_mode);
|
||||
goto out_unlock;
|
||||
break;
|
||||
case XFS_DIR2_FMT_LEAF:
|
||||
case XFS_DIR2_FMT_NODE:
|
||||
error = xfs_dir2_leaf_getdents(&args, ctx, bufsize, &lock_mode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
error = xfs_dir2_leaf_getdents(&args, ctx, bufsize, &lock_mode);
|
||||
|
||||
out_unlock:
|
||||
if (lock_mode)
|
||||
xfs_iunlock(dp, lock_mode);
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user