Re: [PATCH 45/45] libxfs: rename buffer cache index variable b_bn

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 28, 2022 at 03:37:17PM -0600, Eric Sandeen wrote:
> On 1/19/22 6:21 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@xxxxxxxxxx>
> > 
> > To stop external users from using b_bn as the disk address of the
> > buffer, rename it to b_rhash_key to indicate that it is the buffer
> > cache index, not the block number of the buffer. Code that needs the
> > disk address should use xfs_buf_daddr() to obtain it.
> > 
> > Do the rename and clean up any of the remaining internal b_bn users.
> 
> Is there a reason this wasn't done in the prior patch? If not, I'm happy
> to move them for consistency as noted below.

IIRC I created this as a separate patch to keep the "libxfs changes from
the kernel" bits separate from the "libxfs changes to keep the build
going".  Usually I do this so that if I have to rebase the libxfs-apply
patches I'll lose fewer pieces along the way.

If you want to combine these in the final product then please go ahead.
:)

--D

> > Also clean up any remaining b_bn cruft that is now unused.
> > 
> > Inspired-by: Dave Chinner <dchinner@xxxxxxxxxx>
> > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
> > ---
> >   libxfs/libxfs_io.h |    4 ++--
> >   libxfs/rdwr.c      |   16 ++++++++--------
> >   2 files changed, 10 insertions(+), 10 deletions(-)
> > 
> > 
> > diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
> > index a4d0a913..8a42f500 100644
> > --- a/libxfs/libxfs_io.h
> > +++ b/libxfs/libxfs_io.h
> > @@ -79,7 +79,7 @@ struct xfs_buf_ops {
> >   struct xfs_buf {
> >   	struct cache_node	b_node;
> >   	unsigned int		b_flags;
> > -	xfs_daddr_t		b_bn;
> > +	xfs_daddr_t		b_cache_key;	/* buffer cache index */
> >   	unsigned int		b_length;
> >   	struct xfs_buftarg	*b_target;
> >   	pthread_mutex_t		b_lock;
> > @@ -122,7 +122,7 @@ static inline xfs_daddr_t xfs_buf_daddr(struct xfs_buf *bp)
> >   static inline void xfs_buf_set_daddr(struct xfs_buf *bp, xfs_daddr_t blkno)
> >   {
> > -	assert(bp->b_bn == XFS_BUF_DADDR_NULL);
> > +	assert(bp->b_cache_key == XFS_BUF_DADDR_NULL);
> >   	bp->b_maps[0].bm_bn = blkno;
> >   }
> > diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
> > index a55e3a79..2a9e8c98 100644
> > --- a/libxfs/rdwr.c
> > +++ b/libxfs/rdwr.c
> > @@ -205,7 +205,7 @@ libxfs_bcompare(struct cache_node *node, cache_key_t key)
> >   	struct xfs_bufkey	*bkey = (struct xfs_bufkey *)key;
> >   	if (bp->b_target->bt_bdev == bkey->buftarg->bt_bdev &&
> > -	    bp->b_bn == bkey->blkno) {
> > +	    bp->b_cache_key == bkey->blkno) {
> >   		if (bp->b_length == bkey->bblen)
> >   			return CACHE_HIT;
> >   #ifdef IO_BCOMPARE_CHECK
> > @@ -214,7 +214,7 @@ libxfs_bcompare(struct cache_node *node, cache_key_t key)
> >   	"%lx: Badness in key lookup (length)\n"
> >   	"bp=(bno 0x%llx, len %u bytes) key=(bno 0x%llx, len %u bytes)\n",
> >   				pthread_self(),
> > -				(unsigned long long)bp->b_bn,
> > +				(unsigned long long)xfs_buf_daddr(bp),
> 
> here
> 
> >   				BBTOB(bp->b_length),
> >   				(unsigned long long)bkey->blkno,
> >   				BBTOB(bkey->bblen));
> > @@ -230,7 +230,7 @@ __initbuf(struct xfs_buf *bp, struct xfs_buftarg *btp, xfs_daddr_t bno,
> >   		unsigned int bytes)
> >   {
> >   	bp->b_flags = 0;
> > -	bp->b_bn = bno;
> > +	bp->b_cache_key = bno;
> >   	bp->b_length = BTOBB(bytes);
> >   	bp->b_target = btp;
> >   	bp->b_mount = btp->bt_mount;
> > @@ -256,7 +256,7 @@ __initbuf(struct xfs_buf *bp, struct xfs_buftarg *btp, xfs_daddr_t bno,
> >   	if (bp->b_maps == &bp->__b_map) {
> >   		bp->b_nmaps = 1;
> > -		bp->b_maps[0].bm_bn = bp->b_bn;
> > +		bp->b_maps[0].bm_bn = bno;
> >   		bp->b_maps[0].bm_len = bp->b_length;
> >   	}
> >   }
> > @@ -591,7 +591,7 @@ libxfs_readbufr(struct xfs_buftarg *btp, xfs_daddr_t blkno, struct xfs_buf *bp,
> >   	error = __read_buf(fd, bp->b_addr, bytes, LIBXFS_BBTOOFF64(blkno), flags);
> >   	if (!error &&
> >   	    bp->b_target->bt_bdev == btp->bt_bdev &&
> > -	    bp->b_bn == blkno &&
> > +	    bp->b_cache_key == blkno &&
> >   	    bp->b_length == len)
> >   		bp->b_flags |= LIBXFS_B_UPTODATE;
> >   	bp->b_error = error;
> > @@ -833,14 +833,14 @@ libxfs_bwrite(
> >   			fprintf(stderr,
> >   	_("%s: write verifier failed on %s bno 0x%llx/0x%x\n"),
> >   				__func__, bp->b_ops->name,
> > -				(long long)bp->b_bn, bp->b_length);
> > +				(long long)xfs_buf_daddr(bp), bp->b_length);
> 
> here
> 
> >   			return bp->b_error;
> >   		}
> >   	}
> >   	if (!(bp->b_flags & LIBXFS_B_DISCONTIG)) {
> >   		bp->b_error = __write_buf(fd, bp->b_addr, BBTOB(bp->b_length),
> > -				    LIBXFS_BBTOOFF64(bp->b_bn), bp->b_flags);
> > +				    LIBXFS_BBTOOFF64(xfs_buf_daddr(bp)), bp->b_flags);
> 
> here
> 
> >   	} else {
> >   		int	i;
> >   		void	*buf = bp->b_addr;
> > @@ -861,7 +861,7 @@ libxfs_bwrite(
> >   		fprintf(stderr,
> >   	_("%s: write failed on %s bno 0x%llx/0x%x, err=%d\n"),
> >   			__func__, bp->b_ops ? bp->b_ops->name : "(unknown)",
> > -			(long long)bp->b_bn, bp->b_length, -bp->b_error);
> > +			(long long)xfs_buf_daddr(bp), bp->b_length, -bp->b_error);
> 
> and here
> 
> >   	} else {
> >   		bp->b_flags |= LIBXFS_B_UPTODATE;
> >   		bp->b_flags &= ~(LIBXFS_B_DIRTY | LIBXFS_B_UNCHECKED);
> > 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux