Commit 50614bcf authored by Ryusuke Konishi's avatar Ryusuke Konishi

nilfs2: insert checkpoint number in segment summary header

This adds a field to record the latest checkpoint number in the
nilfs_segment_summary structure.  This will help to recover the latest
checkpoint number from logs on disk.  This field is intended for
crucial cases in which super blocks have lost pointer to the latest
log.

Even though this will change the disk format, both backward and
forward compatibility is preserved by a size field prepared in the
segment summary header.
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent 9f130263
...@@ -105,6 +105,8 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi, ...@@ -105,6 +105,8 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi,
ssi->nsumblk = DIV_ROUND_UP(ssi->sumbytes, blocksize); ssi->nsumblk = DIV_ROUND_UP(ssi->sumbytes, blocksize);
ssi->nfileblk = ssi->nblocks - ssi->nsumblk - !!NILFS_SEG_HAS_SR(ssi); ssi->nfileblk = ssi->nblocks - ssi->nsumblk - !!NILFS_SEG_HAS_SR(ssi);
/* need to verify ->ss_bytes field if read ->ss_cno */
} }
/** /**
......
...@@ -134,7 +134,7 @@ int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *segbuf, ...@@ -134,7 +134,7 @@ int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *segbuf,
} }
int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags, int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags,
time_t ctime) time_t ctime, __u64 cno)
{ {
int err; int err;
...@@ -147,6 +147,7 @@ int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags, ...@@ -147,6 +147,7 @@ int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned flags,
segbuf->sb_sum.sumbytes = sizeof(struct nilfs_segment_summary); segbuf->sb_sum.sumbytes = sizeof(struct nilfs_segment_summary);
segbuf->sb_sum.nfinfo = segbuf->sb_sum.nfileblk = 0; segbuf->sb_sum.nfinfo = segbuf->sb_sum.nfileblk = 0;
segbuf->sb_sum.ctime = ctime; segbuf->sb_sum.ctime = ctime;
segbuf->sb_sum.cno = cno;
return 0; return 0;
} }
...@@ -172,6 +173,7 @@ void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *segbuf) ...@@ -172,6 +173,7 @@ void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *segbuf)
raw_sum->ss_nfinfo = cpu_to_le32(segbuf->sb_sum.nfinfo); raw_sum->ss_nfinfo = cpu_to_le32(segbuf->sb_sum.nfinfo);
raw_sum->ss_sumbytes = cpu_to_le32(segbuf->sb_sum.sumbytes); raw_sum->ss_sumbytes = cpu_to_le32(segbuf->sb_sum.sumbytes);
raw_sum->ss_pad = 0; raw_sum->ss_pad = 0;
raw_sum->ss_cno = cpu_to_le64(segbuf->sb_sum.cno);
} }
/* /*
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @sumbytes: Byte count of segment summary * @sumbytes: Byte count of segment summary
* @nfileblk: Total number of file blocks * @nfileblk: Total number of file blocks
* @seg_seq: Segment sequence number * @seg_seq: Segment sequence number
* @cno: Checkpoint number
* @ctime: Creation time * @ctime: Creation time
* @next: Block number of the next full segment * @next: Block number of the next full segment
*/ */
...@@ -48,6 +49,7 @@ struct nilfs_segsum_info { ...@@ -48,6 +49,7 @@ struct nilfs_segsum_info {
unsigned long sumbytes; unsigned long sumbytes;
unsigned long nfileblk; unsigned long nfileblk;
u64 seg_seq; u64 seg_seq;
__u64 cno;
time_t ctime; time_t ctime;
sector_t next; sector_t next;
}; };
...@@ -135,7 +137,7 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf, ...@@ -135,7 +137,7 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf,
struct nilfs_segment_buffer *prev); struct nilfs_segment_buffer *prev);
void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64, void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64,
struct the_nilfs *); struct the_nilfs *);
int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned, time_t); int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned, time_t, __u64);
int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *); int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *);
int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *, int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *,
struct buffer_head **); struct buffer_head **);
......
...@@ -366,7 +366,8 @@ static int nilfs_segctor_reset_segment_buffer(struct nilfs_sc_info *sci) ...@@ -366,7 +366,8 @@ static int nilfs_segctor_reset_segment_buffer(struct nilfs_sc_info *sci)
if (nilfs_doing_gc()) if (nilfs_doing_gc())
flags = NILFS_SS_GC; flags = NILFS_SS_GC;
err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime); err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime,
sci->sc_sbi->s_nilfs->ns_cno);
if (unlikely(err)) if (unlikely(err))
return err; return err;
......
...@@ -377,6 +377,7 @@ union nilfs_binfo { ...@@ -377,6 +377,7 @@ union nilfs_binfo {
* @ss_nfinfo: number of finfo structures * @ss_nfinfo: number of finfo structures
* @ss_sumbytes: total size of segment summary in bytes * @ss_sumbytes: total size of segment summary in bytes
* @ss_pad: padding * @ss_pad: padding
* @ss_cno: checkpoint number
*/ */
struct nilfs_segment_summary { struct nilfs_segment_summary {
__le32 ss_datasum; __le32 ss_datasum;
...@@ -391,6 +392,7 @@ struct nilfs_segment_summary { ...@@ -391,6 +392,7 @@ struct nilfs_segment_summary {
__le32 ss_nfinfo; __le32 ss_nfinfo;
__le32 ss_sumbytes; __le32 ss_sumbytes;
__le32 ss_pad; __le32 ss_pad;
__le64 ss_cno;
/* array of finfo structures */ /* array of finfo structures */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment