From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Upon startup, xfs_copy needs to read the filesystem superblock to mount the filesystem. We cannot know the filesystem sector size until we read the superblock, but we also do not want to introduce aliasing in the buffer cache. Convert this code to the new uncached buffer read API so that we can stop open-coding it. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> --- copy/xfs_copy.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c index 9e9719a0..5cab1a5f 100644 --- a/copy/xfs_copy.c +++ b/copy/xfs_copy.c @@ -562,6 +562,7 @@ main(int argc, char **argv) libxfs_init_t xargs; thread_args *tcarg; struct stat statbuf; + int error; progname = basename(argv[0]); @@ -710,14 +711,20 @@ main(int argc, char **argv) /* We don't yet know the sector size, so read maximal size */ libxfs_buftarg_init(&mbuf, xargs.ddev, xargs.logdev, xargs.rtdev); - sbp = libxfs_buf_read(mbuf.m_ddev_targp, XFS_SB_DADDR, - 1 << (XFS_MAX_SECTORSIZE_LOG - BBSHIFT), 0, NULL); + error = -libxfs_buf_read_uncached(mbuf.m_ddev_targp, XFS_SB_DADDR, + 1 << (XFS_MAX_SECTORSIZE_LOG - BBSHIFT), 0, &sbp, NULL); + if (error) { + do_log(_("%s: couldn't read superblock, error=%d\n"), + progname, error); + exit(1); + } + sb = &mbuf.m_sb; libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbp)); /* Do it again, now with proper length and verifier */ libxfs_buf_relse(sbp); - libxfs_purgebuf(sbp); + sbp = libxfs_buf_read(mbuf.m_ddev_targp, XFS_SB_DADDR, 1 << (sb->sb_sectlog - BBSHIFT), 0, &xfs_sb_buf_ops);