Commit fbe7c2ef authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

nilfs2: pass the operation to bio_alloc

Refactor the segbuf write code to pass the op to bio_alloc instead of
setting it just before the submission.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
Link: https://lore.kernel.org/r/20220222154634.597067-4-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4c4dad11
...@@ -337,8 +337,7 @@ static void nilfs_end_bio_write(struct bio *bio) ...@@ -337,8 +337,7 @@ static void nilfs_end_bio_write(struct bio *bio)
} }
static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf, static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
struct nilfs_write_info *wi, int mode, struct nilfs_write_info *wi)
int mode_flags)
{ {
struct bio *bio = wi->bio; struct bio *bio = wi->bio;
int err; int err;
...@@ -356,7 +355,6 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf, ...@@ -356,7 +355,6 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
bio->bi_end_io = nilfs_end_bio_write; bio->bi_end_io = nilfs_end_bio_write;
bio->bi_private = segbuf; bio->bi_private = segbuf;
bio_set_op_attrs(bio, mode, mode_flags);
submit_bio(bio); submit_bio(bio);
segbuf->sb_nbio++; segbuf->sb_nbio++;
...@@ -384,15 +382,15 @@ static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf, ...@@ -384,15 +382,15 @@ static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf, static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
struct nilfs_write_info *wi, struct nilfs_write_info *wi,
struct buffer_head *bh, int mode) struct buffer_head *bh)
{ {
int len, err; int len, err;
BUG_ON(wi->nr_vecs <= 0); BUG_ON(wi->nr_vecs <= 0);
repeat: repeat:
if (!wi->bio) { if (!wi->bio) {
wi->bio = bio_alloc(wi->nilfs->ns_bdev, wi->nr_vecs, 0, wi->bio = bio_alloc(wi->nilfs->ns_bdev, wi->nr_vecs,
GFP_NOIO); REQ_OP_WRITE, GFP_NOIO);
wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) << wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) <<
(wi->nilfs->ns_blocksize_bits - 9); (wi->nilfs->ns_blocksize_bits - 9);
} }
...@@ -403,7 +401,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf, ...@@ -403,7 +401,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
return 0; return 0;
} }
/* bio is FULL */ /* bio is FULL */
err = nilfs_segbuf_submit_bio(segbuf, wi, mode, 0); err = nilfs_segbuf_submit_bio(segbuf, wi);
/* never submit current bh */ /* never submit current bh */
if (likely(!err)) if (likely(!err))
goto repeat; goto repeat;
...@@ -433,13 +431,13 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf, ...@@ -433,13 +431,13 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
nilfs_segbuf_prepare_write(segbuf, &wi); nilfs_segbuf_prepare_write(segbuf, &wi);
list_for_each_entry(bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) { list_for_each_entry(bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) {
res = nilfs_segbuf_submit_bh(segbuf, &wi, bh, REQ_OP_WRITE); res = nilfs_segbuf_submit_bh(segbuf, &wi, bh);
if (unlikely(res)) if (unlikely(res))
goto failed_bio; goto failed_bio;
} }
list_for_each_entry(bh, &segbuf->sb_payload_buffers, b_assoc_buffers) { list_for_each_entry(bh, &segbuf->sb_payload_buffers, b_assoc_buffers) {
res = nilfs_segbuf_submit_bh(segbuf, &wi, bh, REQ_OP_WRITE); res = nilfs_segbuf_submit_bh(segbuf, &wi, bh);
if (unlikely(res)) if (unlikely(res))
goto failed_bio; goto failed_bio;
} }
...@@ -449,8 +447,8 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf, ...@@ -449,8 +447,8 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
* Last BIO is always sent through the following * Last BIO is always sent through the following
* submission. * submission.
*/ */
res = nilfs_segbuf_submit_bio(segbuf, &wi, REQ_OP_WRITE, wi.bio->bi_opf |= REQ_SYNC;
REQ_SYNC); res = nilfs_segbuf_submit_bio(segbuf, &wi);
} }
failed_bio: failed_bio:
......
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