Resubmit items failed during writeback
v2 cover Resubmit items failed during writeback
Hi,
this is the second version of this patchset, based on the comments on the previous version.
Each patch has its own changelog, but some of the highlights are:
- Use atomic operations to set/clear xfs_log_item flags (including a patch to convert all the existing operations to atomic operations)
- call xfs_buf_do_callbacks_fail() from inside xfS_buf_iodone_error
- Use a helper function to resubmit the failed buffers.
The whole discussion is quite long, so I hope to have addressed all the topics discussed.
- The patchset has passed xfstests and my reproducer to this specific bug.
Signature · 1 line
2.9.3
PATCH v2 1/3 xfs: use atomic operations to handle xfs_log_item flags
In order to fix a bug during buffer retries, a new flag type will be added to xfs_log_item, and such operations need to be atomic.
Change all operations in xfs_log_item flags to atomic operations
To use atomic operations, xfs_log_item->li_flags also needed to be converted to unsigned long type.
There is a small whitespace cleanup in the patch too
--- fs/xfs/xfs_bmap_item.c | 4 ++-- fs/xfs/xfs_buf_item.c | 4 ++-- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_extfree_item.c | 4 ++-- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_icreate_item.c | 2 +- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_refcount_item.c | 4 ++-- fs/xfs/xfs_rmap_item.c | 4 ++-- fs/xfs/xfs_trace.h | 4 ++-- fs/xfs/xfs_trans.c | 4 ++-- fs/xfs/xfs_trans.h | 2 +- fs/xfs/xfs_trans_ail.c | 12 ++++++------ fs/xfs/xfs_trans_buf.c | 2 +- fs/xfs/xfs_trans_priv.h | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-)
fs/xfs/xfs_bmap_item.c +2 -2
@@ -141,7 +141,7 @@ STATIC voidxfs_bui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_bui_item_free (BUI_ITEM (lip)); }
@@ -304,7 +304,7 @@ xfs_bud_item_unlock( {struct xfs_bud_log_item *budp =BUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_bui_release (budp->bud_buip);kmem_zone_free (xfs_bud_zone, budp); }
fs/xfs/xfs_buf_item.c +2 -2
@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;/* * Before possibly freeing the buf item, copy the per-transaction state * so we can reference it safely later after clearing it from the
@@ -975,7 +975,7 @@ xfs_buf_item_relse(xfs_buf_log_item_t *bip = bp->b_fspriv;trace_xfs_buf_item_relse (bp, _RET_IP_); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags))); bp->b_fspriv = bip->bli_item.li_bio_list;if (bp->b_fspriv ==NULL )
fs/xfs/xfs_dquot.c +1 -1
@@ -1003,7 +1003,7 @@ xfs_qm_dqflush_done(* since it's cheaper, and then we recheck while * holding the lock before removing the dquot from the AIL. */ -if ((lip->li_flags &XFS_LI_IN_AIL ) && +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags) && lip->li_lsn == qip->qli_flush_lsn) {/* xfs_trans_ail_delete() drops the AIL lock. */
fs/xfs/xfs_extfree_item.c +2 -2
@@ -150,7 +150,7 @@ STATIC voidxfs_efi_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_efi_item_free (EFI_ITEM (lip)); }
@@ -402,7 +402,7 @@ xfs_efd_item_unlock( {struct xfs_efd_log_item *efdp =EFD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_efi_release (efdp->efd_efip);xfs_efd_item_free (efdp); }
fs/xfs/xfs_icache.c +1 -1
@@ -107,7 +107,7 @@ xfs_inode_free_callback(xfs_idestroy_fork (ip,XFS_COW_FORK );if (ip->i_itemp) { -ASSERT (!(ip->i_itemp->ili_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));xfs_inode_item_destroy (ip); ip->i_itemp =NULL ; }
fs/xfs/xfs_icreate_item.c +1 -1
@@ -91,7 +91,7 @@ xfs_icreate_item_unlock( {struct xfs_icreate_item *icp =ICR_ITEM (lip); -if (icp->ic_item.li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &icp->ic_item.li_flags))kmem_zone_free (xfs_icreate_zone, icp);return ; }
fs/xfs/xfs_inode.c +2 -2
@@ -504,7 +504,7 @@ xfs_lock_inodes(if (!try_lock) {for (j = (i -1 ); j >=0 && !try_lock; j--) { lp = (xfs_log_item_t *)ips[j]->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) try_lock++; } }
@@ -601,7 +601,7 @@ xfs_lock_two_inodes(* and try again. */ lp = (xfs_log_item_t *)ip0->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) { +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) {if (!xfs_ilock_nowait (ip1,xfs_lock_inumorder (lock_mode,1 ))) {xfs_iunlock (ip0, lock_mode);if ((++attempts %5 ) ==0 )
fs/xfs/xfs_inode_item.c +1 -1
@@ -783,7 +783,7 @@ xfs_iflush_abort(xfs_inode_log_item_t *iip = ip->i_itemp;if (iip) { -if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &iip->ili_item.li_flags)) {xfs_trans_ail_remove (&iip->ili_item, stale ?SHUTDOWN_LOG_IO_ERROR :SHUTDOWN_CORRUPT_INCORE );
fs/xfs/xfs_qm.c +1 -1
@@ -169,7 +169,7 @@ xfs_qm_dqpurge(ASSERT (atomic_read (&dqp->q_pincount) ==0 );ASSERT (XFS_FORCED_SHUTDOWN (mp) || - !(dqp->q_logitem.qli_item.li_flags &XFS_LI_IN_AIL )); + !(test_bit (XFS_LI_IN_AIL , &dqp->q_logitem.qli_item.li_flags)));xfs_dqfunlock (dqp);xfs_dqunlock (dqp);
fs/xfs/xfs_refcount_item.c +2 -2
@@ -139,7 +139,7 @@ STATIC voidxfs_cui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_cui_item_free (CUI_ITEM (lip)); }
@@ -308,7 +308,7 @@ xfs_cud_item_unlock( {struct xfs_cud_log_item *cudp =CUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_cui_release (cudp->cud_cuip);kmem_zone_free (xfs_cud_zone, cudp); }
fs/xfs/xfs_rmap_item.c +2 -2
@@ -139,7 +139,7 @@ STATIC voidxfs_rui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_rui_item_free (RUI_ITEM (lip)); }
@@ -330,7 +330,7 @@ xfs_rud_item_unlock( {struct xfs_rud_log_item *rudp =RUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_rui_release (rudp->rud_ruip);kmem_zone_free (xfs_rud_zone, rudp); }
fs/xfs/xfs_trace.h +2 -2
@@ -1031,7 +1031,7 @@ DECLARE_EVENT_CLASS(xfs_log_item_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, lsn) ), TP_fast_assign(
@@ -1083,7 +1083,7 @@ DECLARE_EVENT_CLASS(xfs_ail_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, old_lsn) __field(xfs_lsn_t, new_lsn) ),
fs/xfs/xfs_trans.c +2 -2
@@ -764,7 +764,7 @@ xfs_trans_free_items(if (commit_lsn !=NULLCOMMITLSN ) lip->li_ops->iop_committing (lip, commit_lsn);if (abort) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); lip->li_ops->iop_unlock (lip);xfs_trans_free_item_desc (lidp);
@@ -835,7 +835,7 @@ xfs_trans_committed_bulk(xfs_lsn_t item_lsn;if (aborted) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); item_lsn = lip->li_ops->iop_committed (lip, commit_lsn);/* item_lsn of -1 means the item needs no further processing */
fs/xfs/xfs_trans.h +1 -1
@@ -48,7 +48,7 @@ typedef struct xfs_log_item {struct xfs_mount *li_mountp;/* ptr to fs mount */ struct xfs_ail *li_ailp;/* ptr to AIL */ uint li_type;/* item type */ -uint li_flags;/* misc flags */ +unsigned long li_flags;/* misc flags */ struct xfs_log_item *li_bio_list;/* buffer item list */ void (*li_cb)(struct xfs_buf *,struct xfs_log_item *);
fs/xfs/xfs_trans_ail.c +6 -6
@@ -45,7 +45,7 @@ xfs_ail_check(/* * Check the next and previous entries are valid. */ -ASSERT ((lip->li_flags &XFS_LI_IN_AIL ) !=0 ); +ASSERT (test_bit (XFS_LI_IN_AIL , &lip->li_flags)); prev_lip =list_entry (lip->li_ail.prev, xfs_log_item_t, li_ail);if (&prev_lip->li_ail != &ailp->xa_ail)ASSERT (XFS_LSN_CMP (prev_lip->li_lsn, lip->li_lsn) <=0 );
@@ -653,7 +653,7 @@ xfs_trans_ail_update_bulk(for (i =0 ; i < nr_items; i++) {struct xfs_log_item *lip = log_items[i]; -if (lip->li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags)) {/* check if we really need to move the item */ if (XFS_LSN_CMP (lsn, lip->li_lsn) <=0 )continue ;
@@ -663,7 +663,7 @@ xfs_trans_ail_update_bulk(if (mlip == lip) mlip_changed =1 ; }else { - lip->li_flags |=XFS_LI_IN_AIL ; +set_bit (XFS_LI_IN_AIL , &lip->li_flags);trace_xfs_ail_insert (lip,0 , lsn); } lip->li_lsn = lsn;
@@ -687,13 +687,13 @@ xfs_trans_ail_update_bulk(bool xfs_ail_delete_one (struct xfs_ail *ailp, -struct xfs_log_item *lip) +struct xfs_log_item *lip) {struct xfs_log_item *mlip =xfs_ail_min (ailp);trace_xfs_ail_delete (lip, mlip->li_lsn, lip->li_lsn);xfs_ail_delete (ailp, lip); - lip->li_flags &= ~XFS_LI_IN_AIL ; +clear_bit (XFS_LI_IN_AIL , &lip->li_flags); lip->li_lsn =0 ;return mlip == lip;
@@ -729,7 +729,7 @@ xfs_trans_ail_delete(struct xfs_mount *mp = ailp->xa_mount;bool mlip_changed; -if (!(lip->li_flags &XFS_LI_IN_AIL )) { +if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {spin_unlock (&ailp->xa_lock);if (!XFS_FORCED_SHUTDOWN (mp)) { xfs_alert_tag(mp, XFS_PTAG_AILDELETE,
fs/xfs/xfs_trans_buf.c +1 -1
@@ -433,7 +433,7 @@ xfs_trans_brelse(xfs_trans_t *tp,ASSERT(bp->b_pincount == 0); ***/ ASSERT (atomic_read (&bip->bli_refcount) ==0 ); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));ASSERT (!(bip->bli_flags &XFS_BLI_INODE_ALLOC_BUF ));xfs_buf_item_relse (bp); }
fs/xfs/xfs_trans_priv.h +1 -1
@@ -119,7 +119,7 @@ xfs_trans_ail_remove(spin_lock (&ailp->xa_lock);/* xfs_trans_ail_delete() drops the AIL lock */ -if (lip->li_flags &XFS_LI_IN_AIL ) +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags))xfs_trans_ail_delete (ailp, lip, shutdown_type);else spin_unlock (&ailp->xa_lock);
Signature · 1 line
2.9.3
Re: [PATCH 1/3] xfs: use atomic operations to handle xfs_log_item flags
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 590
Quoted 8 lines
fs/xfs/xfs_buf_item.c +1
-1@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;
aborted = test_bit(XFS_LI_ABORTED, &lip->li_flags);
does the same job in a slightly simpler way.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 591
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));
no need for the inner braces.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 592
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));
Same here. Also please don't break lines after 80 characters.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 593
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ !(test_bit(XFS_LI_IN_AIL, &dqp->q_logitem.qli_item.li_flags)));
Also no need for the braces around test_bit here.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock(
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {
.. again
fs/xfs/xfs_buf_item.c
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));
.. again
Also last but not least the arguments to the *_bit functions are bit indices, so they should be renumber to 0 and 1 (and the tracing helpers will need some updates as well).
Re: [PATCH 1/3] xfs: use atomic operations to handle xfs_log_item flags
Hi,
Quoted 29 lines · Christoph Hellwig
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 590
Quoted 8 lines
fs/xfs/xfs_buf_item.c +1
-1@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;aborted = test_bit(XFS_LI_ABORTED, &lip->li_flags);does the same job in a slightly simpler way.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 591
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));no need for the inner braces.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 592
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));Same here. Also please don't break lines after 80 characters.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 593
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ !(test_bit(XFS_LI_IN_AIL, &dqp->q_logitem.qli_item.li_flags)));Also no need for the braces around
test_bithere.fs/xfs/xfs_buf_item.c xfs_buf_item_unlock(
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {.. again
Quoted 7 lines
fs/xfs/xfs_buf_item.c
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));.. again
Also last but not least the arguments to the
*_bitfunctions are bit indices, so they should be renumber to 0 and 1 (and the tracing helpers will need some updates as well).
Thanks for the review of this series, I'll queue these changes for V3.
Signature · 1 line
Carlos
Re: [PATCH 1/3] xfs: use atomic operations to handle xfs_log_item flags
In reply to Christoph HellwigQuoted 13 lines · Christoph Hellwig
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 590
Quoted 8 lines
fs/xfs/xfs_buf_item.c +1
-1@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;aborted = test_bit(XFS_LI_ABORTED, &lip->li_flags);does the same job in a slightly simpler way.
Quoted 7 lines
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 591
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));no need for the inner braces.
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 592
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));Same here. Also please don't break lines after 80 characters.
Btw, I believe you meant I didn't break the line here? Removing the inner braces will leave it with 82 chars, I wonder if it's worth to break the line here in this case? Just looks harder to read with the line broken for just 2 chars.
Quoted 16 lines
fs/xfs/xfs_buf_item.c xfs_buf_item_unlock( · line 593
Quoted 2 lines
fs/xfs/xfs_buf_item.c +1
-0+ !(test_bit(XFS_LI_IN_AIL, &dqp->q_logitem.qli_item.li_flags)));Also no need for the braces around
test_bithere.fs/xfs/xfs_buf_item.c xfs_buf_item_unlock(
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {.. again
fs/xfs/xfs_buf_item.c
Quoted 1 line
fs/xfs/xfs_buf_item.c +1
-0+ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));.. again
Also last but not least the arguments to the
*_bitfunctions are bit indices, so they should be renumber to 0 and 1 (and the tracing helpers will need some updates as well).
Signature · 1 line
Carlos
Re: [PATCH 1/3] xfs: use atomic operations to handle xfs_log_item flags
In reply to Carlos MaiolinoQuoted 5 lines · Carlos Maiolino
In order to fix a bug during buffer retries, a new flag type will be added to
xfs_log_item, and such operations need to be atomic.Change all operations in
xfs_log_itemflags to atomic operations
Quoted 7 lines
To use atomic operations,
xfs_log_item->li_flagsalso needed to be converted to unsigned long type.There is a small whitespace cleanup in the patch too
Signed-off-by Carlos Maiolino <[email protected]>---
As noted in the v1 discussion, I don't think this needs to be a dependency of the bug fix patch. Provided we can alleviate Dave's concerns over performance and not add any ->xa_lock acquisitions that aren't triggered by I/O errors, can we fix the bug using ->xa_lock and then port this on top? That way we have more of a backportable fix for older kernels affected by this problem.
(Please see my comments on patches 2 and 3 wrt proposed changes to avoid the custom callback and need for atomic flags..)
Brian
Quoted 362 lines
fs/xfs/xfs_bmap_item.c | 4 ++-- fs/xfs/xfs_buf_item.c | 4 ++-- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_extfree_item.c | 4 ++-- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_icreate_item.c | 2 +- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_refcount_item.c | 4 ++-- fs/xfs/xfs_rmap_item.c | 4 ++-- fs/xfs/xfs_trace.h | 4 ++-- fs/xfs/xfs_trans.c | 4 ++-- fs/xfs/xfs_trans.h | 2 +- fs/xfs/xfs_trans_ail.c | 12 ++++++------ fs/xfs/xfs_trans_buf.c | 2 +- fs/xfs/xfs_trans_priv.h | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-)fs/xfs/xfs_bmap_item.c +2
-2@@ -141,7 +141,7 @@ STATIC voidxfs_bui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_bui_item_free (BUI_ITEM (lip)); }@@ -304,7 +304,7 @@ xfs_bud_item_unlock( {struct xfs_bud_log_item *budp =BUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_bui_release (budp->bud_buip);kmem_zone_free (xfs_bud_zone, budp); }fs/xfs/xfs_buf_item.c +2
-2@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;/* * Before possibly freeing the buf item, copy the per-transaction state * so we can reference it safely later after clearing it from the @@ -975,7 +975,7 @@ xfs_buf_item_relse(xfs_buf_log_item_t *bip = bp->b_fspriv;trace_xfs_buf_item_relse (bp, _RET_IP_); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags))); bp->b_fspriv = bip->bli_item.li_bio_list;if (bp->b_fspriv ==NULL )fs/xfs/xfs_dquot.c +1
-1@@ -1003,7 +1003,7 @@ xfs_qm_dqflush_done(* since it's cheaper, and then we recheck while * holding the lock before removing the dquot from the AIL. */ -if ((lip->li_flags &XFS_LI_IN_AIL ) && +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags) && lip->li_lsn == qip->qli_flush_lsn) {/* xfs_trans_ail_delete() drops the AIL lock. */ fs/xfs/xfs_extfree_item.c +2
-2@@ -150,7 +150,7 @@ STATIC voidxfs_efi_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_efi_item_free (EFI_ITEM (lip)); }@@ -402,7 +402,7 @@ xfs_efd_item_unlock( {struct xfs_efd_log_item *efdp =EFD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_efi_release (efdp->efd_efip);xfs_efd_item_free (efdp); }fs/xfs/xfs_icache.c +1
-1@@ -107,7 +107,7 @@ xfs_inode_free_callback(xfs_idestroy_fork (ip,XFS_COW_FORK );if (ip->i_itemp) { -ASSERT (!(ip->i_itemp->ili_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));xfs_inode_item_destroy (ip); ip->i_itemp =NULL ; }fs/xfs/xfs_icreate_item.c +1
-1@@ -91,7 +91,7 @@ xfs_icreate_item_unlock( {struct xfs_icreate_item *icp =ICR_ITEM (lip); -if (icp->ic_item.li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &icp->ic_item.li_flags))kmem_zone_free (xfs_icreate_zone, icp);return ; }fs/xfs/xfs_inode.c +2
-2@@ -504,7 +504,7 @@ xfs_lock_inodes(if (!try_lock) {for (j = (i -1 ); j >=0 && !try_lock; j--) { lp = (xfs_log_item_t *)ips[j]->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) try_lock++; } }@@ -601,7 +601,7 @@ xfs_lock_two_inodes(* and try again. */ lp = (xfs_log_item_t *)ip0->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) { +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) {if (!xfs_ilock_nowait (ip1,xfs_lock_inumorder (lock_mode,1 ))) {xfs_iunlock (ip0, lock_mode);if ((++attempts %5 ) ==0 )fs/xfs/xfs_inode_item.c +1
-1@@ -783,7 +783,7 @@ xfs_iflush_abort(xfs_inode_log_item_t *iip = ip->i_itemp;if (iip) { -if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &iip->ili_item.li_flags)) {xfs_trans_ail_remove (&iip->ili_item, stale ?SHUTDOWN_LOG_IO_ERROR :SHUTDOWN_CORRUPT_INCORE );fs/xfs/xfs_qm.c +1
-1@@ -169,7 +169,7 @@ xfs_qm_dqpurge(ASSERT (atomic_read (&dqp->q_pincount) ==0 );ASSERT (XFS_FORCED_SHUTDOWN (mp) || - !(dqp->q_logitem.qli_item.li_flags &XFS_LI_IN_AIL )); + !(test_bit (XFS_LI_IN_AIL , &dqp->q_logitem.qli_item.li_flags)));xfs_dqfunlock (dqp);xfs_dqunlock (dqp);fs/xfs/xfs_refcount_item.c +2
-2@@ -139,7 +139,7 @@ STATIC voidxfs_cui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_cui_item_free (CUI_ITEM (lip)); }@@ -308,7 +308,7 @@ xfs_cud_item_unlock( {struct xfs_cud_log_item *cudp =CUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_cui_release (cudp->cud_cuip);kmem_zone_free (xfs_cud_zone, cudp); }fs/xfs/xfs_rmap_item.c +2
-2@@ -139,7 +139,7 @@ STATIC voidxfs_rui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_rui_item_free (RUI_ITEM (lip)); }@@ -330,7 +330,7 @@ xfs_rud_item_unlock( {struct xfs_rud_log_item *rudp =RUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_rui_release (rudp->rud_ruip);kmem_zone_free (xfs_rud_zone, rudp); }fs/xfs/xfs_trace.h +2
-2@@ -1031,7 +1031,7 @@ DECLARE_EVENT_CLASS(xfs_log_item_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, lsn) ), TP_fast_assign(@@ -1083,7 +1083,7 @@ DECLARE_EVENT_CLASS(xfs_ail_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, old_lsn) __field(xfs_lsn_t, new_lsn) ),fs/xfs/xfs_trans.c +2
-2@@ -764,7 +764,7 @@ xfs_trans_free_items(if (commit_lsn !=NULLCOMMITLSN ) lip->li_ops->iop_committing (lip, commit_lsn);if (abort) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); lip->li_ops->iop_unlock (lip);xfs_trans_free_item_desc (lidp);@@ -835,7 +835,7 @@ xfs_trans_committed_bulk(xfs_lsn_t item_lsn;if (aborted) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); item_lsn = lip->li_ops->iop_committed (lip, commit_lsn);/* item_lsn of -1 means the item needs no further processing */ fs/xfs/xfs_trans.h +1
-1@@ -48,7 +48,7 @@ typedef struct xfs_log_item {struct xfs_mount *li_mountp;/* ptr to fs mount */ struct xfs_ail *li_ailp;/* ptr to AIL */ uint li_type;/* item type */ -uint li_flags;/* misc flags */ +unsigned long li_flags;/* misc flags */ struct xfs_log_item *li_bio_list;/* buffer item list */ void (*li_cb)(struct xfs_buf *,struct xfs_log_item *);fs/xfs/xfs_trans_ail.c +6
-6@@ -45,7 +45,7 @@ xfs_ail_check(/* * Check the next and previous entries are valid. */ -ASSERT ((lip->li_flags &XFS_LI_IN_AIL ) !=0 ); +ASSERT (test_bit (XFS_LI_IN_AIL , &lip->li_flags)); prev_lip =list_entry (lip->li_ail.prev, xfs_log_item_t, li_ail);if (&prev_lip->li_ail != &ailp->xa_ail)ASSERT (XFS_LSN_CMP (prev_lip->li_lsn, lip->li_lsn) <=0 );@@ -653,7 +653,7 @@ xfs_trans_ail_update_bulk(for (i =0 ; i < nr_items; i++) {struct xfs_log_item *lip = log_items[i]; -if (lip->li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags)) {/* check if we really need to move the item */ if (XFS_LSN_CMP (lsn, lip->li_lsn) <=0 )continue ;@@ -663,7 +663,7 @@ xfs_trans_ail_update_bulk(if (mlip == lip) mlip_changed =1 ; }else { - lip->li_flags |=XFS_LI_IN_AIL ; +set_bit (XFS_LI_IN_AIL , &lip->li_flags);trace_xfs_ail_insert (lip,0 , lsn); } lip->li_lsn = lsn;@@ -687,13 +687,13 @@ xfs_trans_ail_update_bulk(bool xfs_ail_delete_one (struct xfs_ail *ailp, -struct xfs_log_item *lip) +struct xfs_log_item *lip) {struct xfs_log_item *mlip =xfs_ail_min (ailp);trace_xfs_ail_delete (lip, mlip->li_lsn, lip->li_lsn);xfs_ail_delete (ailp, lip); - lip->li_flags &= ~XFS_LI_IN_AIL ; +clear_bit (XFS_LI_IN_AIL , &lip->li_flags); lip->li_lsn =0 ;return mlip == lip;@@ -729,7 +729,7 @@ xfs_trans_ail_delete(struct xfs_mount *mp = ailp->xa_mount;bool mlip_changed; -if (!(lip->li_flags &XFS_LI_IN_AIL )) { +if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {spin_unlock (&ailp->xa_lock);if (!XFS_FORCED_SHUTDOWN (mp)) { xfs_alert_tag(mp, XFS_PTAG_AILDELETE,fs/xfs/xfs_trans_buf.c +1
-1@@ -433,7 +433,7 @@ xfs_trans_brelse(xfs_trans_t *tp,ASSERT(bp->b_pincount == 0); ***/ ASSERT (atomic_read (&bip->bli_refcount) ==0 ); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));ASSERT (!(bip->bli_flags &XFS_BLI_INODE_ALLOC_BUF ));xfs_buf_item_relse (bp); }fs/xfs/xfs_trans_priv.h +1
-1@@ -119,7 +119,7 @@ xfs_trans_ail_remove(spin_lock (&ailp->xa_lock);/* xfs_trans_ail_delete() drops the AIL lock */ -if (lip->li_flags &XFS_LI_IN_AIL ) +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags))xfs_trans_ail_delete (ailp, lip, shutdown_type);else spin_unlock (&ailp->xa_lock);Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] xfs: use atomic operations to handle xfs_log_item flags
Quoted 14 lines · Brian Foster
Quoted 5 lines · Carlos Maiolino
In order to fix a bug during buffer retries, a new flag type will be added to
xfs_log_item, and such operations need to be atomic.Change all operations in
xfs_log_itemflags to atomic operationsQuoted 7 lines
To use atomic operations,
xfs_log_item->li_flagsalso needed to be converted to unsigned long type.There is a small whitespace cleanup in the patch too
Signed-off-by Carlos Maiolino <[email protected]>---
Quoted 7 lines
As noted in the v1 discussion, I don't think this needs to be a dependency of the bug fix patch. Provided we can alleviate Dave's concerns over performance and not add any ->xa_lock acquisitions that aren't triggered by I/O errors, can we fix the bug using ->xa_lock and then port this on top? That way we have more of a backportable fix for older kernels affected by this problem.
Hmm, I'm doing some tests with ->xa_lock, and I am actually deadlocking the system when I try to acquire it in xfs_inode_item_push(), I wonder if ->xa_lock is really correct to be used here, or maybe I'm doing something wrong? Still checking what's going on though.
Quoted 367 lines
(Please see my comments on patches 2 and 3 wrt proposed changes to avoid the custom callback and need for atomic flags..)
Brian
Quoted 362 lines
fs/xfs/xfs_bmap_item.c | 4 ++-- fs/xfs/xfs_buf_item.c | 4 ++-- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_extfree_item.c | 4 ++-- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_icreate_item.c | 2 +- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_refcount_item.c | 4 ++-- fs/xfs/xfs_rmap_item.c | 4 ++-- fs/xfs/xfs_trace.h | 4 ++-- fs/xfs/xfs_trans.c | 4 ++-- fs/xfs/xfs_trans.h | 2 +- fs/xfs/xfs_trans_ail.c | 12 ++++++------ fs/xfs/xfs_trans_buf.c | 2 +- fs/xfs/xfs_trans_priv.h | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-)fs/xfs/xfs_bmap_item.c +2
-2@@ -141,7 +141,7 @@ STATIC voidxfs_bui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_bui_item_free (BUI_ITEM (lip)); }@@ -304,7 +304,7 @@ xfs_bud_item_unlock( {struct xfs_bud_log_item *budp =BUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_bui_release (budp->bud_buip);kmem_zone_free (xfs_bud_zone, budp); }fs/xfs/xfs_buf_item.c +2
-2@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;/* * Before possibly freeing the buf item, copy the per-transaction state * so we can reference it safely later after clearing it from the @@ -975,7 +975,7 @@ xfs_buf_item_relse(xfs_buf_log_item_t *bip = bp->b_fspriv;trace_xfs_buf_item_relse (bp, _RET_IP_); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags))); bp->b_fspriv = bip->bli_item.li_bio_list;if (bp->b_fspriv ==NULL )fs/xfs/xfs_dquot.c +1
-1@@ -1003,7 +1003,7 @@ xfs_qm_dqflush_done(* since it's cheaper, and then we recheck while * holding the lock before removing the dquot from the AIL. */ -if ((lip->li_flags &XFS_LI_IN_AIL ) && +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags) && lip->li_lsn == qip->qli_flush_lsn) {/* xfs_trans_ail_delete() drops the AIL lock. */ fs/xfs/xfs_extfree_item.c +2
-2@@ -150,7 +150,7 @@ STATIC voidxfs_efi_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_efi_item_free (EFI_ITEM (lip)); }@@ -402,7 +402,7 @@ xfs_efd_item_unlock( {struct xfs_efd_log_item *efdp =EFD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_efi_release (efdp->efd_efip);xfs_efd_item_free (efdp); }fs/xfs/xfs_icache.c +1
-1@@ -107,7 +107,7 @@ xfs_inode_free_callback(xfs_idestroy_fork (ip,XFS_COW_FORK );if (ip->i_itemp) { -ASSERT (!(ip->i_itemp->ili_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));xfs_inode_item_destroy (ip); ip->i_itemp =NULL ; }fs/xfs/xfs_icreate_item.c +1
-1@@ -91,7 +91,7 @@ xfs_icreate_item_unlock( {struct xfs_icreate_item *icp =ICR_ITEM (lip); -if (icp->ic_item.li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &icp->ic_item.li_flags))kmem_zone_free (xfs_icreate_zone, icp);return ; }fs/xfs/xfs_inode.c +2
-2@@ -504,7 +504,7 @@ xfs_lock_inodes(if (!try_lock) {for (j = (i -1 ); j >=0 && !try_lock; j--) { lp = (xfs_log_item_t *)ips[j]->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) try_lock++; } }@@ -601,7 +601,7 @@ xfs_lock_two_inodes(* and try again. */ lp = (xfs_log_item_t *)ip0->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) { +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) {if (!xfs_ilock_nowait (ip1,xfs_lock_inumorder (lock_mode,1 ))) {xfs_iunlock (ip0, lock_mode);if ((++attempts %5 ) ==0 )fs/xfs/xfs_inode_item.c +1
-1@@ -783,7 +783,7 @@ xfs_iflush_abort(xfs_inode_log_item_t *iip = ip->i_itemp;if (iip) { -if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &iip->ili_item.li_flags)) {xfs_trans_ail_remove (&iip->ili_item, stale ?SHUTDOWN_LOG_IO_ERROR :SHUTDOWN_CORRUPT_INCORE );fs/xfs/xfs_qm.c +1
-1@@ -169,7 +169,7 @@ xfs_qm_dqpurge(ASSERT (atomic_read (&dqp->q_pincount) ==0 );ASSERT (XFS_FORCED_SHUTDOWN (mp) || - !(dqp->q_logitem.qli_item.li_flags &XFS_LI_IN_AIL )); + !(test_bit (XFS_LI_IN_AIL , &dqp->q_logitem.qli_item.li_flags)));xfs_dqfunlock (dqp);xfs_dqunlock (dqp);fs/xfs/xfs_refcount_item.c +2
-2@@ -139,7 +139,7 @@ STATIC voidxfs_cui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_cui_item_free (CUI_ITEM (lip)); }@@ -308,7 +308,7 @@ xfs_cud_item_unlock( {struct xfs_cud_log_item *cudp =CUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_cui_release (cudp->cud_cuip);kmem_zone_free (xfs_cud_zone, cudp); }fs/xfs/xfs_rmap_item.c +2
-2@@ -139,7 +139,7 @@ STATIC voidxfs_rui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_rui_item_free (RUI_ITEM (lip)); }@@ -330,7 +330,7 @@ xfs_rud_item_unlock( {struct xfs_rud_log_item *rudp =RUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_rui_release (rudp->rud_ruip);kmem_zone_free (xfs_rud_zone, rudp); }fs/xfs/xfs_trace.h +2
-2@@ -1031,7 +1031,7 @@ DECLARE_EVENT_CLASS(xfs_log_item_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, lsn) ), TP_fast_assign(@@ -1083,7 +1083,7 @@ DECLARE_EVENT_CLASS(xfs_ail_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, old_lsn) __field(xfs_lsn_t, new_lsn) ),fs/xfs/xfs_trans.c +2
-2@@ -764,7 +764,7 @@ xfs_trans_free_items(if (commit_lsn !=NULLCOMMITLSN ) lip->li_ops->iop_committing (lip, commit_lsn);if (abort) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); lip->li_ops->iop_unlock (lip);xfs_trans_free_item_desc (lidp);@@ -835,7 +835,7 @@ xfs_trans_committed_bulk(xfs_lsn_t item_lsn;if (aborted) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); item_lsn = lip->li_ops->iop_committed (lip, commit_lsn);/* item_lsn of -1 means the item needs no further processing */ fs/xfs/xfs_trans.h +1
-1@@ -48,7 +48,7 @@ typedef struct xfs_log_item {struct xfs_mount *li_mountp;/* ptr to fs mount */ struct xfs_ail *li_ailp;/* ptr to AIL */ uint li_type;/* item type */ -uint li_flags;/* misc flags */ +unsigned long li_flags;/* misc flags */ struct xfs_log_item *li_bio_list;/* buffer item list */ void (*li_cb)(struct xfs_buf *,struct xfs_log_item *);fs/xfs/xfs_trans_ail.c +6
-6@@ -45,7 +45,7 @@ xfs_ail_check(/* * Check the next and previous entries are valid. */ -ASSERT ((lip->li_flags &XFS_LI_IN_AIL ) !=0 ); +ASSERT (test_bit (XFS_LI_IN_AIL , &lip->li_flags)); prev_lip =list_entry (lip->li_ail.prev, xfs_log_item_t, li_ail);if (&prev_lip->li_ail != &ailp->xa_ail)ASSERT (XFS_LSN_CMP (prev_lip->li_lsn, lip->li_lsn) <=0 );@@ -653,7 +653,7 @@ xfs_trans_ail_update_bulk(for (i =0 ; i < nr_items; i++) {struct xfs_log_item *lip = log_items[i]; -if (lip->li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags)) {/* check if we really need to move the item */ if (XFS_LSN_CMP (lsn, lip->li_lsn) <=0 )continue ;@@ -663,7 +663,7 @@ xfs_trans_ail_update_bulk(if (mlip == lip) mlip_changed =1 ; }else { - lip->li_flags |=XFS_LI_IN_AIL ; +set_bit (XFS_LI_IN_AIL , &lip->li_flags);trace_xfs_ail_insert (lip,0 , lsn); } lip->li_lsn = lsn;@@ -687,13 +687,13 @@ xfs_trans_ail_update_bulk(bool xfs_ail_delete_one (struct xfs_ail *ailp, -struct xfs_log_item *lip) +struct xfs_log_item *lip) {struct xfs_log_item *mlip =xfs_ail_min (ailp);trace_xfs_ail_delete (lip, mlip->li_lsn, lip->li_lsn);xfs_ail_delete (ailp, lip); - lip->li_flags &= ~XFS_LI_IN_AIL ; +clear_bit (XFS_LI_IN_AIL , &lip->li_flags); lip->li_lsn =0 ;return mlip == lip;@@ -729,7 +729,7 @@ xfs_trans_ail_delete(struct xfs_mount *mp = ailp->xa_mount;bool mlip_changed; -if (!(lip->li_flags &XFS_LI_IN_AIL )) { +if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {spin_unlock (&ailp->xa_lock);if (!XFS_FORCED_SHUTDOWN (mp)) { xfs_alert_tag(mp, XFS_PTAG_AILDELETE,fs/xfs/xfs_trans_buf.c +1
-1@@ -433,7 +433,7 @@ xfs_trans_brelse(xfs_trans_t *tp,ASSERT(bp->b_pincount == 0); ***/ ASSERT (atomic_read (&bip->bli_refcount) ==0 ); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));ASSERT (!(bip->bli_flags &XFS_BLI_INODE_ALLOC_BUF ));xfs_buf_item_relse (bp); }fs/xfs/xfs_trans_priv.h +1
-1@@ -119,7 +119,7 @@ xfs_trans_ail_remove(spin_lock (&ailp->xa_lock);/* xfs_trans_ail_delete() drops the AIL lock */ -if (lip->li_flags &XFS_LI_IN_AIL ) +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags))xfs_trans_ail_delete (ailp, lip, shutdown_type);else spin_unlock (&ailp->xa_lock);Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
Re: [PATCH 1/3] xfs: use atomic operations to handle xfs_log_item flags
Quoted 23 lines · Carlos Maiolino
Quoted 14 lines · Brian Foster
Quoted 5 lines · Carlos Maiolino
In order to fix a bug during buffer retries, a new flag type will be added to
xfs_log_item, and such operations need to be atomic.Change all operations in
xfs_log_itemflags to atomic operationsQuoted 7 lines
To use atomic operations,
xfs_log_item->li_flagsalso needed to be converted to unsigned long type.There is a small whitespace cleanup in the patch too
Signed-off-by Carlos Maiolino <[email protected]>---
Quoted 7 lines
As noted in the v1 discussion, I don't think this needs to be a dependency of the bug fix patch. Provided we can alleviate Dave's concerns over performance and not add any ->xa_lock acquisitions that aren't triggered by I/O errors, can we fix the bug using ->xa_lock and then port this on top? That way we have more of a backportable fix for older kernels affected by this problem.
Quoted 5 lines
Hmm, I'm doing some tests with ->xa_lock, and I am actually deadlocking the system when I try to acquire it in
xfs_inode_item_push(), I wonder if ->xa_lock is really correct to be used here, or maybe I'm doing something wrong? Still checking what's going on though.
My bad actually, I didn't realize xa_lock was already acquired when re-submitting a failed buffer, at least for resubmission, it's already protected
Quoted 374 lines
Quoted 367 lines
(Please see my comments on patches 2 and 3 wrt proposed changes to avoid the custom callback and need for atomic flags..)
Brian
Quoted 362 lines
fs/xfs/xfs_bmap_item.c | 4 ++-- fs/xfs/xfs_buf_item.c | 4 ++-- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_extfree_item.c | 4 ++-- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_icreate_item.c | 2 +- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_refcount_item.c | 4 ++-- fs/xfs/xfs_rmap_item.c | 4 ++-- fs/xfs/xfs_trace.h | 4 ++-- fs/xfs/xfs_trans.c | 4 ++-- fs/xfs/xfs_trans.h | 2 +- fs/xfs/xfs_trans_ail.c | 12 ++++++------ fs/xfs/xfs_trans_buf.c | 2 +- fs/xfs/xfs_trans_priv.h | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-)fs/xfs/xfs_bmap_item.c +2
-2@@ -141,7 +141,7 @@ STATIC voidxfs_bui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_bui_item_free (BUI_ITEM (lip)); }@@ -304,7 +304,7 @@ xfs_bud_item_unlock( {struct xfs_bud_log_item *budp =BUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_bui_release (budp->bud_buip);kmem_zone_free (xfs_bud_zone, budp); }fs/xfs/xfs_buf_item.c +2
-2@@ -587,7 +587,7 @@ xfs_buf_item_unlock(* (cancelled) buffers at unpin time, but we'll never go through the * pin/unpin cycle if we abort inside commit. */ - aborted = (lip->li_flags &XFS_LI_ABORTED ) ? true : false; + aborted = (test_bit (XFS_LI_ABORTED , &lip->li_flags)) ? true : false;/* * Before possibly freeing the buf item, copy the per-transaction state * so we can reference it safely later after clearing it from the @@ -975,7 +975,7 @@ xfs_buf_item_relse(xfs_buf_log_item_t *bip = bp->b_fspriv;trace_xfs_buf_item_relse (bp, _RET_IP_); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags))); bp->b_fspriv = bip->bli_item.li_bio_list;if (bp->b_fspriv ==NULL )fs/xfs/xfs_dquot.c +1
-1@@ -1003,7 +1003,7 @@ xfs_qm_dqflush_done(* since it's cheaper, and then we recheck while * holding the lock before removing the dquot from the AIL. */ -if ((lip->li_flags &XFS_LI_IN_AIL ) && +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags) && lip->li_lsn == qip->qli_flush_lsn) {/* xfs_trans_ail_delete() drops the AIL lock. */ fs/xfs/xfs_extfree_item.c +2
-2@@ -150,7 +150,7 @@ STATIC voidxfs_efi_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_efi_item_free (EFI_ITEM (lip)); }@@ -402,7 +402,7 @@ xfs_efd_item_unlock( {struct xfs_efd_log_item *efdp =EFD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_efi_release (efdp->efd_efip);xfs_efd_item_free (efdp); }fs/xfs/xfs_icache.c +1
-1@@ -107,7 +107,7 @@ xfs_inode_free_callback(xfs_idestroy_fork (ip,XFS_COW_FORK );if (ip->i_itemp) { -ASSERT (!(ip->i_itemp->ili_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &ip->i_itemp->ili_item.li_flags)));xfs_inode_item_destroy (ip); ip->i_itemp =NULL ; }fs/xfs/xfs_icreate_item.c +1
-1@@ -91,7 +91,7 @@ xfs_icreate_item_unlock( {struct xfs_icreate_item *icp =ICR_ITEM (lip); -if (icp->ic_item.li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &icp->ic_item.li_flags))kmem_zone_free (xfs_icreate_zone, icp);return ; }fs/xfs/xfs_inode.c +2
-2@@ -504,7 +504,7 @@ xfs_lock_inodes(if (!try_lock) {for (j = (i -1 ); j >=0 && !try_lock; j--) { lp = (xfs_log_item_t *)ips[j]->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) try_lock++; } }@@ -601,7 +601,7 @@ xfs_lock_two_inodes(* and try again. */ lp = (xfs_log_item_t *)ip0->i_itemp; -if (lp && (lp->li_flags &XFS_LI_IN_AIL )) { +if (lp &&test_bit (XFS_LI_IN_AIL , &lp->li_flags)) {if (!xfs_ilock_nowait (ip1,xfs_lock_inumorder (lock_mode,1 ))) {xfs_iunlock (ip0, lock_mode);if ((++attempts %5 ) ==0 )fs/xfs/xfs_inode_item.c +1
-1@@ -783,7 +783,7 @@ xfs_iflush_abort(xfs_inode_log_item_t *iip = ip->i_itemp;if (iip) { -if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &iip->ili_item.li_flags)) {xfs_trans_ail_remove (&iip->ili_item, stale ?SHUTDOWN_LOG_IO_ERROR :SHUTDOWN_CORRUPT_INCORE );fs/xfs/xfs_qm.c +1
-1@@ -169,7 +169,7 @@ xfs_qm_dqpurge(ASSERT (atomic_read (&dqp->q_pincount) ==0 );ASSERT (XFS_FORCED_SHUTDOWN (mp) || - !(dqp->q_logitem.qli_item.li_flags &XFS_LI_IN_AIL )); + !(test_bit (XFS_LI_IN_AIL , &dqp->q_logitem.qli_item.li_flags)));xfs_dqfunlock (dqp);xfs_dqunlock (dqp);fs/xfs/xfs_refcount_item.c +2
-2@@ -139,7 +139,7 @@ STATIC voidxfs_cui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_cui_item_free (CUI_ITEM (lip)); }@@ -308,7 +308,7 @@ xfs_cud_item_unlock( {struct xfs_cud_log_item *cudp =CUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_cui_release (cudp->cud_cuip);kmem_zone_free (xfs_cud_zone, cudp); }fs/xfs/xfs_rmap_item.c +2
-2@@ -139,7 +139,7 @@ STATIC voidxfs_rui_item_unlock ( struct xfs_log_item *lip) { -if (lip->li_flags &XFS_LI_ABORTED ) +if (test_bit (XFS_LI_ABORTED , &lip->li_flags))xfs_rui_item_free (RUI_ITEM (lip)); }@@ -330,7 +330,7 @@ xfs_rud_item_unlock( {struct xfs_rud_log_item *rudp =RUD_ITEM (lip); -if (lip->li_flags &XFS_LI_ABORTED ) { +if (test_bit (XFS_LI_ABORTED , &lip->li_flags)) {xfs_rui_release (rudp->rud_ruip);kmem_zone_free (xfs_rud_zone, rudp); }fs/xfs/xfs_trace.h +2
-2@@ -1031,7 +1031,7 @@ DECLARE_EVENT_CLASS(xfs_log_item_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, lsn) ), TP_fast_assign(@@ -1083,7 +1083,7 @@ DECLARE_EVENT_CLASS(xfs_ail_class, __field(dev_t, dev) __field(void *, lip) __field(uint, type) - __field(uint, flags) + __field(unsigned long, flags) __field(xfs_lsn_t, old_lsn) __field(xfs_lsn_t, new_lsn) ),fs/xfs/xfs_trans.c +2
-2@@ -764,7 +764,7 @@ xfs_trans_free_items(if (commit_lsn !=NULLCOMMITLSN ) lip->li_ops->iop_committing (lip, commit_lsn);if (abort) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); lip->li_ops->iop_unlock (lip);xfs_trans_free_item_desc (lidp);@@ -835,7 +835,7 @@ xfs_trans_committed_bulk(xfs_lsn_t item_lsn;if (aborted) - lip->li_flags |=XFS_LI_ABORTED ; +set_bit (XFS_LI_ABORTED , &lip->li_flags); item_lsn = lip->li_ops->iop_committed (lip, commit_lsn);/* item_lsn of -1 means the item needs no further processing */ fs/xfs/xfs_trans.h +1
-1@@ -48,7 +48,7 @@ typedef struct xfs_log_item {struct xfs_mount *li_mountp;/* ptr to fs mount */ struct xfs_ail *li_ailp;/* ptr to AIL */ uint li_type;/* item type */ -uint li_flags;/* misc flags */ +unsigned long li_flags;/* misc flags */ struct xfs_log_item *li_bio_list;/* buffer item list */ void (*li_cb)(struct xfs_buf *,struct xfs_log_item *);fs/xfs/xfs_trans_ail.c +6
-6@@ -45,7 +45,7 @@ xfs_ail_check(/* * Check the next and previous entries are valid. */ -ASSERT ((lip->li_flags &XFS_LI_IN_AIL ) !=0 ); +ASSERT (test_bit (XFS_LI_IN_AIL , &lip->li_flags)); prev_lip =list_entry (lip->li_ail.prev, xfs_log_item_t, li_ail);if (&prev_lip->li_ail != &ailp->xa_ail)ASSERT (XFS_LSN_CMP (prev_lip->li_lsn, lip->li_lsn) <=0 );@@ -653,7 +653,7 @@ xfs_trans_ail_update_bulk(for (i =0 ; i < nr_items; i++) {struct xfs_log_item *lip = log_items[i]; -if (lip->li_flags &XFS_LI_IN_AIL ) { +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags)) {/* check if we really need to move the item */ if (XFS_LSN_CMP (lsn, lip->li_lsn) <=0 )continue ;@@ -663,7 +663,7 @@ xfs_trans_ail_update_bulk(if (mlip == lip) mlip_changed =1 ; }else { - lip->li_flags |=XFS_LI_IN_AIL ; +set_bit (XFS_LI_IN_AIL , &lip->li_flags);trace_xfs_ail_insert (lip,0 , lsn); } lip->li_lsn = lsn;@@ -687,13 +687,13 @@ xfs_trans_ail_update_bulk(bool xfs_ail_delete_one (struct xfs_ail *ailp, -struct xfs_log_item *lip) +struct xfs_log_item *lip) {struct xfs_log_item *mlip =xfs_ail_min (ailp);trace_xfs_ail_delete (lip, mlip->li_lsn, lip->li_lsn);xfs_ail_delete (ailp, lip); - lip->li_flags &= ~XFS_LI_IN_AIL ; +clear_bit (XFS_LI_IN_AIL , &lip->li_flags); lip->li_lsn =0 ;return mlip == lip;@@ -729,7 +729,7 @@ xfs_trans_ail_delete(struct xfs_mount *mp = ailp->xa_mount;bool mlip_changed; -if (!(lip->li_flags &XFS_LI_IN_AIL )) { +if (!(test_bit (XFS_LI_IN_AIL , &lip->li_flags))) {spin_unlock (&ailp->xa_lock);if (!XFS_FORCED_SHUTDOWN (mp)) { xfs_alert_tag(mp, XFS_PTAG_AILDELETE,fs/xfs/xfs_trans_buf.c +1
-1@@ -433,7 +433,7 @@ xfs_trans_brelse(xfs_trans_t *tp,ASSERT(bp->b_pincount == 0); ***/ ASSERT (atomic_read (&bip->bli_refcount) ==0 ); -ASSERT (!(bip->bli_item.li_flags &XFS_LI_IN_AIL )); +ASSERT (!(test_bit (XFS_LI_IN_AIL , &bip->bli_item.li_flags)));ASSERT (!(bip->bli_flags &XFS_BLI_INODE_ALLOC_BUF ));xfs_buf_item_relse (bp); }fs/xfs/xfs_trans_priv.h +1
-1@@ -119,7 +119,7 @@ xfs_trans_ail_remove(spin_lock (&ailp->xa_lock);/* xfs_trans_ail_delete() drops the AIL lock */ -if (lip->li_flags &XFS_LI_IN_AIL ) +if (test_bit (XFS_LI_IN_AIL , &lip->li_flags))xfs_trans_ail_delete (ailp, lip, shutdown_type);else spin_unlock (&ailp->xa_lock);Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 5 lines
Carlos -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Carlos
PATCH v2 2/3 xfs: Add infrastructure needed for error propagation during buffer IO failure
In reply to Carlos MaiolinoWith the current code, XFS never re-submit a failed buffer for IO, because the failed item in the buffer is kept in the flush locked state forever.
To be able to resubmit an log item for IO, we need a way to mark an item as failed, if, for any reason the buffer which the item belonged to failed during writeback.
Add a new log item callback to be used after an IO completion failure and make the needed clean ups.
---
V2:
- Update commit log to include a better description of why this patch is needed and fix spelling mistakes
- Move xfs_buf_do_callbacks_fail() call into xfs_buf_iodone_callback_error, so the callbacks can be executed before the buffer is released, and only after it has been retried once
fs/xfs/xfs_buf_item.c | 27 ++++++++++++++++++++++++++- fs/xfs/xfs_trans.h | 5 ++++- 2 files changed, 30 insertions(+), 2 deletions(-)
fs/xfs/xfs_buf_item.c +26 -1
@@ -1051,6 +1051,24 @@ xfs_buf_do_callbacks( } } +STATIC void +xfs_buf_do_callbacks_fail ( +struct xfs_buf *bp) +{ +struct xfs_log_item *lip, *next; +unsigned int bflags = bp->b_flags; + + lip = bp->b_fspriv; +while (lip !=NULL ) { + next = lip->li_bio_list; + +if (lip->li_ops->iop_error) + lip->li_ops->iop_error (lip, bflags); + + lip = next; + } +} +static bool xfs_buf_iodone_callback_error (struct xfs_buf *bp)
@@ -1101,6 +1119,7 @@ xfs_buf_iodone_callback_error(xfs_buf_ioerror (bp,0 );xfs_buf_submit (bp); +return true; }
@@ -1120,8 +1139,14 @@ xfs_buf_iodone_callback_error(if ((mp->m_flags &XFS_MOUNT_UNMOUNTING ) && mp->m_fail_unmount) goto permanent_error; -/* still a transient error, higher layers will retry */ +/* +* still a transient error, run IO completion failure callbacks and +* let the higher layers retry the buffer. +* */ xfs_buf_ioerror (bp,0 ); + +/* run failure callbacks before releasing buffer */ +xfs_buf_do_callbacks_fail (bp);xfs_buf_relse (bp);return true;
fs/xfs/xfs_trans.h +4 -1
@@ -65,10 +65,12 @@ typedef struct xfs_log_item {#define XFS_LI_IN_AIL 0x1#define XFS_LI_ABORTED 0x2 +#define XFS_LI_FAILED 0x3#define XFS_LI_FLAGS \ { XFS_LI_IN_AIL, "IN_AIL" }, \ - { XFS_LI_ABORTED, "ABORTED" } + { XFS_LI_ABORTED, "ABORTED" }, \ + { XFS_LI_FAILED, "FAILED" }struct xfs_item_ops {void (*iop_size)(xfs_log_item_t *,int *,int *);
@@ -79,6 +81,7 @@ struct xfs_item_ops {void (*iop_unlock)(xfs_log_item_t *);xfs_lsn_t (*iop_committed)(xfs_log_item_t *,xfs_lsn_t );void (*iop_committing)(xfs_log_item_t *,xfs_lsn_t ); +void (*iop_error)(xfs_log_item_t *,unsigned int bflags); }; void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
Signature · 1 line
2.9.3
Re: [PATCH 2/3 V2] xfs: Add infrastructure needed for error propagation during buffer IO failure
Need to read up on the history and background a bit more, but some cosmetic comments below:
fs/xfs/xfs_buf_item.c xfs_buf_do_callbacks( · line 1069
Quoted 9 lines
fs/xfs/xfs_buf_item.c +9
-0+ lip = bp->b_fspriv; +while (lip !=NULL ) { + next = lip->li_bio_list; + +if (lip->li_ops->iop_error) + lip->li_ops->iop_error (lip, bflags); + + lip = next; + }
for (lip = bp->b_fspriv; lip; lip = next) {
next = lip->li_bio_list;
if (lip->li_ops->iop_error)
lip->li_ops->iop_error(lip, bflags);
}?
fs/xfs/xfs_buf_item.c xfs_buf_iodone_callback_error( · line 1124
Quoted 7 lines
fs/xfs/xfs_buf_item.c +1
-0@@ -1101,6 +1119,7 @@ xfs_buf_iodone_callback_error(xfs_buf_ioerror (bp,0 );xfs_buf_submit (bp); +return true; }
whitespace noise.
Re: [PATCH 2/3 V2] xfs: Add infrastructure needed for error propagation during buffer IO failure
Quoted 19 lines · Christoph Hellwig
Need to read up on the history and background a bit more, but some cosmetic comments below:
fs/xfs/xfs_buf_item.c xfs_buf_do_callbacks( · line 1069
Quoted 9 lines
fs/xfs/xfs_buf_item.c +9
-0+ lip = bp->b_fspriv; +while (lip !=NULL ) { + next = lip->li_bio_list; + +if (lip->li_ops->iop_error) + lip->li_ops->iop_error (lip, bflags); + + lip = next; + }for (lip = bp->b_fspriv; lip; lip = next) { next = lip->li_bio_list; if (lip->li_ops->iop_error) lip->li_ops->iop_error(lip, bflags); }
Quoted 1 line
?
Agree, looks much better.
Quoted 10 lines
fs/xfs/xfs_buf_item.c xfs_buf_iodone_callback_error( · line 1124
Quoted 8 lines
fs/xfs/xfs_buf_item.c +1
-0@@ -1101,6 +1119,7 @@ xfs_buf_iodone_callback_error(xfs_buf_ioerror (bp,0 );xfs_buf_submit (bp); +return true; }whitespace noise.
Fixed and queued for V3, thanks
Signature · 1 line
Carlos
Re: [PATCH 2/3 V2] xfs: Add infrastructure needed for error propagation during buffer IO failure
In reply to Carlos MaiolinoQuoted 39 lines · Carlos Maiolino
With the current code, XFS never re-submit a failed buffer for IO, because the failed item in the buffer is kept in the flush locked state forever.
To be able to resubmit an log item for IO, we need a way to mark an item as failed, if, for any reason the buffer which the item belonged to failed during writeback.
Add a new log item callback to be used after an IO completion failure and make the needed clean ups.
Signed-off-by Carlos Maiolino <[email protected]>---
V2:
- Update commit log to include a better description of why this patch is needed and fix spelling mistakes
- Movexfs_buf_do_callbacks_fail()call intoxfs_buf_iodone_callback_error, so the callbacks can be executed before the buffer is released, and only after it has been retried oncefs/xfs/xfs_buf_item.c | 27 ++++++++++++++++++++++++++- fs/xfs/xfs_trans.h | 5 ++++- 2 files changed, 30 insertions(+), 2 deletions(-)fs/xfs/xfs_buf_item.c +6
-0@@ -1051,6 +1051,24 @@ xfs_buf_do_callbacks( } } +STATIC void +xfs_buf_do_callbacks_fail ( +struct xfs_buf *bp) +{ +struct xfs_log_item *lip, *next; +unsigned int bflags = bp->b_flags;
fs/xfs/xfs_buf_item.c xfs_buf_do_callbacks( · line 1069
Quoted 10 lines
fs/xfs/xfs_buf_item.c +10
-0+ + lip = bp->b_fspriv; +while (lip !=NULL ) { + next = lip->li_bio_list; + +if (lip->li_ops->iop_error) + lip->li_ops->iop_error (lip, bflags); + + lip = next; + }
AFAICT, this could do something like the following:
spin_lock(&ailp->xa_lock);
while (lip != NULL) {
next = lip->li_bio_list;
lip->li_flags |= XFS_LI_FAILED;
lip = next;
}
spin_unlock(&ailp->xa_lock);... to generically and unconditionally flag the log item as failed and avoid the need for ->iop_error(). We also need to clear XFS_LI_FAILED at the same place we clear XFS_LI_IN_AIL (i.e., AIL removal) to ensure a subsequent successful I/O completion updates the log item appropriately.
Then the result of this patch is that all log items are flagged as failed on I/O error until they are ultimately removed from the AIL. We otherwise have so far not changed behavior in any way.
Brian
Quoted 62 lines
fs/xfs/xfs_buf_item.c +10
-1+} +static bool xfs_buf_iodone_callback_error (struct xfs_buf *bp)@@ -1101,6 +1119,7 @@ xfs_buf_iodone_callback_error(xfs_buf_ioerror (bp,0 );xfs_buf_submit (bp); +return true; }@@ -1120,8 +1139,14 @@ xfs_buf_iodone_callback_error(if ((mp->m_flags &XFS_MOUNT_UNMOUNTING ) && mp->m_fail_unmount) goto permanent_error; -/* still a transient error, higher layers will retry */ +/* +* still a transient error, run IO completion failure callbacks and +* let the higher layers retry the buffer. +* */ xfs_buf_ioerror (bp,0 ); + +/* run failure callbacks before releasing buffer */ +xfs_buf_do_callbacks_fail (bp);xfs_buf_relse (bp);return true;fs/xfs/xfs_trans.h +4
-1@@ -65,10 +65,12 @@ typedef struct xfs_log_item {#define XFS_LI_IN_AIL 0x1#define XFS_LI_ABORTED 0x2 +#define XFS_LI_FAILED 0x3#define XFS_LI_FLAGS \ { XFS_LI_IN_AIL, "IN_AIL" }, \ - { XFS_LI_ABORTED, "ABORTED" } + { XFS_LI_ABORTED, "ABORTED" }, \ + { XFS_LI_FAILED, "FAILED" }struct xfs_item_ops {void (*iop_size)(xfs_log_item_t *,int *,int *);@@ -79,6 +81,7 @@ struct xfs_item_ops {void (*iop_unlock)(xfs_log_item_t *);xfs_lsn_t (*iop_committed)(xfs_log_item_t *,xfs_lsn_t );void (*iop_committing)(xfs_log_item_t *,xfs_lsn_t ); +void (*iop_error)(xfs_log_item_t *,unsigned int bflags); }; void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3 V2] xfs: Add infrastructure needed for error propagation during buffer IO failure
Quoted 61 lines · Brian Foster
Quoted 39 lines · Carlos Maiolino
With the current code, XFS never re-submit a failed buffer for IO, because the failed item in the buffer is kept in the flush locked state forever.
To be able to resubmit an log item for IO, we need a way to mark an item as failed, if, for any reason the buffer which the item belonged to failed during writeback.
Add a new log item callback to be used after an IO completion failure and make the needed clean ups.
Signed-off-by Carlos Maiolino <[email protected]>---
V2:
- Update commit log to include a better description of why this patch is needed and fix spelling mistakes
- Movexfs_buf_do_callbacks_fail()call intoxfs_buf_iodone_callback_error, so the callbacks can be executed before the buffer is released, and only after it has been retried oncefs/xfs/xfs_buf_item.c | 27 ++++++++++++++++++++++++++- fs/xfs/xfs_trans.h | 5 ++++- 2 files changed, 30 insertions(+), 2 deletions(-)fs/xfs/xfs_buf_item.c +6
-0@@ -1051,6 +1051,24 @@ xfs_buf_do_callbacks( } } +STATIC void +xfs_buf_do_callbacks_fail ( +struct xfs_buf *bp) +{ +struct xfs_log_item *lip, *next; +unsigned int bflags = bp->b_flags;fs/xfs/xfs_buf_item.c xfs_buf_do_callbacks( · line 1069
Quoted 10 lines
fs/xfs/xfs_buf_item.c +10
-0+ + lip = bp->b_fspriv; +while (lip !=NULL ) { + next = lip->li_bio_list; + +if (lip->li_ops->iop_error) + lip->li_ops->iop_error (lip, bflags); + + lip = next; + }AFAICT, this could do something like the following:
spin_lock(&ailp->xa_lock); while (lip != NULL) { next = lip->li_bio_list; lip->li_flags |= XFS_LI_FAILED; lip = next; } spin_unlock(&ailp->xa_lock);
Quoted 9 lines
... to generically and unconditionally flag the log item as failed and avoid the need for ->iop_error(). We also need to clear
XFS_LI_FAILEDat the same place we clearXFS_LI_IN_AIL(i.e., AIL removal) to ensure a subsequent successful I/O completion updates the log item appropriately.Then the result of this patch is that all log items are flagged as failed on I/O error until they are ultimately removed from the AIL. We otherwise have so far not changed behavior in any way.
After poking around with this the past day or so, I think there is another problem that we have to deal with (two, actually) in this area.
The first is not a problem introduced by these patches, but like the whole flush lock thing, is a flaw in the whole "rely on the AIL to retry" behavior that is already in place. The issue is that once we flush a non-buffer log item to the backing buffer and the buffer I/O happens to fail, we don't hold a reference on the buffer. This means that we could flush an inode, the backing buffer I/O could fail (we flag the log item as such), and the buffer could be reclaimed before the next push of the inode log item. The LI_FAILED inode log item has already been flushed, so we basically just read the buffer off disk and write it back, having lost the inode changes that were flushed in the first place. This is a data corruption vector, so I think needs to be fixed before we unwind the flush lock livelock.
This isn't a problem with buffer log items that fail because the xfs_buf_log_item holds a reference to the buffer. I think the solution for inode/dquot log items is therefore fairly straightforward: do something similar where the log item holds a reference to the buf and releases it at the appropriate point. This could be done generically to xfs_log_item, to the type-specific log item, and at push/flush time or only for LI_FAILED items that are going back to the AIL[1]. IMO, the latter seems like the least invasive approach to start with.
The second problem here is somewhat of a side effect of the first. It's not sufficient to simply pin the buffer in-core (without further code changes, at least) because if the filesystem shuts down with failed items in the AIL, the buffer read path is short circuited to return error. This means that the xfs_imap_to_bp() call in the LI_FAILED handling path is simply not safe. If the filesystem has shut down due to unrelated reasons, it returns -EIO and we end up in a similar livelock as with the flush lock problem.
I think this can also be addressed by the solution noted above by also holding a pointer to the underlying xfs_buf in the LI_FAILED log item (which is also something that xfs_buf_log_item has today). That basically means that any LI_FAILED log item should have an ->*li_buf pointer that can be directly referenced to requeue the buffer to the delwri queue. I think that should clean everything up properly in the shutdown case as the I/O submission sets an error on the buf, runs the ioend processing and the buf error handling invokes the callbacks now that the fs is shutdown. Thoughts..?
Brian
[1] Note that if we end up changing behavior on error and on the type-specific log item, this could reintroduce the need for ->iop_error(). Sorry for being back and forth on that, I basically just think we should keep it if the implementation needs to access the xfs_inode_log_item from the xfs_log_item or kill it otherwise.
Quoted 68 lines
Brian
Quoted 62 lines
fs/xfs/xfs_buf_item.c +10
-1+} +static bool xfs_buf_iodone_callback_error (struct xfs_buf *bp)@@ -1101,6 +1119,7 @@ xfs_buf_iodone_callback_error(xfs_buf_ioerror (bp,0 );xfs_buf_submit (bp); +return true; }@@ -1120,8 +1139,14 @@ xfs_buf_iodone_callback_error(if ((mp->m_flags &XFS_MOUNT_UNMOUNTING ) && mp->m_fail_unmount) goto permanent_error; -/* still a transient error, higher layers will retry */ +/* +* still a transient error, run IO completion failure callbacks and +* let the higher layers retry the buffer. +* */ xfs_buf_ioerror (bp,0 ); + +/* run failure callbacks before releasing buffer */ +xfs_buf_do_callbacks_fail (bp);xfs_buf_relse (bp);return true;fs/xfs/xfs_trans.h +4
-1@@ -65,10 +65,12 @@ typedef struct xfs_log_item {#define XFS_LI_IN_AIL 0x1#define XFS_LI_ABORTED 0x2 +#define XFS_LI_FAILED 0x3#define XFS_LI_FLAGS \ { XFS_LI_IN_AIL, "IN_AIL" }, \ - { XFS_LI_ABORTED, "ABORTED" } + { XFS_LI_ABORTED, "ABORTED" }, \ + { XFS_LI_FAILED, "FAILED" }struct xfs_item_ops {void (*iop_size)(xfs_log_item_t *,int *,int *);@@ -79,6 +81,7 @@ struct xfs_item_ops {void (*iop_unlock)(xfs_log_item_t *);xfs_lsn_t (*iop_committed)(xfs_log_item_t *,xfs_lsn_t );void (*iop_committing)(xfs_log_item_t *,xfs_lsn_t ); +void (*iop_error)(xfs_log_item_t *,unsigned int bflags); }; void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/3 xfs: Properly retry failed inode items in case of error during buffer writeback
In reply to Carlos MaiolinoWhen a buffer has been failed during writeback, the inode items into it are kept flush locked, and are never resubmitted due the flush lock, so, if any buffer fails to be written, the items in AIL are never written to disk and never unlocked.
This causes unmount operation to hang due these items flush locked in AIL, but this also causes the items in AIL to never be written back, even when the IO device comes back to normal.
I've been testing this patch with a DM-thin device, creating a filesystem larger than the real device.
When writing enough data to fill the DM-thin device, XFS receives ENOSPC errors from the device, and keep spinning on xfsaild (when 'retry forever' configuration is set).
At this point, the filesystem can not be unmounted because of the flush locked items in AIL, but worse, the items in AIL are never retried at all (once xfs_inode_item_push() will skip the items that are flush locked), even if the underlying DM-thin device is expanded to the proper size.
This patch fixes both cases, retrying any item that has been failed previously, using the infra-structure provided by the previous patch.
---
V2:
- Fix XFS_LI_FAILED flag removal
- Use atomic operations to set and clear XFS_LI_FAILED flag
- Remove check for XBF_WRITE_FAIL in xfs_inode_item_push
- Add more comments to the code
- Add a helper function to resubmit the failed buffers, so this can be also used in dquot system without duplicating code
fs/xfs/xfs_buf_item.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_buf_item.h | 2 ++ fs/xfs/xfs_inode_item.c | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 1 deletion(-)
fs/xfs/xfs_buf_item.c +42 -0
@@ -29,6 +29,7 @@#include "xfs_error.h" #include "xfs_trace.h" #include "xfs_log.h" +#include "xfs_inode.h" kmem_zone_t *xfs_buf_item_zone;
@@ -1226,3 +1227,44 @@ xfs_buf_iodone(xfs_trans_ail_delete (ailp, lip,SHUTDOWN_CORRUPT_INCORE );xfs_buf_item_free (BUF_ITEM (lip)); } + +/* Requeue a failed buffer for writeback +* +* Return true if the buffer has been re-queued properly, false otherwise +* +*/ +bool +xfs_buf_resubmit_failed_buffers ( +struct xfs_inode *ip, +struct xfs_log_item *lip, +struct xfs_buf *bp, +struct list_head *buffer_list) +{ +struct xfs_dinode *dip; +struct xfs_log_item *next; +int error; +bool ret; + + error =xfs_imap_to_bp (ip->i_mount,NULL , &ip->i_imap, + &dip, &bp,XBF_TRYLOCK ,0 ); + +if (error) +return false; + +/* Clear XFS_LI_FAILED flag from all items before resubmit */ +while (lip !=NULL ) { + next = lip->li_bio_list; + +clear_bit (XFS_LI_FAILED , &lip->li_flags); + lip = next; + } + +/* Add this buffer back to the delayed write list */ +if (!xfs_buf_delwri_queue (bp, buffer_list)) + ret = false; +else + ret = true; + +xfs_buf_relse (bp); +return ret; +}
fs/xfs/xfs_buf_item.h +2 -0
@@ -70,6 +70,8 @@ void xfs_buf_attach_iodone(struct xfs_buf *, xfs_log_item_t *);void xfs_buf_iodone_callbacks (struct xfs_buf *);void xfs_buf_iodone (struct xfs_buf *,struct xfs_log_item *); +bool xfs_buf_resubmit_failed_buffers (struct xfs_inode *,struct xfs_log_item *, +struct xfs_buf *,struct list_head *);extern kmem_zone_t *xfs_buf_item_zone;
fs/xfs/xfs_inode_item.c +35 -1
@@ -27,6 +27,7 @@#include "xfs_error.h" #include "xfs_trace.h" #include "xfs_trans_priv.h" +#include "xfs_buf_item.h" #include "xfs_log.h"
@@ -475,6 +476,24 @@ xfs_inode_item_unpin(wake_up_bit (&ip->i_flags, __XFS_IPINNED_BIT); } +STATIC void +xfs_inode_item_error ( +struct xfs_log_item *lip, +unsigned int bflags) +{ + +/* +* The buffer writeback containing this inode has been failed +* mark it as failed and unlock the flush lock, so it can be retried +* again. +* It requires an atomic operation, once the parent object is not locked +* in this context, and we need to avoid races with other log item state +* changes. +*/ +if (bflags &XBF_WRITE_FAIL ) +set_bit (XFS_LI_FAILED , &lip->li_flags); +} + STATIC uint xfs_inode_item_push( struct xfs_log_item *lip,
@@ -517,8 +536,22 @@ xfs_inode_item_push(* the AIL. */ if (!xfs_iflock_nowait (ip)) { + +/* +* The buffer containing this item failed to be written back +* previously. Resubmit the buffer for IO. +*/ +if (lip->li_flags &XFS_LI_FAILED ) { +if (!xfs_buf_resubmit_failed_buffers (ip, lip, bp, + buffer_list)) + rval =XFS_ITEM_FLUSHING ; + + goto out_unlock; + } + rval =XFS_ITEM_FLUSHING ; goto out_unlock; + }ASSERT (iip->ili_fields !=0 ||XFS_FORCED_SHUTDOWN (ip->i_mount));
@@ -622,7 +655,8 @@ static const struct xfs_item_ops xfs_inode_item_ops = { .iop_unlock = xfs_inode_item_unlock, .iop_committed = xfs_inode_item_committed, .iop_push = xfs_inode_item_push, - .iop_committing = xfs_inode_item_committing + .iop_committing = xfs_inode_item_committing, + .iop_error = xfs_inode_item_error };
Signature · 1 line
2.9.3
Re: [PATCH 3/3 V2] xfs: Properly retry failed inode items in case of error during buffer writeback
Quoted 39 lines · Carlos Maiolino
When a buffer has been failed during writeback, the inode items into it are kept flush locked, and are never resubmitted due the flush lock, so, if any buffer fails to be written, the items in AIL are never written to disk and never unlocked.
This causes unmount operation to hang due these items flush locked in AIL, but this also causes the items in AIL to never be written back, even when the IO device comes back to normal.
I've been testing this patch with a DM-thin device, creating a filesystem larger than the real device.
When writing enough data to fill the DM-thin device, XFS receives ENOSPC errors from the device, and keep spinning on xfsaild (when 'retry forever' configuration is set).
At this point, the filesystem can not be unmounted because of the flush locked items in AIL, but worse, the items in AIL are never retried at all (once
xfs_inode_item_push()will skip the items that are flush locked), even if the underlying DM-thin device is expanded to the proper size.This patch fixes both cases, retrying any item that has been failed previously, using the infra-structure provided by the previous patch.
Signed-off-by Carlos Maiolino <[email protected]>---
V2:
- FixXFS_LI_FAILEDflag removal
- Use atomic operations to set and clearXFS_LI_FAILEDflag
- Remove check forXBF_WRITE_FAILinxfs_inode_item_push
- Add more comments to the code
- Add a helper function to resubmit the failed buffers, so this can be also used in dquot system without duplicating codefs/xfs/xfs_buf_item.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_buf_item.h | 2 ++ fs/xfs/xfs_inode_item.c | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 1 deletion(-)
...
Quoted 23 lines
fs/xfs/xfs_inode_item.c +8
-0@@ -27,6 +27,7 @@#include "xfs_error.h" #include "xfs_trace.h" #include "xfs_trans_priv.h" +#include "xfs_buf_item.h" #include "xfs_log.h" @@ -475,6 +476,24 @@ xfs_inode_item_unpin(wake_up_bit (&ip->i_flags, __XFS_IPINNED_BIT); } +STATIC void +xfs_inode_item_error ( +struct xfs_log_item *lip, +unsigned int bflags) +{ + +/*
fs/xfs/xfs_inode_item.c xfs_inode_item_unpin( · line 495
Quoted 10 lines
fs/xfs/xfs_inode_item.c +10
-0+* The buffer writeback containing this inode has been failed +* mark it as failed and unlock the flush lock, so it can be retried +* again. +* It requires an atomic operation, once the parent object is not locked +* in this context, and we need to avoid races with other log item state +* changes. +*/ +if (bflags &XBF_WRITE_FAIL ) +set_bit (XFS_LI_FAILED , &lip->li_flags); +}
With the change to patch 2 to set LI_FAILED on all log items, this can go away completely. We know that LI_FAILED will be set on any log item attached to a buffer that fails.
Quoted 11 lines
fs/xfs/xfs_inode_item.c +4
-0+ STATIC uint xfs_inode_item_push( struct xfs_log_item *lip,@@ -517,8 +536,22 @@ xfs_inode_item_push(* the AIL. */ if (!xfs_iflock_nowait (ip)) { + +/* +* The buffer containing this item failed to be written back
fs/xfs/xfs_inode_item.c xfs_inode_item_push( · line 551
Quoted 10 lines
fs/xfs/xfs_inode_item.c +10
-0+* previously. Resubmit the buffer for IO. +*/ +if (lip->li_flags &XFS_LI_FAILED ) { +if (!xfs_buf_resubmit_failed_buffers (ip, lip, bp, + buffer_list)) + rval =XFS_ITEM_FLUSHING ; + + goto out_unlock; + } +
I think we need to do the XFS_LI_FAILED check first thing in xfs_inode_item_push(). As part of the v1 discussion, Dave pointed out that there is the possibility that somebody else is holding the inode lock and blocking on the flush lock by the time xfs_inode_item_push() is called. That means we would never get past the xfs_ilock_nowait() call earlier in the function and thus never resubmit the buffer.
That aside, we're now modifying inode log item behavior based on LI_FAILED. Since we now skip an iflush when LI_FAILED is set, we need to handle the case in xfs_iflush_done() where the flush lock is unlocked but the log item is not removed from the AIL. I think this should be quite rare, but IIUC the scenario goes something like this:
- Inode 1 transaction is committed, AIL push flushes the inode, buffer I/O fails and the log item is set LI_FAILED. The inode log item is now sitting in the AIL waiting for a retry.
- Inode 1 is relogged and committed in another transaction. Its place in the AIL is moved. The changes to the xfs_inode in this tx have not been flushed to the buffer.
- Inode 2 transaction is committed and inserted to AIL. Inode 2 is backed by the same buffer as inode 1.
- AIL pushes inode 2, flushes to the buffer and submits. It does not clear LI_FAILED of inode 1 because inode 2 has never failed.
- Buffer I/O succeeds, xfs_iflush_done() runs and removes inode 2 from the AIL and flush unlocks. Inode 1 is flush unlocked but remains on the AIL because the flush from the second transaction above has not yet occurred.
- xfs_iflush_done() clears LI_FAILED so the subsequent AIL push of inode 1 actually flushes the latest in-core inode to the buffer.
So IOW, I think we need to include something like the hunk appended below (untested) to this patch.
Dave,
Do you see anything wrong with this overall approach? I think this avoids the hard dependency on atomic flags because all li_flags updates remain under ->xa_lock. We've covered the I/O submission context concern because we incorporate the previously discussed idea of clearing the flag on successful I/O completion. Finally, normal running performance should not be affected because the ->xa_lock is not taken anywhere new unless I/O errors have occurred. Thoughts?
Brian
--- 8< ---
fs/xfs/xfs_inode_item.c +6 -2
@@ -722,7 +722,8 @@ xfs_iflush_done(* the AIL lock. */ iip =INODE_ITEM (blip); -if (iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) +if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) || + blip->li_flags &XFS_LI_FAILED ) need_ail++; blip = next;
@@ -730,7 +731,8 @@ xfs_iflush_done(/* make sure we capture the state of the initial inode. */ iip =INODE_ITEM (lip); -if (iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn) +if ((iip->ili_logged && lip->li_lsn == iip->ili_flush_lsn) || + lip->li_flags &XFS_LI_FAILED ) need_ail++;/*
@@ -751,6 +753,8 @@ xfs_iflush_done(if (INODE_ITEM (blip)->ili_logged && blip->li_lsn ==INODE_ITEM (blip)->ili_flush_lsn) mlip_changed |=xfs_ail_delete_one (ailp, blip); +else if (blip->li_flags &XFS_LI_FAILED ) + blip->li_flags &= ~XFS_LI_FAILED ; }if (mlip_changed) {