From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Upon startup, xfs_db needs to check if it is even looking at an XFS filesystem, and it needs the AG 0 superblock contents to initialize the incore mount. 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> --- db/init.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db/init.c b/db/init.c index 8bad7e53..61eea111 100644 --- a/db/init.c +++ b/db/init.c @@ -47,6 +47,7 @@ init( struct xfs_buf *bp; unsigned int agcount; int c; + int error; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -112,10 +113,9 @@ init( */ memset(&xmount, 0, sizeof(struct xfs_mount)); libxfs_buftarg_init(&xmount, x.ddev, x.logdev, x.rtdev); - bp = libxfs_buf_read(xmount.m_ddev_targp, XFS_SB_DADDR, - 1 << (XFS_MAX_SECTORSIZE_LOG - BBSHIFT), 0, NULL); - - if (!bp || bp->b_error) { + error = -libxfs_buf_read_uncached(xmount.m_ddev_targp, XFS_SB_DADDR, + 1 << (XFS_MAX_SECTORSIZE_LOG - BBSHIFT), 0, &bp, NULL); + if (error) { fprintf(stderr, _("%s: %s is invalid (cannot read first 512 " "bytes)\n"), progname, fsdevice); exit(1); @@ -124,7 +124,6 @@ init( /* copy SB from buffer to in-core, converting architecture as we go */ libxfs_sb_from_disk(&xmount.m_sb, XFS_BUF_TO_SBP(bp)); libxfs_buf_relse(bp); - libxfs_purgebuf(bp); sbp = &xmount.m_sb; if (sbp->sb_magicnum != XFS_SB_MAGIC) {