Skip to contentSkip to conversation

periodic write-back timer optimization

PATCH Superseded Artem Bityutskiy 3 participants 28 messages May 27, 2009 – Jun 3, 2009

Subsystems (13)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#2 lore raw

PATCH 2/19 AFFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] AFFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/affs/bitmap.c |    4 ++--
 fs/affs/super.c  |   11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)
fs/affs/bitmap.c +2 -2
index dc5ef14..0be510c 100644
@@ -102,7 +102,7 @@ affs_free_block(struct super_block *sb, u32 block)
 	*(__be32 *)bh->b_data = cpu_to_be32(tmp - mask);
 
 	mark_buffer_dirty(bh);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	bm->bm_free++;
 
 	mutex_unlock(&sbi->s_bmlock);
@@ -247,7 +247,7 @@ find_bit:
 	*(__be32 *)bh->b_data = cpu_to_be32(tmp + mask);
 
 	mark_buffer_dirty(bh);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	mutex_unlock(&sbi->s_bmlock);
 
fs/affs/super.c +7 -4
index 280d361..fab17aa 100644
@@ -64,9 +64,12 @@ affs_write_super(struct super_block *sb)
 				  &AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
 		affs_fix_checksum(sb, sbi->s_root_bh);
 		mark_buffer_dirty(sbi->s_root_bh);
-		sb->s_dirt = !clean;	/* redo until bitmap synced */
+		if (clean)
+			mark_sb_clean(sb);
+		else
+			mark_sb_dirty(sb);
 	} else
-		sb->s_dirt = 0;
+		mark_sb_clean(sb);
 	unlock_super(sb);
 
 	pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean);
@@ -522,8 +525,8 @@ affs_remount(struct super_block *sb, int *flags, char *data)
 	if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
 		return 0;
 	if (*flags & MS_RDONLY) {
-		sb->s_dirt = 1;
-		while (sb->s_dirt)
+		mark_sb_dirty(sb);
+		while (sb_is_dirty(sb))
 			affs_write_super(sb);
 		affs_free_bitmap(sb);
 	} else
Signature · 1 line
1.6.0.6
#3 lore raw

PATCH 3/19 BFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] BFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/bfs/inode.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/bfs/inode.c +3 -3
index 3a9a136..7ab0792 100644
@@ -219,7 +219,7 @@ static void bfs_put_super(struct super_block *s)
 
 	lock_kernel();
 
-	if (s->s_dirt)
+	if (sb_is_dirty(s))
 		bfs_write_super(s);
 
 	brelse(info->si_sbh);
@@ -255,7 +255,7 @@ static void bfs_write_super(struct super_block *s)
 	mutex_lock(&info->bfs_lock);
 	if (!(s->s_flags & MS_RDONLY))
 		mark_buffer_dirty(info->si_sbh);
-	s->s_dirt = 0;
+	mark_sb_clean(s);
 	mutex_unlock(&info->bfs_lock);
 }
 
@@ -464,7 +464,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
 	brelse(bh);
 	if (!(s->s_flags & MS_RDONLY)) {
 		mark_buffer_dirty(info->si_sbh);
-		s->s_dirt = 1;
+		mark_sb_dirty(s);
 	} 
 	dump_imap("read_super", s);
 	mutex_init(&info->bfs_lock);
Signature · 1 line
1.6.0.6
#1 lore raw

PATCH 1/19 VFS: introduce helpers for manipulation s_dirty flag

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] VFS: introduce helpers for manipulation s_dirty flag

This patch introduces 3 new VFS helpers: 'mark_sb_dirty()', 'mark_sb_clean()', and 'sb_is_dirty()'. The helpers simply set 'sb->s_dirt' or test 'sb->s_dirt'. The plan is to make every FS use these helpers instead of manipulating 'sb->s_dirt' directly. And the further plan is to stop the periodic write-back when there is no dirt.

This patch is just a preparation. No functional changes yet.

Cc Christoph Hellwig <[email protected]>
---
 include/linux/fs.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
include/linux/fs.h +13 -0
index 73242c3..437939c 100644
@@ -1782,6 +1782,19 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
 extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
 int __put_super_and_need_restart(struct super_block *sb);
 
+static inline void mark_sb_dirty(struct super_block *sb)
+{
+	sb->s_dirt = 1;
+}
+static inline void mark_sb_clean(struct super_block *sb)
+{
+	sb->s_dirt = 0;
+}
+static inline int sb_is_dirty(struct super_block *sb)
+{
+	return sb->s_dirt;
+}
+
 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
 #define fops_get(fops) \
 	(((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
Signature · 1 line
1.6.0.6
#4 lore raw

PATCH 4/19 EXOFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] EXOFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/exofs/inode.c |    2 +-
 fs/exofs/super.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/exofs/inode.c +1 -1
index ba8d9fa..80d3d03 100644
@@ -1066,7 +1066,7 @@ struct inode *exofs_new_inode(struct inode *dir, int mode)
 
 	sbi = sb->s_fs_info;
 
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	inode->i_uid = current->cred->fsuid;
 	if (dir->i_mode & S_ISGID) {
 		inode->i_gid = dir->i_gid;
fs/exofs/super.c +2 -2
index 49e16af..9cf9738 100644
@@ -241,7 +241,7 @@ static void exofs_write_super(struct super_block *sb)
 		EXOFS_ERR("exofs_write_super: exofs_sync_op failed.\n");
 		goto out;
 	}
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 
 out:
 	if (or)
@@ -262,7 +262,7 @@ static void exofs_put_super(struct super_block *sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (is_sb_dirty(sb))
 		exofs_write_super(sb);
 
 	/* make sure there are no pending commands */
Signature · 1 line
1.6.0.6
#6 lore raw

PATCH 6/19 EXT4: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] EXT4: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/ext4/balloc.c  |    2 +-
 fs/ext4/ialloc.c  |    4 ++--
 fs/ext4/inode.c   |    2 +-
 fs/ext4/mballoc.c |    4 ++--
 fs/ext4/resize.c  |    4 ++--
 fs/ext4/super.c   |   16 ++++++++--------
 fs/ext4/xattr.c   |    2 +-
 7 files changed, 17 insertions(+), 17 deletions(-)
fs/ext4/balloc.c +1 -1
index 53c72ad..ccb83ff 100644
@@ -490,7 +490,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
 	ret = ext4_handle_dirty_metadata(handle, NULL, gd_bh);
 	if (!err)
 		err = ret;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 error_return:
 	brelse(bitmap_bh);
fs/ext4/ialloc.c +2 -2
index f18e0a0..949e4a7 100644
@@ -297,7 +297,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
 	err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
 	if (!fatal)
 		fatal = err;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 error_return:
 	brelse(bitmap_bh);
 	ext4_std_error(sb, fatal);
@@ -968,7 +968,7 @@ got:
 	percpu_counter_dec(&sbi->s_freeinodes_counter);
 	if (S_ISDIR(mode))
 		percpu_counter_inc(&sbi->s_dirs_counter);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	if (sbi->s_log_groups_per_flex) {
 		flex_group = ext4_flex_group(sbi, group);
fs/ext4/inode.c +1 -1
index e91f978..743ca39 100644
@@ -4598,7 +4598,7 @@ static int ext4_do_update_inode(handle_t *handle,
 			ext4_update_dynamic_rev(sb);
 			EXT4_SET_RO_COMPAT_FEATURE(sb,
 					EXT4_FEATURE_RO_COMPAT_LARGE_FILE);
-			sb->s_dirt = 1;
+			mark_sb_dirty(sb);
 			ext4_handle_sync(handle);
 			err = ext4_handle_dirty_metadata(handle, inode,
 					EXT4_SB(sb)->s_sbh);
fs/ext4/mballoc.c +2 -2
index f871677..191cf37 100644
@@ -3054,7 +3054,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
 	err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh);
 
 out_err:
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	brelse(bitmap_bh);
 	return err;
 }
@@ -4909,7 +4909,7 @@ do_more:
 		put_bh(bitmap_bh);
 		goto do_more;
 	}
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 error_return:
 	brelse(bitmap_bh);
 	ext4_std_error(sb, err);
fs/ext4/resize.c +2 -2
index 546c7dd..323d741 100644
@@ -945,7 +945,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
 	}
 
 	ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 exit_journal:
 	unlock_super(sb);
@@ -1076,7 +1076,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
 	}
 	ext4_blocks_count_set(es, o_blocks_count + add);
 	ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	unlock_super(sb);
 	ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count,
 		   o_blocks_count + add);
fs/ext4/super.c +8 -8
index d789833..017052a 100644
@@ -566,7 +566,7 @@ static void ext4_put_super(struct super_block *sb)
 
 	lock_super(sb);
 	lock_kernel();
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		ext4_write_super_locked(sb);
 
 	ext4_mb_release(sb);
@@ -2482,7 +2482,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 #else
 		es->s_flags |= cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
 #endif
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 	}
 
 	if (sbi->s_blocks_per_group > blocksize * 8) {
@@ -3117,7 +3117,7 @@ static int ext4_load_journal(struct super_block *sb,
 	if (journal_devnum &&
 	    journal_devnum != le32_to_cpu(es->s_journal_dev)) {
 		es->s_journal_dev = cpu_to_le32(journal_devnum);
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 
 		/* Make sure we flush the recovery flag to disk. */
 		ext4_commit_super(sb, es, 1);
@@ -3199,7 +3199,7 @@ static void ext4_mark_recovery_complete(struct super_block *sb,
 	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) &&
 	    sb->s_flags & MS_RDONLY) {
 		EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
-		sb->s_dirt = 0;
+		mark_sb_clean(sb);
 		ext4_commit_super(sb, es, 1);
 	}
 	unlock_super(sb);
@@ -3261,7 +3261,7 @@ int ext4_force_commit(struct super_block *sb)
 
 	journal = EXT4_SB(sb)->s_journal;
 	if (journal) {
-		sb->s_dirt = 0;
+		mark_sb_clean(sb);
 		ret = ext4_journal_force_commit(journal);
 	}
 
@@ -3279,7 +3279,7 @@ static void ext4_write_super_locked(struct super_block *sb)
 	if (EXT4_SB(sb)->s_journal) {
 		if (mutex_trylock(&sb->s_lock) != 0)
 			BUG();
-		sb->s_dirt = 0;
+		mark_sb_clean(sb);
 	} else {
 		ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
 	}
@@ -3298,7 +3298,7 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
 	tid_t target;
 
 	trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	if (EXT4_SB(sb)->s_journal) {
 		if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal,
 					      &target)) {
@@ -3320,7 +3320,7 @@ static int ext4_freeze(struct super_block *sb)
 {
 	int error = 0;
 	journal_t *journal;
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 
 	if (!(sb->s_flags & MS_RDONLY)) {
 		journal = EXT4_SB(sb)->s_journal;
fs/ext4/xattr.c +1 -1
index 62b31c2..3589b7a 100644
@@ -456,7 +456,7 @@ static void ext4_xattr_update_super_block(handle_t *handle,
 
 	if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
 		EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 		ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
 	}
 }
Signature · 1 line
1.6.0.6
#5 lore raw

PATCH 5/19 EXT2: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] EXT2: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/ext2/balloc.c |    4 ++--
 fs/ext2/ialloc.c |    4 ++--
 fs/ext2/super.c  |    8 ++++----
 fs/ext2/xattr.c  |    2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)
fs/ext2/balloc.c +2 -2
index 7f8d2e5..a3de92b 100644
@@ -164,7 +164,7 @@ static void release_blocks(struct super_block *sb, int count)
 		struct ext2_sb_info *sbi = EXT2_SB(sb);
 
 		percpu_counter_add(&sbi->s_freeblocks_counter, count);
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 	}
 }
 
@@ -179,7 +179,7 @@ static void group_adjust_blocks(struct super_block *sb, int group_no,
 		free_blocks = le16_to_cpu(desc->bg_free_blocks_count);
 		desc->bg_free_blocks_count = cpu_to_le16(free_blocks + count);
 		spin_unlock(sb_bgl_lock(sbi, group_no));
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 		mark_buffer_dirty(bh);
 	}
 }
fs/ext2/ialloc.c +2 -2
index 15387c9..bb8cf4e 100644
@@ -81,7 +81,7 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir)
 	spin_unlock(sb_bgl_lock(EXT2_SB(sb), group));
 	if (dir)
 		percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	mark_buffer_dirty(bh);
 }
 
@@ -548,7 +548,7 @@ got:
 	}
 	spin_unlock(sb_bgl_lock(sbi, group));
 
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	mark_buffer_dirty(bh2);
 	inode->i_uid = current_fsuid();
 	if (test_opt (sb, GRPID))
