Skip to content

Commit a578a8e

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: clean up the initial read logic in xfs_readsb
The initial sb read is always for a device logical block size buffer. The device logical block size is provided in the bt_logical_sectorsize in struct buftarg, so use that instead of the confusingly named xfs_getsize_buftarg buffer that reads it from the bdev. Update the comments surrounding the code to better describe what is going on. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent f2eb279 commit a578a8e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

fs/xfs/xfs_buf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ extern void xfs_buftarg_wait(struct xfs_buftarg *);
375375
extern void xfs_buftarg_drain(struct xfs_buftarg *);
376376
int xfs_configure_buftarg(struct xfs_buftarg *btp, unsigned int sectorsize);
377377

378-
#define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev)
379378
#define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev)
380379

381380
int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops);

fs/xfs/xfs_mount.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,16 @@ xfs_readsb(
171171
ASSERT(mp->m_ddev_targp != NULL);
172172

173173
/*
174-
* For the initial read, we must guess at the sector
175-
* size based on the block device. It's enough to
176-
* get the sb_sectsize out of the superblock and
177-
* then reread with the proper length.
178-
* We don't verify it yet, because it may not be complete.
174+
* In the first pass, use the device sector size to just read enough
175+
* of the superblock to extract the XFS sector size.
176+
*
177+
* The device sector size must be smaller than or equal to the XFS
178+
* sector size and thus we can always read the superblock. Once we know
179+
* the XFS sector size, re-read it and run the buffer verifier.
179180
*/
180-
sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
181+
sector_size = mp->m_ddev_targp->bt_logical_sectorsize;
181182
buf_ops = NULL;
182183

183-
/*
184-
* Allocate a (locked) buffer to hold the superblock. This will be kept
185-
* around at all times to optimize access to the superblock.
186-
*/
187184
reread:
188185
error = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR,
189186
BTOBB(sector_size), &bp, buf_ops);
@@ -247,6 +244,10 @@ xfs_readsb(
247244
/* no need to be quiet anymore, so reset the buf ops */
248245
bp->b_ops = &xfs_sb_buf_ops;
249246

247+
/*
248+
* Keep a pointer of the sb buffer around instead of caching it in the
249+
* buffer cache because we access it frequently.
250+
*/
250251
mp->m_sb_bp = bp;
251252
xfs_buf_unlock(bp);
252253
return 0;

0 commit comments

Comments
 (0)