mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 10:43:43 +00:00
nilfs2: move out checksum routines to segment buffer code
This moves out checksum routines in log writer to segbuf.c for cleanup. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
This commit is contained in:
parent
1e2b68bf28
commit
aaed1d5bfa
@ -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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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
|
||||
*/
|
||||
|
@ -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,
|
||||
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user