nilfs2: asynchronous super block updates
cover nilfs2: asynchronous super block updates
Hi,
This is revised patch series to update super block asynchronously.
First patch separates super block validity check from nilfs_commit_super, and moved the function into callers.
Second patch introduces nilfs_write_log_cursor to advance log cursor for one of super blocks. This patch also define a macro that generates inline function to update information both super blocks for convenience.
fs/nilfs2/nilfs.h | 2 + fs/nilfs2/segment.c | 8 +-- fs/nilfs2/super.c | 144 ++++++++++++++++++++++++++++++++++--------------- fs/nilfs2/the_nilfs.c | 11 +++- fs/nilfs2/the_nilfs.h | 23 +++++--- 5 files changed, 128 insertions(+), 60 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 nilfs2: introduce nilfs_prepare_super
In reply to a message not in the archiveThis function checks validity of super block pointers.
If first super block is invalid, it will swap the super blocks. The function should be called before any super block information updates. Caller must obtain nilfs->ns_sem.
--- fs/nilfs2/nilfs.h | 1 + fs/nilfs2/segment.c | 7 +++- fs/nilfs2/super.c | 84 ++++++++++++++++++++++++++++++++---------------- fs/nilfs2/the_nilfs.c | 11 +++++-- 4 files changed, 70 insertions(+), 33 deletions(-)
fs/nilfs2/nilfs.h +1 -0
@@ -270,6 +270,7 @@ extern struct nilfs_super_block * nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);extern int nilfs_store_magic_and_option (struct super_block *,struct nilfs_super_block *,char *); +extern struct nilfs_super_block **nilfs_prepare_super (struct nilfs_sb_info *);extern int nilfs_commit_super (struct nilfs_sb_info *,int );extern int nilfs_attach_checkpoint (struct nilfs_sb_info *,__u64 );extern void nilfs_detach_checkpoint (struct nilfs_sb_info *);
fs/nilfs2/segment.c +5 -2
@@ -2490,8 +2490,11 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode)if (test_bit (NILFS_SC_SUPER_ROOT , &sci->sc_flags) &&nilfs_discontinued (nilfs)) {down_write (&nilfs->ns_sem); - err =nilfs_commit_super ( - sbi,nilfs_altsb_need_update (nilfs)); +if (likely (nilfs_prepare_super (sbi))) + err =nilfs_commit_super ( + sbi,nilfs_altsb_need_update (nilfs)); +else + err = -EIO ;up_write (&nilfs->ns_sem); } }
fs/nilfs2/super.c +56 -28
157 lines not on this page · raw message
fs/nilfs2/the_nilfs.c +8 -3
@@ -262,6 +262,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)unsigned int s_flags = sbi->s_super->s_flags;int really_read_only =bdev_read_only (nilfs->ns_bdev);int valid_fs =nilfs_valid_fs (nilfs); +struct nilfs_super_block **sbp;int err;if (nilfs_loaded (nilfs)) {
@@ -325,9 +326,13 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) goto failed_unload;down_write (&nilfs->ns_sem); - nilfs->ns_mount_state |=NILFS_VALID_FS ; - nilfs->ns_sbp[0 ]->s_state =cpu_to_le16 (nilfs->ns_mount_state); - err =nilfs_commit_super (sbi,1 ); + sbp =nilfs_prepare_super (sbi); +if (likely (sbp)) { + nilfs->ns_mount_state |=NILFS_VALID_FS ; + sbp[0 ]->s_state =cpu_to_le16 (nilfs->ns_mount_state); + err =nilfs_commit_super (sbi,1 ); + }else + err = -EIO ;up_write (&nilfs->ns_sem);if (err) {
Signature · 6 lines
1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 nilfs2: sync super blocks in turns
In reply to a message not in the archiveThis will sync super blocks in turns instead of syncing duplicate super blocks at the time. This will help searching valid super root when super block is written into disk before log is written, which is happen when barrier-less block devices are unmounted uncleanly.
In the stiation, old super block likely points valid log.
This patch introduces nilfs_write_log_cursor to advance log cursor one of super blocks. To update super block information other than log cursor, caller of nilfs_commit_super must set the information on both super blocks.
--- fs/nilfs2/nilfs.h | 1 + fs/nilfs2/segment.c | 11 +----- fs/nilfs2/super.c | 88 +++++++++++++++++++++++++++++++++---------------- fs/nilfs2/the_nilfs.c | 2 +- fs/nilfs2/the_nilfs.h | 23 ++++++++---- 5 files changed, 78 insertions(+), 47 deletions(-)
fs/nilfs2/nilfs.h +1 -0
@@ -270,6 +270,7 @@ extern struct nilfs_super_block * nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);extern int nilfs_store_magic_and_option (struct super_block *,struct nilfs_super_block *,char *); +extern int nilfs_write_log_cursor (struct nilfs_sb_info *);extern struct nilfs_super_block **nilfs_prepare_super (struct nilfs_sb_info *);extern int nilfs_commit_super (struct nilfs_sb_info *,int );extern int nilfs_attach_checkpoint (struct nilfs_sb_info *,__u64 );
fs/nilfs2/segment.c +2 -9
@@ -2488,15 +2488,8 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode)if (mode !=SC_FLUSH_DAT )atomic_set (&nilfs->ns_ndirtyblks,0 );if (test_bit (NILFS_SC_SUPER_ROOT , &sci->sc_flags) && -nilfs_discontinued (nilfs)) { -down_write (&nilfs->ns_sem); -if (likely (nilfs_prepare_super (sbi))) - err =nilfs_commit_super ( - sbi,nilfs_altsb_need_update (nilfs)); -else - err = -EIO ; -up_write (&nilfs->ns_sem); - } +nilfs_discontinued (nilfs)) + err =nilfs_write_log_cursor (sbi); }nilfs_segctor_notify (sci, mode, err);
fs/nilfs2/super.c +59 -29
147 lines not on this page · raw message
fs/nilfs2/the_nilfs.c +1 -1
@@ -329,7 +329,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) sbp =nilfs_prepare_super (sbi);if (likely (sbp)) { nilfs->ns_mount_state |=NILFS_VALID_FS ; - sbp[0 ]->s_state =cpu_to_le16 (nilfs->ns_mount_state); +nilfs_super_set_state (sbp,cpu_to_le16 (nilfs->ns_mount_state)); err =nilfs_commit_super (sbi,1 ); }else err = -EIO ;
fs/nilfs2/the_nilfs.h +15 -8
@@ -201,9 +201,23 @@ THE_NILFS_FNS(DISCONTINUED, discontinued) THE_NILFS_FNS(GC_RUNNING, gc_running) THE_NILFS_FNS(SB_DIRTY, sb_dirty) +#define NILFS_SUPER_SET_FN (name, type) \ +static inline void nilfs_super_set_##name( \ + struct nilfs_super_block **sbp, \ + type val) \ +{ \ + sbp[0]->s_##name = val; \ + if (sbp[1] && sbp[1]->s_magic == NILFS_SUPER_MAGIC) \ + sbp[1]->s_##name = val; \ +} + +NILFS_SUPER_SET_FN(state, __le16) +NILFS_SUPER_SET_FN(mnt_count, __le16) +NILFS_SUPER_SET_FN(max_mnt_count, __le16) +NILFS_SUPER_SET_FN (mtime, __le64) + /* Minimum interval of periodical update of superblocks (in seconds) */#define NILFS_SB_FREQ 10 -#define NILFS_ALTSB_FREQ 60/* spare superblock */ static inline int nilfs_sb_need_update (struct the_nilfs *nilfs) {
@@ -212,13 +226,6 @@ static inline int nilfs_sb_need_update(struct the_nilfs *nilfs) 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 · 6 lines
1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Jiro SEKIBA
Hi,
This is revised patch series to update super block asynchronously.
First patch separates super block validity check from
nilfs_commit_super, and moved the function into callers.Second patch introduces
nilfs_write_log_cursorto advance log cursor for one of super blocks. This patch also define a macro that generates inline function to update information both super blocks for convenience.
Ahh, this series doesn't apply as is.
Could you rebase it onto the for-next branch ?
Thanks,
Ryusuke Konishi
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html