mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
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>
This commit is contained in:
committed by
Jens Axboe
parent
b77c88c210
commit
07888c665b
+1
-4
@@ -347,10 +347,7 @@ EXPORT_SYMBOL(bio_chain);
|
||||
struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev,
|
||||
unsigned int nr_pages, unsigned int opf, gfp_t gfp)
|
||||
{
|
||||
struct bio *new = bio_alloc(gfp, nr_pages);
|
||||
|
||||
bio_set_dev(new, bdev);
|
||||
new->bi_opf = opf;
|
||||
struct bio *new = bio_alloc(bdev, nr_pages, opf, gfp);
|
||||
|
||||
if (bio) {
|
||||
bio_chain(bio, new);
|
||||
|
||||
+1
-3
@@ -256,9 +256,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
|
||||
}
|
||||
atomic_inc(&dio->ref);
|
||||
submit_bio(bio);
|
||||
bio = bio_alloc(GFP_KERNEL, nr_pages);
|
||||
bio_set_dev(bio, bdev);
|
||||
bio->bi_opf = opf;
|
||||
bio = bio_alloc(bdev, nr_pages, opf, GFP_KERNEL);
|
||||
}
|
||||
|
||||
blk_finish_plug(&plug);
|
||||
|
||||
@@ -1279,7 +1279,8 @@ static void one_flush_endio(struct bio *bio)
|
||||
|
||||
static void submit_one_flush(struct drbd_device *device, struct issue_flush_context *ctx)
|
||||
{
|
||||
struct bio *bio = bio_alloc(GFP_NOIO, 0);
|
||||
struct bio *bio = bio_alloc(device->ldev->backing_bdev, 0,
|
||||
REQ_OP_FLUSH | REQ_PREFLUSH, GFP_NOIO);
|
||||
struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO);
|
||||
|
||||
if (!octx) {
|
||||
@@ -1297,10 +1298,8 @@ static void submit_one_flush(struct drbd_device *device, struct issue_flush_cont
|
||||
|
||||
octx->device = device;
|
||||
octx->ctx = ctx;
|
||||
bio_set_dev(bio, device->ldev->backing_bdev);
|
||||
bio->bi_private = octx;
|
||||
bio->bi_end_io = one_flush_endio;
|
||||
bio->bi_opf = REQ_OP_FLUSH | REQ_PREFLUSH;
|
||||
|
||||
device->flush_jif = jiffies;
|
||||
set_bit(FLUSH_PENDING, &device->flags);
|
||||
@@ -1685,11 +1684,10 @@ int drbd_submit_peer_request(struct drbd_device *device,
|
||||
* generated bio, but a bio allocated on behalf of the peer.
|
||||
*/
|
||||
next_bio:
|
||||
bio = bio_alloc(GFP_NOIO, nr_pages);
|
||||
bio = bio_alloc(device->ldev->backing_bdev, nr_pages, op | op_flags,
|
||||
GFP_NOIO);
|
||||
/* > peer_req->i.sector, unless this is the first bio */
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio_set_dev(bio, device->ldev->backing_bdev);
|
||||
bio_set_op_attrs(bio, op, op_flags);
|
||||
bio->bi_private = peer_req;
|
||||
bio->bi_end_io = drbd_peer_request_endio;
|
||||
|
||||
|
||||
@@ -149,7 +149,8 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
|
||||
priv->sess_dev = sess_dev;
|
||||
priv->id = id;
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, 1);
|
||||
bio = bio_alloc(sess_dev->rnbd_dev->bdev, 1,
|
||||
rnbd_to_bio_flags(le32_to_cpu(msg->rw)), GFP_KERNEL);
|
||||
if (bio_add_page(bio, virt_to_page(data), datalen,
|
||||
offset_in_page(data)) != datalen) {
|
||||
rnbd_srv_err(sess_dev, "Failed to map data to bio\n");
|
||||
@@ -159,13 +160,11 @@ static int process_rdma(struct rnbd_srv_session *srv_sess,
|
||||
|
||||
bio->bi_end_io = rnbd_dev_bi_end_io;
|
||||
bio->bi_private = priv;
|
||||
bio->bi_opf = rnbd_to_bio_flags(le32_to_cpu(msg->rw));
|
||||
bio->bi_iter.bi_sector = le64_to_cpu(msg->sector);
|
||||
bio->bi_iter.bi_size = le32_to_cpu(msg->bi_size);
|
||||
prio = srv_sess->ver < RNBD_PROTO_VER_MAJOR ||
|
||||
usrlen < sizeof(*msg) ? 0 : le16_to_cpu(msg->prio);
|
||||
bio_set_prio(bio, prio);
|
||||
bio_set_dev(bio, sess_dev->rnbd_dev->bdev);
|
||||
|
||||
submit_bio(bio);
|
||||
|
||||
|
||||
@@ -1326,13 +1326,13 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
|
||||
pages[i]->page,
|
||||
seg[i].nsec << 9,
|
||||
seg[i].offset) == 0)) {
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(nseg - i));
|
||||
bio = bio_alloc(preq.bdev, bio_max_segs(nseg - i),
|
||||
operation | operation_flags,
|
||||
GFP_KERNEL);
|
||||
biolist[nbio++] = bio;
|
||||
bio_set_dev(bio, preq.bdev);
|
||||
bio->bi_private = pending_req;
|
||||
bio->bi_end_io = end_block_io_op;
|
||||
bio->bi_iter.bi_sector = preq.sector_number;
|
||||
bio_set_op_attrs(bio, operation, operation_flags);
|
||||
}
|
||||
|
||||
preq.sector_number += seg[i].nsec;
|
||||
@@ -1342,12 +1342,11 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
|
||||
if (!bio) {
|
||||
BUG_ON(operation_flags != REQ_PREFLUSH);
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, 0);
|
||||
bio = bio_alloc(preq.bdev, 0, operation | operation_flags,
|
||||
GFP_KERNEL);
|
||||
biolist[nbio++] = bio;
|
||||
bio_set_dev(bio, preq.bdev);
|
||||
bio->bi_private = pending_req;
|
||||
bio->bi_end_io = end_block_io_op;
|
||||
bio_set_op_attrs(bio, operation, operation_flags);
|
||||
}
|
||||
|
||||
atomic_set(&pending_req->pendcnt, nbio);
|
||||
|
||||
@@ -616,24 +616,21 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
|
||||
{
|
||||
struct bio *bio;
|
||||
|
||||
bio = bio_alloc(GFP_NOIO, 1);
|
||||
bio = bio_alloc(zram->bdev, 1, parent ? parent->bi_opf : REQ_OP_READ,
|
||||
GFP_NOIO);
|
||||
if (!bio)
|
||||
return -ENOMEM;
|
||||
|
||||
bio->bi_iter.bi_sector = entry * (PAGE_SIZE >> 9);
|
||||
bio_set_dev(bio, zram->bdev);
|
||||
if (!bio_add_page(bio, bvec->bv_page, bvec->bv_len, bvec->bv_offset)) {
|
||||
bio_put(bio);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
bio->bi_opf = REQ_OP_READ;
|
||||
if (!parent)
|
||||
bio->bi_end_io = zram_page_end_io;
|
||||
} else {
|
||||
bio->bi_opf = parent->bi_opf;
|
||||
else
|
||||
bio_chain(bio, parent);
|
||||
}
|
||||
|
||||
submit_bio(bio);
|
||||
return 1;
|
||||
|
||||
@@ -217,14 +217,12 @@ static int write_metadata(struct log_writes_c *lc, void *entry,
|
||||
void *ptr;
|
||||
size_t ret;
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, 1);
|
||||
bio = bio_alloc(lc->logdev->bdev, 1, REQ_OP_WRITE, GFP_KERNEL);
|
||||
bio->bi_iter.bi_size = 0;
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio_set_dev(bio, lc->logdev->bdev);
|
||||
bio->bi_end_io = (sector == WRITE_LOG_SUPER_SECTOR) ?
|
||||
log_end_super : log_end_io;
|
||||
bio->bi_private = lc;
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
|
||||
page = alloc_page(GFP_KERNEL);
|
||||
if (!page) {
|
||||
@@ -271,13 +269,12 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
|
||||
|
||||
atomic_inc(&lc->io_blocks);
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, bio_pages);
|
||||
bio = bio_alloc(lc->logdev->bdev, bio_pages, REQ_OP_WRITE,
|
||||
GFP_KERNEL);
|
||||
bio->bi_iter.bi_size = 0;
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio_set_dev(bio, lc->logdev->bdev);
|
||||
bio->bi_end_io = log_end_io;
|
||||
bio->bi_private = lc;
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
|
||||
for (i = 0; i < bio_pages; i++) {
|
||||
pg_datalen = min_t(int, datalen, PAGE_SIZE);
|
||||
@@ -353,13 +350,12 @@ static int log_one_block(struct log_writes_c *lc,
|
||||
goto out;
|
||||
|
||||
atomic_inc(&lc->io_blocks);
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(block->vec_cnt));
|
||||
bio = bio_alloc(lc->logdev->bdev, bio_max_segs(block->vec_cnt),
|
||||
REQ_OP_WRITE, GFP_KERNEL);
|
||||
bio->bi_iter.bi_size = 0;
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio_set_dev(bio, lc->logdev->bdev);
|
||||
bio->bi_end_io = log_end_io;
|
||||
bio->bi_private = lc;
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
|
||||
for (i = 0; i < block->vec_cnt; i++) {
|
||||
/*
|
||||
@@ -371,14 +367,13 @@ static int log_one_block(struct log_writes_c *lc,
|
||||
if (ret != block->vecs[i].bv_len) {
|
||||
atomic_inc(&lc->io_blocks);
|
||||
submit_bio(bio);
|
||||
bio = bio_alloc(GFP_KERNEL,
|
||||
bio_max_segs(block->vec_cnt - i));
|
||||
bio = bio_alloc(lc->logdev->bdev,
|
||||
bio_max_segs(block->vec_cnt - i),
|
||||
REQ_OP_WRITE, GFP_KERNEL);
|
||||
bio->bi_iter.bi_size = 0;
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio_set_dev(bio, lc->logdev->bdev);
|
||||
bio->bi_end_io = log_end_io;
|
||||
bio->bi_private = lc;
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
|
||||
ret = bio_add_page(bio, block->vecs[i].bv_page,
|
||||
block->vecs[i].bv_len, 0);
|
||||
|
||||
@@ -1177,13 +1177,12 @@ static void process_prepared_discard_passdown_pt1(struct dm_thin_new_mapping *m)
|
||||
return;
|
||||
}
|
||||
|
||||
discard_parent = bio_alloc(GFP_NOIO, 1);
|
||||
discard_parent = bio_alloc(NULL, 1, 0, GFP_NOIO);
|
||||
discard_parent->bi_end_io = passdown_endio;
|
||||
discard_parent->bi_private = m;
|
||||
|
||||
if (m->maybe_shared)
|
||||
passdown_double_checking_shared_status(m, discard_parent);
|
||||
else {
|
||||
if (m->maybe_shared)
|
||||
passdown_double_checking_shared_status(m, discard_parent);
|
||||
else {
|
||||
struct discard_op op;
|
||||
|
||||
begin_discard(&op, tc, discard_parent);
|
||||
|
||||
@@ -550,7 +550,8 @@ static struct dmz_mblock *dmz_get_mblock_slow(struct dmz_metadata *zmd,
|
||||
if (!mblk)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
bio = bio_alloc(GFP_NOIO, 1);
|
||||
bio = bio_alloc(dev->bdev, 1, REQ_OP_READ | REQ_META | REQ_PRIO,
|
||||
GFP_NOIO);
|
||||
|
||||
spin_lock(&zmd->mblk_lock);
|
||||
|
||||
@@ -574,10 +575,8 @@ static struct dmz_mblock *dmz_get_mblock_slow(struct dmz_metadata *zmd,
|
||||
|
||||
/* Submit read BIO */
|
||||
bio->bi_iter.bi_sector = dmz_blk2sect(block);
|
||||
bio_set_dev(bio, dev->bdev);
|
||||
bio->bi_private = mblk;
|
||||
bio->bi_end_io = dmz_mblock_bio_end_io;
|
||||
bio_set_op_attrs(bio, REQ_OP_READ, REQ_META | REQ_PRIO);
|
||||
bio_add_page(bio, mblk->page, DMZ_BLOCK_SIZE, 0);
|
||||
submit_bio(bio);
|
||||
|
||||
@@ -721,15 +720,14 @@ static int dmz_write_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk,
|
||||
if (dmz_bdev_is_dying(dev))
|
||||
return -EIO;
|
||||
|
||||
bio = bio_alloc(GFP_NOIO, 1);
|
||||
bio = bio_alloc(dev->bdev, 1, REQ_OP_WRITE | REQ_META | REQ_PRIO,
|
||||
GFP_NOIO);
|
||||
|
||||
set_bit(DMZ_META_WRITING, &mblk->state);
|
||||
|
||||
bio->bi_iter.bi_sector = dmz_blk2sect(block);
|
||||
bio_set_dev(bio, dev->bdev);
|
||||
bio->bi_private = mblk;
|
||||
bio->bi_end_io = dmz_mblock_bio_end_io;
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_META | REQ_PRIO);
|
||||
bio_add_page(bio, mblk->page, DMZ_BLOCK_SIZE, 0);
|
||||
submit_bio(bio);
|
||||
|
||||
@@ -751,10 +749,9 @@ static int dmz_rdwr_block(struct dmz_dev *dev, int op,
|
||||
if (dmz_bdev_is_dying(dev))
|
||||
return -EIO;
|
||||
|
||||
bio = bio_alloc(GFP_NOIO, 1);
|
||||
bio = bio_alloc(dev->bdev, 1, op | REQ_SYNC | REQ_META | REQ_PRIO,
|
||||
GFP_NOIO);
|
||||
bio->bi_iter.bi_sector = dmz_blk2sect(block);
|
||||
bio_set_dev(bio, dev->bdev);
|
||||
bio_set_op_attrs(bio, op, REQ_SYNC | REQ_META | REQ_PRIO);
|
||||
bio_add_page(bio, page, DMZ_BLOCK_SIZE, 0);
|
||||
ret = submit_bio_wait(bio);
|
||||
bio_put(bio);
|
||||
|
||||
@@ -105,12 +105,12 @@ int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
|
||||
* parent bio. Otherwise directly call nd_region flush.
|
||||
*/
|
||||
if (bio && bio->bi_iter.bi_sector != -1) {
|
||||
struct bio *child = bio_alloc(GFP_ATOMIC, 0);
|
||||
struct bio *child = bio_alloc(bio->bi_bdev, 0, REQ_PREFLUSH,
|
||||
GFP_ATOMIC);
|
||||
|
||||
if (!child)
|
||||
return -ENOMEM;
|
||||
bio_copy_dev(child, bio);
|
||||
child->bi_opf = REQ_PREFLUSH;
|
||||
bio_clone_blkg_association(child, bio);
|
||||
child->bi_iter.bi_sector = -1;
|
||||
bio_chain(child, bio);
|
||||
submit_bio(child);
|
||||
|
||||
@@ -268,14 +268,15 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
|
||||
if (nvmet_use_inline_bvec(req)) {
|
||||
bio = &req->b.inline_bio;
|
||||
bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio->bi_opf = op;
|
||||
} else {
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(sg_cnt));
|
||||
bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), op,
|
||||
GFP_KERNEL);
|
||||
}
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio->bi_private = req;
|
||||
bio->bi_end_io = nvmet_bio_done;
|
||||
bio->bi_opf = op;
|
||||
|
||||
blk_start_plug(&plug);
|
||||
if (req->metadata_len)
|
||||
@@ -296,10 +297,9 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
|
||||
}
|
||||
}
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(sg_cnt));
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt),
|
||||
op, GFP_KERNEL);
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio->bi_opf = op;
|
||||
|
||||
bio_chain(bio, prev);
|
||||
submit_bio(prev);
|
||||
|
||||
@@ -207,11 +207,12 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
|
||||
if (nvmet_use_inline_bvec(req)) {
|
||||
bio = &req->p.inline_bio;
|
||||
bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
|
||||
bio->bi_opf = req_op(rq);
|
||||
} else {
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(req->sg_cnt));
|
||||
bio = bio_alloc(NULL, bio_max_segs(req->sg_cnt), req_op(rq),
|
||||
GFP_KERNEL);
|
||||
bio->bi_end_io = bio_put;
|
||||
}
|
||||
bio->bi_opf = req_op(rq);
|
||||
|
||||
for_each_sg(req->sg, sg, req->sg_cnt, i) {
|
||||
if (bio_add_pc_page(rq->q, bio, sg_page(sg), sg->length,
|
||||
|
||||
@@ -522,6 +522,7 @@ static void nvmet_bdev_zone_append_bio_done(struct bio *bio)
|
||||
void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
|
||||
{
|
||||
sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba);
|
||||
const unsigned int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE;
|
||||
u16 status = NVME_SC_SUCCESS;
|
||||
unsigned int total_len = 0;
|
||||
struct scatterlist *sg;
|
||||
@@ -552,13 +553,12 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
|
||||
if (nvmet_use_inline_bvec(req)) {
|
||||
bio = &req->z.inline_bio;
|
||||
bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
|
||||
bio->bi_opf = op;
|
||||
} else {
|
||||
bio = bio_alloc(GFP_KERNEL, req->sg_cnt);
|
||||
bio = bio_alloc(req->ns->bdev, req->sg_cnt, op, GFP_KERNEL);
|
||||
}
|
||||
|
||||
bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE;
|
||||
bio->bi_end_io = nvmet_bdev_zone_append_bio_done;
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio->bi_iter.bi_sector = sect;
|
||||
bio->bi_private = req;
|
||||
if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA))
|
||||
|
||||
@@ -494,7 +494,7 @@ static struct ufshpb_req *ufshpb_get_map_req(struct ufshpb_lu *hpb,
|
||||
if (!map_req)
|
||||
return NULL;
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, hpb->pages_per_srgn);
|
||||
bio = bio_alloc(NULL, hpb->pages_per_srgn, 0, GFP_KERNEL);
|
||||
if (!bio) {
|
||||
ufshpb_put_req(hpb, map_req);
|
||||
return NULL;
|
||||
@@ -2050,7 +2050,7 @@ static int ufshpb_pre_req_mempool_init(struct ufshpb_lu *hpb)
|
||||
INIT_LIST_HEAD(&pre_req->list_req);
|
||||
pre_req->req = NULL;
|
||||
|
||||
pre_req->bio = bio_alloc(GFP_KERNEL, 1);
|
||||
pre_req->bio = bio_alloc(NULL, 1, 0, GFP_KERNEL);
|
||||
if (!pre_req->bio)
|
||||
goto release_mem;
|
||||
|
||||
|
||||
@@ -415,10 +415,9 @@ iblock_execute_sync_cache(struct se_cmd *cmd)
|
||||
if (immed)
|
||||
target_complete_cmd(cmd, SAM_STAT_GOOD);
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, 0);
|
||||
bio = bio_alloc(ib_dev->ibd_bd, 0, REQ_OP_WRITE | REQ_PREFLUSH,
|
||||
GFP_KERNEL);
|
||||
bio->bi_end_io = iblock_end_io_flush;
|
||||
bio_set_dev(bio, ib_dev->ibd_bd);
|
||||
bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
|
||||
if (!immed)
|
||||
bio->bi_private = cmd;
|
||||
submit_bio(bio);
|
||||
|
||||
+3
-3
@@ -4029,8 +4029,9 @@ static int write_dev_supers(struct btrfs_device *device,
|
||||
* to do I/O, so we don't lose the ability to do integrity
|
||||
* checking.
|
||||
*/
|
||||
bio = bio_alloc(GFP_NOFS, 1);
|
||||
bio_set_dev(bio, device->bdev);
|
||||
bio = bio_alloc(device->bdev, 1,
|
||||
REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PRIO,
|
||||
GFP_NOFS);
|
||||
bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT;
|
||||
bio->bi_private = device;
|
||||
bio->bi_end_io = btrfs_end_super_write;
|
||||
@@ -4042,7 +4043,6 @@ static int write_dev_supers(struct btrfs_device *device,
|
||||
* go down lazy and there's a short window where the on-disk
|
||||
* copies might still contain the older version.
|
||||
*/
|
||||
bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PRIO;
|
||||
if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER))
|
||||
bio->bi_opf |= REQ_FUA;
|
||||
|
||||
|
||||
+6
-8
@@ -3024,12 +3024,16 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
|
||||
if (test_set_buffer_req(bh) && (op == REQ_OP_WRITE))
|
||||
clear_buffer_write_io_error(bh);
|
||||
|
||||
bio = bio_alloc(GFP_NOIO, 1);
|
||||
if (buffer_meta(bh))
|
||||
op_flags |= REQ_META;
|
||||
if (buffer_prio(bh))
|
||||
op_flags |= REQ_PRIO;
|
||||
|
||||
bio = bio_alloc(bh->b_bdev, 1, op | op_flags, GFP_NOIO);
|
||||
|
||||
fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO);
|
||||
|
||||
bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
|
||||
bio_set_dev(bio, bh->b_bdev);
|
||||
bio->bi_write_hint = write_hint;
|
||||
|
||||
bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh));
|
||||
@@ -3038,12 +3042,6 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
|
||||
bio->bi_end_io = end_bio_bh_io_sync;
|
||||
bio->bi_private = bh;
|
||||
|
||||
if (buffer_meta(bh))
|
||||
op_flags |= REQ_META;
|
||||
if (buffer_prio(bh))
|
||||
op_flags |= REQ_PRIO;
|
||||
bio_set_op_attrs(bio, op, op_flags);
|
||||
|
||||
/* Take care of bh's that straddle the end of the device */
|
||||
guard_bio_eod(bio);
|
||||
|
||||
|
||||
+7
-6
@@ -54,7 +54,8 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
|
||||
int num_pages = 0;
|
||||
|
||||
/* This always succeeds since __GFP_DIRECT_RECLAIM is set. */
|
||||
bio = bio_alloc(GFP_NOFS, BIO_MAX_VECS);
|
||||
bio = bio_alloc(inode->i_sb->s_bdev, BIO_MAX_VECS, REQ_OP_WRITE,
|
||||
GFP_NOFS);
|
||||
|
||||
while (len) {
|
||||
unsigned int blocks_this_page = min(len, blocks_per_page);
|
||||
@@ -62,10 +63,8 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
|
||||
|
||||
if (num_pages == 0) {
|
||||
fscrypt_set_bio_crypt_ctx(bio, inode, lblk, GFP_NOFS);
|
||||
bio_set_dev(bio, inode->i_sb->s_bdev);
|
||||
bio->bi_iter.bi_sector =
|
||||
pblk << (blockbits - SECTOR_SHIFT);
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
}
|
||||
ret = bio_add_page(bio, ZERO_PAGE(0), bytes_this_page, 0);
|
||||
if (WARN_ON(ret != bytes_this_page)) {
|
||||
@@ -82,6 +81,8 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
|
||||
if (err)
|
||||
goto out;
|
||||
bio_reset(bio);
|
||||
bio_set_dev(bio, inode->i_sb->s_bdev);
|
||||
bio->bi_opf = REQ_OP_WRITE;
|
||||
num_pages = 0;
|
||||
}
|
||||
}
|
||||
@@ -150,12 +151,10 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
|
||||
return -EINVAL;
|
||||
|
||||
/* This always succeeds since __GFP_DIRECT_RECLAIM is set. */
|
||||
bio = bio_alloc(GFP_NOFS, nr_pages);
|
||||
bio = bio_alloc(inode->i_sb->s_bdev, nr_pages, REQ_OP_WRITE, GFP_NOFS);
|
||||
|
||||
do {
|
||||
bio_set_dev(bio, inode->i_sb->s_bdev);
|
||||
bio->bi_iter.bi_sector = pblk << (blockbits - 9);
|
||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||
|
||||
i = 0;
|
||||
offset = 0;
|
||||
@@ -183,6 +182,8 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
|
||||
if (err)
|
||||
goto out;
|
||||
bio_reset(bio);
|
||||
bio_set_dev(bio, inode->i_sb->s_bdev);
|
||||
bio->bi_opf = REQ_OP_WRITE;
|
||||
} while (len != 0);
|
||||
err = 0;
|
||||
out:
|
||||
|
||||
+1
-4
@@ -396,11 +396,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
|
||||
* bio_alloc() is guaranteed to return a bio when allowed to sleep and
|
||||
* we request a valid number of vectors.
|
||||
*/
|
||||
bio = bio_alloc(GFP_KERNEL, nr_vecs);
|
||||
|
||||
bio_set_dev(bio, bdev);
|
||||
bio = bio_alloc(bdev, nr_vecs, dio->op | dio->op_flags, GFP_KERNEL);
|
||||
bio->bi_iter.bi_sector = first_sector;
|
||||
bio_set_op_attrs(bio, dio->op, dio->op_flags);
|
||||
if (dio->is_async)
|
||||
bio->bi_end_io = dio_bio_end_aio;
|
||||
else
|
||||
|
||||
+2
-3
@@ -1371,15 +1371,14 @@ submit_bio_retry:
|
||||
}
|
||||
|
||||
if (!bio) {
|
||||
bio = bio_alloc(GFP_NOIO, BIO_MAX_VECS);
|
||||
bio = bio_alloc(mdev.m_bdev, BIO_MAX_VECS,
|
||||
REQ_OP_READ, GFP_NOIO);
|
||||
bio->bi_end_io = z_erofs_decompressqueue_endio;
|
||||
|
||||
bio_set_dev(bio, mdev.m_bdev);
|
||||
last_bdev = mdev.m_bdev;
|
||||
bio->bi_iter.bi_sector = (sector_t)cur <<
|
||||
LOG_SECTORS_PER_BLOCK;
|
||||
bio->bi_private = bi_private;
|
||||
bio->bi_opf = REQ_OP_READ;
|
||||
if (f->readahead)
|
||||
bio->bi_opf |= REQ_RAHEAD;
|
||||
++nr_bios;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user