[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240813163638.3751939-9-john.g.garry@oracle.com>
Date: Tue, 13 Aug 2024 16:36:32 +0000
From: John Garry <john.g.garry@...cle.com>
To: chandan.babu@...cle.com, djwong@...nel.org, dchinner@...hat.com,
hch@....de
Cc: viro@...iv.linux.org.uk, brauner@...nel.org, jack@...e.cz,
linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, catherine.hoang@...cle.com,
martin.petersen@...cle.com, John Garry <john.g.garry@...cle.com>
Subject: [PATCH v4 08/14] xfs: Update xfs_inode_alloc_unitsize() for forcealign
For forcealign enabled, the allocation unit size is in ip->i_extsize, and
this must never be zero.
Add helper xfs_inode_alloc_fsbsize() to return alloc unit in FSBs, and use
it in xfs_inode_alloc_unitsize().
Reviewed-by: "Darrick J. Wong" <djwong@...nel.org>
Signed-off-by: John Garry <john.g.garry@...cle.com>
---
fs/xfs/xfs_inode.c | 17 +++++++++++++----
fs/xfs/xfs_inode.h | 1 +
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 7dc6f326936c..5af12f35062d 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3107,17 +3107,26 @@ xfs_break_layouts(
return error;
}
-/* Returns the size of fundamental allocation unit for a file, in bytes. */
unsigned int
-xfs_inode_alloc_unitsize(
+xfs_inode_alloc_fsbsize(
struct xfs_inode *ip)
{
unsigned int blocks = 1;
- if (XFS_IS_REALTIME_INODE(ip))
+ if (xfs_inode_has_forcealign(ip))
+ blocks = ip->i_extsize;
+ else if (XFS_IS_REALTIME_INODE(ip))
blocks = ip->i_mount->m_sb.sb_rextsize;
- return XFS_FSB_TO_B(ip->i_mount, blocks);
+ return blocks;
+}
+
+/* Returns the size of fundamental allocation unit for a file, in bytes. */
+unsigned int
+xfs_inode_alloc_unitsize(
+ struct xfs_inode *ip)
+{
+ return XFS_FSB_TO_B(ip->i_mount, xfs_inode_alloc_fsbsize(ip));
}
/* Should we always be using copy on write for file writes? */
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 3e7664ec4d6c..158afad8c7a4 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -641,6 +641,7 @@ int xfs_inode_reload_unlinked(struct xfs_inode *ip);
bool xfs_ifork_zapped(const struct xfs_inode *ip, int whichfork);
void xfs_inode_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_filblks_t *dblocks, xfs_filblks_t *rblocks);
+unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip);
unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip);
int xfs_icreate_dqalloc(const struct xfs_icreate_args *args,
--
2.31.1
Powered by blists - more mailing lists