linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-block@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-nvme@lists.infradead.org,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org,
	cluster-devel@redhat.com
Cc: jfs-discussion@lists.sourceforge.net, dm-devel@redhat.com,
	axboe@kernel.dk, philipp.reisner@linbit.com,
	lars.ellenberg@linbit.com, efremov@linux.com, colyli@suse.de,
	kent.overstreet@gmail.com, agk@redhat.com, snitzer@redhat.com,
	song@kernel.org, hch@lst.de, sagi@grimberg.me,
	martin.petersen@oracle.com, viro@zeniv.linux.org.uk, clm@fb.com,
	josef@toxicpanda.com, dsterba@suse.com, tytso@mit.edu,
	adilger.kernel@dilger.ca, rpeterso@redhat.com,
	agruenba@redhat.com, darrick.wong@oracle.com, shaggy@kernel.org,
	damien.lemoal@wdc.com, naohiro.aota@wdc.com, jth@kernel.org,
	tj@kernel.org, osandov@fb.com, bvanassche@acm.org,
	gustavo@embeddedor.com, asml.silence@gmail.com,
	jefflexu@linux.alibaba.com,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [RFC PATCH 01/37] block: introduce bio_init_fields() helper
Date: Mon, 18 Jan 2021 21:05:55 -0800	[thread overview]
Message-ID: <20210119050631.57073-2-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20210119050631.57073-1-chaitanya.kulkarni@wdc.com>

There are several places in the file-system, block layer, device drivers
where struct bio members such as bdev, sector, private, end io callback,
io priority, write hints are initialized where we can use a helper
function.

This pach introduces a helper function which we use in the block lyaer
code. Subsequent patches use this function to reduce repeated code.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 block/blk-lib.c     | 13 +++++--------
 include/linux/bio.h | 13 +++++++++++++
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 752f9c722062..5ee488c1bcc6 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -95,8 +95,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_init_fields(bio, bdev, sector, NULL, NULL, 0, 0);
 		bio_set_op_attrs(bio, op, 0);
 
 		bio->bi_iter.bi_size = req_sects << 9;
