Skip to contentSkip to conversation

v3: write_super clean up

PATCH In review Jiro SEKIBA 2 participants 5 messages Jul 22, 2009 1 message not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

cover v3: write_super clean up

Hi, this is re-revised version of write_super clean up patch.

This time, 3rd one removed nilfs_write_super out.

Any comments and suggestions are appreciate.

Thanks,

Regards,

Signature · 6 lines
Jiro SEKIBA <[email protected]>                                                     

 fs/nilfs2/segment.c   |    7 +++++-
 fs/nilfs2/super.c     |   61 +++++++-----------------------------------------
 fs/nilfs2/the_nilfs.h |   14 +++++++++++
 3 files changed, 29 insertions(+), 53 deletions(-)

A message that is not in the archive (sent off-list or not yet received): 1248252323-22959-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org

#2 lore raw

PATCH 1/3 nilfs2: fix disorder of nilfs_write_super in nilfs_sync_fs

fix disorder of nilfs_write_super in nilfs_sync_fs. commiting super block must be the end of the function so that every chanages are reflected.

->sync_fs() is not called frequently so call nilfs_commit_super instead of calling nilfs_write_super.

---
 fs/nilfs2/super.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
fs/nilfs2/super.c +8 -2
index 63ab2d1..13614d8 100644
@@ -384,12 +384,18 @@ static void nilfs_write_super(struct super_block *sb)
 static int nilfs_sync_fs(struct super_block *sb, int wait)
 {
 	int err = 0;
-
-	nilfs_write_super(sb);
+	struct nilfs_sb_info *sbi = NILFS_SB(sb);
+	struct the_nilfs *nilfs = sbi->s_nilfs;
 
 	/* This function is called when super block should be written back */
 	if (wait)
 		err = nilfs_construct_segment(sb);
+
+	down_write(&nilfs->ns_sem);
+	if (sb->s_dirt)
+		nilfs_commit_super(NILFS_SB(sb), 1);
+	up_write(&nilfs->ns_sem);
+
 	return err;
 }
 
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 2/3 nilfs2: clean up nilfs_write_super

In reply to a message not in the archive

Separate conditions that check if syncing super block and alternative super block are required as inline functions to reuse the conditions.

---
 fs/nilfs2/super.c     |   11 +++--------
 fs/nilfs2/the_nilfs.h |   14 ++++++++++++++
 2 files changed, 17 insertions(+), 8 deletions(-)
fs/nilfs2/super.c +3 -8
index 13614d8..02f7a76 100644
@@ -365,17 +365,12 @@ static void nilfs_write_super(struct super_block *sb)
 
 	down_write(&nilfs->ns_sem);
 	if (!(sb->s_flags & MS_RDONLY)) {
-		struct nilfs_super_block **sbp = nilfs->ns_sbp;
-		u64 t = get_seconds();
-		int dupsb;
-
-		if (!nilfs_discontinued(nilfs) && t >= nilfs->ns_sbwtime[0] &&
-		    t < nilfs->ns_sbwtime[0] + NILFS_SB_FREQ) {
+		if (!nilfs_discontinued(nilfs) &&
+		    !nilfs_sb_need_update(nilfs)) {
 			up_write(&nilfs->ns_sem);
 			return;
 		}
-		dupsb = sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ;
-		nilfs_commit_super(sbi, dupsb);
+		nilfs_commit_super(sbi, nilfs_altsb_need_update(nilfs));
 	}
 	sb->s_dirt = 0;
 	up_write(&nilfs->ns_sem);
fs/nilfs2/the_nilfs.h +14 -0
index e8adbff..37f9f35 100644
@@ -202,6 +202,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued)
 #define NILFS_SB_FREQ		10
 #define NILFS_ALTSB_FREQ	60  /* spare superblock */
 
+static inline int nilfs_sb_need_update(struct the_nilfs *nilfs)
+{
+	u64 t = get_seconds();
+	return t < nilfs->ns_sbwtime[0] ||
+		 t > nilfs->ns_sbwtime[0] + NILFS_SB_FREQ;
+}
+
+static inline int nilfs_altsb_need_update(struct the_nilfs *nilfs)
+{
+	u64 t = get_seconds();
+	struct nilfs_super_block **sbp = nilfs->ns_sbp;
+	return sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ;
+}
+
 void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
 struct the_nilfs *find_or_create_nilfs(struct block_device *);
 void put_nilfs(struct the_nilfs *);
Signature · 1 line
1.5.6.5
#4 lore raw

PATCH 3/3 nilfs2: stop using periodic write_super callback

In reply to a message not in the archive

remove nilfs_write_super and commit super block in nilfs internal thread, instead of periodic write_super callback.

VFS layer calls ->write_super callback periodically. However, it looks like that calling back is ommited when disk I/O is busy. And when cleanerd (nilfs GC) is runnig, disk I/O tend to be busy thus nilfs superblock is not synchronized as nilfs designed.

To avoid it, syncing superblock by nilfs thread instead of pdflush.

---
 fs/nilfs2/segment.c |    7 ++++++-
 fs/nilfs2/super.c   |   46 +---------------------------------------------
 2 files changed, 7 insertions(+), 46 deletions(-)
fs/nilfs2/segment.c +6 -1
index 8b5e477..0f110a1 100644
@@ -2487,7 +2487,8 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci,
 		if (test_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags) &&
 		    nilfs_discontinued(nilfs)) {
 			down_write(&nilfs->ns_sem);
-			req->sb_err = nilfs_commit_super(sbi, 0);
+			req->sb_err = nilfs_commit_super(sbi,
+					nilfs_altsb_need_update(nilfs));
 			up_write(&nilfs->ns_sem);
 		}
 	}
@@ -2675,6 +2676,7 @@ static int nilfs_segctor_thread(void *arg)
 	} else {
 		DEFINE_WAIT(wait);
 		int should_sleep = 1;
+		struct the_nilfs *nilfs;
 
 		prepare_to_wait(&sci->sc_wait_daemon, &wait,
 				TASK_INTERRUPTIBLE);
@@ -2695,6 +2697,9 @@ static int nilfs_segctor_thread(void *arg)
 		finish_wait(&sci->sc_wait_daemon, &wait);
 		timeout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) &&
 			   time_after_eq(jiffies, sci->sc_timer->expires));
+		nilfs = sci->sc_sbi->s_nilfs;
+		if (sci->sc_super->s_dirt && nilfs_sb_need_update(nilfs))
+			set_nilfs_discontinued(nilfs);
 	}
 	goto loop;
 
fs/nilfs2/super.c +1 -45

64 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#5 lore raw
In reply to a message not in the archive

Hi,

Quoted 11 lines · Jiro SEKIBA

Hi, this is re-revised version of write_super clean up patch.

This time, 3rd one removed nilfs_write_super out.

Any comments and suggestions are appreciate.

Thanks,

Regards,
--
Jiro SEKIBA <[email protected]>

I've queued this in the experimental tree.

Thank you for your help!

Ryusuke Konishi

Quoted 4 lines
 fs/nilfs2/segment.c   |    7 +++++-
 fs/nilfs2/super.c     |   61 +++++++-----------------------------------------
 fs/nilfs2/the_nilfs.h |   14 +++++++++++
 3 files changed, 29 insertions(+), 53 deletions(-)