Skip to contentSkip to conversation

hfsplus: stop using write_supers and s_dirt

PATCH In review Artem Bityutskiy 2 participants 8 messages Jul 12, 2012 – Jul 13, 2012

Subsystems (2)

v3 of 7 In review Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover hfsplus: stop using write_supers and s_dirt

Hi Andrew, here is v3 of the patches, could you please pick them instead of the ones you have in your tree? The differences to v2 are:

1. checkpatch.pl warnings fixed
2. removed 'cancel_delayed_work()' from 'hfsplus_sync_fs()' because it is not enough to just cancel the job, we need to set the work_queued flag to zero as well. I could do this, but it is simpler to just remove this tiny optimization - we do not gain much with it. I caught this bug while doing some more testing.

This patch-set makes hfsplus file-system stop using the VFS '->write_supers()' call-back and the '->s_dirt' superblock field because I plan to remove them once all users are gone.

Like some other similar patch-sets (affs, hfs, ufs, reiserfs), we switch to a delayed job for writing out the superblock instead of using the 's_dirt' flag. Additionally, this patch-set includes several clean-ups.

Tested using the fsstress test from the LTP project.

 fs/hfsplus/bitmap.c     |    4 ++--
 fs/hfsplus/dir.c        |    2 +-
 fs/hfsplus/hfsplus_fs.h |    7 +++++--
 fs/hfsplus/inode.c      |    6 +++---
 fs/hfsplus/super.c      |   46 +++++++++++++++++++++++++++++++++-------------
 5 files changed, 44 insertions(+), 21 deletions(-)

Reminder
========

The goal is to get rid of the 'sync_supers()' kernel thread. This kernel thread wakes up every 5 seconds (by default) and calls '->write_super()' for all mounted file-systems. And the bad thing is that this is done even if all the superblocks are clean. Moreover, many file-systems do not even need this and they do not even register the '->write_super()' method at all (e.g., btrfs).

So 'sync_supers()' mostly just generates useless wake-ups and wastes power. I am trying to make all file-systems independent of '->write_super()' and plan to remove 'sync_supers()' and '->write_super()' completely once there are no more users.

Overall status
==============

1. ext4: patches submitted (v7)

    http://thread.gmane.org/gmane.linux.kernel/1326181/focus=33332
2.  ufs: patches submitted,
    https://lkml.org/lkml/2012/7/12/248
3.  exofs: patch submitted,
    https://lkml.org/lkml/2012/6/4/211
4.  sysv: patches submitted,
    http://lkml.org/lkml/2012/7/3/250
5.  udf: patch sits in Jan Kara's tree:
    https://lkml.org/lkml/2012/6/4/233
    git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs for_testing
6.  affs: patches sit in Al Viro's tree:
    https://lkml.org/lkml/2012/6/6/400
    git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs for-next
7.  hfs: patches sit in Andrew Morton's tree (-mm, visible in linux-next)
8.  hfsplus: patches sit in Andrew Morton's tree (-mm, visible in linux-next)
9.  ext2:     done, see commit f72cf5e223a28d3b3ea7dc9e40464fd534e359e8

10. vfat: done, see commit 78491189ddb6d84d4a4abae992ed891a236d0263
11. jffs2: done, see commit 208b14e507c00ff7f108e1a388dd3d8cc805a443
12. reiserfs: done, see commit 033369d1af1264abc23bea2e174aa47cdd212f6f

Thanks,
Artem.

#2 lore raw

PATCH v3 2/4 hfsplus: amend debugging print

From: Artem Bityutskiy <[email protected]>

Print correct function name in the debugging print of the 'hfsplus_sync_fs()' function.

---
 fs/hfsplus/super.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/hfsplus/super.c +1 -1
index 5df771e..9e9c2788 100644
@@ -171,7 +171,7 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait)
 	if (!wait)
 		return 0;
 
-	dprint(DBG_SUPER, "hfsplus_write_super\n");
+	dprint(DBG_SUPER, "hfsplus_sync_fs\n");
 
 	sb->s_dirt = 0;
 
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH v3 1/4 hfsplus: make hfsplus_sync_fs static

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

... because it is used only in fs/hfsplus/super.c.

---
 fs/hfsplus/hfsplus_fs.h |    1 -
 fs/hfsplus/super.c      |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)
