From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH v3 04/13] xfs: ensure EFD trans aborts on log recovery extent free failure
Date: Mon, 10 Aug 2015 15:01:40 -0400 [thread overview]
Message-ID: <1439233309-19959-5-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1439233309-19959-1-git-send-email-bfoster@redhat.com>
Log recovery attempts to free extents with leftover EFIs in the AIL
after initial processing. If the extent free fails (e.g., due to
unrelated fs corruption), the transaction is cancelled, though it might
not be dirtied at the time. If this is the case, the EFD does not abort
and thus does not release the EFI. This can lead to hangs as the EFI
pins the AIL.
Update xlog_recover_process_efi() to log the EFD in the transaction
before xfs_free_extent() errors are handled to ensure the transaction is
dirty, aborts the EFD and releases the EFI on error. Since this is a
requirement for EFD processing (and consistent with xfs_bmap_finish()),
update the EFD logging helper to do the extent free and unconditionally
log the EFD. This encodes the required EFD logging behavior into the
helper and reduces the likelihood of errors down the road.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_bmap_util.c | 21 +++++++--------------
fs/xfs/xfs_log_recover.c | 7 +++----
fs/xfs/xfs_trans.h | 7 +++----
fs/xfs/xfs_trans_extfree.c | 32 +++++++++++++++++++++++---------
4 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index fa65f67..73aab0d 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -112,24 +112,17 @@ xfs_bmap_finish(
return error;
}
+ /*
+ * Get an EFD and free each extent in the list, logging to the EFD in
+ * the process. The remaining bmap free list is cleaned up by the caller
+ * on error.
+ */
efd = xfs_trans_get_efd(*tp, efi, flist->xbf_count);
for (free = flist->xbf_first; free != NULL; free = next) {
next = free->xbfi_next;
- /*
- * Free the extent and log the EFD to dirty the transaction
- * before handling errors. This ensures that the transaction is
- * aborted, which:
- *
- * 1.) releases the EFI and frees the EFD
- * 2.) shuts down the filesystem
- *
- * The bmap free list is cleaned up at a higher level.
- */
- error = xfs_free_extent(*tp, free->xbfi_startblock,
- free->xbfi_blockcount);
- xfs_trans_log_efd_extent(*tp, efd, free->xbfi_startblock,
- free->xbfi_blockcount);
+ error = xfs_trans_free_extent(*tp, efd, free->xbfi_startblock,
+ free->xbfi_blockcount);
if (error)
return error;
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 9d8f242..c77dfb5 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -34,7 +34,6 @@
#include "xfs_inode_item.h"
#include "xfs_extfree_item.h"
#include "xfs_trans_priv.h"
-#include "xfs_alloc.h"
#include "xfs_ialloc.h"
#include "xfs_quota.h"
#include "xfs_cksum.h"
@@ -3779,11 +3778,11 @@ xlog_recover_process_efi(
for (i = 0; i < efip->efi_format.efi_nextents; i++) {
extp = &(efip->efi_format.efi_extents[i]);
- error = xfs_free_extent(tp, extp->ext_start, extp->ext_len);
+ error = xfs_trans_free_extent(tp, efdp, extp->ext_start,
+ extp->ext_len);
if (error)
goto abort_error;
- xfs_trans_log_efd_extent(tp, efdp, extp->ext_start,
- extp->ext_len);
+
}
set_bit(XFS_EFI_RECOVERED, &efip->efi_flags);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index ba1660b..4643070 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -220,10 +220,9 @@ void xfs_trans_log_efi_extent(xfs_trans_t *,
struct xfs_efd_log_item *xfs_trans_get_efd(xfs_trans_t *,
struct xfs_efi_log_item *,
uint);
-void xfs_trans_log_efd_extent(xfs_trans_t *,
- struct xfs_efd_log_item *,
- xfs_fsblock_t,
- xfs_extlen_t);
+int xfs_trans_free_extent(struct xfs_trans *,
+ struct xfs_efd_log_item *, xfs_fsblock_t,
+ xfs_extlen_t);
int xfs_trans_commit(struct xfs_trans *);
int __xfs_trans_roll(struct xfs_trans **, struct xfs_inode *, int *);
int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c
index 284397d..a96ae54 100644
--- a/fs/xfs/xfs_trans_extfree.c
+++ b/fs/xfs/xfs_trans_extfree.c
@@ -25,6 +25,7 @@
#include "xfs_trans.h"
#include "xfs_trans_priv.h"
#include "xfs_extfree_item.h"
+#include "xfs_alloc.h"
/*
* This routine is called to allocate an "extent free intention"
@@ -108,19 +109,30 @@ xfs_trans_get_efd(xfs_trans_t *tp,
}
/*
- * This routine is called to indicate that the described
- * extent is to be logged as having been freed. It should
- * be called once for each extent freed.
+ * Free an extent and log it to the EFD. Note that the transaction is marked
+ * dirty regardless of whether the extent free succeeds or fails to support the
+ * EFI/EFD lifecycle rules.
*/
-void
-xfs_trans_log_efd_extent(xfs_trans_t *tp,
- xfs_efd_log_item_t *efdp,
- xfs_fsblock_t start_block,
- xfs_extlen_t ext_len)
+int
+xfs_trans_free_extent(
+ struct xfs_trans *tp,
+ struct xfs_efd_log_item *efdp,
+ xfs_fsblock_t start_block,
+ xfs_extlen_t ext_len)
{
uint next_extent;
- xfs_extent_t *extp;
+ struct xfs_extent *extp;
+ int error;
+ error = xfs_free_extent(tp, start_block, ext_len);
+
+ /*
+ * Mark the transaction dirty, even on error. This ensures the
+ * transaction is aborted, which:
+ *
+ * 1.) releases the EFI and frees the EFD
+ * 2.) shuts down the filesystem
+ */
tp->t_flags |= XFS_TRANS_DIRTY;
efdp->efd_item.li_desc->lid_flags |= XFS_LID_DIRTY;
@@ -130,4 +142,6 @@ xfs_trans_log_efd_extent(xfs_trans_t *tp,
extp->ext_start = start_block;
extp->ext_len = ext_len;
efdp->efd_next_extent++;
+
+ return error;
}
--
2.1.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-08-10 19:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 19:01 [PATCH v3 00/13] xfs: miscellaneous logging, recovery, umount fixes Brian Foster
2015-08-10 19:01 ` [PATCH v3 01/13] xfs: disentagle EFI release from the extent count Brian Foster
2015-08-10 19:01 ` [PATCH v3 02/13] xfs: return committed status from xfs_trans_roll() Brian Foster
2015-08-10 19:01 ` [PATCH v3 03/13] xfs: fix efi/efd error handling to avoid fs shutdown hangs Brian Foster
2015-08-10 19:01 ` Brian Foster [this message]
2015-08-18 23:23 ` [PATCH v3 04/13] xfs: ensure EFD trans aborts on log recovery extent free failure Dave Chinner
2015-08-19 11:02 ` Brian Foster
2015-08-10 19:01 ` [PATCH v3 05/13] xfs: use EFI refcount consistently in log recovery Brian Foster
2015-08-10 19:01 ` [PATCH v3 06/13] xfs: don't leave EFIs on AIL on mount failure Brian Foster
2015-08-10 19:01 ` [PATCH v3 07/13] xfs: icreate log item recovery and cancellation tracepoints Brian Foster
2015-08-10 19:01 ` [PATCH v3 08/13] xfs: fix broken icreate log item cancellation Brian Foster
2015-08-10 19:01 ` [PATCH v3 09/13] xfs: checksum log record ext headers based on record size Brian Foster
2015-08-10 19:01 ` [PATCH v3 10/13] xfs: clean up root inode properly on mount failure Brian Foster
2015-08-10 19:01 ` [PATCH v3 11/13] xfs: fix btree cursor error cleanups Brian Foster
2015-08-10 19:01 ` [PATCH v3 12/13] xfs: add helper to conditionally remove items from the AIL Brian Foster
2015-08-12 7:17 ` Christoph Hellwig
2015-08-12 12:48 ` Brian Foster
2015-08-12 13:00 ` [PATCH v4 " Brian Foster
2015-08-10 19:01 ` [PATCH v3 13/13] xfs: add missing bmap cancel calls in error paths Brian Foster
2015-08-12 7:21 ` Christoph Hellwig
2015-08-12 12:48 ` Brian Foster
2015-08-17 16:47 ` [PATCH 14/13] xfs: swap leaf buffer into path struct atomically during path shift Brian Foster
2015-08-17 21:34 ` Dave Chinner
2015-08-17 22:19 ` Brian Foster
2015-08-17 22:25 ` [PATCH v2 " Brian Foster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439233309-19959-5-git-send-email-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox