Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: pass a block_device and opf to bio_alloc

Pass the block_device and operation that we plan to use this bio for to
bio_alloc to optimize the assignment. NULL/0 can be passed, both for the
passthrough case on a raw request_queue and to temporarily avoid
refactoring some nasty code.

Also move the gfp_mask argument after the nr_vecs argument for a much
more logical calling convention matching what most of the kernel does.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220124091107.642561-18-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
07888c66 b77c88c2

+130 -194
+1 -4
block/bio.c
··· 347 347 struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev, 348 348 unsigned int nr_pages, unsigned int opf, gfp_t gfp) 349 349 { 350 - struct bio *new = bio_alloc(gfp, nr_pages); 351 - 352 - bio_set_dev(new, bdev); 353 - new->bi_opf = opf; 350 + struct bio *new = bio_alloc(bdev, nr_pages, opf, gfp); 354 351 355 352 if (bio) { 356 353 bio_chain(bio, new);
+1 -3
block/fops.c
··· 256 256 } 257 257 atomic_inc(&dio->ref); 258 258 submit_bio(bio); 259 - bio = bio_alloc(GFP_KERNEL, nr_pages); 260 - bio_set_dev(bio, bdev); 261 - bio->bi_opf = opf; 259 + bio = bio_alloc(bdev, nr_pages, opf, GFP_KERNEL); 262 260 } 263 261 264 262 blk_finish_plug(&plug);
+4 -6
drivers/block/drbd/drbd_receiver.c
··· 1279 1279 1280 1280 static void submit_one_flush(struct drbd_device *device, struct issue_flush_context *ctx) 1281 1281 { 1282 - struct bio *bio = bio_alloc(GFP_NOIO, 0); 1282 + struct bio *bio = bio_alloc(device->ldev->backing_bdev, 0, 1283 + REQ_OP_FLUSH | REQ_PREFLUSH, GFP_NOIO); 1283 1284 struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO); 1284 1285 1285 1286 if (!octx) { ··· 1298 1297 1299 1298 octx->device = device; 1300 1299 octx->ctx = ctx; 1301 - bio_set_dev(bio, device->ldev->backing_bdev); 1302 1300 bio->bi_private = octx; 1303 1301 bio->bi_end_io = one_flush_endio; 1304 - bio->bi_opf = REQ_OP_FLUSH | REQ_PREFLUSH; 1305 1302 1306 1303 device->flush_jif = jiffies; 1307 1304 set_bit(FLUSH_PENDING, &device->flags); ··· 1684 1685 * generated bio, but a bio allocated on behalf of the peer. 1685 1686 */ 1686 1687 next_bio: 1687 - bio = bio_alloc(GFP_NOIO, nr_pages); 1688 + bio = bio_alloc(device->ldev->backing_bdev, nr_pages, op | op_flags, 1689 + GFP_NOIO); 1688 1690 /* > peer_req->i.sector, unless this is the first bio */ 1689 1691 bio->bi_iter.bi_sector = sector; 1690 - bio_set_dev(bio, device->ldev->backing_bdev); 1691 - bio_set_op_attrs(bio, op, op_flags); 1692 1692 bio->bi_private = peer_req; 1693 1693 bio->bi_end_io = drbd_peer_request_endio; 1694 1694
+2 -3
drivers/block/rnbd/rnbd-srv.c
··· 149 149 priv->sess_dev = sess_dev; 150 150 priv->id = id; 151 151 152 - bio = bio_alloc(GFP_KERNEL, 1); 152 + bio = bio_alloc(sess_dev->rnbd_dev->bdev, 1, 153 + rnbd_to_bio_flags(le32_to_cpu(msg->rw)), GFP_KERNEL); 153 154 if (bio_add_page(bio, virt_to_page(data), datalen, 154 155 offset_in_page(data)) != datalen) { 155 156 rnbd_srv_err(sess_dev, "Failed to map data to bio\n"); ··· 160 159 161 160 bio->bi_end_io = rnbd_dev_bi_end_io; 162 161 bio->bi_private = priv; 163 - bio->bi_opf = rnbd_to_bio_flags(le32_to_cpu(msg->rw)); 164 162 bio->bi_iter.bi_sector = le64_to_cpu(msg->sector); 165 163 bio->bi_iter.bi_size = le32_to_cpu(msg->bi_size); 166 164 prio = srv_sess->ver < RNBD_PROTO_VER_MAJOR || 167 165 usrlen < sizeof(*msg) ? 0 : le16_to_cpu(msg->prio); 168 166 bio_set_prio(bio, prio); 169 - bio_set_dev(bio, sess_dev->rnbd_dev->bdev); 170 167 171 168 submit_bio(bio); 172 169
+5 -6
drivers/block/xen-blkback/blkback.c
··· 1326 1326 pages[i]->page, 1327 1327 seg[i].nsec << 9, 1328 1328 seg[i].offset) == 0)) { 1329 - bio = bio_alloc(GFP_KERNEL, bio_max_segs(nseg - i)); 1329 + bio = bio_alloc(preq.bdev, bio_max_segs(nseg - i), 1330 + operation | operation_flags, 1331 + GFP_KERNEL); 1330 1332 biolist[nbio++] = bio; 1331 - bio_set_dev(bio, preq.bdev); 1332 1333 bio->bi_private = pending_req; 1333 1334 bio->bi_end_io = end_block_io_op; 1334 1335 bio->bi_iter.bi_sector = preq.sector_number; 1335 - bio_set_op_attrs(bio, operation, operation_flags); 1336 1336 } 1337 1337 1338 1338 preq.sector_number += seg[i].nsec; ··· 1342 1342 if (!bio) { 1343 1343 BUG_ON(operation_flags != REQ_PREFLUSH); 1344 1344 1345 - bio = bio_alloc(GFP_KERNEL, 0); 1345 + bio = bio_alloc(preq.bdev, 0, operation | operation_flags, 1346 + GFP_KERNEL); 1346 1347 biolist[nbio++] = bio; 1347 - bio_set_dev(bio, preq.bdev); 1348 1348 bio->bi_private = pending_req; 1349 1349 bio->bi_end_io = end_block_io_op; 1350 - bio_set_op_attrs(bio, operation, operation_flags); 1351 1350 } 1352 1351 1353 1352 atomic_set(&pending_req->pendcnt, nbio);
+4 -7
drivers/block/zram/zram_drv.c
··· 616 616 { 617 617 struct bio *bio; 618 618 619 - bio = bio_alloc(GFP_NOIO, 1); 619 + bio = bio_alloc(zram->bdev, 1, parent ? parent->bi_opf : REQ_OP_READ, 620 + GFP_NOIO); 620 621 if (!bio) 621 622 return -ENOMEM; 622 623 623 624 bio->bi_iter.bi_sector = entry * (PAGE_SIZE >> 9); 624 - bio_set_dev(bio, zram->bdev); 625 625 if (!bio_add_page(bio, bvec->bv_page, bvec->bv_len, bvec->bv_offset)) { 626 626 bio_put(bio); 627 627 return -EIO; 628 628 } 629 629 630 - if (!parent) { 631 - bio->bi_opf = REQ_OP_READ; 630 + if (!parent) 632 631 bio->bi_end_io = zram_page_end_io; 633 - } else { 634 - bio->bi_opf = parent->bi_opf; 632 + else 635 633 bio_chain(bio, parent); 636 - } 637 634 638 635 submit_bio(bio); 639 636 return 1;
+8 -13
drivers/md/dm-log-writes.c
··· 217 217 void *ptr; 218 218 size_t ret; 219 219 220 - bio = bio_alloc(GFP_KERNEL, 1); 220 + bio = bio_alloc(lc->logdev->bdev, 1, REQ_OP_WRITE, GFP_KERNEL); 221 221 bio->bi_iter.bi_size = 0; 222 222 bio->bi_iter.bi_sector = sector; 223 - bio_set_dev(bio, lc->logdev->bdev); 224 223 bio->bi_end_io = (sector == WRITE_LOG_SUPER_SECTOR) ? 225 224 log_end_super : log_end_io; 226 225 bio->bi_private = lc; 227 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 228 226 229 227 page = alloc_page(GFP_KERNEL); 230 228 if (!page) { ··· 269 271 270 272 atomic_inc(&lc->io_blocks); 271 273 272 - bio = bio_alloc(GFP_KERNEL, bio_pages); 274 + bio = bio_alloc(lc->logdev->bdev, bio_pages, REQ_OP_WRITE, 275 + GFP_KERNEL); 273 276 bio->bi_iter.bi_size = 0; 274 277 bio->bi_iter.bi_sector = sector; 275 - bio_set_dev(bio, lc->logdev->bdev); 276 278 bio->bi_end_io = log_end_io; 277 279 bio->bi_private = lc; 278 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 279 280 280 281 for (i = 0; i < bio_pages; i++) { 281 282 pg_datalen = min_t(int, datalen, PAGE_SIZE); ··· 350 353 goto out; 351 354 352 355 atomic_inc(&lc->io_blocks); 353 - bio = bio_alloc(GFP_KERNEL, bio_max_segs(block->vec_cnt)); 356 + bio = bio_alloc(lc->logdev->bdev, bio_max_segs(block->vec_cnt), 357 + REQ_OP_WRITE, GFP_KERNEL); 354 358 bio->bi_iter.bi_size = 0; 355 359 bio->bi_iter.bi_sector = sector; 356 - bio_set_dev(bio, lc->logdev->bdev); 357 360 bio->bi_end_io = log_end_io; 358 361 bio->bi_private = lc; 359 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 360 362 361 363 for (i = 0; i < block->vec_cnt; i++) { 362 364 /* ··· 367 371 if (ret != block->vecs[i].bv_len) { 368 372 atomic_inc(&lc->io_blocks); 369 373 submit_bio(bio); 370 - bio = bio_alloc(GFP_KERNEL, 371 - bio_max_segs(block->vec_cnt - i)); 374 + bio = bio_alloc(lc->logdev->bdev, 375 + bio_max_segs(block->vec_cnt - i), 376 + REQ_OP_WRITE, GFP_KERNEL); 372 377 bio->bi_iter.bi_size = 0; 373 378 bio->bi_iter.bi_sector = sector; 374 - bio_set_dev(bio, lc->logdev->bdev); 375 379 bio->bi_end_io = log_end_io; 376 380 bio->bi_private = lc; 377 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 378 381 379 382 ret = bio_add_page(bio, block->vecs[i].bv_page, 380 383 block->vecs[i].bv_len, 0);
+4 -5
drivers/md/dm-thin.c
··· 1177 1177 return; 1178 1178 } 1179 1179 1180 - discard_parent = bio_alloc(GFP_NOIO, 1); 1180 + discard_parent = bio_alloc(NULL, 1, 0, GFP_NOIO); 1181 1181 discard_parent->bi_end_io = passdown_endio; 1182 1182 discard_parent->bi_private = m; 1183 - 1184 - if (m->maybe_shared) 1185 - passdown_double_checking_shared_status(m, discard_parent); 1186 - else { 1183 + if (m->maybe_shared) 1184 + passdown_double_checking_shared_status(m, discard_parent); 1185 + else { 1187 1186 struct discard_op op; 1188 1187 1189 1188 begin_discard(&op, tc, discard_parent);
+6 -9
drivers/md/dm-zoned-metadata.c
··· 550 550 if (!mblk) 551 551 return ERR_PTR(-ENOMEM); 552 552 553 - bio = bio_alloc(GFP_NOIO, 1); 553 + bio = bio_alloc(dev->bdev, 1, REQ_OP_READ | REQ_META | REQ_PRIO, 554 + GFP_NOIO); 554 555 555 556 spin_lock(&zmd->mblk_lock); 556 557 ··· 575 574 576 575 /* Submit read BIO */ 577 576 bio->bi_iter.bi_sector = dmz_blk2sect(block); 578 - bio_set_dev(bio, dev->bdev); 579 577 bio->bi_private = mblk; 580 578 bio->bi_end_io = dmz_mblock_bio_end_io; 581 - bio_set_op_attrs(bio, REQ_OP_READ, REQ_META | REQ_PRIO); 582 579 bio_add_page(bio, mblk->page, DMZ_BLOCK_SIZE, 0); 583 580 submit_bio(bio); 584 581 ··· 720 721 if (dmz_bdev_is_dying(dev)) 721 722 return -EIO; 722 723 723 - bio = bio_alloc(GFP_NOIO, 1); 724 + bio = bio_alloc(dev->bdev, 1, REQ_OP_WRITE | REQ_META | REQ_PRIO, 725 + GFP_NOIO); 724 726 725 727 set_bit(DMZ_META_WRITING, &mblk->state); 726 728 727 729 bio->bi_iter.bi_sector = dmz_blk2sect(block); 728 - bio_set_dev(bio, dev->bdev); 729 730 bio->bi_private = mblk; 730 731 bio->bi_end_io = dmz_mblock_bio_end_io; 731 - bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_META | REQ_PRIO); 732 732 bio_add_page(bio, mblk->page, DMZ_BLOCK_SIZE, 0); 733 733 submit_bio(bio); 734 734 ··· 749 751 if (dmz_bdev_is_dying(dev)) 750 752 return -EIO; 751 753 752 - bio = bio_alloc(GFP_NOIO, 1); 754 + bio = bio_alloc(dev->bdev, 1, op | REQ_SYNC | REQ_META | REQ_PRIO, 755 + GFP_NOIO); 753 756 bio->bi_iter.bi_sector = dmz_blk2sect(block); 754 - bio_set_dev(bio, dev->bdev); 755 - bio_set_op_attrs(bio, op, REQ_SYNC | REQ_META | REQ_PRIO); 756 757 bio_add_page(bio, page, DMZ_BLOCK_SIZE, 0); 757 758 ret = submit_bio_wait(bio); 758 759 bio_put(bio);
+3 -3
drivers/nvdimm/nd_virtio.c
··· 105 105 * parent bio. Otherwise directly call nd_region flush. 106 106 */ 107 107 if (bio && bio->bi_iter.bi_sector != -1) { 108 - struct bio *child = bio_alloc(GFP_ATOMIC, 0); 108 + struct bio *child = bio_alloc(bio->bi_bdev, 0, REQ_PREFLUSH, 109 + GFP_ATOMIC); 109 110 110 111 if (!child) 111 112 return -ENOMEM; 112 - bio_copy_dev(child, bio); 113 - child->bi_opf = REQ_PREFLUSH; 113 + bio_clone_blkg_association(child, bio); 114 114 child->bi_iter.bi_sector = -1; 115 115 bio_chain(child, bio); 116 116 submit_bio(child);
+6 -6
drivers/nvme/target/io-cmd-bdev.c
··· 268 268 if (nvmet_use_inline_bvec(req)) { 269 269 bio = &req->b.inline_bio; 270 270 bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec)); 271 + bio_set_dev(bio, req->ns->bdev); 272 + bio->bi_opf = op; 271 273 } else { 272 - bio = bio_alloc(GFP_KERNEL, bio_max_segs(sg_cnt)); 274 + bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), op, 275 + GFP_KERNEL); 273 276 } 274 - bio_set_dev(bio, req->ns->bdev); 275 277 bio->bi_iter.bi_sector = sector; 276 278 bio->bi_private = req; 277 279 bio->bi_end_io = nvmet_bio_done; 278 - bio->bi_opf = op; 279 280 280 281 blk_start_plug(&plug); 281 282 if (req->metadata_len) ··· 297 296 } 298 297 } 299 298 300 - bio = bio_alloc(GFP_KERNEL, bio_max_segs(sg_cnt)); 301 - bio_set_dev(bio, req->ns->bdev); 299 + bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), 300 + op, GFP_KERNEL); 302 301 bio->bi_iter.bi_sector = sector; 303 - bio->bi_opf = op; 304 302 305 303 bio_chain(bio, prev); 306 304 submit_bio(prev);
+3 -2
drivers/nvme/target/passthru.c
··· 207 207 if (nvmet_use_inline_bvec(req)) { 208 208 bio = &req->p.inline_bio; 209 209 bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec)); 210 + bio->bi_opf = req_op(rq); 210 211 } else { 211 - bio = bio_alloc(GFP_KERNEL, bio_max_segs(req->sg_cnt)); 212 + bio = bio_alloc(NULL, bio_max_segs(req->sg_cnt), req_op(rq), 213 + GFP_KERNEL); 212 214 bio->bi_end_io = bio_put; 213 215 } 214 - bio->bi_opf = req_op(rq); 215 216 216 217 for_each_sg(req->sg, sg, req->sg_cnt, i) { 217 218 if (bio_add_pc_page(rq->q, bio, sg_page(sg), sg->length,
+3 -3
drivers/nvme/target/zns.c
··· 522 522 void nvmet_bdev_execute_zone_append(struct nvmet_req *req) 523 523 { 524 524 sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); 525 + const unsigned int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; 525 526 u16 status = NVME_SC_SUCCESS; 526 527 unsigned int total_len = 0; 527 528 struct scatterlist *sg; ··· 553 552 if (nvmet_use_inline_bvec(req)) { 554 553 bio = &req->z.inline_bio; 555 554 bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec)); 555 + bio->bi_opf = op; 556 556 } else { 557 - bio = bio_alloc(GFP_KERNEL, req->sg_cnt); 557 + bio = bio_alloc(req->ns->bdev, req->sg_cnt, op, GFP_KERNEL); 558 558 } 559 559 560 - bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; 561 560 bio->bi_end_io = nvmet_bdev_zone_append_bio_done; 562 - bio_set_dev(bio, req->ns->bdev); 563 561 bio->bi_iter.bi_sector = sect; 564 562 bio->bi_private = req; 565 563 if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA))
+2 -2
drivers/scsi/ufs/ufshpb.c
··· 494 494 if (!map_req) 495 495 return NULL; 496 496 497 - bio = bio_alloc(GFP_KERNEL, hpb->pages_per_srgn); 497 + bio = bio_alloc(NULL, hpb->pages_per_srgn, 0, GFP_KERNEL); 498 498 if (!bio) { 499 499 ufshpb_put_req(hpb, map_req); 500 500 return NULL; ··· 2050 2050 INIT_LIST_HEAD(&pre_req->list_req); 2051 2051 pre_req->req = NULL; 2052 2052 2053 - pre_req->bio = bio_alloc(GFP_KERNEL, 1); 2053 + pre_req->bio = bio_alloc(NULL, 1, 0, GFP_KERNEL); 2054 2054 if (!pre_req->bio) 2055 2055 goto release_mem; 2056 2056
+2 -3
drivers/target/target_core_iblock.c
··· 415 415 if (immed) 416 416 target_complete_cmd(cmd, SAM_STAT_GOOD); 417 417 418 - bio = bio_alloc(GFP_KERNEL, 0); 418 + bio = bio_alloc(ib_dev->ibd_bd, 0, REQ_OP_WRITE | REQ_PREFLUSH, 419 + GFP_KERNEL); 419 420 bio->bi_end_io = iblock_end_io_flush; 420 - bio_set_dev(bio, ib_dev->ibd_bd); 421 - bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; 422 421 if (!immed) 423 422 bio->bi_private = cmd; 424 423 submit_bio(bio);
+3 -3
fs/btrfs/disk-io.c
··· 4029 4029 * to do I/O, so we don't lose the ability to do integrity 4030 4030 * checking. 4031 4031 */ 4032 - bio = bio_alloc(GFP_NOFS, 1); 4033 - bio_set_dev(bio, device->bdev); 4032 + bio = bio_alloc(device->bdev, 1, 4033 + REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PRIO, 4034 + GFP_NOFS); 4034 4035 bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT; 4035 4036 bio->bi_private = device; 4036 4037 bio->bi_end_io = btrfs_end_super_write; ··· 4043 4042 * go down lazy and there's a short window where the on-disk 4044 4043 * copies might still contain the older version. 4045 4044 */ 4046 - bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PRIO; 4047 4045 if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER)) 4048 4046 bio->bi_opf |= REQ_FUA; 4049 4047
+6 -8
fs/buffer.c
··· 3024 3024 if (test_set_buffer_req(bh) && (op == REQ_OP_WRITE)) 3025 3025 clear_buffer_write_io_error(bh); 3026 3026 3027 - bio = bio_alloc(GFP_NOIO, 1); 3027 + if (buffer_meta(bh)) 3028 + op_flags |= REQ_META; 3029 + if (buffer_prio(bh)) 3030 + op_flags |= REQ_PRIO; 3031 + 3032 + bio = bio_alloc(bh->b_bdev, 1, op | op_flags, GFP_NOIO); 3028 3033 3029 3034 fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO); 3030 3035 3031 3036 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 3032 - bio_set_dev(bio, bh->b_bdev); 3033 3037 bio->bi_write_hint = write_hint; 3034 3038 3035 3039 bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh)); ··· 3041 3037 3042 3038 bio->bi_end_io = end_bio_bh_io_sync; 3043 3039 bio->bi_private = bh; 3044 - 3045 - if (buffer_meta(bh)) 3046 - op_flags |= REQ_META; 3047 - if (buffer_prio(bh)) 3048 - op_flags |= REQ_PRIO; 3049 - bio_set_op_attrs(bio, op, op_flags); 3050 3040 3051 3041 /* Take care of bh's that straddle the end of the device */ 3052 3042 guard_bio_eod(bio);
+7 -6
fs/crypto/bio.c
··· 54 54 int num_pages = 0; 55 55 56 56 /* This always succeeds since __GFP_DIRECT_RECLAIM is set. */ 57 - bio = bio_alloc(GFP_NOFS, BIO_MAX_VECS); 57 + bio = bio_alloc(inode->i_sb->s_bdev, BIO_MAX_VECS, REQ_OP_WRITE, 58 + GFP_NOFS); 58 59 59 60 while (len) { 60 61 unsigned int blocks_this_page = min(len, blocks_per_page); ··· 63 62 64 63 if (num_pages == 0) { 65 64 fscrypt_set_bio_crypt_ctx(bio, inode, lblk, GFP_NOFS); 66 - bio_set_dev(bio, inode->i_sb->s_bdev); 67 65 bio->bi_iter.bi_sector = 68 66 pblk << (blockbits - SECTOR_SHIFT); 69 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 70 67 } 71 68 ret = bio_add_page(bio, ZERO_PAGE(0), bytes_this_page, 0); 72 69 if (WARN_ON(ret != bytes_this_page)) { ··· 81 82 if (err) 82 83 goto out; 83 84 bio_reset(bio); 85 + bio_set_dev(bio, inode->i_sb->s_bdev); 86 + bio->bi_opf = REQ_OP_WRITE; 84 87 num_pages = 0; 85 88 } 86 89 } ··· 151 150 return -EINVAL; 152 151 153 152 /* This always succeeds since __GFP_DIRECT_RECLAIM is set. */ 154 - bio = bio_alloc(GFP_NOFS, nr_pages); 153 + bio = bio_alloc(inode->i_sb->s_bdev, nr_pages, REQ_OP_WRITE, GFP_NOFS); 155 154 156 155 do { 157 - bio_set_dev(bio, inode->i_sb->s_bdev); 158 156 bio->bi_iter.bi_sector = pblk << (blockbits - 9); 159 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 160 157 161 158 i = 0; 162 159 offset = 0; ··· 182 183 if (err) 183 184 goto out; 184 185 bio_reset(bio); 186 + bio_set_dev(bio, inode->i_sb->s_bdev); 187 + bio->bi_opf = REQ_OP_WRITE; 185 188 } while (len != 0); 186 189 err = 0; 187 190 out:
+1 -4
fs/direct-io.c
··· 396 396 * bio_alloc() is guaranteed to return a bio when allowed to sleep and 397 397 * we request a valid number of vectors. 398 398 */ 399 - bio = bio_alloc(GFP_KERNEL, nr_vecs); 400 - 401 - bio_set_dev(bio, bdev); 399 + bio = bio_alloc(bdev, nr_vecs, dio->op | dio->op_flags, GFP_KERNEL); 402 400 bio->bi_iter.bi_sector = first_sector; 403 - bio_set_op_attrs(bio, dio->op, dio->op_flags); 404 401 if (dio->is_async) 405 402 bio->bi_end_io = dio_bio_end_aio; 406 403 else
+2 -3
fs/erofs/zdata.c
··· 1371 1371 } 1372 1372 1373 1373 if (!bio) { 1374 - bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS); 1374 + bio = bio_alloc(mdev.m_bdev, BIO_MAX_VECS, 1375 + REQ_OP_READ, GFP_NOIO); 1375 1376 bio->bi_end_io = z_erofs_decompressqueue_endio; 1376 1377 1377 - bio_set_dev(bio, mdev.m_bdev); 1378 1378 last_bdev = mdev.m_bdev; 1379 1379 bio->bi_iter.bi_sector = (sector_t)cur << 1380 1380 LOG_SECTORS_PER_BLOCK; 1381 1381 bio->bi_private = bi_private; 1382 - bio->bi_opf = REQ_OP_READ; 1383 1382 if (f->readahead) 1384 1383 bio->bi_opf |= REQ_RAHEAD; 1385 1384 ++nr_bios;
+1 -2
fs/ext4/page-io.c
··· 398 398 * bio_alloc will _always_ be able to allocate a bio if 399 399 * __GFP_DIRECT_RECLAIM is set, see comments for bio_alloc_bioset(). 400 400 */ 401 - bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS); 401 + bio = bio_alloc(bh->b_bdev, BIO_MAX_VECS, 0, GFP_NOIO); 402 402 fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO); 403 403 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 404 - bio_set_dev(bio, bh->b_bdev); 405 404 bio->bi_end_io = ext4_end_bio; 406 405 bio->bi_private = ext4_get_io_end(io->io_end); 407 406 io->io_bio = bio;
+4 -4
fs/ext4/readpage.c
··· 365 365 * bio_alloc will _always_ be able to allocate a bio if 366 366 * __GFP_DIRECT_RECLAIM is set, see bio_alloc_bioset(). 367 367 */ 368 - bio = bio_alloc(GFP_KERNEL, bio_max_segs(nr_pages)); 368 + bio = bio_alloc(bdev, bio_max_segs(nr_pages), 369 + REQ_OP_READ, GFP_KERNEL); 369 370 fscrypt_set_bio_crypt_ctx(bio, inode, next_block, 370 371 GFP_KERNEL); 371 372 ext4_set_bio_post_read_ctx(bio, inode, page->index); 372 - bio_set_dev(bio, bdev); 373 373 bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); 374 374 bio->bi_end_io = mpage_end_io; 375 - bio_set_op_attrs(bio, REQ_OP_READ, 376 - rac ? REQ_RAHEAD : 0); 375 + if (rac) 376 + bio->bi_opf |= REQ_RAHEAD; 377 377 } 378 378 379 379 length = first_hole << blkbits;
+3 -5
fs/gfs2/lops.c
··· 265 265 bio_end_io_t *end_io) 266 266 { 267 267 struct super_block *sb = sdp->sd_vfs; 268 - struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS); 268 + struct bio *bio = bio_alloc(sb->s_bdev, BIO_MAX_VECS, 0, GFP_NOIO); 269 269 270 270 bio->bi_iter.bi_sector = blkno << sdp->sd_fsb2bb_shift; 271 - bio_set_dev(bio, sb->s_bdev); 272 271 bio->bi_end_io = end_io; 273 272 bio->bi_private = sdp; 274 273 ··· 488 489 { 489 490 struct bio *new; 490 491 491 - new = bio_alloc(GFP_NOIO, nr_iovecs); 492 - bio_copy_dev(new, prev); 492 + new = bio_alloc(prev->bi_bdev, nr_iovecs, prev->bi_opf, GFP_NOIO); 493 + bio_clone_blkg_association(new, prev); 493 494 new->bi_iter.bi_sector = bio_end_sector(prev); 494 - new->bi_opf = prev->bi_opf; 495 495 new->bi_write_hint = prev->bi_write_hint; 496 496 bio_chain(new, prev); 497 497 submit_bio(prev);
+1 -3
fs/gfs2/meta_io.c
··· 222 222 struct buffer_head *bh = *bhs; 223 223 struct bio *bio; 224 224 225 - bio = bio_alloc(GFP_NOIO, num); 225 + bio = bio_alloc(bh->b_bdev, num, op | op_flags, GFP_NOIO); 226 226 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 227 - bio_set_dev(bio, bh->b_bdev); 228 227 while (num > 0) { 229 228 bh = *bhs; 230 229 if (!bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh))) { ··· 234 235 num--; 235 236 } 236 237 bio->bi_end_io = gfs2_meta_read_endio; 237 - bio_set_op_attrs(bio, op, op_flags); 238 238 submit_bio(bio); 239 239 } 240 240 }
+1 -3
fs/gfs2/ops_fstype.c
··· 251 251 ClearPageDirty(page); 252 252 lock_page(page); 253 253 254 - bio = bio_alloc(GFP_NOFS, 1); 254 + bio = bio_alloc(sb->s_bdev, 1, REQ_OP_READ | REQ_META, GFP_NOFS); 255 255 bio->bi_iter.bi_sector = sector * (sb->s_blocksize >> 9); 256 - bio_set_dev(bio, sb->s_bdev); 257 256 bio_add_page(bio, page, PAGE_SIZE, 0); 258 257 259 258 bio->bi_end_io = end_bio_io_page; 260 259 bio->bi_private = page; 261 - bio_set_op_attrs(bio, REQ_OP_READ, REQ_META); 262 260 submit_bio(bio); 263 261 wait_on_page_locked(page); 264 262 bio_put(bio);
+1 -3
fs/hfsplus/wrapper.c
··· 63 63 offset = start & (io_size - 1); 64 64 sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1); 65 65 66 - bio = bio_alloc(GFP_NOIO, 1); 66 + bio = bio_alloc(sb->s_bdev, 1, op | op_flags, GFP_NOIO); 67 67 bio->bi_iter.bi_sector = sector; 68 - bio_set_dev(bio, sb->s_bdev); 69 - bio_set_op_attrs(bio, op, op_flags); 70 68 71 69 if (op != WRITE && data) 72 70 *data = (u8 *)buf + offset;
+8 -8
fs/iomap/buffered-io.c
··· 290 290 291 291 if (ctx->rac) /* same as readahead_gfp_mask */ 292 292 gfp |= __GFP_NORETRY | __GFP_NOWARN; 293 - ctx->bio = bio_alloc(gfp, bio_max_segs(nr_vecs)); 293 + ctx->bio = bio_alloc(iomap->bdev, bio_max_segs(nr_vecs), 294 + REQ_OP_READ, gfp); 294 295 /* 295 296 * If the bio_alloc fails, try it again for a single page to 296 297 * avoid having to deal with partial page reads. This emulates 297 298 * what do_mpage_readpage does. 298 299 */ 299 - if (!ctx->bio) 300 - ctx->bio = bio_alloc(orig_gfp, 1); 301 - ctx->bio->bi_opf = REQ_OP_READ; 300 + if (!ctx->bio) { 301 + ctx->bio = bio_alloc(iomap->bdev, 1, REQ_OP_READ, 302 + orig_gfp); 303 + } 302 304 if (ctx->rac) 303 305 ctx->bio->bi_opf |= REQ_RAHEAD; 304 306 ctx->bio->bi_iter.bi_sector = sector; 305 - bio_set_dev(ctx->bio, iomap->bdev); 306 307 ctx->bio->bi_end_io = iomap_read_end_io; 307 308 bio_add_folio(ctx->bio, folio, plen, poff); 308 309 } ··· 1227 1226 { 1228 1227 struct bio *new; 1229 1228 1230 - new = bio_alloc(GFP_NOFS, BIO_MAX_VECS); 1231 - bio_copy_dev(new, prev);/* also copies over blkcg information */ 1229 + new = bio_alloc(prev->bi_bdev, BIO_MAX_VECS, prev->bi_opf, GFP_NOFS); 1230 + bio_clone_blkg_association(new, prev); 1232 1231 new->bi_iter.bi_sector = bio_end_sector(prev); 1233 - new->bi_opf = prev->bi_opf; 1234 1232 new->bi_write_hint = prev->bi_write_hint; 1235 1233 1236 1234 bio_chain(prev, new);
+2 -6
fs/iomap/direct-io.c
··· 183 183 int flags = REQ_SYNC | REQ_IDLE; 184 184 struct bio *bio; 185 185 186 - bio = bio_alloc(GFP_KERNEL, 1); 187 - bio_set_dev(bio, iter->iomap.bdev); 186 + bio = bio_alloc(iter->iomap.bdev, 1, REQ_OP_WRITE | flags, GFP_KERNEL); 188 187 bio->bi_iter.bi_sector = iomap_sector(&iter->iomap, pos); 189 188 bio->bi_private = dio; 190 189 bio->bi_end_io = iomap_dio_bio_end_io; 191 190 192 191 get_page(page); 193 192 __bio_add_page(bio, page, len, 0); 194 - bio_set_op_attrs(bio, REQ_OP_WRITE, flags); 195 193 iomap_dio_submit_bio(iter, dio, bio, pos); 196 194 } 197 195 ··· 307 309 goto out; 308 310 } 309 311 310 - bio = bio_alloc(GFP_KERNEL, nr_pages); 311 - bio_set_dev(bio, iomap->bdev); 312 + bio = bio_alloc(iomap->bdev, nr_pages, bio_opf, GFP_KERNEL); 312 313 bio->bi_iter.bi_sector = iomap_sector(iomap, pos); 313 314 bio->bi_write_hint = dio->iocb->ki_hint; 314 315 bio->bi_ioprio = dio->iocb->ki_ioprio; 315 316 bio->bi_private = dio; 316 317 bio->bi_end_io = iomap_dio_bio_end_io; 317 - bio->bi_opf = bio_opf; 318 318 319 319 ret = bio_iov_iter_get_pages(bio, dio->submit.iter); 320 320 if (unlikely(ret)) {
+2 -9
fs/jfs/jfs_logmgr.c
··· 1980 1980 1981 1981 bp->l_flag |= lbmREAD; 1982 1982 1983 - bio = bio_alloc(GFP_NOFS, 1); 1984 - 1983 + bio = bio_alloc(log->bdev, 1, REQ_OP_READ, GFP_NOFS); 1985 1984 bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); 1986 - bio_set_dev(bio, log->bdev); 1987 - 1988 1985 bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset); 1989 1986 BUG_ON(bio->bi_iter.bi_size != LOGPSIZE); 1990 1987 1991 1988 bio->bi_end_io = lbmIODone; 1992 1989 bio->bi_private = bp; 1993 - bio->bi_opf = REQ_OP_READ; 1994 1990 /*check if journaling to disk has been disabled*/ 1995 1991 if (log->no_integrity) { 1996 1992 bio->bi_iter.bi_size = 0; ··· 2121 2125 2122 2126 jfs_info("lbmStartIO"); 2123 2127 2124 - bio = bio_alloc(GFP_NOFS, 1); 2128 + bio = bio_alloc(log->bdev, 1, REQ_OP_WRITE | REQ_SYNC, GFP_NOFS); 2125 2129 bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); 2126 - bio_set_dev(bio, log->bdev); 2127 - 2128 2130 bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset); 2129 2131 BUG_ON(bio->bi_iter.bi_size != LOGPSIZE); 2130 2132 2131 2133 bio->bi_end_io = lbmIODone; 2132 2134 bio->bi_private = bp; 2133 - bio->bi_opf = REQ_OP_WRITE | REQ_SYNC; 2134 2135 2135 2136 /* check if journaling to disk has been disabled */ 2136 2137 if (log->no_integrity) {
+3 -6
fs/jfs/jfs_metapage.c
··· 417 417 } 418 418 len = min(xlen, (int)JFS_SBI(inode->i_sb)->nbperpage); 419 419 420 - bio = bio_alloc(GFP_NOFS, 1); 421 - bio_set_dev(bio, inode->i_sb->s_bdev); 420 + bio = bio_alloc(inode->i_sb->s_bdev, 1, REQ_OP_WRITE, GFP_NOFS); 422 421 bio->bi_iter.bi_sector = pblock << (inode->i_blkbits - 9); 423 422 bio->bi_end_io = metapage_write_end_io; 424 423 bio->bi_private = page; 425 - bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 426 424 427 425 /* Don't call bio_add_page yet, we may add to this vec */ 428 426 bio_offset = offset; ··· 495 497 if (bio) 496 498 submit_bio(bio); 497 499 498 - bio = bio_alloc(GFP_NOFS, 1); 499 - bio_set_dev(bio, inode->i_sb->s_bdev); 500 + bio = bio_alloc(inode->i_sb->s_bdev, 1, REQ_OP_READ, 501 + GFP_NOFS); 500 502 bio->bi_iter.bi_sector = 501 503 pblock << (inode->i_blkbits - 9); 502 504 bio->bi_end_io = metapage_read_end_io; 503 505 bio->bi_private = page; 504 - bio_set_op_attrs(bio, REQ_OP_READ, 0); 505 506 len = xlen << inode->i_blkbits; 506 507 offset = block_offset << inode->i_blkbits; 507 508 if (bio_add_page(bio, page, len, offset) < len)
+3 -4
fs/mpage.c
··· 273 273 page)) 274 274 goto out; 275 275 } 276 - args->bio = bio_alloc(gfp, bio_max_segs(args->nr_pages)); 276 + args->bio = bio_alloc(bdev, bio_max_segs(args->nr_pages), 0, 277 + gfp); 277 278 if (args->bio == NULL) 278 279 goto confused; 279 - bio_set_dev(args->bio, bdev); 280 280 args->bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); 281 281 } 282 282 ··· 586 586 page, wbc)) 587 587 goto out; 588 588 } 589 - bio = bio_alloc(GFP_NOFS, BIO_MAX_VECS); 590 - bio_set_dev(bio, bdev); 589 + bio = bio_alloc(bdev, BIO_MAX_VECS, 0, GFP_NOFS); 591 590 bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); 592 591 593 592 wbc_init_bio(wbc, bio);
+1 -3
fs/nfs/blocklayout/blocklayout.c
··· 154 154 155 155 retry: 156 156 if (!bio) { 157 - bio = bio_alloc(GFP_NOIO, bio_max_segs(npg)); 157 + bio = bio_alloc(map->bdev, bio_max_segs(npg), rw, GFP_NOIO); 158 158 bio->bi_iter.bi_sector = disk_addr >> SECTOR_SHIFT; 159 - bio_set_dev(bio, map->bdev); 160 159 bio->bi_end_io = end_io; 161 160 bio->bi_private = par; 162 - bio_set_op_attrs(bio, rw, 0); 163 161 } 164 162 if (bio_add_page(bio, page, *len, offset) < *len) { 165 163 bio = bl_submit_bio(bio);
+2 -2
fs/nilfs2/segbuf.c
··· 391 391 BUG_ON(wi->nr_vecs <= 0); 392 392 repeat: 393 393 if (!wi->bio) { 394 - wi->bio = bio_alloc(GFP_NOIO, wi->nr_vecs); 395 - bio_set_dev(wi->bio, wi->nilfs->ns_bdev); 394 + wi->bio = bio_alloc(wi->nilfs->ns_bdev, wi->nr_vecs, 0, 395 + GFP_NOIO); 396 396 wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) << 397 397 (wi->nilfs->ns_blocksize_bits - 9); 398 398 }
+2 -6
fs/ntfs3/fsntfs.c
··· 1485 1485 lbo = ((u64)lcn << cluster_bits) + off; 1486 1486 len = ((u64)clen << cluster_bits) - off; 1487 1487 new_bio: 1488 - new = bio_alloc(GFP_NOFS, nr_pages - page_idx); 1488 + new = bio_alloc(bdev, nr_pages - page_idx, op, GFP_NOFS); 1489 1489 if (bio) { 1490 1490 bio_chain(bio, new); 1491 1491 submit_bio(bio); 1492 1492 } 1493 1493 bio = new; 1494 - bio_set_dev(bio, bdev); 1495 1494 bio->bi_iter.bi_sector = lbo >> 9; 1496 - bio->bi_opf = op; 1497 1495 1498 1496 while (len) { 1499 1497 off = vbo & (PAGE_SIZE - 1); ··· 1582 1584 lbo = (u64)lcn << cluster_bits; 1583 1585 len = (u64)clen << cluster_bits; 1584 1586 new_bio: 1585 - new = bio_alloc(GFP_NOFS, BIO_MAX_VECS); 1587 + new = bio_alloc(bdev, BIO_MAX_VECS, REQ_OP_WRITE, GFP_NOFS); 1586 1588 if (bio) { 1587 1589 bio_chain(bio, new); 1588 1590 submit_bio(bio); 1589 1591 } 1590 1592 bio = new; 1591 - bio_set_dev(bio, bdev); 1592 - bio->bi_opf = REQ_OP_WRITE; 1593 1593 bio->bi_iter.bi_sector = lbo >> 9; 1594 1594 1595 1595 for (;;) {
+1 -3
fs/ocfs2/cluster/heartbeat.c
··· 518 518 * GFP_KERNEL that the local node can get fenced. It would be 519 519 * nicest if we could pre-allocate these bios and avoid this 520 520 * all together. */ 521 - bio = bio_alloc(GFP_ATOMIC, 16); 521 + bio = bio_alloc(reg->hr_bdev, 16, op | op_flags, GFP_ATOMIC); 522 522 if (!bio) { 523 523 mlog(ML_ERROR, "Could not alloc slots BIO!\n"); 524 524 bio = ERR_PTR(-ENOMEM); ··· 527 527 528 528 /* Must put everything in 512 byte sectors for the bio... */ 529 529 bio->bi_iter.bi_sector = (reg->hr_start_block + cs) << (bits - 9); 530 - bio_set_dev(bio, reg->hr_bdev); 531 530 bio->bi_private = wc; 532 531 bio->bi_end_io = o2hb_bio_end_io; 533 - bio_set_op_attrs(bio, op, op_flags); 534 532 535 533 vec_start = (cs << bits) % PAGE_SIZE; 536 534 while(cs < max_slots) {
+6 -5
fs/squashfs/block.c
··· 86 86 int error, i; 87 87 struct bio *bio; 88 88 89 - if (page_count <= BIO_MAX_VECS) 90 - bio = bio_alloc(GFP_NOIO, page_count); 91 - else 89 + if (page_count <= BIO_MAX_VECS) { 90 + bio = bio_alloc(sb->s_bdev, page_count, REQ_OP_READ, GFP_NOIO); 91 + } else { 92 92 bio = bio_kmalloc(GFP_NOIO, page_count); 93 + bio_set_dev(bio, sb->s_bdev); 94 + bio->bi_opf = REQ_OP_READ; 95 + } 93 96 94 97 if (!bio) 95 98 return -ENOMEM; 96 99 97 - bio_set_dev(bio, sb->s_bdev); 98 - bio->bi_opf = READ; 99 100 bio->bi_iter.bi_sector = block * (msblk->devblksize >> SECTOR_SHIFT); 100 101 101 102 for (i = 0; i < page_count; ++i) {
+4 -6
fs/xfs/xfs_bio_io.c
··· 61 61 if (is_vmalloc && op == REQ_OP_WRITE) 62 62 flush_kernel_vmap_range(data, count); 63 63 64 - bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left)); 65 - bio_set_dev(bio, bdev); 64 + bio = bio_alloc(bdev, bio_max_vecs(left), op | REQ_META | REQ_SYNC, 65 + GFP_KERNEL); 66 66 bio->bi_iter.bi_sector = sector; 67 - bio->bi_opf = op | REQ_META | REQ_SYNC; 68 67 69 68 do { 70 69 struct page *page = kmem_to_page(data); ··· 73 74 while (bio_add_page(bio, page, len, off) != len) { 74 75 struct bio *prev = bio; 75 76 76 - bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left)); 77 - bio_copy_dev(bio, prev); 77 + bio = bio_alloc(prev->bi_bdev, bio_max_vecs(left), 78 + prev->bi_opf, GFP_KERNEL); 78 79 bio->bi_iter.bi_sector = bio_end_sector(prev); 79 - bio->bi_opf = prev->bi_opf; 80 80 bio_chain(prev, bio); 81 81 82 82 submit_bio(prev);
+1 -3
fs/xfs/xfs_buf.c
··· 1440 1440 atomic_inc(&bp->b_io_remaining); 1441 1441 nr_pages = bio_max_segs(total_nr_pages); 1442 1442 1443 - bio = bio_alloc(GFP_NOIO, nr_pages); 1444 - bio_set_dev(bio, bp->b_target->bt_bdev); 1443 + bio = bio_alloc(bp->b_target->bt_bdev, nr_pages, op, GFP_NOIO); 1445 1444 bio->bi_iter.bi_sector = sector; 1446 1445 bio->bi_end_io = xfs_buf_bio_end_io; 1447 1446 bio->bi_private = bp; 1448 - bio->bi_opf = op; 1449 1447 1450 1448 for (; size && nr_pages; nr_pages--, page_index++) { 1451 1449 int rbytes, nbytes = PAGE_SIZE - offset;
+2 -3
fs/zonefs/super.c
··· 692 692 if (!nr_pages) 693 693 return 0; 694 694 695 - bio = bio_alloc(GFP_NOFS, nr_pages); 696 - bio_set_dev(bio, bdev); 695 + bio = bio_alloc(bdev, nr_pages, 696 + REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE, GFP_NOFS); 697 697 bio->bi_iter.bi_sector = zi->i_zsector; 698 698 bio->bi_write_hint = iocb->ki_hint; 699 699 bio->bi_ioprio = iocb->ki_ioprio; 700 - bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE; 701 700 if (iocb->ki_flags & IOCB_DSYNC) 702 701 bio->bi_opf |= REQ_FUA; 703 702
+3 -2
include/linux/bio.h
··· 418 418 419 419 extern struct bio_set fs_bio_set; 420 420 421 - static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned short nr_iovecs) 421 + static inline struct bio *bio_alloc(struct block_device *bdev, 422 + unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask) 422 423 { 423 - return bio_alloc_bioset(NULL, nr_iovecs, 0, gfp_mask, &fs_bio_set); 424 + return bio_alloc_bioset(bdev, nr_vecs, opf, gfp_mask, &fs_bio_set); 424 425 } 425 426 426 427 void submit_bio(struct bio *bio);
+2 -3
kernel/power/swap.c
··· 276 276 struct bio *bio; 277 277 int error = 0; 278 278 279 - bio = bio_alloc(GFP_NOIO | __GFP_HIGH, 1); 279 + bio = bio_alloc(hib_resume_bdev, 1, op | op_flags, 280 + GFP_NOIO | __GFP_HIGH); 280 281 bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9); 281 - bio_set_dev(bio, hib_resume_bdev); 282 - bio_set_op_attrs(bio, op, op_flags); 283 282 284 283 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { 285 284 pr_err("Adding page to bio failed at %llu\n",
+4 -6
mm/page_io.c
··· 338 338 return 0; 339 339 } 340 340 341 - bio = bio_alloc(GFP_NOIO, 1); 342 - bio_set_dev(bio, sis->bdev); 341 + bio = bio_alloc(sis->bdev, 1, 342 + REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc), 343 + GFP_NOIO); 343 344 bio->bi_iter.bi_sector = swap_page_sector(page); 344 - bio->bi_opf = REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc); 345 345 bio->bi_end_io = end_write_func; 346 346 bio_add_page(bio, page, thp_size(page), 0); 347 347 ··· 403 403 } 404 404 405 405 ret = 0; 406 - bio = bio_alloc(GFP_KERNEL, 1); 407 - bio_set_dev(bio, sis->bdev); 408 - bio->bi_opf = REQ_OP_READ; 406 + bio = bio_alloc(sis->bdev, 1, REQ_OP_READ, GFP_KERNEL); 409 407 bio->bi_iter.bi_sector = swap_page_sector(page); 410 408 bio->bi_end_io = end_swap_bio_read; 411 409 bio_add_page(bio, page, thp_size(page), 0);