Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 196013
b: refs/heads/master
c: aaed1d5
h: refs/heads/master
i:
  196011: b136e8e
v: v3
  • Loading branch information
Ryusuke Konishi committed May 10, 2010
1 parent 14e3044 commit 960719b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1e2b68bf285dce604388fcb6f85b7e612156db17
refs/heads/master: aaed1d5bfac459ead9aaad324e7fe3326250f50a
39 changes: 35 additions & 4 deletions trunk/fs/nilfs2/segbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *segbuf)
/*
* CRC calculation routines
*/
void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf,
u32 seed)
static void
nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf, u32 seed)
{
struct buffer_head *bh;
struct nilfs_segment_summary *raw_sum;
Expand All @@ -230,8 +230,8 @@ void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *segbuf,
raw_sum->ss_sumsum = cpu_to_le32(crc);
}

void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
u32 seed)
static void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
u32 seed)
{
struct buffer_head *bh;
struct nilfs_segment_summary *raw_sum;
Expand All @@ -257,6 +257,20 @@ void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
raw_sum->ss_datasum = cpu_to_le32(crc);
}

static void
nilfs_segbuf_fill_in_super_root_crc(struct nilfs_segment_buffer *segbuf,
u32 seed)
{
struct nilfs_super_root *raw_sr;
u32 crc;

raw_sr = (struct nilfs_super_root *)segbuf->sb_super_root->b_data;
crc = crc32_le(seed,
(unsigned char *)raw_sr + sizeof(raw_sr->sr_sum),
NILFS_SR_BYTES - sizeof(raw_sr->sr_sum));
raw_sr->sr_sum = cpu_to_le32(crc);
}

static void nilfs_release_buffers(struct list_head *list)
{
struct buffer_head *bh, *n;
Expand Down Expand Up @@ -336,6 +350,23 @@ int nilfs_wait_on_logs(struct list_head *logs)
return ret;
}

/**
* nilfs_add_checksums_on_logs - add checksums on the logs
* @logs: list of segment buffers storing target logs
* @seed: checksum seed value
*/
void nilfs_add_checksums_on_logs(struct list_head *logs, u32 seed)
{
struct nilfs_segment_buffer *segbuf;

list_for_each_entry(segbuf, logs, sb_list) {
if (segbuf->sb_super_root)
nilfs_segbuf_fill_in_super_root_crc(segbuf, seed);
nilfs_segbuf_fill_in_segsum_crc(segbuf, seed);
nilfs_segbuf_fill_in_data_crc(segbuf, seed);
}
}

/*
* BIO operations
*/
Expand Down
3 changes: 1 addition & 2 deletions trunk/fs/nilfs2/segbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *);
int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *,
struct buffer_head **);
void nilfs_segbuf_fill_in_segsum(struct nilfs_segment_buffer *);
void nilfs_segbuf_fill_in_segsum_crc(struct nilfs_segment_buffer *, u32);
void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *, u32);

static inline void
nilfs_segbuf_add_segsum_buffer(struct nilfs_segment_buffer *segbuf,
Expand Down Expand Up @@ -173,6 +171,7 @@ void nilfs_truncate_logs(struct list_head *logs,
struct nilfs_segment_buffer *last);
int nilfs_write_logs(struct list_head *logs, struct the_nilfs *nilfs);
int nilfs_wait_on_logs(struct list_head *logs);
void nilfs_add_checksums_on_logs(struct list_head *logs, u32 seed);

static inline void nilfs_destroy_logs(struct list_head *logs)
{
Expand Down
33 changes: 3 additions & 30 deletions trunk/fs/nilfs2/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,35 +932,6 @@ static void nilfs_segctor_fill_in_file_bmap(struct nilfs_sc_info *sci,
}
}

/*
* CRC calculation routines
*/
static void nilfs_fill_in_super_root_crc(struct buffer_head *bh_sr, u32 seed)
{
struct nilfs_super_root *raw_sr =
(struct nilfs_super_root *)bh_sr->b_data;
u32 crc;

crc = crc32_le(seed,
(unsigned char *)raw_sr + sizeof(raw_sr->sr_sum),
NILFS_SR_BYTES - sizeof(raw_sr->sr_sum));
raw_sr->sr_sum = cpu_to_le32(crc);
}

static void nilfs_segctor_fill_in_checksums(struct nilfs_sc_info *sci,
u32 seed)
{
struct nilfs_segment_buffer *segbuf;

list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) {
if (segbuf->sb_super_root)
nilfs_fill_in_super_root_crc(segbuf->sb_super_root,
seed);
nilfs_segbuf_fill_in_segsum_crc(segbuf, seed);
nilfs_segbuf_fill_in_data_crc(segbuf, seed);
}
}

static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
struct the_nilfs *nilfs)
{
Expand Down Expand Up @@ -2174,7 +2145,9 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
nilfs_abort_logs(&sci->sc_segbufs, failed_page, err);
goto failed_to_write;
}
nilfs_segctor_fill_in_checksums(sci, nilfs->ns_crc_seed);

nilfs_add_checksums_on_logs(&sci->sc_segbufs,
nilfs->ns_crc_seed);

err = nilfs_segctor_write(sci, nilfs);
if (unlikely(err))
Expand Down

0 comments on commit 960719b

Please sign in to comment.