fs/hfsplus/hfsplus_fs.h +0 -1
index 4e75ac6..66a9365 100644
@@ -428,7 +428,6 @@ int hfsplus_show_options(struct seq_file *, struct dentry *);
 
 /* super.c */
 struct inode *hfsplus_iget(struct super_block *, unsigned long);
-int hfsplus_sync_fs(struct super_block *sb, int wait);
 
 /* tables.c */
 extern u16 hfsplus_case_fold_table[];
fs/hfsplus/super.c +1 -1
index a9bca4b..5df771e 100644
@@ -161,7 +161,7 @@ static void hfsplus_evict_inode(struct inode *inode)
 	}
 }
 
-int hfsplus_sync_fs(struct super_block *sb, int wait)
+static int hfsplus_sync_fs(struct super_block *sb, int wait)
 {
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	struct hfsplus_vh *vhdr = sbi->s_vhdr;
Signature · 1 line
1.7.7.6
#4 lore raw

PATCH v3 4/4 hfsplus: get rid of write_super

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

This patch makes hfsplus stop using the VFS '->write_super()' method along with the 's_dirt' superblock flag, because they are on their way out.

The whole "superblock write-out" VFS infrastructure is served by the 'sync_supers()' kernel thread, which wakes up every 5 (by default) seconds and writes out all dirty superblocks using the '->write_super()' call-back. But the problem with this thread is that it wastes power by waking up the system every 5 seconds, even if there are no diry superblocks, or there are no client file-systems which would need this (e.g., btrfs does not use '->write_super()'). So we want to kill it completely and thus, we need to make file-systems to stop using the '->write_super()' VFS service, and then remove it together with the kernel thread.

Tested using fsstress from the LTP project.

---
 fs/hfsplus/bitmap.c     |    4 ++--
 fs/hfsplus/dir.c        |    2 +-
 fs/hfsplus/hfsplus_fs.h |    6 +++++-
 fs/hfsplus/inode.c      |    6 +++---
 fs/hfsplus/super.c      |   41 ++++++++++++++++++++++++++++++++---------
 5 files changed, 43 insertions(+), 16 deletions(-)
fs/hfsplus/bitmap.c +2 -2
index 1cad80c..4cfbe2e 100644
@@ -153,7 +153,7 @@ done:
 	kunmap(page);
 	*max = offset + (curr - pptr) * 32 + i - start;
 	sbi->free_blocks -= *max;
-	sb->s_dirt = 1;
+	hfsplus_mark_mdb_dirty(sb);
 	dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
 out:
 	mutex_unlock(&sbi->alloc_mutex);
@@ -228,7 +228,7 @@ out:
 	set_page_dirty(page);
 	kunmap(page);
 	sbi->free_blocks += len;
-	sb->s_dirt = 1;
+	hfsplus_mark_mdb_dirty(sb);
 	mutex_unlock(&sbi->alloc_mutex);
 
 	return 0;
fs/hfsplus/dir.c +1 -1
index 26b53fb..8375504 100644
@@ -316,7 +316,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
 	inode->i_ctime = CURRENT_TIME_SEC;
 	mark_inode_dirty(inode);
 	sbi->file_count++;
-	dst_dir->i_sb->s_dirt = 1;
+	hfsplus_mark_mdb_dirty(dst_dir->i_sb);
 out:
 	mutex_unlock(&sbi->vh_mutex);
 	return res;
fs/hfsplus/hfsplus_fs.h +5 -1
index 66a9365..558dbb4 100644
@@ -153,8 +153,11 @@ struct hfsplus_sb_info {
 	gid_t gid;
 
 	int part, session;
-
 	unsigned long flags;
+
+	int work_queued;               /* non-zero delayed work is queued */
+	struct delayed_work sync_work; /* FS sync delayed work */
+	spinlock_t work_lock;          /* protects sync_work and work_queued */
 };
 
 #define HFSPLUS_SB_WRITEBACKUP	0
@@ -428,6 +431,7 @@ int hfsplus_show_options(struct seq_file *, struct dentry *);
 
 /* super.c */
 struct inode *hfsplus_iget(struct super_block *, unsigned long);
+void hfsplus_mark_mdb_dirty(struct super_block *sb);
 
 /* tables.c */
 extern u16 hfsplus_case_fold_table[];
fs/hfsplus/inode.c +3 -3
index 82b69ee..ad1f16f 100644
@@ -431,7 +431,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
 		sbi->file_count++;
 	insert_inode_hash(inode);
 	mark_inode_dirty(inode);
-	sb->s_dirt = 1;
+	hfsplus_mark_mdb_dirty(sb);
 
 	return inode;
 }
