Thread (45 messages) 45 messages, 3 authors, 2021-08-23

Re: [PATCH V2 03/12] xfs: Introduce xfs_iext_max() helper

From: "Darrick J. Wong" <djwong@kernel.org>
Date: 2021-07-27 21:58:23

On Mon, Jul 26, 2021 at 05:15:32PM +0530, Chandan Babu R wrote:
xfs_iext_max() returns the maximum number of extents possible for one of
data, cow or attribute fork. This helper will be extended further in a
future commit when maximum extent counts associated with data/attribute
forks are increased.

Signed-off-by: Chandan Babu R <redacted>
---
 fs/xfs/libxfs/xfs_bmap.c       | 9 ++++-----
 fs/xfs/libxfs/xfs_inode_buf.c  | 8 +++-----
 fs/xfs/libxfs/xfs_inode_fork.c | 6 +++---
 fs/xfs/libxfs/xfs_inode_fork.h | 8 ++++++++
 fs/xfs/scrub/inode_repair.c    | 2 +-
 5 files changed, 19 insertions(+), 14 deletions(-)
<snip>
quoted hunk ↗ jump to hunk
diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
index cf82be263b48..1eda2163603e 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -133,6 +133,14 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp)
 	return ifp->if_format;
 }
 
+static inline xfs_extnum_t xfs_iext_max(struct xfs_mount *mp, int whichfork)
xfs_iext_max_nextents() to go with the constants?  "max" on its own is a
little vague.  I /really/ like this getting cleaned up finally though.
+{
+	if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK)
+		return XFS_IFORK_EXTCNT_MAXS32;
+	else
+		return XFS_IFORK_EXTCNT_MAXS16;
No need for the 'else'.

--D
quoted hunk ↗ jump to hunk
+}
+
 struct xfs_ifork *xfs_ifork_alloc(enum xfs_dinode_fmt format,
 				xfs_extnum_t nextents);
 struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state);
diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c
index c44f8d06939b..a44d7b48c374 100644
--- a/fs/xfs/scrub/inode_repair.c
+++ b/fs/xfs/scrub/inode_repair.c
@@ -1198,7 +1198,7 @@ xrep_inode_blockcounts(
 			return error;
 		if (count >= sc->mp->m_sb.sb_dblocks)
 			return -EFSCORRUPTED;
-		if (nextents >= XFS_IFORK_EXTCNT_MAXS16)
+		if (nextents >= xfs_iext_max(sc->mp, XFS_ATTR_FORK))
 			return -EFSCORRUPTED;
 		ifp->if_nextents = nextents;
 	} else {
-- 
2.30.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help