xfs: remove the call to xfs_buf_reverify in xfs_trans_read_buf_map
PATCH 1/1 xfs: remove the call to xfs_buf_reverify in xfs_trans_read_buf_map
xfs_trans_read_buf_map asserts bp->b_ops is non-NULL just before calling xfs_buf_reverify which is a no-op if bp->b_ops is set, making the call dead code ever since it as added in commit 1aff5696f3e0 ("xfs: always assign buffer verifiers when one is provided").
Remove the useless call, mark xfs_buf_reverify static and clean up the branch dealing with a buffer attached to the transaction in a bit by deduplicating and keeping together the asserts and removing the bip variable only used once outside of asserts and tracing.
--- fs/xfs/xfs_buf.c | 2 +- fs/xfs/xfs_buf.h | 1 - fs/xfs/xfs_trans_buf.c | 39 ++++----------------------------------- 3 files changed, 5 insertions(+), 37 deletions(-)
fs/xfs/xfs_buf.c +1 -1
@@ -623,7 +623,7 @@ _xfs_buf_read(* type. If repair can't establish that, the buffer will be left in memory * with NULL buffer ops. */ -int +static int xfs_buf_reverify (struct xfs_buf *bp,const struct xfs_buf_ops *ops)
fs/xfs/xfs_buf.h +0 -1
@@ -365,7 +365,6 @@ int xfs_configure_buftarg(struct xfs_buftarg *btp, unsigned int sectorsize,#define xfs_readonly_buftarg (buftarg) bdev_read_only((buftarg)->bt_bdev) -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);
fs/xfs/xfs_trans_buf.c +4 -35
@@ -234,7 +234,6 @@ xfs_trans_read_buf_map( const struct xfs_buf_ops *ops) {struct xfs_buf *bp =NULL ; -struct xfs_buf_log_item *bip;int error; *bpp =NULL ;
@@ -251,9 +250,10 @@ xfs_trans_read_buf_map(if (bp) {ASSERT (xfs_buf_islocked (bp));ASSERT (bp->b_transp == tp); -ASSERT (bp->b_log_item !=NULL );ASSERT (!bp->b_error);ASSERT (bp->b_flags &XBF_DONE ); +ASSERT (atomic_read (&bp->b_log_item->bli_refcount) >0 ); +ASSERT (bp->b_ops);/* * We never locked this buf ourselves, so we shouldn't
@@ -264,39 +264,8 @@ xfs_trans_read_buf_map(return -EIO ; } -/* -* Check if the caller is trying to read a buffer that is -* already attached to the transaction yet has no buffer ops -* assigned. Ops are usually attached when the buffer is -* attached to the transaction, or by the read caller if -* special circumstances. That didn't happen, which is not -* how this is supposed to go. -* -* If the buffer passes verification we'll let this go, but if -* not we have to shut down. Let the transaction cleanup code -* release this buffer when it kills the tranaction. -*/ -ASSERT (bp->b_ops !=NULL ); - error =xfs_buf_reverify (bp, ops); -if (error) { -xfs_buf_ioerror_alert (bp, __return_address); - -if (tp->t_flags &XFS_TRANS_DIRTY ) -xfs_force_shutdown (tp->t_mountp, -SHUTDOWN_META_IO_ERROR ); - -/* bad CRC means corrupted metadata */ -if (error == -EFSBADCRC ) - error = -EFSCORRUPTED ; -return error; - } - - bip = bp->b_log_item; - bip->bli_recur++; - -ASSERT (atomic_read (&bip->bli_refcount) >0 ); -trace_xfs_trans_read_buf_recur (bip); -ASSERT (bp->b_ops !=NULL || ops ==NULL ); + bp->b_log_item->bli_recur++; +trace_xfs_trans_read_buf_recur (bp->b_log_item); *bpp = bp;return 0 ; }
Signature · 1 line
2.53.0
Quoted 9 lines · Christoph Hellwig
xfs_trans_read_buf_mapassertsbp->b_opsis non-NULL just before callingxfs_buf_reverifywhich is a no-op ifbp->b_opsis set, making the call dead code ever since it as added in commit1aff5696f3e0("xfs: always assign buffer verifiers when one is provided").Remove the useless call, mark
xfs_buf_reverifystatic and clean up the branch dealing with a buffer attached to the transaction in a bit by deduplicating and keeping together the asserts and removing the bip variable only used once outside of asserts and tracing.
Looks good,
Quoted 103 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_buf.c | 2 +- fs/xfs/xfs_buf.h | 1 - fs/xfs/xfs_trans_buf.c | 39 ++++----------------------------------- 3 files changed, 5 insertions(+), 37 deletions(-)fs/xfs/xfs_buf.c +1
-1@@ -623,7 +623,7 @@ _xfs_buf_read(* type. If repair can't establish that, the buffer will be left in memory * with NULL buffer ops. */ -int +static int xfs_buf_reverify (struct xfs_buf *bp,const struct xfs_buf_ops *ops)fs/xfs/xfs_buf.h +0
-1@@ -365,7 +365,6 @@ int xfs_configure_buftarg(struct xfs_buftarg *btp, unsigned int sectorsize,#define xfs_readonly_buftarg (buftarg) bdev_read_only((buftarg)->bt_bdev) -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);fs/xfs/xfs_trans_buf.c +4
-35@@ -234,7 +234,6 @@ xfs_trans_read_buf_map( const struct xfs_buf_ops *ops) {struct xfs_buf *bp =NULL ; -struct xfs_buf_log_item *bip;int error; *bpp =NULL ;@@ -251,9 +250,10 @@ xfs_trans_read_buf_map(if (bp) {ASSERT (xfs_buf_islocked (bp));ASSERT (bp->b_transp == tp); -ASSERT (bp->b_log_item !=NULL );ASSERT (!bp->b_error);ASSERT (bp->b_flags &XBF_DONE ); +ASSERT (atomic_read (&bp->b_log_item->bli_refcount) >0 ); +ASSERT (bp->b_ops);/* * We never locked this buf ourselves, so we shouldn't @@ -264,39 +264,8 @@ xfs_trans_read_buf_map(return -EIO ; } -/* -* Check if the caller is trying to read a buffer that is -* already attached to the transaction yet has no buffer ops -* assigned. Ops are usually attached when the buffer is -* attached to the transaction, or by the read caller if -* special circumstances. That didn't happen, which is not -* how this is supposed to go. -* -* If the buffer passes verification we'll let this go, but if -* not we have to shut down. Let the transaction cleanup code -* release this buffer when it kills the tranaction. -*/ -ASSERT (bp->b_ops !=NULL ); - error =xfs_buf_reverify (bp, ops); -if (error) { -xfs_buf_ioerror_alert (bp, __return_address); - -if (tp->t_flags &XFS_TRANS_DIRTY ) -xfs_force_shutdown (tp->t_mountp, -SHUTDOWN_META_IO_ERROR ); - -/* bad CRC means corrupted metadata */ -if (error == -EFSBADCRC ) - error = -EFSCORRUPTED ; -return error; - } - - bip = bp->b_log_item; - bip->bli_recur++; - -ASSERT (atomic_read (&bip->bli_refcount) >0 ); -trace_xfs_trans_read_buf_recur (bip); -ASSERT (bp->b_ops !=NULL || ops ==NULL ); + bp->b_log_item->bli_recur++; +trace_xfs_trans_read_buf_recur (bp->b_log_item); *bpp = bp;return 0 ; }Signature · 1 line
2.53.0
Quoted 11 lines · Christoph Hellwig
xfs_trans_read_buf_mapassertsbp->b_opsis non-NULL just before callingxfs_buf_reverifywhich is a no-op ifbp->b_opsis set, making the call dead code ever since it as added in commit1aff5696f3e0("xfs: always assign buffer verifiers when one is provided").Remove the useless call, mark
xfs_buf_reverifystatic and clean up the branch dealing with a buffer attached to the transaction in a bit by deduplicating and keeping together the asserts and removing the bip variable only used once outside of asserts and tracing.[...]
Applied to for-next, thanks!
[1/1] xfs: remove the call to xfs_buf_reverify in xfs_trans_read_buf_map
commit: f8e9350fff08217591eaab01551a7a253fbb1fc0
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>