@@ -442,7 +442,7 @@ void hfsplus_delete_inode(struct inode *inode)
 
 	if (S_ISDIR(inode->i_mode)) {
 		HFSPLUS_SB(sb)->folder_count--;
-		sb->s_dirt = 1;
+		hfsplus_mark_mdb_dirty(sb);
 		return;
 	}
 	HFSPLUS_SB(sb)->file_count--;
@@ -455,7 +455,7 @@ void hfsplus_delete_inode(struct inode *inode)
 		inode->i_size = 0;
 		hfsplus_file_truncate(inode);
 	}
-	sb->s_dirt = 1;
+	hfsplus_mark_mdb_dirty(sb);
 }
 
 void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
fs/hfsplus/super.c +32 -9

78 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#3 lore raw

PATCH v3 3/4 hfsplus: remove useless check

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

This check is useless because we always have 'sb->s_fs_info' to be non-NULL.

---
 fs/hfsplus/super.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
fs/hfsplus/super.c +0 -3
index 9e9c2788..f4f3d54 100644
@@ -240,9 +240,6 @@ static void hfsplus_put_super(struct super_block *sb)
 
 	dprint(DBG_SUPER, "hfsplus_put_super\n");
 
-	if (!sb->s_fs_info)
-		return;
-
 	if (!(sb->s_flags & MS_RDONLY) && sbi->s_vhdr) {
 		struct hfsplus_vh *vhdr = sbi->s_vhdr;
 
Signature · 1 line
1.7.7.6
#5 lore raw
In reply to Artem Bityutskiy
Quoted 2 lines · On Thu, 12 Jul 2012 17:26:27 +0300 Artem Bityutskiy <[email protected]> wrote:

Hi Andrew, here is v3 of the patches, could you please pick them instead of the ones you have in your tree?

I really do dislike dropping patches and replacing them. For a whole bunch of reasons. One of which is that a wholesale replacement requires a full re-review. Another is that wholesale replacement makes it hard to see what was changed.

Quoted 8 lines

The differences to v2 are:

1. checkpatch.pl warnings fixed
2. removed 'cancel_delayed_work()' from 'hfsplus_sync_fs()' because it is not enough to just cancel the job, we need to set the work_queued flag to zero as well. I could do this, but it is simpler to just remove this tiny optimization - we do not gain much with it. I caught this bug while doing some more testing.

And lo, when I look at "what was changed", I see that this patchset actually does *not* remove the cancel_delayed_work() call. What's up with that?

This latest patchset is identical to the code which is presently in -mm.

#6 lore raw
Quoted 9 lines · On Thu, 12 Jul 2012 16:09:51 -0700 Andrew Morton <[email protected]>…
Quoted 5 lines

2. removed 'cancel_delayed_work()' from 'hfsplus_sync_fs()' because it is not enough to just cancel the job, we need to set the work_queued flag to zero as well. I could do this, but it is simpler to just remove this tiny optimization - we do not gain much with it. I caught this bug while doing some more testing.

And lo, when I look at "what was changed", I see that this patchset actually does *not* remove the cancel_delayed_work() call. What's up with that?

Ah, no. I was looking at the cancel_delayed_work() in hfs_put_super().

#7 lore raw
In reply to Andrew Morton
Quoted 4 lines · Andrew Morton

I really do dislike dropping patches and replacing them. For a whole bunch of reasons. One of which is that a wholesale replacement requires a full re-review. Another is that wholesale replacement makes it hard to see what was changed.

I will keep this in mind and in future will send you incremental changes instead. Apologies Andrew.

Quoted 1 line

This latest patchset is identical to the code which is presently in -mm.

I am now away and cannot easily send you a diff between v2 and v3, but it really does have changes - exactly as I described - checkpatch.pl fixes (spaces replaced by tabs) and one line removed. Sorry for confusion, I really should have sent an incremental patch.

Signature · 2 lines
Best Regards,
Artem Bityutskiy