[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250501195208.GF25675@frogsfrogsfrogs>
Date: Thu, 1 May 2025 12:52:08 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: John Garry <john.g.garry@...cle.com>
Cc: brauner@...nel.org, hch@....de, viro@...iv.linux.org.uk, jack@...e.cz,
cem@...nel.org, linux-fsdevel@...r.kernel.org, dchinner@...hat.com,
linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
ojaswin@...ux.ibm.com, ritesh.list@...il.com,
martin.petersen@...cle.com, linux-ext4@...r.kernel.org,
linux-block@...r.kernel.org, catherine.hoang@...cle.com,
linux-api@...r.kernel.org
Subject: [PATCH 16/15] xfs: only call xfs_setsize_buftarg once per buffer
target
From: Darrick J. Wong <djwong@...nel.org>
It's silly to call xfs_setsize_buftarg from xfs_alloc_buftarg with the
block device LBA size because we don't need to ask the block layer to
validate a geometry number that it provided us. Instead, set the
preliminary bt_meta_sector* fields to the LBA size in preparation for
reading the primary super.
It's ok to lose the sync_blockdev call at buftarg creation time for the
external log and rt devices because we don't read from them until after
calling xfs_setup_devices. We do need an explicit sync for the data
device because we read the primary super before calling
xfs_setup_devices.
This will enable the next patch to validate hw atomic write geometry
against the filesystem geometry.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
fs/xfs/xfs_buf.h | 5 +++++
fs/xfs/xfs_buf.c | 8 ++++----
fs/xfs/xfs_super.c | 6 +++++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 6f691779887f77..2f809e33ec66da 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -384,6 +384,11 @@ int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops);
bool xfs_verify_magic(struct xfs_buf *bp, __be32 dmagic);
bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic);
+static inline int xfs_buftarg_sync(struct xfs_buftarg *btp)
+{
+ return sync_blockdev(btp->bt_bdev);
+}
+
/* for xfs_buf_mem.c only: */
int xfs_init_buftarg(struct xfs_buftarg *btp, size_t logical_sectorsize,
const char *descr);
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index c1bd5654c3afa8..437fef08b7cf7b 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1837,10 +1837,10 @@ xfs_alloc_buftarg(
* When allocating the buftargs we have not yet read the super block and
* thus don't know the file system sector size yet.
*/
- if (xfs_setsize_buftarg(btp, bdev_logical_block_size(btp->bt_bdev)))
- goto error_free;
- if (xfs_init_buftarg(btp, bdev_logical_block_size(btp->bt_bdev),
- mp->m_super->s_id))
+ btp->bt_meta_sectorsize = bdev_logical_block_size(btp->bt_bdev);
+ btp->bt_meta_sectormask = btp->bt_meta_sectorsize - 1;
+
+ if (xfs_init_buftarg(btp, btp->bt_meta_sectorsize, mp->m_super->s_id))
goto error_free;
return btp;
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f021bdf8d0b592..b6b6fb4ce8ca65 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -507,7 +507,11 @@ xfs_open_devices(
bdev_fput(logdev_file);
}
- return 0;
+ /*
+ * Flush and invalidate the data device pagecache before reading the
+ * primary super because XFS doesn't use the bdev pagecache.
+ */
+ return xfs_buftarg_sync(mp->m_ddev_targp);
out_free_rtdev_targ:
if (mp->m_rtdev_targp)
Powered by blists - more mailing lists