fs/ext2/super.c +4 -4
index f5b7fad..4f054d5 100644
@@ -116,7 +116,7 @@ static void ext2_put_super (struct super_block * sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		ext2_write_super(sb);
 
 	ext2_xattr_put_super(sb);
@@ -1107,7 +1107,7 @@ static void ext2_commit_super (struct super_block * sb,
 {
 	es->s_wtime = cpu_to_le32(get_seconds());
 	mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 }
 
 static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
@@ -1117,7 +1117,7 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
 	es->s_wtime = cpu_to_le32(get_seconds());
 	mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
 	sync_dirty_buffer(EXT2_SB(sb)->s_sbh);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 }
 
 /*
@@ -1148,7 +1148,7 @@ void ext2_write_super (struct super_block * sb)
 		} else
 			ext2_commit_super (sb, es);
 	}
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	unlock_kernel();
 }
 
fs/ext2/xattr.c +1 -1
index 7913531..1673ee4 100644
@@ -343,7 +343,7 @@ static void ext2_xattr_update_super_block(struct super_block *sb)
 		return;
 
 	EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
 }
 
Signature · 1 line
1.6.0.6
#7 lore raw

PATCH 7/19 FAT: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] FAT: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/fat/fatent.c |    8 ++++----
 fs/fat/inode.c  |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/fat/fatent.c +4 -4
index da6eea4..fa19a9d 100644
@@ -495,7 +495,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
 				sbi->prev_free = entry;
 				if (sbi->free_clusters != -1)
 					sbi->free_clusters--;
-				sb->s_dirt = 1;
+				mark_sb_dirty(sb);
 
 				cluster[idx_clus] = entry;
 				idx_clus++;
@@ -517,7 +517,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
 	/* Couldn't allocate the free entries */
 	sbi->free_clusters = 0;
 	sbi->free_clus_valid = 1;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	err = -ENOSPC;
 
 out:
@@ -578,7 +578,7 @@ int fat_free_clusters(struct inode *inode, int cluster)
 		ops->ent_put(&fatent, FAT_ENT_FREE);
 		if (sbi->free_clusters != -1) {
 			sbi->free_clusters++;
-			sb->s_dirt = 1;
+			mark_sb_dirty(sb);
 		}
 
 		if (nr_bhs + fatent.nr_bhs > MAX_BUF_PER_PAGE) {
@@ -668,7 +668,7 @@ int fat_count_free_clusters(struct super_block *sb)
 	}
 	sbi->free_clusters = free;
 	sbi->free_clus_valid = 1;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	fatent_brelse(&fatent);
 out:
 	unlock_fat(sbi);
fs/fat/inode.c +2 -2
index 2292cbf..f3b6410 100644
@@ -442,7 +442,7 @@ static void fat_clear_inode(struct inode *inode)
 static void fat_write_super(struct super_block *sb)
 {
 	lock_super(sb);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 
 	if (!(sb->s_flags & MS_RDONLY))
 		fat_clusters_flush(sb);
@@ -455,7 +455,7 @@ static void fat_put_super(struct super_block *sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		fat_write_super(sb);
 
 	if (sbi->nls_disk) {
Signature · 1 line
1.6.0.6
#8 lore raw

PATCH 8/19 HFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] HFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/hfs/extent.c |    2 +-
 fs/hfs/hfs_fs.h |    2 +-
 fs/hfs/inode.c  |    6 +++---
 fs/hfs/super.c  |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)
fs/hfs/extent.c +1 -1
index 2c16316..bff476a 100644
@@ -432,7 +432,7 @@ out:
 		if (inode->i_ino < HFS_FIRSTUSER_CNID)
 			set_bit(HFS_FLG_ALT_MDB_DIRTY, &HFS_SB(sb)->flags);
 		set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 	}
 	return res;
 
fs/hfs/hfs_fs.h +1 -1
index 052387e..3b6631f 100644
@@ -251,7 +251,7 @@ static inline const char *hfs_mdb_name(struct super_block *sb)
 static inline void hfs_bitmap_dirty(struct super_block *sb)
 {
 	set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 }
 
 static inline void hfs_buffer_sync(struct buffer_head *bh)
fs/hfs/inode.c +3 -3
index a1cbff2..b87dcf0 100644
@@ -198,7 +198,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)
 	insert_inode_hash(inode);
 	mark_inode_dirty(inode);
 	set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	return inode;
 }
@@ -213,7 +213,7 @@ void hfs_delete_inode(struct inode *inode)
 		if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
 			HFS_SB(sb)->root_dirs--;
 		set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 		return;
 	}
 	HFS_SB(sb)->file_count--;
@@ -226,7 +226,7 @@ void hfs_delete_inode(struct inode *inode)
 		}
 	}
 	set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 }
 
 void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
fs/hfs/super.c +2 -2
index 3aac417..6b84117 100644
@@ -50,7 +50,7 @@ MODULE_LICENSE("GPL");
 static void hfs_write_super(struct super_block *sb)
 {
 	lock_super(sb);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 
 	/* sync everything to the buffers */
 	if (!(sb->s_flags & MS_RDONLY))
@@ -69,7 +69,7 @@ static void hfs_put_super(struct super_block *sb)
 {
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		hfs_write_super(sb);
 	hfs_mdb_close(sb);
 	/* release the MDB's resources */
Signature · 1 line
1.6.0.6
#0 lore raw

cover periodic write-back timer optimization

Hi,

This is the second attempt. The first one was here:
http://marc.info/?l=linux-fsdevel&m=124301072305588&w=2
It was very hacky and got no comments.

Here is a cleaner set of patches. They attempt to optimize the periodic write-back and stop it when there are no dirty data. At the moment "pdflush" thread wakes up every 5 seconds (by default). Even if there are no dirty data, it still wakes up. In the embedded world this means that power consumption is higher, because the pdflush makes the CPU to leave low power consumption/retention mode every 5 seconds.

The patch set consists of 2 parts. Patches 01-17 are rather mechanical. They simply introduce 3 VFS helpers which encapsulate the 'sb->s_dirt' handling, so file-systems do not manipulate it directly, but rather use VFS helpers for this.

Patch 18 is just a simple preparation for patch 19.

Patch 19 introduces a global 'periodic_wb_enabled' flag. Then it adds few code to the 'mark_sb_dirty()' and the '__mark_inode_dirty(); function. This code enables the periodic write-back if it is disabled. I tried to make this additional code light-weight.

The periodic WB function, in turn, checks whether there is dirt. If there is, it sets the 'wb_timer' for itself. Otherwise, it just deletes the timer. Should something become dirty, it will be woken up again.

This is still RFC.

Signature · 6 lines
Best Regards,
Artem Bityutskiy (�ртём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH 9/19 HFSPLUS: do not manipulate s_dirt directly

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] HFSPLUS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/hfsplus/bitmap.c |    4 ++--
 fs/hfsplus/dir.c    |    2 +-
 fs/hfsplus/inode.c  |    6 +++---
 fs/hfsplus/super.c  |   14 +++++++-------
 4 files changed, 13 insertions(+), 13 deletions(-)
fs/hfsplus/bitmap.c +2 -2
index ea30afc..345b0e3 100644
@@ -151,7 +151,7 @@ done:
 	kunmap(page);
 	*max = offset + (curr - pptr) * 32 + i - start;
 	HFSPLUS_SB(sb).free_blocks -= *max;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
 out:
 	mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
@@ -225,7 +225,7 @@ out:
 	set_page_dirty(page);
 	kunmap(page);
 	HFSPLUS_SB(sb).free_blocks += len;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
 
 	return 0;
fs/hfsplus/dir.c +1 -1
index 5f40236..71868b5 100644
@@ -305,7 +305,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
 	inode->i_ctime = CURRENT_TIME_SEC;
 	mark_inode_dirty(inode);
 	HFSPLUS_SB(sb).file_count++;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	return 0;
 }
fs/hfsplus/inode.c +3 -3
index 1bcf597..76fe933 100644
@@ -333,7 +333,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
 		HFSPLUS_SB(sb).file_count++;
 	insert_inode_hash(inode);
 	mark_inode_dirty(inode);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	return inode;
 }
@@ -344,7 +344,7 @@ void hfsplus_delete_inode(struct inode *inode)
 
 	if (S_ISDIR(inode->i_mode)) {
 		HFSPLUS_SB(sb).folder_count--;
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 		return;
 	}
 	HFSPLUS_SB(sb).file_count--;
