Skip to contentSkip to conversation

Fix incorrect fs sync behaviour [2/5]

GFS2 Steven Whitehouse 2 participants 3 messages Nov 6, 2006 – Dec 4, 2006 GFS2 file system

lore
Share & tools
lore
#0 lore raw
Quoted 1 line

From 4a221953ed121692aa25998451a57c7f4be8b4f6 Mon Sep 17 00:00:00 2001

From: Steven Whitehouse <[email protected]>
Date: Wed, 1 Nov 2006 09:57:57 -0500
Subject: [PATCH] [GFS2] Fix incorrect fs sync behaviour.

This adds a sync_fs superblock operation for GFS2 and removes the journal flush from write_super in favour of sync_fs where it ought to be. This is more or less identical to the way in which ext3 does this.

This bug was pointed out by Russell Cattelan <[email protected]>

---
 fs/gfs2/ops_super.c |   44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 deletions(-)
fs/gfs2/ops_super.c +28 -16
index 06f06f7..b47d959 100644
@@ -138,16 +138,27 @@ static void gfs2_put_super(struct super_
 }
 
 /**
- * gfs2_write_super - disk commit all incore transactions
- * @sb: the filesystem
+ * gfs2_write_super
+ * @sb: the superblock
  *
- * This function is called every time sync(2) is called.
- * After this exits, all dirty buffers are synced.
  */
 
 static void gfs2_write_super(struct super_block *sb)
 {
+	sb->s_dirt = 0;
+}
+
+/**
+ * gfs2_sync_fs - sync the filesystem
+ * @sb: the superblock
+ *
+ * Flushes the log to disk.
+ */
+static int gfs2_sync_fs(struct super_block *sb, int wait)
+{
+	sb->s_dirt = 0;
 	gfs2_log_flush(sb->s_fs_info, NULL);
+	return 0;
 }
 
 /**
@@ -452,17 +463,18 @@ static void gfs2_destroy_inode(struct in
 }
 
 struct super_operations gfs2_super_ops = {
-	.alloc_inode = gfs2_alloc_inode,
-	.destroy_inode = gfs2_destroy_inode,
-	.write_inode = gfs2_write_inode,
-	.delete_inode = gfs2_delete_inode,
-	.put_super = gfs2_put_super,
-	.write_super = gfs2_write_super,
-	.write_super_lockfs = gfs2_write_super_lockfs,
-	.unlockfs = gfs2_unlockfs,
-	.statfs = gfs2_statfs,
-	.remount_fs = gfs2_remount_fs,
-	.clear_inode = gfs2_clear_inode,
-	.show_options = gfs2_show_options,
+	.alloc_inode		= gfs2_alloc_inode,
+	.destroy_inode		= gfs2_destroy_inode,
+	.write_inode		= gfs2_write_inode,
+	.delete_inode		= gfs2_delete_inode,
+	.put_super		= gfs2_put_super,
+	.write_super		= gfs2_write_super,
+	.sync_fs		= gfs2_sync_fs,
+	.write_super_lockfs 	= gfs2_write_super_lockfs,
+	.unlockfs		= gfs2_unlockfs,
+	.statfs			= gfs2_statfs,
+	.remount_fs		= gfs2_remount_fs,
+	.clear_inode		= gfs2_clear_inode,
+	.show_options		= gfs2_show_options,
 };
 
Signature · 1 line
1.4.1
#1 lore raw
Quoted 28 lines · Steven Whitehouse
Quoted 1 line

From 4a221953ed121692aa25998451a57c7f4be8b4f6 Mon Sep 17 00:00:00 2001

From: Steven Whitehouse <[email protected]>
Date: Wed, 1 Nov 2006 09:57:57 -0500
Subject: [PATCH] [GFS2] Fix incorrect fs sync behaviour.

This adds a sync_fs superblock operation for GFS2 and removes the journal flush from write_super in favour of sync_fs where it ought to be. This is more or less identical to the way in which ext3 does this.

This bug was pointed out by Russell Cattelan <[email protected]>

---
 fs/gfs2/ops_super.c |   44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 deletions(-)
fs/gfs2/ops_super.c +0 -2
index 06f06f7..b47d959 100644
@@ -138,16 +138,27 @@ static void gfs2_put_super(struct super_
 }
 
 /**
- * gfs2_write_super - disk commit all incore transactions
- * @sb: the filesystem

fs/gfs2/ops_super.c static void gfs2_put_super(struct super_ · line 148

Quoted 10 lines
fs/gfs2/ops_super.c +3 -2
+ * gfs2_write_super
+ * @sb: the superblock
  *
- * This function is called every time sync(2) is called.
- * After this exits, all dirty buffers are synced.
  */
 
 static void gfs2_write_super(struct super_block *sb)
 {
+	sb->s_dirt = 0;

This is a bit different than my original patch?
Are you sure we don't need the s_lock here?

Quoted 47 lines
fs/gfs2/ops_super.c +25 -12
+}
+
+/**
+ * gfs2_sync_fs - sync the filesystem
+ * @sb: the superblock
+ *
+ * Flushes the log to disk.
+ */
+static int gfs2_sync_fs(struct super_block *sb, int wait)
+{
+	sb->s_dirt = 0;
 	gfs2_log_flush(sb->s_fs_info, NULL);
+	return 0;
 }
 
 /**
@@ -452,17 +463,18 @@ static void gfs2_destroy_inode(struct in
 }
 
 struct super_operations gfs2_super_ops = {
-	.alloc_inode = gfs2_alloc_inode,
-	.destroy_inode = gfs2_destroy_inode,
-	.write_inode = gfs2_write_inode,
-	.delete_inode = gfs2_delete_inode,
-	.put_super = gfs2_put_super,
-	.write_super = gfs2_write_super,
-	.write_super_lockfs = gfs2_write_super_lockfs,
-	.unlockfs = gfs2_unlockfs,
-	.statfs = gfs2_statfs,
-	.remount_fs = gfs2_remount_fs,
-	.clear_inode = gfs2_clear_inode,
-	.show_options = gfs2_show_options,
+	.alloc_inode		= gfs2_alloc_inode,
+	.destroy_inode		= gfs2_destroy_inode,
+	.write_inode		= gfs2_write_inode,
+	.delete_inode		= gfs2_delete_inode,
+	.put_super		= gfs2_put_super,
+	.write_super		= gfs2_write_super,
+	.sync_fs		= gfs2_sync_fs,
+	.write_super_lockfs 	= gfs2_write_super_lockfs,
+	.unlockfs		= gfs2_unlockfs,
+	.statfs			= gfs2_statfs,
+	.remount_fs		= gfs2_remount_fs,
+	.clear_inode		= gfs2_clear_inode,
+	.show_options		= gfs2_show_options,
 };
 
Signature · 1 line
Russell Cattelan <[email protected]>
#2 lore raw

Hi,

Quoted 36 lines · Russell Cattelan
Quoted 35 lines · Steven Whitehouse
Quoted 1 line

From 4a221953ed121692aa25998451a57c7f4be8b4f6 Mon Sep 17 00:00:00 2001

From: Steven Whitehouse <[email protected]>
Date: Wed, 1 Nov 2006 09:57:57 -0500
Subject: [PATCH] [GFS2] Fix incorrect fs sync behaviour.

This adds a sync_fs superblock operation for GFS2 and removes the journal flush from write_super in favour of sync_fs where it ought to be. This is more or less identical to the way in which ext3 does this.

This bug was pointed out by Russell Cattelan <[email protected]>

---
 fs/gfs2/ops_super.c |   44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 deletions(-)
fs/gfs2/ops_super.c +2 -4
index 06f06f7..b47d959 100644
@@ -138,16 +138,27 @@ static void gfs2_put_super(struct super_
 }
 
 /**
- * gfs2_write_super - disk commit all incore transactions
- * @sb: the filesystem
+ * gfs2_write_super
+ * @sb: the superblock
  *
- * This function is called every time sync(2) is called.
- * After this exits, all dirty buffers are synced.
  */
 
Quoted 4 lines

fs/gfs2/ops_super.c static void gfs2_put_super(struct super_ · line 148

Quoted 3 lines
fs/gfs2/ops_super.c +1 -0
 static void gfs2_write_super(struct super_block *sb)
 {
+	sb->s_dirt = 0;

This is a bit different than my original patch?

This was largely taken from the ext3 code as an example, rather than your patch.

Quoted 3 lines

Are you sure we don't need the s_lock here?

Yes. See linux-2.6/Documentation/filesystems/Locking:

locking rules:
All may block.
BKL s_lock s_umount
[snip]
write_super: no yes read

it is already held on entry to write_super,

Steve.