@@ -189,8 +188,7 @@ static int __blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
 
 	while (nr_sects) {
 		bio = blk_next_bio(bio, 1, gfp_mask);
-		bio->bi_iter.bi_sector = sector;
-		bio_set_dev(bio, bdev);
+		bio_init_fields(bio, bdev, sector, NULL, NULL, 0, 0);
 		bio->bi_vcnt = 1;
 		bio->bi_io_vec->bv_page = page;
 		bio->bi_io_vec->bv_offset = 0;
@@ -265,8 +263,7 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
 
 	while (nr_sects) {
 		bio = blk_next_bio(bio, 0, gfp_mask);
-		bio->bi_iter.bi_sector = sector;
-		bio_set_dev(bio, bdev);
+		bio_init_fields(bio, bdev, sector, NULL, NULL, 0, 0);
 		bio->bi_opf = REQ_OP_WRITE_ZEROES;
 		if (flags & BLKDEV_ZERO_NOUNMAP)
 			bio->bi_opf |= REQ_NOUNMAP;
@@ -317,8 +314,8 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
 	while (nr_sects != 0) {
 		bio = blk_next_bio(bio, __blkdev_sectors_to_bio_pages(nr_sects),
 				   gfp_mask);
-		bio->bi_iter.bi_sector = sector;
-		bio_set_dev(bio, bdev);
+		bio_init_fields(bio, bdev, sector, NULL, NULL, 0, 0);
+
 		bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
 
 		while (nr_sects != 0) {
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 1edda614f7ce..fbeaa5e42a5d 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -820,4 +820,17 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
 		bio->bi_opf |= REQ_NOWAIT;
 }
 
+static inline void bio_init_fields(struct bio *bio, struct block_device *bdev,
+				   sector_t sect, void *priv,
+				   bio_end_io_t *end_io,
+				   unsigned short prio, unsigned short whint)
+{
+	bio_set_dev(bio, bdev);
+	bio->bi_iter.bi_sector = sect;
+	bio->bi_private = priv;
+	bio->bi_end_io = end_io;
+	bio->bi_ioprio = prio;
+	bio->bi_write_hint = whint;
+}
+
 #endif /* __LINUX_BIO_H */
-- 
2.22.1


  reply	other threads:[~2021-01-19  5:35 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19  5:05 [RFC PATCH 00/37] block: introduce bio_init_fields() Chaitanya Kulkarni
2021-01-19  5:05 ` Chaitanya Kulkarni [this message]
2021-01-19  5:05 ` [RFC PATCH 02/37] fs: use bio_init_fields in block_dev Chaitanya Kulkarni
2021-01-19  5:05 ` [RFC PATCH 03/37] btrfs: use bio_init_fields in disk-io Chaitanya Kulkarni
2021-01-19  5:05 ` [RFC PATCH 04/37] btrfs: use bio_init_fields in volumes Chaitanya Kulkarni
2021-01-19 13:52   ` Nikolay Borisov
2021-01-19  5:05 ` [RFC PATCH 05/37] ext4: use bio_init_fields in page_io Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 06/37] gfs2: use bio_init_fields in lops Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 07/37] gfs2: use bio_init_fields in meta_io Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 08/37] gfs2: use bio_init_fields in ops_fstype Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 09/37] iomap: use bio_init_fields in buffered-io Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 10/37] iomap: use bio_init_fields in direct-io Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 11/37] jfs: use bio_init_fields in logmgr Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 12/37] zonefs: use bio_init_fields in append Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 13/37] drdb: use bio_init_fields in actlog Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 14/37] drdb: use bio_init_fields in bitmap Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 15/37] drdb: use bio_init_fields in receiver Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 16/37] floppy: use bio_init_fields Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 17/37] pktcdvd: " Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 18/37] bcache: use bio_init_fields in journal Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 19/37] bcache: use bio_init_fields in super Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 20/37] bcache: use bio_init_fields in writeback Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 21/37] dm-bufio: use bio_init_fields Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 22/37] dm-crypt: " Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 23/37] dm-zoned: use bio_init_fields metadata Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 24/37] dm-zoned: use bio_init_fields target Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 25/37] dm-zoned: use bio_init_fields Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 26/37] dm log writes: " Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 27/37] nvmet: use bio_init_fields in bdev-ns Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 28/37] target: use bio_init_fields in iblock Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 29/37] btrfs: use bio_init_fields in scrub Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 30/37] fs: use bio_init_fields in buffer Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 31/37] eros: use bio_init_fields in data Chaitanya Kulkarni
2021-01-20  4:05   ` Gao Xiang
2021-01-20  4:08     ` Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 32/37] eros: use bio_init_fields in zdata Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 33/37] jfs: use bio_init_fields in metadata Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 34/37] nfs: use bio_init_fields in blocklayout Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 35/37] ocfs: use bio_init_fields in heartbeat Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 36/37] xfs: use bio_init_fields in xfs_buf Chaitanya Kulkarni
2021-01-19  5:06 ` [RFC PATCH 37/37] xfs: use bio_init_fields in xfs_log Chaitanya Kulkarni
2021-01-19 14:14 ` [RFC PATCH 00/37] block: introduce bio_init_fields() Mike Snitzer
2021-01-19 15:00 ` Josef Bacik
2021-01-20  3:27 ` Chaitanya Kulkarni
2021-01-21  3:00 ` Julian Calaby
2021-01-21  8:23   ` 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=20210119050631.57073-2-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=agk@redhat.com \
    --cc=agruenba@redhat.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=clm@fb.com \
    --cc=cluster-devel@redhat.com \
    --cc=colyli@suse.de \
    --cc=damien.lemoal@wdc.com \
    --cc=darrick.wong@oracle.com \
    --cc=dm-devel@redhat.com \
    --cc=drbd-dev@lists.linbit.com \
    --cc=dsterba@suse.com \
    --cc=efremov@linux.com \
    --cc=gustavo@embeddedor.com \
    --cc=hch@lst.de \
    --cc=jefflexu@linux.alibaba.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=josef@toxicpanda.com \
    --cc=jth@kernel.org \
    --cc=kent.overstreet@gmail.com \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=naohiro.aota@wdc.com \
    --cc=osandov@fb.com \
    --cc=philipp.reisner@linbit.com \
    --cc=rpeterso@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=shaggy@kernel.org \
    --cc=snitzer@redhat.com \
    --cc=song@kernel.org \
    --cc=target-devel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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).