@@ -357,7 +357,7 @@ void hfsplus_delete_inode(struct inode *inode)
 		inode->i_size = 0;
 		hfsplus_file_truncate(inode);
 	}
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 }
 
 void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
fs/hfsplus/super.c +7 -7
index 1aab8aa..4be3653 100644
@@ -104,7 +104,7 @@ static int hfsplus_write_inode(struct inode *inode, int unused)
 	case HFSPLUS_EXT_CNID:
 		if (vhdr->ext_file.total_size != cpu_to_be64(inode->i_size)) {
 			HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
-			inode->i_sb->s_dirt = 1;
+			mark_sb_dirty(inode->i_sb);
 		}
 		hfsplus_inode_write_fork(inode, &vhdr->ext_file);
 		hfs_btree_write(HFSPLUS_SB(inode->i_sb).ext_tree);
@@ -112,7 +112,7 @@ static int hfsplus_write_inode(struct inode *inode, int unused)
 	case HFSPLUS_CAT_CNID:
 		if (vhdr->cat_file.total_size != cpu_to_be64(inode->i_size)) {
 			HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
-			inode->i_sb->s_dirt = 1;
+			mark_sb_dirty(inode->i_sb);
 		}
 		hfsplus_inode_write_fork(inode, &vhdr->cat_file);
 		hfs_btree_write(HFSPLUS_SB(inode->i_sb).cat_tree);
@@ -120,21 +120,21 @@ static int hfsplus_write_inode(struct inode *inode, int unused)
 	case HFSPLUS_ALLOC_CNID:
 		if (vhdr->alloc_file.total_size != cpu_to_be64(inode->i_size)) {
 			HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
-			inode->i_sb->s_dirt = 1;
+			mark_sb_dirty(inode->i_sb);
 		}
 		hfsplus_inode_write_fork(inode, &vhdr->alloc_file);
 		break;
 	case HFSPLUS_START_CNID:
 		if (vhdr->start_file.total_size != cpu_to_be64(inode->i_size)) {
 			HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
-			inode->i_sb->s_dirt = 1;
+			mark_sb_dirty(inode->i_sb);
 		}
 		hfsplus_inode_write_fork(inode, &vhdr->start_file);
 		break;
 	case HFSPLUS_ATTR_CNID:
 		if (vhdr->attr_file.total_size != cpu_to_be64(inode->i_size)) {
 			HFSPLUS_SB(inode->i_sb).flags |= HFSPLUS_SB_WRITEBACKUP;
-			inode->i_sb->s_dirt = 1;
+			mark_sb_dirty(inode->i_sb);
 		}
 		hfsplus_inode_write_fork(inode, &vhdr->attr_file);
 		hfs_btree_write(HFSPLUS_SB(inode->i_sb).attr_tree);
@@ -159,7 +159,7 @@ static void hfsplus_write_super(struct super_block *sb)
 	dprint(DBG_SUPER, "hfsplus_write_super\n");
 
 	lock_super(sb);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	if (sb->s_flags & MS_RDONLY)
 		/* warn? */
 		goto out;
@@ -206,7 +206,7 @@ static void hfsplus_put_super(struct super_block *sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		hfsplus_write_super(sb);
 	if (!(sb->s_flags & MS_RDONLY) && HFSPLUS_SB(sb).s_vhdr) {
 		struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
Signature · 1 line
1.6.0.6
#10 lore raw

PATCH 10/19 JFFS2: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] JFFS2: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/jffs2/os-linux.h |    2 +-
 fs/jffs2/super.c    |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/jffs2/os-linux.h +1 -1
index 2228380..ad12212 100644
@@ -147,7 +147,7 @@ void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c);
 /* erase.c */
 static inline void jffs2_erase_pending_trigger(struct jffs2_sb_info *c)
 {
-	OFNI_BS_2SFFJ(c)->s_dirt = 1;
+	mark_sb_dirty(OFNI_BS_2SFFJ(c));
 }
 
 /* background.c */
fs/jffs2/super.c +2 -2
index f7bfd3a..5b321fa 100644
@@ -58,7 +58,7 @@ static void jffs2_write_super(struct super_block *sb)
 	struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
 
 	lock_super(sb);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 
 	if (!(sb->s_flags & MS_RDONLY)) {
 		D1(printk(KERN_DEBUG "jffs2_write_super()\n"));
@@ -193,7 +193,7 @@ static void jffs2_put_super (struct super_block *sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		jffs2_write_super(sb);
 
 	mutex_lock(&c->alloc_sem);
Signature · 1 line
1.6.0.6
#11 lore raw

PATCH 11/19 NILFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] NILFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/nilfs2/segment.c   |    2 +-
 fs/nilfs2/super.c     |   18 +++++++++---------
 fs/nilfs2/the_nilfs.c |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)
fs/nilfs2/segment.c +1 -1
index fb70ec3..0dcac79 100644
@@ -2069,7 +2069,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
 	if (update_sr) {
 		nilfs_set_last_segment(nilfs, segbuf->sb_pseg_start,
 				       segbuf->sb_sum.seg_seq, nilfs->ns_cno++);
-		sbi->s_super->s_dirt = 1;
+		mark_sb_dirty(sbi->s_super);
 
 		clear_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags);
 		clear_bit(NILFS_SC_DIRTY, &sci->sc_flags);
fs/nilfs2/super.c +9 -9
index 7262e84..6f3707b 100644
@@ -307,7 +307,7 @@ int nilfs_commit_super(struct nilfs_sb_info *sbi, int dupsb)
 		memcpy(sbp[1], sbp[0], nilfs->ns_sbsize);
 		nilfs->ns_sbwtime[1] = t;
 	}
-	sbi->s_super->s_dirt = 0;
+	mark_sb_clean(sbi->s_super);
 	return nilfs_sync_super(sbi, dupsb);
 }
 
@@ -318,7 +318,7 @@ static void nilfs_put_super(struct super_block *sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		nilfs_write_super(sb);
 
 	nilfs_detach_segment_constructor(sbi);
@@ -344,17 +344,17 @@ static void nilfs_put_super(struct super_block *sb)
  * @sb: super_block
  *
  * nilfs_write_super() gets a fs-dependent lock, writes super block(s), and
- * clears s_dirt.  This function is called in the section protected by
- * lock_super().
+ * clears the superblock.  This function is called in the section protected
+ * by lock_super().
  *
- * The s_dirt flag is managed by each filesystem and we protect it by ns_sem
- * of the struct the_nilfs.  Lock order must be as follows:
+ * The super block s_dirt flag is managed by each filesystem and we protect
+ * it by ns_sem of the struct the_nilfs.  Lock order must be as follows:
  *
  *   1. lock_super()
  *   2.    down_write(&nilfs->ns_sem)
  *
- * Inside NILFS, locking ns_sem is enough to protect s_dirt and the buffer
- * of the super block (nilfs->ns_sbp[]).
+ * Inside NILFS, locking ns_sem is enough to protect the super block s_dirt
+ * and the buffer of the super block (nilfs->ns_sbp[]).
  *
  * In most cases, VFS functions call lock_super() before calling these
  * methods.  So we must be careful not to bring on deadlocks when using
@@ -383,7 +383,7 @@ static void nilfs_write_super(struct super_block *sb)
 		dupsb = sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ;
 		nilfs_commit_super(sbi, dupsb);
 	}
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	up_write(&nilfs->ns_sem);
 }
 
