[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-xfs
Subject:    [PATCH 15/16] xfs: move the block format conversion out of line in xfs_dir2_sf_addname
From:       Christoph Hellwig <hch () lst ! de>
Date:       2024-04-30 12:49:25
Message-ID: 20240430124926.1775355-16-hch () lst ! de
[Download RAW message or body]

Move the code to convert to the block format and add the entry to the end
of xfs_dir2_sf_addname instead of the current very hard to read compound
statement in the middle of the function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_dir2_sf.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index 02aa176348a795..0598465357cc3a 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -426,26 +426,16 @@ xfs_dir2_sf_addname(
 	}
 
 	new_isize = (int)dp->i_disk_size + incr_isize;
+
 	/*
-	 * Won't fit as shortform any more (due to size),
-	 * or the pick routine says it won't (due to offset values).
+	 * Too large to fit into the inode fork or too large offset?
 	 */
-	if (new_isize > xfs_inode_data_fork_size(dp) ||
-	    (pick =
-	     xfs_dir2_sf_addname_pick(args, objchange, &sfep, &offset)) == 0) {
-		/*
-		 * Just checking or no space reservation, it doesn't fit.
-		 */
-		if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
-			return -ENOSPC;
-		/*
-		 * Convert to block form then add the name.
-		 */
-		error = xfs_dir2_sf_to_block(args);
-		if (error)
-			return error;
-		return xfs_dir2_block_addname(args);
-	}
+	if (new_isize > xfs_inode_data_fork_size(dp))
+		goto convert;
+	pick = xfs_dir2_sf_addname_pick(args, objchange, &sfep, &offset);
+	if (pick == 0)
+		goto convert;
+
 	/*
 	 * Just checking, it fits.
 	 */
@@ -479,6 +469,17 @@ xfs_dir2_sf_addname(
 	xfs_dir2_sf_check(args);
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
 	return 0;
+
+convert:
+	/*
+	 * Just checking or no space reservation, it doesn't fit.
+	 */
+	if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
+		return -ENOSPC;
+	error = xfs_dir2_sf_to_block(args);
+	if (error)
+		return error;
+	return xfs_dir2_block_addname(args);
 }
 
 /*
-- 
2.39.2


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic