From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
dm-devel@redhat.com, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, drbd-dev@lists.linbit.com,
xen-devel@lists.xenproject.org, linux-nvme@lists.infradead.org,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
linux-fscrypt@vger.kernel.org,
jfs-discussion@lists.sourceforge.net,
linux-nilfs@vger.kernel.org, ocfs2-devel@oss.oracle.com,
linux-pm@vger.kernel.org, linux-mm@kvack.org
Cc: shaggy@kernel.org, sergey.senozhatsky.work@gmail.com,
snitzer@redhat.com, tiwai@suse.de, djwong@kernel.org,
gustavoars@kernel.org, pavel@ucw.cz, alex.shi@linux.alibaba.com,
agk@redhat.com, naohiro.aota@wdc.com, sagi@grimberg.me,
osandov@fb.com, ebiggers@kernel.org, ngupta@vflare.org,
len.brown@intel.com, chaitanya.kulkarni@wdc.com,
konrad.wilk@oracle.com, hare@suse.de, ming.lei@redhat.com,
viro@zeniv.linux.org.uk, jefflexu@linux.alibaba.com,
jaegeuk@kernel.org, konishi.ryusuke@gmail.com,
bvanassche@acm.org, axboe@kernel.dk, damien.lemoal@wdc.com,
tytso@mit.edu, rjw@rjwysocki.net, philipp.reisner@linbit.com,
minchan@kernel.org, tj@kernel.org, lars.ellenberg@linbit.com,
jth@kernel.org, asml.silence@gmail.com, roger.pau@citrix.com
Subject: [Ocfs2-devel] [RFC PATCH 01/34] block: move common code into blk_next_bio()
Date: Wed, 27 Jan 2021 23:11:00 -0800 [thread overview]
Message-ID: <20210128071133.60335-2-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20210128071133.60335-1-chaitanya.kulkarni@wdc.com>
blk_next_bio() is the central function which allocates the bios for
discard, write-same, write-zeroes and zone-mgmt. The initialization of
various bio members is duplicated in disacrd, write-same, write-zeores.
In this preparation patch we add bdev, sector, op, and opf arguments to
the blk_next_bio() to reduce the duplication.
In the next patch we introduce bio_new(), this prepration patch allows
us to call it inside blk_next_bio().
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
block/blk-lib.c | 36 +++++++++++++++---------------------
block/blk-zoned.c | 4 +---
block/blk.h | 5 +++--
3 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 752f9c722062..fb486a0bdb58 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -10,7 +10,9 @@
#include "blk.h"
-struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp)
+struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev,
+ sector_t sect, unsigned op, unsigned opf,
+ unsigned int nr_pages, gfp_t gfp)
{
struct bio *new = bio_alloc(gfp, nr_pages);
@@ -19,6 +21,10 @@ struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp)
submit_bio(bio);
}
+ new->bi_iter.bi_sector = sect;
+ bio_set_dev(new, bdev);
+ bio_set_op_attrs(new, op, opf);
+
return new;
}
@@ -94,11 +100,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
WARN_ON_ONCE((req_sects << 9) > UINT_MAX);
- bio = blk_next_bio(bio, 0, gfp_mask);
- bio->bi_iter.bi_sector = sector;
- bio_set_dev(bio, bdev);
- bio_set_op_attrs(bio, op, 0);
-
+ bio = blk_next_bio(bio, bdev, sector, op, 0, 0, gfp_mask);
bio->bi_iter.bi_size = req_sects << 9;
sector += req_sects;
nr_sects -= req_sects;
@@ -168,6 +170,7 @@ static int __blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
{
struct request_queue *q = bdev_get_queue(bdev);
unsigned int max_write_same_sectors;
+ unsigned int op = REQ_OP_WRITE_SAME;
struct bio *bio = *biop;
sector_t bs_mask;
@@ -188,14 +191,11 @@ static int __blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
max_write_same_sectors = bio_allowed_max_sectors(q);
while (nr_sects) {
- bio = blk_next_bio(bio, 1, gfp_mask);
- bio->bi_iter.bi_sector = sector;
- bio_set_dev(bio, bdev);
+ bio = blk_next_bio(bio, bdev, sector, op, 0, 1, gfp_mask);
bio->bi_vcnt = 1;
bio->bi_io_vec->bv_page = page;
bio->bi_io_vec->bv_offset = 0;
bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev);
- bio_set_op_attrs(bio, REQ_OP_WRITE_SAME, 0);
if (nr_sects > max_write_same_sectors) {
bio->bi_iter.bi_size = max_write_same_sectors << 9;
@@ -249,7 +249,9 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
{
struct bio *bio = *biop;
unsigned int max_write_zeroes_sectors;
+ unsigned int op = REQ_OP_WRITE_ZEROES;
struct request_queue *q = bdev_get_queue(bdev);
+ unsigned int opf = flags & BLKDEV_ZERO_NOUNMAP ? REQ_NOUNMAP : 0;
if (!q)
return -ENXIO;
@@ -264,13 +266,7 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
return -EOPNOTSUPP;
while (nr_sects) {
- bio = blk_next_bio(bio, 0, gfp_mask);
- bio->bi_iter.bi_sector = sector;
- bio_set_dev(bio, bdev);
- bio->bi_opf = REQ_OP_WRITE_ZEROES;
- if (flags & BLKDEV_ZERO_NOUNMAP)
- bio->bi_opf |= REQ_NOUNMAP;
-
+ bio = blk_next_bio(bio, bdev, sector, op, opf, 0, gfp_mask);
if (nr_sects > max_write_zeroes_sectors) {
bio->bi_iter.bi_size = max_write_zeroes_sectors << 9;
nr_sects -= max_write_zeroes_sectors;
@@ -303,6 +299,7 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
sector_t sector, sector_t nr_sects, gfp_t gfp_mask,
struct bio **biop)
{
+ unsigned int nr_pages = __blkdev_sectors_to_bio_pages(nr_sects);
struct request_queue *q = bdev_get_queue(bdev);
struct bio *bio = *biop;
int bi_size = 0;
@@ -315,11 +312,8 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
return -EPERM;
while (nr_sects != 0) {
- bio = blk_next_bio(bio, __blkdev_sectors_to_bio_pages(nr_sects),
+ bio = blk_next_bio(bio, bdev, sector, REQ_OP_WRITE, 0, nr_pages,
gfp_mask);
- bio->bi_iter.bi_sector = sector;
- bio_set_dev(bio, bdev);
- bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
while (nr_sects != 0) {
sz = min((sector_t) PAGE_SIZE, nr_sects << 9);
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 7a68b6e4300c..68e77628348d 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -231,8 +231,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
return -EINVAL;
while (sector < end_sector) {
- bio = blk_next_bio(bio, 0, gfp_mask);
- bio_set_dev(bio, bdev);
+ bio = blk_next_bio(bio, bdev, 0 , op, REQ_SYNC, 0, gfp_mask);
/*
* Special case for the zone reset operation that reset all
@@ -244,7 +243,6 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
break;
}
- bio->bi_opf = op | REQ_SYNC;
bio->bi_iter.bi_sector = sector;
sector += zone_sectors;
diff --git a/block/blk.h b/block/blk.h
index 0198335c5838..0a278bae5478 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -329,8 +329,9 @@ extern int blk_iolatency_init(struct request_queue *q);
static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
#endif
-struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp);
-
+struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev,
+ sector_t sect, unsigned op, unsigned opf,
+ unsigned int nr_pages, gfp_t gfp);
#ifdef CONFIG_BLK_DEV_ZONED
void blk_queue_free_zone_bitmaps(struct request_queue *q);
#else
--
2.22.1
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
next prev parent reply other threads:[~2021-01-28 7:27 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 7:10 [Ocfs2-devel] [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
2021-01-28 7:11 ` Chaitanya Kulkarni [this message]
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 02/34] block: introduce and use bio_new Chaitanya Kulkarni
2021-01-28 7:21 ` Damien Le Moal
2021-01-28 7:27 ` Damien Le Moal
2021-01-28 8:34 ` Chaitanya Kulkarni
2021-01-28 8:33 ` Chaitanya Kulkarni
2021-01-28 16:47 ` Matthew Wilcox
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 03/34] drdb: use bio_new in drdb Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 04/34] drdb: use bio_new() in submit_one_flush Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 05/34] xen-blkback: use bio_new Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 06/34] zram: " Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 07/34] dm: use bio_new in dm-log-writes Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 08/34] dm-zoned: use bio_new in get_mblock_slow Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 09/34] dm-zoned: use bio_new in dmz_write_mblock Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 10/34] dm-zoned: use bio_new in dmz_rdwr_block Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 11/34] nvmet: use bio_new in nvmet_bdev_execute_rw Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 12/34] scsi: target/iblock: use bio_new Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 13/34] block: use bio_new in __blkdev_direct_IO Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 14/34] fs/buffer: use bio_new in submit_bh_wbc Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 15/34] fscrypt: use bio_new in fscrypt_zeroout_range Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 16/34] fs/direct-io: use bio_new in dio_bio_alloc Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 17/34] iomap: use bio_new in iomap_dio_zero Chaitanya Kulkarni
2021-01-28 16:59 ` Darrick J. Wong
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 18/34] iomap: use bio_new in iomap_dio_bio_actor Chaitanya Kulkarni
2021-01-28 17:24 ` Darrick J. Wong
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 19/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmRead Chaitanya Kulkarni
2021-01-28 12:43 ` Dave Kleikamp
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 20/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmStartIO Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 21/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_writepage Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 22/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_readpage Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 23/34] fs/mpage.c: use bio_new mpage_alloc Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 24/34] fs/nilfs: use bio_new nilfs_alloc_seg_bio Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 25/34] ocfs/cluster: use bio_new in dm-log-writes Chaitanya Kulkarni
2021-01-28 12:13 ` Joseph Qi
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 26/34] xfs: use bio_new in xfs_rw_bdev Chaitanya Kulkarni
2021-01-28 17:21 ` Darrick J. Wong
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 27/34] xfs: use bio_new in xfs_buf_ioapply_map Chaitanya Kulkarni
2021-01-28 17:21 ` Darrick J. Wong
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 28/34] zonefs: use bio_new Chaitanya Kulkarni
2021-01-28 7:25 ` Damien Le Moal
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io Chaitanya Kulkarni
2021-01-28 10:21 ` Rafael J. Wysocki
2021-02-17 22:02 ` Pavel Machek
2021-02-18 1:28 ` Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 30/34] hfsplus: use bio_new in hfsplus_submit_bio() Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 31/34] iomap: use bio_new in iomap_readpage_actor Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 32/34] mm: use bio_new in __swap_writepage Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 33/34] mm: use bio_new in swap_readpage Chaitanya Kulkarni
2021-01-28 7:11 ` [Ocfs2-devel] [RFC PATCH 34/34] mm: add swap_bio_new common bio helper Chaitanya Kulkarni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210128071133.60335-2-chaitanya.kulkarni@wdc.com \
--to=chaitanya.kulkarni@wdc.com \
--cc=agk@redhat.com \
--cc=alex.shi@linux.alibaba.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@wdc.com \
--cc=djwong@kernel.org \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=ebiggers@kernel.org \
--cc=gustavoars@kernel.org \
--cc=hare@suse.de \
--cc=jaegeuk@kernel.org \
--cc=jefflexu@linux.alibaba.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jth@kernel.org \
--cc=konishi.ryusuke@gmail.com \
--cc=konrad.wilk@oracle.com \
--cc=lars.ellenberg@linbit.com \
--cc=len.brown@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=ming.lei@redhat.com \
--cc=naohiro.aota@wdc.com \
--cc=ngupta@vflare.org \
--cc=ocfs2-devel@oss.oracle.com \
--cc=osandov@fb.com \
--cc=pavel@ucw.cz \
--cc=philipp.reisner@linbit.com \
--cc=rjw@rjwysocki.net \
--cc=roger.pau@citrix.com \
--cc=sagi@grimberg.me \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=shaggy@kernel.org \
--cc=snitzer@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=tj@kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).