fs/nilfs2/the_nilfs.c +1 -1
index 7f65b3b..5b02f50 100644
@@ -278,7 +278,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
 			goto failed;
 		}
 		if (ri.ri_need_recovery == NILFS_RECOVERY_SR_UPDATED)
-			sbi->s_super->s_dirt = 1;
+			mark_sb_dirty(sbi->s_super);
 	}
 
 	set_nilfs_loaded(nilfs);
Signature · 1 line
1.6.0.6
#12 lore raw

PATCH 12/19 reiserfs: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] reiserfs: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/reiserfs/journal.c |    6 +++---
 fs/reiserfs/resize.c  |    2 +-
 fs/reiserfs/super.c   |   10 +++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)
fs/reiserfs/journal.c +3 -3
index 77f5bb7..1d2fb0e 100644
@@ -3259,7 +3259,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
 			       th->t_trans_id, journal->j_trans_id);
 	}
 
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	prepared = test_clear_buffer_journal_prepared(bh);
 	clear_buffer_journal_restore_dirty(bh);
@@ -3554,7 +3554,7 @@ int reiserfs_flush_old_commits(struct super_block *sb)
 			do_journal_end(&th, sb, 1, COMMIT_NOW | WAIT);
 		}
 	}
-	return sb->s_dirt;
+	return sb_is_dirty(sb);
 }
 
 /*
@@ -3984,7 +3984,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
 	 ** it tells us if we should continue with the journal_end, or just return
 	 */
 	if (!check_journal_end(th, sb, nblocks, flags)) {
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 		wake_queued_writers(sb);
 		reiserfs_async_progress_wait(sb);
 		goto out;
fs/reiserfs/resize.c +1 -1
index 238e9d9..9157d38 100644
@@ -202,7 +202,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
 					  (bmap_nr_new - bmap_nr)));
 	PUT_SB_BLOCK_COUNT(s, block_count_new);
 	PUT_SB_BMAP_NR(s, bmap_would_wrap(bmap_nr_new) ? : bmap_nr_new);
-	s->s_dirt = 1;
+	mark_sb_dirty(s);
 
 	journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
 
fs/reiserfs/super.c +5 -5
index 90dcb7b..f45c78f 100644
@@ -70,8 +70,8 @@ static int reiserfs_sync_fs(struct super_block *s, int wait)
 	if (!journal_begin(&th, s, 1))
 		if (!journal_end_sync(&th, s, 1))
 			reiserfs_flush_old_commits(s);
-	s->s_dirt = 0;	/* Even if it's not true.
-			 * We'll loop forever in sync_supers otherwise */
+	mark_sb_clean(s); /* Even if it's not true.
+			   * We'll loop forever in sync_supers otherwise */
 	reiserfs_write_unlock(s);
 	return 0;
 }
@@ -97,7 +97,7 @@ static int reiserfs_freeze(struct super_block *s)
 			journal_end_sync(&th, s, 1);
 		}
 	}
-	s->s_dirt = 0;
+	mark_sb_clean(s);
 	reiserfs_write_unlock(s);
 	return 0;
 }
@@ -467,7 +467,7 @@ static void reiserfs_put_super(struct super_block *s)
 
 	lock_kernel();
 
-	if (s->s_dirt)
+	if (sb_is_dirty(s))
 		reiserfs_write_super(s);
 
 	/* change file system state to current state if it was mounted with read-write permissions */
@@ -1309,7 +1309,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 	err = journal_end(&th, s, 10);
 	if (err)
 		goto out_err;
-	s->s_dirt = 0;
+	mark_sb_clean(s);
 
 	if (!(*mount_flags & MS_RDONLY)) {
 		finish_unfinished(s);
Signature · 1 line
1.6.0.6
#13 lore raw

PATCH 13/19 SYSV: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] SYSV: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/sysv/inode.c |    8 ++++----
 fs/sysv/super.c |    2 +-
 fs/sysv/sysv.h  |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
fs/sysv/inode.c +4 -4
index a3f45fc..3c5ea5c 100644
@@ -31,7 +31,7 @@
 #include <asm/byteorder.h>
 #include "sysv.h"
 
-/* This is only called on sync() and umount(), when s_dirt=1. */
+/* This is only called on sync() and umount(), when the super block is dirty. */
 static void sysv_write_super(struct super_block *sb)
 {
 	struct sysv_sb_info *sbi = SYSV_SB(sb);
@@ -55,7 +55,7 @@ static void sysv_write_super(struct super_block *sb)
 		mark_buffer_dirty(sbi->s_bh2);
 	}
 clean:
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	unlock_kernel();
 	unlock_super(sb);
 }
@@ -67,7 +67,7 @@ static int sysv_remount(struct super_block *sb, int *flags, char *data)
 	if (sbi->s_forced_ro)
 		*flags |= MS_RDONLY;
 	if (!(*flags & MS_RDONLY))
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 	unlock_super(sb);
 	return 0;
 }
@@ -78,7 +78,7 @@ static void sysv_put_super(struct super_block *sb)
 
 	lock_kernel();
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		sysv_write_super(sb);
 
 	if (!(sb->s_flags & MS_RDONLY)) {
fs/sysv/super.c +1 -1
index 5a903da..f0d3679 100644
@@ -347,7 +347,7 @@ static int complete_read_super(struct super_block *sb, int silent, int size)
 		sb->s_flags |= MS_RDONLY;
 	if (sbi->s_truncate)
 		sb->s_root->d_op = &sysv_dentry_operations;
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	return 1;
 }
 
fs/sysv/sysv.h +1 -1
index 5784a31..4d1b784 100644
@@ -118,7 +118,7 @@ static inline void dirty_sb(struct super_block *sb)
 	mark_buffer_dirty(sbi->s_bh1);
 	if (sbi->s_bh1 != sbi->s_bh2)
 		mark_buffer_dirty(sbi->s_bh2);
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 }
 
 
Signature · 1 line
1.6.0.6
#14 lore raw

PATCH 14/19 UDF: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] UDF: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/udf/super.c   |    6 +++---
 fs/udf/udfdecl.h |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/udf/super.c +3 -3
index e2e06b0..7926436 100644
@@ -1908,7 +1908,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	sb->s_op = &udf_sb_ops;
 	sb->s_export_op = &udf_export_ops;
 	sb->dq_op = NULL;
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	sb->s_magic = UDF_SUPER_MAGIC;
 	sb->s_time_gran = 1000;
 
