xfs
[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: [PATCH] [PATCH] Stop periodic syncing if filesystem is already shutdown.
From: raghu.prabhu13@xxxxxxxxx
Date: Mon, 7 May 2012 14:44:07 +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=us8dw+CkLQ4rDG7S9WXRgbFaX5OjJVhnh+eV1Y35mYI=; b=v1ZqsnxP9DdLp9ZjbxZ3hPiNXciza5aaHuqjH9K2k7XyhafZcrp38m8yljTrijE5dh dMq9gIfTUrRJ6RH8tIB0JDfSLSn+NDy3tmq9yuDBESyDLAd99m7SxDtZjQUF9dD2dqDS p1w5n3BOJAldvGu1rAqJF0/5SK4u+5wEFgpcN+RXpO7HnqJQUYW//ZxVk0raePwoh6Dr 9aCpkGTslk6VZ8MRc4lz3bTvE0izKUkMC1aMk3CFULhOQA7SxcPs21t238hf3esqVhfY doulg3aEZoW+bQalxEdIsvDRp8ej6mvqkm9x3EknrjACnxPQpdofMkQVUbAhE3z1YZMV iTDg==
From: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>

This is to prevent syncing from running ad-infinitum till umount if the disk 
has been forcefully unplugged.

This is to prevent messages like these from being displayed.

==========================================
[ 3816.416570] XFS (sdb3): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[ 3816.416586] XFS (sdb3): I/O Error Detected. Shutting down filesystem
[ 3816.416592] XFS (sdb3): Please umount the filesystem and rectify the 
problem(s)
[ 3842.941953] XFS (sdb3): xfs_log_force: error 5 returned.
[ 3873.009329] XFS (sdb3): xfs_log_force: error 5 returned.
[ 3878.913310] XFS (sdb3): xfs_log_force: error 5 returned.
[ 3878.913322] XFS (sdb3): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[ 3878.913350] XFS (sdb3): xfs_log_force: error 5 returned.
[ 3878.913362] 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 simulate it, mount an xfs filesystem located on external disk, and then pull
the power to the disk (non-usb powered disk).

Tested it on latest linus tree. 
Now, the kernel log looks,

[ 2477.305280] XFS (sdc3): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[ 2477.305295] XFS (sdc3): I/O Error Detected. Shutting down filesystem
[ 2477.305300] XFS (sdc3): Please umount the filesystem and rectify the 
problem(s)
[ 2477.305588] XFS (sdc2): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[ 2477.305600] XFS (sdc2): I/O Error Detected. Shutting down filesystem
[ 2477.305604] XFS (sdc2): Please umount the filesystem and rectify the 
problem(s)
[ 2487.810718] XFS (sdc3): xfs_log_force: error 5 returned.
[ 2487.810729] XFS (sdc3): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[ 2487.812981] XFS (sdc2): xfs_log_force: error 5 returned.
[ 2487.812991] XFS (sdc2): xfs_do_force_shutdown(0x1) called from line 1031 of 
file fs/xfs/xfs_buf.c.  Return address = 0xffffffff8127c13a
[ 2489.420042] XFS (sdc3): Filesystem not writable / already shutdown.
[ 2490.955438] XFS (sdc2): Filesystem not writable / already shutdown.

Signed-off-by: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>
Tested-by: Raghavendra D Prabhu <rprabhu@xxxxxxxxxxx>
---
 fs/xfs/xfs_sync.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index 205ebcb..7ec412c 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -460,6 +460,12 @@ xfs_sync_worker(
                                        struct xfs_mount, m_sync_work);
        int             error;
 
+       if (!xfs_fs_writable(mp)) {
+               xfs_err(mp, "Filesystem not writable / already shutdown.");
+               xfs_syncd_stop(mp);
+               return;
+       }
+
        if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
                /* dgc: errors ignored here */
                if (mp->m_super->s_frozen == SB_UNFROZEN &&
@@ -551,6 +557,12 @@ xfs_flush_worker(
        struct xfs_mount *mp = container_of(work,
                                        struct xfs_mount, m_flush_work);
 
+       if (!xfs_fs_writable(mp)) {
+               xfs_err(mp, "Filesystem not writable / already shutdown.");
+               xfs_syncd_stop(mp);
+               return;
+       }
+
        xfs_sync_data(mp, SYNC_TRYLOCK);
        xfs_sync_data(mp, SYNC_TRYLOCK | SYNC_WAIT);
 }
-- 
1.7.10.1

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