diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-08-20 07:10:38 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-10-22 20:24:33 -0400 |
commit | 6c43f41000312fefa482c3bfdd97e7f81d6be0ec (patch) | |
tree | de22a81c028f33d9fc2354bfdc218191b96240cf | |
parent | 7d6cd92fe2de3c286b8e95f43223f09db9302635 (diff) |
nilfs2: keep zero value in i_cno except for gc-inodes
On-memory inode structures of nilfs have a member "i_cno" which stores
a checkpoint number related to the inode. For gc-inodes, this field
indicates version of data each gc-inode caches for GC. Log writer
temporarily uses "i_cno" to transfer the latest checkpoint number.
This stops the latter use and lets only gc-inodes use it.
The purpose of this patch is to allow the successive change use
"i_cno" for inode lookup.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
-rw-r--r-- | fs/nilfs2/segment.c | 29 | ||||
-rw-r--r-- | fs/nilfs2/segment.h | 3 | ||||
-rw-r--r-- | include/linux/nilfs2_fs.h | 8 |
3 files changed, 24 insertions, 16 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 9fd051a33c4f..eee4b223c293 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -366,8 +366,7 @@ static int nilfs_segctor_reset_segment_buffer(struct nilfs_sc_info *sci) | |||
366 | 366 | ||
367 | if (nilfs_doing_gc()) | 367 | if (nilfs_doing_gc()) |
368 | flags = NILFS_SS_GC; | 368 | flags = NILFS_SS_GC; |
369 | err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime, | 369 | err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime, sci->sc_cno); |
370 | sci->sc_sbi->s_nilfs->ns_cno); | ||
371 | if (unlikely(err)) | 370 | if (unlikely(err)) |
372 | return err; | 371 | return err; |
373 | 372 | ||
@@ -440,17 +439,26 @@ static void nilfs_segctor_end_finfo(struct nilfs_sc_info *sci, | |||
440 | struct nilfs_finfo *finfo; | 439 | struct nilfs_finfo *finfo; |
441 | struct nilfs_inode_info *ii; | 440 | struct nilfs_inode_info *ii; |
442 | struct nilfs_segment_buffer *segbuf; | 441 | struct nilfs_segment_buffer *segbuf; |
442 | __u64 cno; | ||
443 | 443 | ||
444 | if (sci->sc_blk_cnt == 0) | 444 | if (sci->sc_blk_cnt == 0) |
445 | return; | 445 | return; |
446 | 446 | ||
447 | ii = NILFS_I(inode); | 447 | ii = NILFS_I(inode); |
448 | |||
449 | if (test_bit(NILFS_I_GCINODE, &ii->i_state)) | ||
450 | cno = ii->i_cno; | ||
451 | else if (NILFS_ROOT_METADATA_FILE(inode->i_ino)) | ||
452 | cno = 0; | ||
453 | else | ||
454 | cno = sci->sc_cno; | ||
455 | |||
448 | finfo = nilfs_segctor_map_segsum_entry(sci, &sci->sc_finfo_ptr, | 456 | finfo = nilfs_segctor_map_segsum_entry(sci, &sci->sc_finfo_ptr, |
449 | sizeof(*finfo)); | 457 | sizeof(*finfo)); |
450 | finfo->fi_ino = cpu_to_le64(inode->i_ino); | 458 | finfo->fi_ino = cpu_to_le64(inode->i_ino); |
451 | finfo->fi_nblocks = cpu_to_le32(sci->sc_blk_cnt); | 459 | finfo->fi_nblocks = cpu_to_le32(sci->sc_blk_cnt); |
452 | finfo->fi_ndatablk = cpu_to_le32(sci->sc_datablk_cnt); | 460 | finfo->fi_ndatablk = cpu_to_le32(sci->sc_datablk_cnt); |
453 | finfo->fi_cno = cpu_to_le64(ii->i_cno); | 461 | finfo->fi_cno = cpu_to_le64(cno); |
454 | 462 | ||
455 | segbuf = sci->sc_curseg; | 463 | segbuf = sci->sc_curseg; |
456 | segbuf->sb_sum.sumbytes = sci->sc_binfo_ptr.offset + | 464 | segbuf->sb_sum.sumbytes = sci->sc_binfo_ptr.offset + |
@@ -1976,7 +1984,6 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
1976 | struct nilfs_sb_info *sbi) | 1984 | struct nilfs_sb_info *sbi) |
1977 | { | 1985 | { |
1978 | struct nilfs_inode_info *ii, *n; | 1986 | struct nilfs_inode_info *ii, *n; |
1979 | __u64 cno = sbi->s_nilfs->ns_cno; | ||
1980 | 1987 | ||
1981 | spin_lock(&sbi->s_inode_lock); | 1988 | spin_lock(&sbi->s_inode_lock); |
1982 | retry: | 1989 | retry: |
@@ -2002,7 +2009,6 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
2002 | brelse(ibh); | 2009 | brelse(ibh); |
2003 | goto retry; | 2010 | goto retry; |
2004 | } | 2011 | } |
2005 | ii->i_cno = cno; | ||
2006 | 2012 | ||
2007 | clear_bit(NILFS_I_QUEUED, &ii->i_state); | 2013 | clear_bit(NILFS_I_QUEUED, &ii->i_state); |
2008 | set_bit(NILFS_I_BUSY, &ii->i_state); | 2014 | set_bit(NILFS_I_BUSY, &ii->i_state); |
@@ -2011,8 +2017,6 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
2011 | } | 2017 | } |
2012 | spin_unlock(&sbi->s_inode_lock); | 2018 | spin_unlock(&sbi->s_inode_lock); |
2013 | 2019 | ||
2014 | NILFS_I(sbi->s_ifile)->i_cno = cno; | ||
2015 | |||
2016 | return 0; | 2020 | return 0; |
2017 | } | 2021 | } |
2018 | 2022 | ||
@@ -2021,19 +2025,13 @@ static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | |||
2021 | { | 2025 | { |
2022 | struct nilfs_transaction_info *ti = current->journal_info; | 2026 | struct nilfs_transaction_info *ti = current->journal_info; |
2023 | struct nilfs_inode_info *ii, *n; | 2027 | struct nilfs_inode_info *ii, *n; |
2024 | __u64 cno = sbi->s_nilfs->ns_cno; | ||
2025 | 2028 | ||
2026 | spin_lock(&sbi->s_inode_lock); | 2029 | spin_lock(&sbi->s_inode_lock); |
2027 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { | 2030 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { |
2028 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || | 2031 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || |
2029 | test_bit(NILFS_I_DIRTY, &ii->i_state)) { | 2032 | test_bit(NILFS_I_DIRTY, &ii->i_state)) |
2030 | /* The current checkpoint number (=nilfs->ns_cno) is | ||
2031 | changed between check-in and check-out only if the | ||
2032 | super root is written out. So, we can update i_cno | ||
2033 | for the inodes that remain in the dirty list. */ | ||
2034 | ii->i_cno = cno; | ||
2035 | continue; | 2033 | continue; |
2036 | } | 2034 | |
2037 | clear_bit(NILFS_I_BUSY, &ii->i_state); | 2035 | clear_bit(NILFS_I_BUSY, &ii->i_state); |
2038 | brelse(ii->i_bh); | 2036 | brelse(ii->i_bh); |
2039 | ii->i_bh = NULL; | 2037 | ii->i_bh = NULL; |
@@ -2054,6 +2052,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2054 | int err; | 2052 | int err; |
2055 | 2053 | ||
2056 | sci->sc_stage.scnt = NILFS_ST_INIT; | 2054 | sci->sc_stage.scnt = NILFS_ST_INIT; |
2055 | sci->sc_cno = nilfs->ns_cno; | ||
2057 | 2056 | ||
2058 | err = nilfs_segctor_check_in_files(sci, sbi); | 2057 | err = nilfs_segctor_check_in_files(sci, sbi); |
2059 | if (unlikely(err)) | 2058 | if (unlikely(err)) |
diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h index 17c487bd8152..675d932148a4 100644 --- a/fs/nilfs2/segment.h +++ b/fs/nilfs2/segment.h | |||
@@ -107,6 +107,7 @@ struct nilfs_segsum_pointer { | |||
107 | * @sc_datablk_cnt: Data block count of a file | 107 | * @sc_datablk_cnt: Data block count of a file |
108 | * @sc_nblk_this_inc: Number of blocks included in the current logical segment | 108 | * @sc_nblk_this_inc: Number of blocks included in the current logical segment |
109 | * @sc_seg_ctime: Creation time | 109 | * @sc_seg_ctime: Creation time |
110 | * @sc_cno: checkpoint number of current log | ||
110 | * @sc_flags: Internal flags | 111 | * @sc_flags: Internal flags |
111 | * @sc_state_lock: spinlock for sc_state and so on | 112 | * @sc_state_lock: spinlock for sc_state and so on |
112 | * @sc_state: Segctord state flags | 113 | * @sc_state: Segctord state flags |
@@ -156,7 +157,7 @@ struct nilfs_sc_info { | |||
156 | unsigned long sc_datablk_cnt; | 157 | unsigned long sc_datablk_cnt; |
157 | unsigned long sc_nblk_this_inc; | 158 | unsigned long sc_nblk_this_inc; |
158 | time_t sc_seg_ctime; | 159 | time_t sc_seg_ctime; |
159 | 160 | __u64 sc_cno; | |
160 | unsigned long sc_flags; | 161 | unsigned long sc_flags; |
161 | 162 | ||
162 | spinlock_t sc_state_lock; | 163 | spinlock_t sc_state_lock; |
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h index b07f5cdff5e2..bcdb34c68d08 100644 --- a/include/linux/nilfs2_fs.h +++ b/include/linux/nilfs2_fs.h | |||
@@ -271,6 +271,14 @@ struct nilfs_super_block { | |||
271 | segments */ | 271 | segments */ |
272 | 272 | ||
273 | /* | 273 | /* |
274 | * We call DAT, cpfile, and sufile root metadata files. Inodes of | ||
275 | * these files are written in super root block instead of ifile, and | ||
276 | * garbage collector doesn't keep any past versions of these files. | ||
277 | */ | ||
278 | #define NILFS_ROOT_METADATA_FILE(ino) \ | ||
279 | ((ino) >= NILFS_DAT_INO && (ino) <= NILFS_SUFILE_INO) | ||
280 | |||
281 | /* | ||
274 | * bytes offset of secondary super block | 282 | * bytes offset of secondary super block |
275 | */ | 283 | */ |
276 | #define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12) | 284 | #define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12) |