@@ -2035,7 +2035,7 @@ static void udf_error(struct super_block *sb, const char *function,
 
 	if (!(sb->s_flags & MS_RDONLY)) {
 		/* mark sb error */
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 	}
 	va_start(args, fmt);
 	vsnprintf(error_buf, sizeof(error_buf), fmt, args);
@@ -2095,7 +2095,7 @@ static int udf_sync_fs(struct super_block *sb, int wait)
 		 * the buffer for IO
 		 */
 		mark_buffer_dirty(sbi->s_lvid_bh);
-		sb->s_dirt = 0;
+		mark_sb_clean(sb);
 		sbi->s_lvid_dirty = 0;
 	}
 	mutex_unlock(&sbi->s_alloc_mutex);
fs/udf/udfdecl.h +1 -1
index cac51b7..8ad1818 100644
@@ -119,7 +119,7 @@ static inline void udf_updated_lvid(struct super_block *sb)
 	WARN_ON_ONCE(((struct logicalVolIntegrityDesc *)
 		     bh->b_data)->integrityType !=
 		     cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN));
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	UDF_SB(sb)->s_lvid_dirty = 1;
 }
 
Signature · 1 line
1.6.0.6
#15 lore raw

PATCH 15/19 UFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] UFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/ufs/balloc.c |    8 ++++----
 fs/ufs/ialloc.c |    4 ++--
 fs/ufs/super.c  |   10 +++++-----
 3 files changed, 11 insertions(+), 11 deletions(-)
fs/ufs/balloc.c +4 -4
index 54c16ec..71a6971 100644
@@ -122,7 +122,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)
 		ubh_ll_rw_block(SWRITE, UCPI_UBH(ucpi));
 		ubh_wait_on_buffer (UCPI_UBH(ucpi));
 	}
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	
 	unlock_super (sb);
 	UFSD("EXIT\n");
@@ -223,7 +223,7 @@ do_more:
 		goto do_more;
 	}
 
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	unlock_super (sb);
 	UFSD("EXIT\n");
 	return;
@@ -571,7 +571,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
 		ubh_ll_rw_block(SWRITE, UCPI_UBH(ucpi));
 		ubh_wait_on_buffer (UCPI_UBH(ucpi));
 	}
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	UFSD("EXIT, fragment %llu\n", (unsigned long long)fragment);
 	
@@ -698,7 +698,7 @@ succed:
 		ubh_ll_rw_block(SWRITE, UCPI_UBH(ucpi));
 		ubh_wait_on_buffer (UCPI_UBH(ucpi));
 	}
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	result += cgno * uspi->s_fpg;
 	UFSD("EXIT3, result %llu\n", (unsigned long long)result);
fs/ufs/ialloc.c +2 -2
index 3527c00..b33cfe6 100644
@@ -124,7 +124,7 @@ void ufs_free_inode (struct inode * inode)
 		ubh_wait_on_buffer (UCPI_UBH(ucpi));
 	}
 	
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	unlock_super (sb);
 	UFSD("EXIT\n");
 }
@@ -300,7 +300,7 @@ cg_found:
 		ubh_ll_rw_block(SWRITE, UCPI_UBH(ucpi));
 		ubh_wait_on_buffer (UCPI_UBH(ucpi));
 	}
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 
 	inode->i_ino = cg * uspi->s_ipg + bit;
 	inode->i_mode = mode;
fs/ufs/super.c +5 -5
index c97210e..0316f83 100644
@@ -237,7 +237,7 @@ void ufs_error (struct super_block * sb, const char * function,
 	if (!(sb->s_flags & MS_RDONLY)) {
 		usb1->fs_clean = UFS_FSBAD;
 		ubh_mark_buffer_dirty(USPI_UBH(uspi));
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 		sb->s_flags |= MS_RDONLY;
 	}
 	va_start (args, fmt);
@@ -269,7 +269,7 @@ void ufs_panic (struct super_block * sb, const char * function,
 	if (!(sb->s_flags & MS_RDONLY)) {
 		usb1->fs_clean = UFS_FSBAD;
 		ubh_mark_buffer_dirty(USPI_UBH(uspi));
-		sb->s_dirt = 1;
+		mark_sb_dirty(sb);
 	}
 	va_start (args, fmt);
 	vsnprintf (error_buf, sizeof(error_buf), fmt, args);
@@ -1148,7 +1148,7 @@ static void ufs_write_super(struct super_block *sb)
 					UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time));
 		ufs_put_cstotal(sb);
 	}
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 	UFSD("EXIT\n");
 	unlock_kernel();
 	unlock_super(sb);
@@ -1160,7 +1160,7 @@ static void ufs_put_super(struct super_block *sb)
 		
 	UFSD("ENTER\n");
 
-	if (sb->s_dirt)
+	if (sb_is_dirty(sb))
 		ufs_write_super(sb);
 
 	if (!(sb->s_flags & MS_RDONLY))
@@ -1226,7 +1226,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
 			ufs_set_fs_state(sb, usb1, usb3,
 				UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time));
 		ubh_mark_buffer_dirty (USPI_UBH(uspi));
-		sb->s_dirt = 0;
+		mark_sb_clean(sb);
 		sb->s_flags |= MS_RDONLY;
 	} else {
 	/*
Signature · 1 line
1.6.0.6
#17 lore raw

PATCH 17/19 VFS: use sb_is_dirty helper

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] VFS: use sb_is_dirty helper

... instead of checking 's_dirt' directly. This is just a little cleaner and more consistent. We have only 3 VFS helpers which access 's_dirt' now.

Cc Christoph Hellwig <[email protected]>
---
 fs/super.c |    4 ++--
 fs/sync.c  |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/super.c +2 -2
index 2ea1586..ef9a24a 100644
@@ -415,12 +415,12 @@ void sync_supers(void)
 	spin_lock(&sb_lock);
 restart:
 	list_for_each_entry(sb, &super_blocks, s_list) {
-		if (sb->s_op->write_super && sb->s_dirt) {
+		if (sb->s_op->write_super && sb_is_dirty(sb)) {
 			sb->s_count++;
 			spin_unlock(&sb_lock);
 
 			down_read(&sb->s_umount);
-			if (sb->s_root && sb->s_dirt)
+			if (sb->s_root && sb_is_dirty(sb))
 				sb->s_op->write_super(sb);
 			up_read(&sb->s_umount);
 
fs/sync.c +2 -2
index e9d56f6..12f36d7 100644
@@ -33,7 +33,7 @@ static int __sync_filesystem(struct super_block *sb, int wait)
 	else
 		sync_quota_sb(sb, -1);
 	sync_inodes_sb(sb, wait);
-	if (sb->s_dirt && sb->s_op->write_super)
+	if (sb_is_dirty(sb) && sb->s_op->write_super)
 		sb->s_op->write_super(sb);
 	if (sb->s_op->sync_fs)
 		sb->s_op->sync_fs(sb, wait);
@@ -162,7 +162,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
 
 	/* sync the superblock to buffers */
 	sb = inode->i_sb;
-	if (sb->s_dirt && sb->s_op->write_super)
+	if (sb_is_dirty(sb) && sb->s_op->write_super)
 		sb->s_op->write_super(sb);
 
 	/* .. finally sync the buffers to disk */
Signature · 1 line
1.6.0.6
#16 lore raw

PATCH 16/19 XFS: do not manipulate s_dirt directly

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] XFS: do not manipulate s_dirt directly

