28 #include <linux/slab.h>
56 INIT_LIST_HEAD(&segbuf->
sb_list);
77 nilfs_get_segment_range(nilfs, segnum, &segbuf->
sb_fseg_start,
105 segbuf->
sb_sum.next = nilfs_get_segment_start_blocknr(nilfs, nextnum);
110 struct buffer_head *bh;
117 nilfs_segbuf_add_segsum_buffer(segbuf, bh);
122 struct buffer_head **bhp)
124 struct buffer_head *bh;
131 nilfs_segbuf_add_payload_buffer(segbuf, bh);
160 struct buffer_head *bh_sum;
163 struct buffer_head, b_assoc_buffers);
185 struct buffer_head *bh;
194 size =
min_t(
unsigned long, bytes, bh->b_size);
196 (
unsigned char *)raw_sum +
204 size =
min_t(
unsigned long, bytes, bh->b_size);
205 crc =
crc32_le(crc, bh->b_data, size);
213 struct buffer_head *bh;
222 (
unsigned char *)raw_sum +
sizeof(raw_sum->
ss_datasum),
227 crc =
crc32_le(crc, bh->b_data, bh->b_size);
231 crc =
crc32_le(crc, kaddr + bh_offset(bh), bh->b_size);
249 (
unsigned char *)raw_sr +
sizeof(raw_sr->
sr_sum),
250 srsize -
sizeof(raw_sr->
sr_sum));
256 struct buffer_head *bh, *
n;
259 list_del_init(&bh->b_assoc_buffers);
279 nilfs_segbuf_clear(segbuf);
289 list_del_init(&segbuf->
sb_list);
290 nilfs_segbuf_clear(segbuf);
301 ret = nilfs_segbuf_write(segbuf, nilfs);
314 err = nilfs_segbuf_wait(segbuf);
332 nilfs_segbuf_fill_in_super_root_crc(segbuf, seed);
333 nilfs_segbuf_fill_in_segsum_crc(segbuf, seed);
334 nilfs_segbuf_fill_in_data_crc(segbuf, seed);
341 static void nilfs_end_bio_write(
struct bio *bio,
int err)
343 const int uptodate =
test_bit(BIO_UPTODATE, &bio->bi_flags);
347 set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
362 struct bio *bio = wi->
bio;
366 bdi_write_congested(segbuf->
sb_super->s_bdi)) {
376 bio->bi_end_io = nilfs_end_bio_write;
377 bio->bi_private = segbuf;
380 if (bio_flagged(bio, BIO_EOPNOTSUPP)) {
415 while (!bio && (nr_vecs >>= 1))
438 struct buffer_head *bh,
int mode)
452 if (len == bh->b_size) {
457 err = nilfs_segbuf_submit_bio(segbuf, wi, mode);
480 struct buffer_head *bh;
484 nilfs_segbuf_prepare_write(segbuf, &wi);
487 res = nilfs_segbuf_submit_bh(segbuf, &wi, bh,
rw);
493 res = nilfs_segbuf_submit_bh(segbuf, &wi, bh,
rw);
504 res = nilfs_segbuf_submit_bio(segbuf, &wi,
rw);
529 }
while (--segbuf->
sb_nbio > 0);