xfs
[Top] [All Lists]

[PATCH v6] Stop periodic syncing if filesystem is already shutdown.

To: david@xxxxxxxxxxxxx
Subject: [PATCH v6] Stop periodic syncing if filesystem is already shutdown.
From: raghu.prabhu13@xxxxxxxxx
Date: Fri, 21 Sep 2012 10:24:04 +0530
Cc: xfs@xxxxxxxxxxx, Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=wSpl6e4rQvlAmnVuLW40M22ULTRFR++Vi/Ut6zDH52g=; b=EeqUTkJZ+kbVS/iGMyc0x+qIJyPvNHGessTI6JobNroFlFDGNQpaBxkJ5rKNXRkbtM ObTzzIzRa5zzY9efirmI9Entodmwd9UDxDaFM2vVi5Dwb9csLUI/XCQY8f2KepDG74YR RDbUQz0gLOvIN5BsV8E0suyZAFXDH0zEFHTAQ/1RkCKS7ZWVUminoqo4jGGVnvYucvqI 0xEs+r8qEuQd7TNVzhsOdTQUNbzmW1bOB2M9su0gLS+IOCXmYVqnNuk6wHi66RCVqgfw uiLbuTY7uGuDNj5ZSjaj0WIoDXpqqbMNt9kH6vparnReYzkeY7LS4urafQLWLqjYeZTJ aZ5w==
From: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>

This is to prevent xfs_log_force from printing error message continuously (due
to xfs_sync and others) till umount if the disk has been forcefully unplugged.

This is to prevent messages like these from being displayed repeatedly.

[ 3873.009329] XFS (sdb3): xfs_log_force: error 5 returned.

Note, that even after xfs_do_force_shutdown has been called, xfs_log_force
doesn't stop till the filesystem has been unmounted (and it keeps printing
"error 5 returned" to kernel log).

To fix this, added condition over XFS_FORCED_SHUTDOWN to xfs_log_force and
xfs_fs_sync_fs.

To simulate it, mount an xfs filesystem located on external disk, and then pull
the power to the disk.

Now, the dmesg looks,

[  268.307303] XFS (sdb2): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[  268.307318] XFS (sdb2): I/O Error Detected. Shutting down filesystem
[  268.307323] XFS (sdb2): Please umount the filesystem and rectify the 
problem(s)

Version 1: Removed calling xfs_syncd_stop from xfs_sync_worker.
Version 2: Removed calling xfs_fs_writable in xfs_sync_worker and 
xfs_flush_worker.
Version 3: Removed calling xfs_syncd_stop in xfs_bwrite.
Version 4: Added return statements to xfs_log_force and xfs_fs_sync_fs.
Version 5: As per suggestion, removed EIO return in xfs_log_force.

Signed-off-by: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>
---
 fs/xfs/xfs_log.c   | 5 ++++-
 fs/xfs/xfs_super.c | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 7f4f937..161c925 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3002,7 +3002,10 @@ xfs_log_force(
 
        trace_xfs_log_force(mp, 0);
        error = _xfs_log_force(mp, flags, NULL);
-       if (error)
+       /*
+        * Avoid warning when the filesystem has already shutdown.
+        */
+       if (error && !XFS_FORCED_SHUTDOWN(mp))
                xfs_warn(mp, "%s: error %d returned.", __func__, error);
 }
 
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 19e2380..8df3387 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -944,6 +944,10 @@ xfs_fs_sync_fs(
        if (!wait)
                return 0;
 
+       if (XFS_FORCED_SHUTDOWN(mp)) {
+               return XFS_ERROR(EIO);
+       }
+
        error = xfs_quiesce_data(mp);
        if (error)
                return -error;
-- 
1.7.12.1

<Prev in Thread] Current Thread [Next in Thread>