... use new VFS helpers instead.

Cc Christoph Hellwig <[email protected]>
---
 fs/xfs/linux-2.6/xfs_super.c |    6 +++---
 fs/xfs/xfs_trans.c           |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/xfs/linux-2.6/xfs_super.c +3 -3
index d29218e..4c25456 100644
@@ -1114,7 +1114,7 @@ xfs_fs_write_super(
 {
 	if (!(sb->s_flags & MS_RDONLY))
 		xfs_sync_fsdata(XFS_M(sb), 0);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 }
 
 STATIC int
@@ -1141,7 +1141,7 @@ xfs_fs_sync_super(
 		error = xfs_quiesce_data(mp);
 	else
 		error = xfs_sync_fsdata(mp, 0);
-	sb->s_dirt = 0;
+	mark_sb_clean(sb);
 
 	if (unlikely(laptop_mode)) {
 		int	prev_sync_seq = mp->m_sync_seq;
@@ -1447,7 +1447,7 @@ xfs_fs_fill_super(
 
 	XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
 
-	sb->s_dirt = 1;
+	mark_sb_dirty(sb);
 	sb->s_magic = XFS_SB_MAGIC;
 	sb->s_blocksize = mp->m_sb.sb_blocksize;
 	sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
fs/xfs/xfs_trans.c +1 -1
index 8570b82..2552bae 100644
@@ -629,7 +629,7 @@ xfs_trans_apply_sb_deltas(
 				  offsetof(xfs_dsb_t, sb_frextents) +
 				  sizeof(sbp->sb_frextents) - 1);
 
-	tp->t_mountp->m_super->s_dirt = 1;
+	mark_sb_dirty(tp->t_mountp->m_super);
 }
 
 /*
Signature · 1 line
1.6.0.6
#19 lore raw

PATCH 19/19 periodic write-back: do not wake up unnecessarily

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] periodic write-back: do not wake up unnecessarily

This patch is an optimization which is targeted to lessen power consumption.

At the moment the periodic write-back thread (pdflush) is woken up every 5 seconds (by default). It wake up and writes back old dirty dirty data. And even if there are no dirty data, the thread keeps waking up to find no dirty data. And it repeats this every 5 seconds.

This patch makes the periodic write-back thread wake up only when there are dirty data. Otherwise it just sleeps and does not disturb CPU. Indeed, CPU may be resting in a low frequency and low power consumption mode - why do we have to distract it unnecessarily?

Cc Christoph Hellwig <[email protected]>
---
 fs/fs-writeback.c   |   41 ++++++++++++++++++++++++++++
 include/linux/fs.h  |    7 ++---
 mm/page-writeback.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 114 insertions(+), 8 deletions(-)
fs/fs-writeback.c +41 -0
index e0fb2e7..133944c 100644
@@ -65,6 +65,24 @@ static void writeback_release(struct backing_dev_info *bdi)
 }
 
 /**
+ * enable_pwb - enable periodic write-back after an inode was marked as dirty.
+ * @inode: the inode which was marked as dirty
+ *
+ * This is a helper function for '__mark_inode_dirty()' which enables the
+ * periodic write-back, unless:
+ *   * the backing device @inode belongs to does not support write-back;
+ *   * periodic write-back is already enabled.
+ */
+static void enable_pwb(struct inode *inode)
+{
+	struct backing_dev_info *bdi = inode->i_mapping->backing_dev_info;
+
+	if (bdi_cap_writeback_dirty(bdi) &&
+	    atomic_add_unless(&periodic_wb_enabled, 1, 1))
+		enable_periodic_wb();
+}
+
+/**
  *	__mark_inode_dirty -	internal function
  *	@inode: inode to mark
  *	@flags: what kind of dirty (i.e. I_DIRTY_SYNC)
@@ -164,6 +182,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
 		if (!was_dirty) {
 			inode->dirtied_when = jiffies;
 			list_move(&inode->i_list, &sb->s_dirty);
+			enable_pwb(inode);
 		}
 	}
 out:
@@ -172,6 +191,28 @@ out:
 
 EXPORT_SYMBOL(__mark_inode_dirty);
 
+/**
+ * mark_sb_dirty - mark super block as dirty.
+ * @sb: the super block to mark as dirty
+ *
+ * This function marks super block @sb as dirty and enables the periodic
+ * write-back, unless it is already enabled. Note, VFS does not serialize the
+ * super block clean/dirty (@sb->s_dirt) state changes, and each FS is
+ * responsible for doing its own serialization.
+ */
+void mark_sb_dirty(struct super_block *sb)
+{
+	sb->s_dirt = 1;
+	/*
+	 * If 'periodic_wb_enabled' is 0, set it to 1 and enable the periodic
+	 * write-back.
+	 */
+	if (atomic_add_unless(&periodic_wb_enabled, 1, 1))
+		enable_periodic_wb();
+}
+
+EXPORT_SYMBOL(mark_sb_dirty);
+
 static int write_inode(struct inode *inode, int sync)
 {
 	if (inode->i_sb->s_op->write_inode && !is_bad_inode(inode))
include/linux/fs.h +3 -4
index 437939c..230e308 100644
@@ -1782,10 +1782,9 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
 extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
 int __put_super_and_need_restart(struct super_block *sb);
 
-static inline void mark_sb_dirty(struct super_block *sb)
-{
-	sb->s_dirt = 1;
-}
+extern atomic_t periodic_wb_enabled;
+extern void enable_periodic_wb(void);
+extern void mark_sb_dirty(struct super_block *sb);
 static inline void mark_sb_clean(struct super_block *sb)
 {
 	sb->s_dirt = 0;
mm/page-writeback.c +70 -4

92 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#18 lore raw

PATCH 18/19 write-back: introduce a helper function

In reply to Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] write-back: introduce a helper function

This patch is just a clean up and a preparation for the following periodic write-back optimization patches. It introduces a helper 'setup_wb_timer()' function which sets up the periodic write-back timer to the specified value, or to the default value. The code just looks neater with this helper.

Cc Christoph Hellwig <[email protected]>
---
 mm/page-writeback.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
mm/page-writeback.c +19 -6
index 30351f0..8a213a9 100644
@@ -738,6 +738,21 @@ static DEFINE_TIMER(wb_timer, wb_timer_fn, 0, 0);
 static DEFINE_TIMER(laptop_mode_wb_timer, laptop_timer_fn, 0, 0);
 
 /*
+ * Setup the periodic write-back timer to expires at @expires jiffies. If
+ * @expires is zero, the timer is set up to the default interval.
+ */
+static void setup_wb_timer(unsigned long expires)
+{
+	if (!expires) {
+		/* Setup to the default wake-up period value */
+		expires = jiffies;
+		expires += msecs_to_jiffies(dirty_writeback_interval * 10);
+	}
+
+	mod_timer(&wb_timer, expires);
+}
+
+/*
  * Periodic writeback of "old" data.
  *
  * Define "old": the first time one of an inode's pages is dirtied, we mark the
@@ -792,7 +807,7 @@ static void wb_kupdate(unsigned long arg)
 	if (time_before(next_jif, jiffies + HZ))
 		next_jif = jiffies + HZ;
 	if (dirty_writeback_interval)
-		mod_timer(&wb_timer, next_jif);
+		setup_wb_timer(next_jif);
 }
 
 /*
@@ -803,8 +818,7 @@ int dirty_writeback_centisecs_handler(ctl_table *table, int write,
 {
 	proc_dointvec(table, write, file, buffer, length, ppos);
 	if (dirty_writeback_interval)
-		mod_timer(&wb_timer, jiffies +
-			msecs_to_jiffies(dirty_writeback_interval * 10));
+		setup_wb_timer(0);
 	else
 		del_timer(&wb_timer);
 	return 0;
@@ -813,7 +827,7 @@ int dirty_writeback_centisecs_handler(ctl_table *table, int write,
 static void wb_timer_fn(unsigned long unused)
 {
 	if (pdflush_operation(wb_kupdate, 0) < 0)
-		mod_timer(&wb_timer, jiffies + HZ); /* delay 1 second */
+		setup_wb_timer( jiffies + HZ); /* delay 1 second */
 }
 
 static void laptop_flush(unsigned long unused)
@@ -906,8 +920,7 @@ void __init page_writeback_init(void)
 {
 	int shift;
 
-	mod_timer(&wb_timer,
-		  jiffies + msecs_to_jiffies(dirty_writeback_interval * 10));
+	setup_wb_timer(0);
 	writeback_set_ratelimit();
 	register_cpu_notifier(&ratelimit_nb);
 
Signature · 1 line
1.6.0.6
#21 lore raw
Quoted 10 lines · ext Arnd Bergmann
Quoted 5 lines · Artem Bityutskiy

Hi,

This is the second attempt. The first one was here:
http://marc.info/?l=linux-fsdevel&m=124301072305588&w=2
It was very hacky and got no comments.

How does this relate to the per-BDI writeback patches that Jens is working on? Doesn't that require a completely different (probably simpler) implementation of your patch?

At a quick glance, our works do not intersect. He seems to be changing the guts of write-back, while I only touch the timer which wakes up the periodic write-back thread, nothing else. I'll try to take Jens' patches and see.

Signature · 6 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#22 lore raw
Quoted 8 lines · Artem Bityutskiy
Quoted 7 lines · ext Arnd Bergmann
Quoted 5 lines · Artem Bityutskiy

Hi,

This is the second attempt. The first one was here:
http://marc.info/?l=linux-fsdevel&m=124301072305588&w=2
It was very hacky and got no comments.

Quoted 8 lines
Quoted 3 lines

How does this relate to the per-BDI writeback patches that Jens is working on? Doesn't that require a completely different (probably simpler) implementation of your patch?

At a quick glance, our works do not intersect. He seems to be changing the guts of write-back, while I only touch the timer which wakes up the periodic write-back thread, nothing else. I'll try to take Jens' patches and see.

There's definitely overlap! The timer is gone with my patches and so is pdflush. For an idle (idle here meaning no background writeback activity) system, there should just be bdi-default running. And that will wake up every dirty_writeback_interval by default.

Signature · 1 line
Jens Axboe
#23 lore raw
Quoted 16 lines · Jens Axboe
Quoted 7 lines · Artem Bityutskiy
Quoted 6 lines · ext Arnd Bergmann
Quoted 5 lines · Artem Bityutskiy

Hi,

This is the second attempt. The first one was here:
http://marc.info/?l=linux-fsdevel&m=124301072305588&w=2
It was very hacky and got no comments.

Quoted 7 lines
Quoted 3 lines

How does this relate to the per-BDI writeback patches that Jens is working on? Doesn't that require a completely different (probably simpler) implementation of your patch?

At a quick glance, our works do not intersect. He seems to be changing the guts of write-back, while I only touch the timer which wakes up the periodic write-back thread, nothing else. I'll try to take Jens' patches and see.

Quoted 4 lines

There's definitely overlap! The timer is gone with my patches and so is pdflush. For an idle (idle here meaning no background writeback activity) system, there should just be bdi-default running. And that will wake up every dirty_writeback_interval by default.

Hmm, right. Will be working on top of your patches then.

Signature · 6 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw
Quoted 17 lines · Artem Bityutskiy
Quoted 16 lines · Jens Axboe
Quoted 14 lines · Artem Bityutskiy
Quoted 9 lines · ext Arnd Bergmann
Quoted 5 lines · Artem Bityutskiy

Hi,

This is the second attempt. The first one was here:
http://marc.info/?l=linux-fsdevel&m=124301072305588&w=2
It was very hacky and got no comments.

How does this relate to the per-BDI writeback patches that Jens is working on? Doesn't that require a completely different (probably simpler) implementation of your patch?

At a quick glance, our works do not intersect. He seems to be changing the guts of write-back, while I only touch the timer which wakes up the periodic write-back thread, nothing else. I'll try to take Jens' patches and see.

Quoted 6 lines
Quoted 4 lines

There's definitely overlap! The timer is gone with my patches and so is pdflush. For an idle (idle here meaning no background writeback activity) system, there should just be bdi-default running. And that will wake up every dirty_writeback_interval by default.

Hmm, right. Will be working on top of your patches then.

That would be great, I would have no problem integrating such a feature. It definitely makes sense.

Signature · 1 line
Jens Axboe
#25 lore raw
Quoted 2 lines · Jens Axboe

That would be great, I would have no problem integrating such a feature. It definitely makes sense.

Hi Al, Christoph,

unless you have objections against the whole idea, I wonder if it would be possible to make the patches which wrap sb->s_dirt usage go via VFS tree first, and then I'd continue the timer optimization work separately. IMO, wrapping s_dirt makes sense in general. I mean, patches 01-17 from this series.

Signature · 6 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#26 lore raw
Quoted 11 lines · Artem Bityutskiy
Quoted 2 lines · Jens Axboe

That would be great, I would have no problem integrating such a feature. It definitely makes sense.

Hi Al, Christoph,

unless you have objections against the whole idea, I wonder if it would be possible to make the patches which wrap sb->s_dirt usage go via VFS tree first, and then I'd continue the timer optimization work separately. IMO, wrapping s_dirt makes sense in general. I mean, patches 01-17 from this series.

That makese sense, those are totally separate from the actual functionality.

Signature · 1 line
Jens Axboe
#27 lore raw
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Artem Bityutskiy
Quoted 2 lines · Jens Axboe

That would be great, I would have no problem integrating such a feature. It definitely makes sense.

Hi Al, Christoph,

Quoted 8 lines
Quoted 5 lines

unless you have objections against the whole idea, I wonder if it would be possible to make the patches which wrap sb->s_dirt usage go via VFS tree first, and then I'd continue the timer optimization work separately. IMO, wrapping s_dirt makes sense in general. I mean, patches 01-17 from this series.

That makese sense, those are totally separate from the actual functionality.

Reminding ping.

Signature · 6 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html