[PATCH] xfs: xfs_trans_cancel() path must check for log shutdown

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

 



The following error occurred when do IO fault injection test:

XFS: Assertion failed: xlog_is_shutdown(lip->li_log), file: fs/xfs/xfs_inode_item.c, line: 748

In commit 3c4cb76bce43 (xfs: xfs_trans_commit() path must check for log
shutdown) fix a problem that dirty transaction was canceled before log
shutdown, because of the log is still running, it result dirty and
unlogged inode item that isn't in the AIL in memory that can be flushed
to disk via writeback clustering.

xfs_trans_cancel() has the same problem, if a shut down races with
xfs_trans_cancel() and we have shut down the filesystem but not the log,
we will still cancel the transaction before log shutdown. So
xfs_trans_cancel() needs to check log state for shutdown, not mount.

Signed-off-by: Long Li <leo.lilong@xxxxxxxxxx>
---
 fs/xfs/xfs_trans.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 8afc0c080861..033991854d4f 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1059,11 +1059,9 @@ xfs_trans_commit(
  *
  * This is a high level function (equivalent to xfs_trans_commit()) and so can
  * be called after the transaction has effectively been aborted due to the mount
- * being shut down. However, if the mount has not been shut down and the
+ * being shut down. However, if the log has not been shut down and the
  * transaction is dirty we will shut the mount down and, in doing so, that
- * guarantees that the log is shut down, too. Hence we don't need to be as
- * careful with shutdown state and dirty items here as we need to be in
- * xfs_trans_commit().
+ * guarantees that the log is shut down.
  */
 void
 xfs_trans_cancel(
@@ -1089,11 +1087,12 @@ xfs_trans_cancel(
 
 	/*
 	 * See if the caller is relying on us to shut down the filesystem. We
-	 * only want an error report if there isn't already a shutdown in
-	 * progress, so we only need to check against the mount shutdown state
-	 * here.
+	 * only want an error report if there isn't already a log shutdown. We
+	 * must check against log shutdown here because we cannot abort log and
+	 * leave them dirty, inconsistent and unpinned in memory while the log
+	 * is active, as we needed in xfs_trans_commit().
 	 */
-	if (dirty && !xfs_is_shutdown(mp)) {
+	if (dirty && !xlog_is_shutdown(log)) {
 		XFS_ERROR_REPORT("xfs_trans_cancel", XFS_ERRLEVEL_LOW, mp);
 		xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
 	}
-- 
2.31.1




[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