Skip to content

Commit fbe7c2e

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: Christoph Hellwig <[email protected]> Acked-by: Ryusuke Konishi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4c4dad1 commit fbe7c2e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

fs/nilfs2/segbuf.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ static void nilfs_end_bio_write(struct bio *bio)
337337
}
338338

339339
static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
340-
struct nilfs_write_info *wi, int mode,
341-
int mode_flags)
340+
struct nilfs_write_info *wi)
342341
{
343342
struct bio *bio = wi->bio;
344343
int err;
@@ -356,7 +355,6 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
356355

357356
bio->bi_end_io = nilfs_end_bio_write;
358357
bio->bi_private = segbuf;
359-
bio_set_op_attrs(bio, mode, mode_flags);
360358
submit_bio(bio);
361359
segbuf->sb_nbio++;
362360

@@ -384,15 +382,15 @@ static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
384382

385383
static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
386384
struct nilfs_write_info *wi,
387-
struct buffer_head *bh, int mode)
385+
struct buffer_head *bh)
388386
{
389387
int len, err;
390388

391389
BUG_ON(wi->nr_vecs <= 0);
392390
repeat:
393391
if (!wi->bio) {
394-
wi->bio = bio_alloc(wi->nilfs->ns_bdev, wi->nr_vecs, 0,
395-
GFP_NOIO);
392+
wi->bio = bio_alloc(wi->nilfs->ns_bdev, wi->nr_vecs,
393+
REQ_OP_WRITE, GFP_NOIO);
396394
wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) <<
397395
(wi->nilfs->ns_blocksize_bits - 9);
398396
}
@@ -403,7 +401,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
403401
return 0;
404402
}
405403
/* bio is FULL */
406-
err = nilfs_segbuf_submit_bio(segbuf, wi, mode, 0);
404+
err = nilfs_segbuf_submit_bio(segbuf, wi);
407405
/* never submit current bh */
408406
if (likely(!err))
409407
goto repeat;
@@ -433,13 +431,13 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
433431
nilfs_segbuf_prepare_write(segbuf, &wi);
434432

435433
list_for_each_entry(bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) {
436-
res = nilfs_segbuf_submit_bh(segbuf, &wi, bh, REQ_OP_WRITE);
434+
res = nilfs_segbuf_submit_bh(segbuf, &wi, bh);
437435
if (unlikely(res))
438436
goto failed_bio;
439437
}
440438

441439
list_for_each_entry(bh, &segbuf->sb_payload_buffers, b_assoc_buffers) {
442-
res = nilfs_segbuf_submit_bh(segbuf, &wi, bh, REQ_OP_WRITE);
440+
res = nilfs_segbuf_submit_bh(segbuf, &wi, bh);
443441
if (unlikely(res))
444442
goto failed_bio;
445443
}
@@ -449,8 +447,8 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,
449447
* Last BIO is always sent through the following
450448
* submission.
451449
*/
452-
res = nilfs_segbuf_submit_bio(segbuf, &wi, REQ_OP_WRITE,
453-
REQ_SYNC);
450+
wi.bio->bi_opf |= REQ_SYNC;
451+
res = nilfs_segbuf_submit_bio(segbuf, &wi);
454452
}
455453

456454
failed_bio:

0 commit comments

Comments
 (0)