xfs
[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: [PATCH v4] Stop periodic syncing if filesystem is already shutdown.
From: raghu.prabhu13@xxxxxxxxx
Date: Thu, 31 May 2012 23:37:34 +0530
Cc: raghu.prabhu13@xxxxxxxxx, 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=U36PKnE0tJ3bfcKRIO+J57n8lgEYZjNiqdufMadKUyQ=; b=bNZpvfzf4HOmEJfovPpfYTShIWqj3S+6HDPmmeObVyldLLUumSCrrRkb85rl/8Hze5 3oZkbOmOvBYtp3zI5yRYLwTZUH2lNnqZ+PZiT308YlHsr/j/U/X9DLv6dzvqDV6r4nie nOSJg9VGd+6H/3jSM7znDyt4C+gPlETqmrZQqlQhako65IS4OhQH88V14S74UT9NqwKQ 6M5P5CgtlnHAl8UxnO6g+dr79h6bvvTpYbyO8MUyMgvqWz3nMzX2FMpvLjfTnXhP/Uxb EFUSeCpYxc99NuNnTerBnAaysd22YM9sSdxJ+XpiaDudRUU3T/IpkfUrHlKiA39IUcxQ sRPQ==
From: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>

This is to prevent xfs_log_force from running ad-infinitum (due to xfs_sync)
till umount if the disk has been forcefully unplugged.

This is also 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 it, added return statements to xfs_log_force and xfs_fs_sync_fs if the
filesystem is already shutdown -- based on XFS_FORCED_SHUTDOWN.

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

Tested it on latest linus tree.

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.

Signed-off-by: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>
Tested-by: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>
  ---
---
 fs/xfs/xfs_log.c   |    7 +++++++
 fs/xfs/xfs_super.c |    7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 6db1fef..e4192b2 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2932,6 +2932,13 @@ xfs_log_force(
 {
        int     error;
 
+       /*
+        * No need to printk here since xfs_bwrite already printks about xfs
+        * shutdown if it has shutdown already.
+        */
+       if (XFS_FORCED_SHUTDOWN(mp))
+               return;
+
        error = _xfs_log_force(mp, flags, NULL);
        if (error)
                xfs_warn(mp, "%s: error %d returned.", __func__, error);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index dab9a5f..b0f6041 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1010,6 +1010,13 @@ xfs_fs_sync_fs(
        int                     error;
 
        /*
+        * No need to printk here since xfs_bwrite already printks about xfs
+        * shutdown if it has shutdown already.
+        */
+       if (XFS_FORCED_SHUTDOWN(mp))
+               return XFS_ERROR(EIO);
+
+       /*
         * Doing anything during the async pass would be counterproductive.
         */
        if (!wait)
-- 
1.7.10.3

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH v4] Stop periodic syncing if filesystem is already shutdown., raghu . prabhu13 <=