linux-fscrypt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/34] block: introduce bio_new()
@ 2021-01-28  7:10 Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 01/34] block: move common code into blk_next_bio() Chaitanya Kulkarni
                   ` (33 more replies)
  0 siblings, 34 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:10 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Hi,

This is a *compile only RFC* which adds a generic helper to initialize
the various fields of the bio that is repeated all the places in
file-systems, block layer, and drivers.

The new helper allows callers to initialize non-optional members of bio
such as bdev, sector, op, opflags, max_bvecs and gfp_mask by
encapsulating new bio allocation with bio alloc with initialization
at one place.

The objective of this RFC is to only start a discussion, this it not 
completely tested at all.

-ck                         

Chaitanya Kulkarni (34):
  block: move common code into blk_next_bio()
  block: introduce and use bio_new
  drdb: use bio_new in drdb
  drdb: use bio_new() in submit_one_flush
  xen-blkback: use bio_new
  zram: use bio_new
  dm: use bio_new in dm-log-writes
  dm-zoned: use bio_new in get_mblock_slow
  dm-zoned: use bio_new in dmz_write_mblock
  dm-zoned: use bio_new in dmz_rdwr_block
  nvmet: use bio_new in nvmet_bdev_execute_rw
  scsi: target/iblock: use bio_new
  block: use bio_new in __blkdev_direct_IO
  fs/buffer: use bio_new in submit_bh_wbc
  fscrypt: use bio_new in fscrypt_zeroout_range
  fs/direct-io: use bio_new in dio_bio_alloc
  iomap: use bio_new in iomap_dio_zero
  iomap: use bio_new in iomap_dio_bio_actor
  fs/jfs/jfs_logmgr.c: use bio_new in lbmRead
  fs/jfs/jfs_logmgr.c: use bio_new in lbmStartIO
  fs/jfs/jfs_metapage.c: use bio_new in metapage_writepage
  fs/jfs/jfs_metapage.c: use bio_new in metapage_readpage
  fs/mpage.c: use bio_new mpage_alloc
  fs/nilfs: use bio_new nilfs_alloc_seg_bio
  ocfs/cluster: use bio_new in dm-log-writes
  xfs: use bio_new in xfs_rw_bdev
  xfs: use bio_new in xfs_buf_ioapply_map
  zonefs: use bio_new
  power/swap: use bio_new in hib_submit_io
  hfsplus: use bio_new in hfsplus_submit_bio()
  iomap: use bio_new in iomap_readpage_actor
  mm: use bio_new in __swap_writepage
  mm: use bio_new in swap_readpage
  mm: add swap_bio_new common bio helper

 block/blk-lib.c                     | 34 ++++++++++-------------------
 block/blk-zoned.c                   |  4 +---
 block/blk.h                         |  5 +++--
 drivers/block/drbd/drbd_receiver.c  | 12 +++++-----
 drivers/block/xen-blkback/blkback.c | 20 +++++++++++------
 drivers/block/zram/zram_drv.c       |  5 ++---
 drivers/md/dm-log-writes.c          | 30 +++++++++----------------
 drivers/md/dm-zoned-metadata.c      | 18 +++++----------
 drivers/nvme/target/io-cmd-bdev.c   |  9 +++-----
 drivers/target/target_core_iblock.c |  5 ++---
 fs/block_dev.c                      |  6 ++---
 fs/buffer.c                         | 16 ++++++--------
 fs/crypto/bio.c                     |  5 ++---
 fs/direct-io.c                      |  6 ++---
 fs/hfsplus/wrapper.c                |  5 +----
 fs/iomap/buffered-io.c              | 12 +++++-----
 fs/iomap/direct-io.c                | 11 ++++------
 fs/jfs/jfs_logmgr.c                 | 13 ++++-------
 fs/jfs/jfs_metapage.c               | 15 +++++--------
 fs/mpage.c                          | 18 +++++----------
 fs/nilfs2/segbuf.c                  | 10 ++-------
 fs/ocfs2/cluster/heartbeat.c        |  6 ++---
 fs/xfs/xfs_bio_io.c                 |  7 ++----
 fs/xfs/xfs_buf.c                    |  6 ++---
 fs/zonefs/super.c                   |  6 ++---
 include/linux/bio.h                 | 25 +++++++++++++++++++++
 kernel/power/swap.c                 |  7 +++---
 mm/page_io.c                        | 30 +++++++++++++------------
 28 files changed, 151 insertions(+), 195 deletions(-)

-- 
2.22.1


^ permalink raw reply	[flat|nested] 48+ messages in thread

* [RFC PATCH 01/34] block: move common code into blk_next_bio()
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 02/34] block: introduce and use bio_new Chaitanya Kulkarni
                   ` (32 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

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


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 02/34] block: introduce and use bio_new
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 01/34] block: move common code into blk_next_bio() Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:21   ` Damien Le Moal
  2021-01-28  7:11 ` [RFC PATCH 03/34] drdb: use bio_new in drdb Chaitanya Kulkarni
                   ` (31 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Introduce bio_new() helper and use it in blk-lib.c to allocate and
initialize various non-optional or semi-optional members of the bio
along with bio allocation done with bio_alloc(). Here we also calmp the
max_bvecs for bio with BIO_MAX_PAGES before we pass to bio_alloc().

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

diff --git a/block/blk-lib.c b/block/blk-lib.c
index fb486a0bdb58..ec29415f00dd 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -14,17 +14,13 @@ 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);
+	struct bio *new = bio_new(bdev, sect, op, opf, gfp, nr_pages);
 
 	if (bio) {
 		bio_chain(bio, new);
 		submit_bio(bio);
 	}
 
-	new->bi_iter.bi_sector = sect;
-	bio_set_dev(new, bdev);
-	bio_set_op_attrs(new, op, opf);
-
 	return new;
 }
 
diff --git a/include/linux/bio.h b/include/linux/bio.h
index c74857cf1252..2a09ba100546 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -826,5 +826,30 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
 	if (!is_sync_kiocb(kiocb))
 		bio->bi_opf |= REQ_NOWAIT;
 }
+/**
+ * bio_new -	allcate and initialize new bio
+ * @bdev:	blockdev to issue discard for
+ * @sector:	start sector
+ * @op:		REQ_OP_XXX from enum req_opf
+ * @op_flags:	REQ_XXX from enum req_flag_bits
+ * @max_bvecs:	maximum bvec to be allocated for this bio
+ * @gfp_mask:	memory allocation flags (for bio_alloc)
+ *
+ * Description:
+ *    Allocates, initializes common members, and returns a new bio.
+ */
+static inline struct bio *bio_new(struct block_device *bdev, sector_t sector,
+				  unsigned int op, unsigned int op_flags,
+				  unsigned int max_bvecs, gfp_t gfp_mask)
+{
+	unsigned nr_bvec = clamp_t(unsigned int, max_bvecs, 0, BIO_MAX_PAGES);
+	struct bio *bio = bio_alloc(gfp_mask, nr_bvec);
+
+	bio_set_dev(bio, bdev);
+	bio->bi_iter.bi_sector = sector;
+	bio_set_op_attrs(bio, op, op_flags);
+
+	return bio;
+}
 
 #endif /* __LINUX_BIO_H */
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 03/34] drdb: use bio_new in drdb
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 01/34] block: move common code into blk_next_bio() Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 02/34] block: introduce and use bio_new Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 04/34] drdb: use bio_new() in submit_one_flush Chaitanya Kulkarni
                   ` (30 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/block/drbd/drbd_receiver.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 09c86ef3f0fd..e1cd3427b28b 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1643,6 +1643,7 @@ int drbd_submit_peer_request(struct drbd_device *device,
 	struct bio *bio;
 	struct page *page = peer_req->pages;
 	sector_t sector = peer_req->i.sector;
+	struct block_device *bdev = device->ldev->backing_bdev;
 	unsigned data_size = peer_req->i.size;
 	unsigned n_bios = 0;
 	unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT;
@@ -1687,15 +1688,12 @@ 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_new(bdev, sector, op, op_flags, GFP_NOIO, nr_pages);
 	if (!bio) {
 		drbd_err(device, "submit_ee: Allocation of a bio failed (nr_pages=%u)\n", nr_pages);
 		goto fail;
 	}
 	/* > 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;
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 04/34] drdb: use bio_new() in submit_one_flush
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 03/34] drdb: use bio_new in drdb Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 05/34] xen-blkback: use bio_new Chaitanya Kulkarni
                   ` (29 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/block/drbd/drbd_receiver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index e1cd3427b28b..b86bbf725cbd 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1277,8 +1277,10 @@ 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 block_device *bdev = device->ldev->backing_bdev;
+	struct bio *bio = bio_new(bdev, 0, REQ_OP_FLUSH, REQ_PREFLUSH, 0, GFP_NOIO);
 	struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO);
+
 	if (!bio || !octx) {
 		drbd_warn(device, "Could not allocate a bio, CANNOT ISSUE FLUSH\n");
 		/* FIXME: what else can I do now?  disconnecting or detaching
@@ -1296,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);
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 05/34] xen-blkback: use bio_new
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 04/34] drdb: use bio_new() in submit_one_flush Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 06/34] zram: " Chaitanya Kulkarni
                   ` (28 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Create a wrapper on the tio of the bio_new() named get_new_bio() & use
it in the dispatch_rw_block_io().
p
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/block/xen-blkback/blkback.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 9ebf53903d7b..3760278f0ee6 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -1174,6 +1174,15 @@ do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags)
 
 	return more_to_do;
 }
+
+static struct bio *
+get_new_bio(struct phys_req *preq, unsigned int op, unsigned int op_flags,
+	    gfp_t gfp_mask, unsigned int nr_bvec)
+{
+	return bio_new(preq->bdev, preq->sector_number, op, op_flags, nr_bvec,
+		       gfp_mask);
+
+}
 /*
  * Transmutation of the 'struct blkif_request' to a proper 'struct bio'
  * and call the 'submit_bio' to pass it to the underlying storage.
@@ -1324,16 +1333,14 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
 				     seg[i].offset) == 0)) {
 
 			int nr_iovecs = min_t(int, (nseg-i), BIO_MAX_PAGES);
-			bio = bio_alloc(GFP_KERNEL, nr_iovecs);
+			bio = get_new_bio(&preq, operation, operation_flags,
+					  GFP_KERNEL, nr_iovecs);
 			if (unlikely(bio == NULL))
 				goto fail_put_bio;
 
 			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;
@@ -1343,15 +1350,14 @@ 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 = get_new_bio(&preq, operation, operation_flags,
+				  GFP_KERNEL, 0);
 		if (unlikely(bio == NULL))
 			goto fail_put_bio;
 
 		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);
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 06/34] zram: use bio_new
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (4 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 05/34] xen-blkback: use bio_new Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 07/34] dm: use bio_new in dm-log-writes Chaitanya Kulkarni
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/block/zram/zram_drv.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index d7018543842e..5d744e528d4f 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -587,12 +587,11 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
 {
 	struct bio *bio;
 
-	bio = bio_alloc(GFP_ATOMIC, 1);
+	bio = bio_alloc(zram->bdev, entry * (PAGE_SIZE >> 9), 0, 0,
+			1, GFP_ATOMIC);
 	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;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 07/34] dm: use bio_new in dm-log-writes
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (5 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 06/34] zram: " Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 08/34] dm-zoned: use bio_new in get_mblock_slow Chaitanya Kulkarni
                   ` (26 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/md/dm-log-writes.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
index e3d35c6c9f71..7ca9af407647 100644
--- a/drivers/md/dm-log-writes.c
+++ b/drivers/md/dm-log-writes.c
@@ -217,18 +217,15 @@ static int write_metadata(struct log_writes_c *lc, void *entry,
 	void *ptr;
 	size_t ret;
 
-	bio = bio_alloc(GFP_KERNEL, 1);
+	bio = bio_new(lc->logdev->bdev, sector, REQ_OP_WRITE, 0, 1, GFP_KERNEL);
 	if (!bio) {
 		DMERR("Couldn't alloc log bio");
 		goto error;
 	}
 	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) {
@@ -264,7 +261,7 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
 			     size_t entrylen, void *data, size_t datalen,
 			     sector_t sector)
 {
-	int num_pages, bio_pages, pg_datalen, pg_sectorlen, i;
+	int num_pages, pg_datalen, pg_sectorlen, i;
 	struct page *page;
 	struct bio *bio;
 	size_t ret;
@@ -272,24 +269,21 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
 
 	while (datalen) {
 		num_pages = ALIGN(datalen, PAGE_SIZE) >> PAGE_SHIFT;
-		bio_pages = min(num_pages, BIO_MAX_PAGES);
 
 		atomic_inc(&lc->io_blocks);
 
-		bio = bio_alloc(GFP_KERNEL, bio_pages);
+		bio = bio_new(lc->logdev->bdev, sector, REQ_OP_WRITE, 0,
+			      num_pages, GFP_KERNEL);
 		if (!bio) {
 			DMERR("Couldn't alloc inline data bio");
 			goto error;
 		}
 
 		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++) {
+		for (i = 0; i < bio->bi_max_vecs; i++) {
 			pg_datalen = min_t(int, datalen, PAGE_SIZE);
 			pg_sectorlen = ALIGN(pg_datalen, lc->sectorsize);
 
@@ -317,7 +311,7 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
 		}
 		submit_bio(bio);
 
-		sector += bio_pages * PAGE_SECTORS;
+		sector += bio->bi_max_vecs * PAGE_SECTORS;
 	}
 	return 0;
 error_bio:
@@ -364,17 +358,15 @@ static int log_one_block(struct log_writes_c *lc,
 		goto out;
 
 	atomic_inc(&lc->io_blocks);
-	bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt, BIO_MAX_PAGES));
+	bio = bio_new(lc->logdev->bdev, sector, REQ_OP_WRITE, 0,
+			block->vec_cnt, GFP_KERNEL);
 	if (!bio) {
 		DMERR("Couldn't alloc log bio");
 		goto error;
 	}
 	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++) {
 		/*
@@ -386,17 +378,15 @@ 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, min(block->vec_cnt - i, BIO_MAX_PAGES));
+			bio = bio_new(lc->logdev->bdev, sector, REQ_OP_WRITE,
+					0, block->vec_cnt - i, GFP_KERNEL);
 			if (!bio) {
 				DMERR("Couldn't alloc log bio");
 				goto error;
 			}
 			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);
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 08/34] dm-zoned: use bio_new in get_mblock_slow
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (6 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 07/34] dm: use bio_new in dm-log-writes Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 09/34] dm-zoned: use bio_new in dmz_write_mblock Chaitanya Kulkarni
                   ` (25 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/md/dm-zoned-metadata.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 039d17b28938..e6252f48a49c 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -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_new(dev->bdev, dmz_blk2sect(block), REQ_OP_READ,
+		      REQ_META | REQ_PRIO, 1, GFP_NOIO);
 	if (!bio) {
 		dmz_free_mblock(zmd, mblk);
 		return ERR_PTR(-ENOMEM);
@@ -577,11 +578,8 @@ static struct dmz_mblock *dmz_get_mblock_slow(struct dmz_metadata *zmd,
 	spin_unlock(&zmd->mblk_lock);
 
 	/* 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);
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 09/34] dm-zoned: use bio_new in dmz_write_mblock
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (7 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 08/34] dm-zoned: use bio_new in get_mblock_slow Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 10/34] dm-zoned: use bio_new in dmz_rdwr_block Chaitanya Kulkarni
                   ` (24 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/md/dm-zoned-metadata.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index e6252f48a49c..fa0ee732c6e9 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -723,7 +723,8 @@ 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_new(dev->bdev, dmz_blk2sect(block), REQ_OP_WRITE,
+		      REQ_META | REQ_PRIO, 1, GFP_NOIO);
 	if (!bio) {
 		set_bit(DMZ_META_ERROR, &mblk->state);
 		return -ENOMEM;
@@ -731,11 +732,8 @@ static int dmz_write_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk,
 
 	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);
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 10/34] dm-zoned: use bio_new in dmz_rdwr_block
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (8 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 09/34] dm-zoned: use bio_new in dmz_write_mblock Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 11/34] nvmet: use bio_new in nvmet_bdev_execute_rw Chaitanya Kulkarni
                   ` (23 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/md/dm-zoned-metadata.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index fa0ee732c6e9..5b5ed5fce2ed 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -755,13 +755,11 @@ 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_new(dev->bdev, dmz_blk2sect(block), op,
+		      REQ_SYNC | REQ_META | REQ_PRIO, 1, GFP_NOIO);
 	if (!bio)
 		return -ENOMEM;
 
-	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);
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 11/34] nvmet: use bio_new in nvmet_bdev_execute_rw
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (9 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 10/34] dm-zoned: use bio_new in dmz_rdwr_block Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 12/34] scsi: target/iblock: use bio_new Chaitanya Kulkarni
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/io-cmd-bdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index bf6e0ac9ad28..f5fd93a796a6 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -225,6 +225,7 @@ static int nvmet_bdev_alloc_bip(struct nvmet_req *req, struct bio *bio,
 
 static void nvmet_bdev_execute_rw(struct nvmet_req *req)
 {
+	struct block_device *bdev = req->ns->bdev;
 	int sg_cnt = req->sg_cnt;
 	struct bio *bio;
 	struct scatterlist *sg;
@@ -265,7 +266,7 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
 	} else {
 		bio = bio_alloc(GFP_KERNEL, min(sg_cnt, BIO_MAX_PAGES));
 	}
-	bio_set_dev(bio, req->ns->bdev);
+	bio_set_dev(bio, bdev);
 	bio->bi_iter.bi_sector = sector;
 	bio->bi_private = req;
 	bio->bi_end_io = nvmet_bio_done;
@@ -290,11 +291,7 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
 				}
 			}
 
-			bio = bio_alloc(GFP_KERNEL, min(sg_cnt, BIO_MAX_PAGES));
-			bio_set_dev(bio, req->ns->bdev);
-			bio->bi_iter.bi_sector = sector;
-			bio->bi_opf = op;
-
+			bio = bio_new(bdev, sector, op, 0, sg_cnt, GFP_KERNEL);
 			bio_chain(bio, prev);
 			submit_bio(prev);
 		}
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 12/34] scsi: target/iblock: use bio_new
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (10 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 11/34] nvmet: use bio_new in nvmet_bdev_execute_rw Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 13/34] block: use bio_new in __blkdev_direct_IO Chaitanya Kulkarni
                   ` (21 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/target/target_core_iblock.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 8ed93fd205c7..f1264918aee1 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -379,10 +379,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_new(ib_dev->ibd_bd, 0, REQ_OP_WRITE, REQ_PREFLUSH, 0,
+		      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);
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 13/34] block: use bio_new in __blkdev_direct_IO
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (11 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 12/34] scsi: target/iblock: use bio_new Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 14/34] fs/buffer: use bio_new in submit_bh_wbc Chaitanya Kulkarni
                   ` (20 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/block_dev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9d4b1a884d76..f3e3247894d7 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -367,6 +367,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 		return -EINVAL;
 
 	bio = bio_alloc_bioset(GFP_KERNEL, nr_pages, &blkdev_dio_pool);
+	bio_set_dev(bio, bdev);
+	bio->bi_iter.bi_sector = pos >> 9;
 
 	dio = container_of(bio, struct blkdev_dio, bio);
 	dio->is_sync = is_sync = is_sync_kiocb(iocb);
@@ -389,8 +391,6 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 		blk_start_plug(&plug);
 
 	for (;;) {
-		bio_set_dev(bio, bdev);
-		bio->bi_iter.bi_sector = pos >> 9;
 		bio->bi_write_hint = iocb->ki_hint;
 		bio->bi_private = dio;
 		bio->bi_end_io = blkdev_bio_end_io;
@@ -446,7 +446,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 		}
 
 		submit_bio(bio);
-		bio = bio_alloc(GFP_KERNEL, nr_pages);
+		bio = bio_new(bdev, pos >> 9, 0, 0, nr_pages, GFP_KERNEL);
 	}
 
 	if (!is_poll)
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 14/34] fs/buffer: use bio_new in submit_bh_wbc
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (12 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 13/34] block: use bio_new in __blkdev_direct_IO Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 15/34] fscrypt: use bio_new in fscrypt_zeroout_range Chaitanya Kulkarni
                   ` (19 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/buffer.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 32647d2011df..fcbea667fa04 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3023,12 +3023,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_new(bh->b_bdev,  bh->b_blocknr * (bh->b_size >> 9), op,
+		      op_flags, GFP_NOIO, 1);
 
 	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));
@@ -3037,12 +3041,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);
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 15/34] fscrypt: use bio_new in fscrypt_zeroout_range
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (13 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 14/34] fs/buffer: use bio_new in submit_bh_wbc Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 16/34] fs/direct-io: use bio_new in dio_bio_alloc Chaitanya Kulkarni
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/crypto/bio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index b048a0e38516..20dab9bdf098 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -148,12 +148,11 @@ 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, 0, REQ_OP_WRITE, 0, nr_pages,
+			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;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 16/34] fs/direct-io: use bio_new in dio_bio_alloc
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (14 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 15/34] fscrypt: use bio_new in fscrypt_zeroout_range Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 17/34] iomap: use bio_new in iomap_dio_zero Chaitanya Kulkarni
                   ` (17 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/crypto/bio.c | 2 +-
 fs/direct-io.c  | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index 20dab9bdf098..28cd62ce853e 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -148,7 +148,7 @@ 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(inode->i_sb->s_bdev, 0, REQ_OP_WRITE, 0, nr_pages,
+	bio = bio_new(inode->i_sb->s_bdev, 0, REQ_OP_WRITE, 0, nr_pages,
 			GFP_NOFS);
 
 	do {
diff --git a/fs/direct-io.c b/fs/direct-io.c
index aa1083ecd623..6aab1bd167bc 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -397,11 +397,9 @@ 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 = bio_new(bdev, first_sector, dio->op, dio->op_flags, nr_vecs,
+		      GFP_KERNEL);
 
-	bio_set_dev(bio, bdev);
-	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.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 17/34] iomap: use bio_new in iomap_dio_zero
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (15 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 16/34] fs/direct-io: use bio_new in dio_bio_alloc Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 16:59   ` Darrick J. Wong
  2021-01-28  7:11 ` [RFC PATCH 18/34] iomap: use bio_new in iomap_dio_bio_actor Chaitanya Kulkarni
                   ` (16 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/iomap/direct-io.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index ea1e8f696076..f6c557a1bd25 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -189,15 +189,13 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
 	int flags = REQ_SYNC | REQ_IDLE;
 	struct bio *bio;
 
-	bio = bio_alloc(GFP_KERNEL, 1);
-	bio_set_dev(bio, iomap->bdev);
-	bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
+	bio = bio_new(iomap->bdev, iomap_sector(iomap, pos), REQ_OP_WRITE,
+		      flags, 1, GFP_KERNEL);
 	bio->bi_private = dio;
 	bio->bi_end_io = iomap_dio_bio_end_io;
 
 	get_page(page);
 	__bio_add_page(bio, page, len, 0);
-	bio_set_op_attrs(bio, REQ_OP_WRITE, flags);
 	iomap_dio_submit_bio(dio, iomap, bio, pos);
 }
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 18/34] iomap: use bio_new in iomap_dio_bio_actor
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (16 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 17/34] iomap: use bio_new in iomap_dio_zero Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 17:24   ` Darrick J. Wong
  2021-01-28  7:11 ` [RFC PATCH 19/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmRead Chaitanya Kulkarni
                   ` (15 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/iomap/direct-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index f6c557a1bd25..0737192f7e5c 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -267,9 +267,8 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
 			goto out;
 		}
 
-		bio = bio_alloc(GFP_KERNEL, nr_pages);
-		bio_set_dev(bio, iomap->bdev);
-		bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
+		bio = bio_new(iomap->bdev, iomap_sector(iomap, pos), 0, 0,
+			      nr_pages, GFP_KERNEL);
 		bio->bi_write_hint = dio->iocb->ki_hint;
 		bio->bi_ioprio = dio->iocb->ki_ioprio;
 		bio->bi_private = dio;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 19/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmRead
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (17 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 18/34] iomap: use bio_new in iomap_dio_bio_actor Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 12:43   ` Dave Kleikamp
  2021-01-28  7:11 ` [RFC PATCH 20/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmStartIO Chaitanya Kulkarni
                   ` (14 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/jfs/jfs_logmgr.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 9330eff210e0..4481f3e33a3f 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -1979,17 +1979,14 @@ static int lbmRead(struct jfs_log * log, int pn, struct lbuf ** bpp)
 
 	bp->l_flag |= lbmREAD;
 
-	bio = bio_alloc(GFP_NOFS, 1);
-
-	bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9);
-	bio_set_dev(bio, log->bdev);
+	bio = bio_new(log->bdev, bp->l_blkno << (log->l2bsize - 9),
+			REQ_OP_READ, 0, 1, GFP_NOFS);
 
 	bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset);
 	BUG_ON(bio->bi_iter.bi_size != LOGPSIZE);
 
 	bio->bi_end_io = lbmIODone;
 	bio->bi_private = bp;
-	bio->bi_opf = REQ_OP_READ;
 	/*check if journaling to disk has been disabled*/
 	if (log->no_integrity) {
 		bio->bi_iter.bi_size = 0;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 20/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmStartIO
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (18 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 19/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmRead Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 21/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_writepage Chaitanya Kulkarni
                   ` (13 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/jfs/jfs_logmgr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 4481f3e33a3f..bb25737d52f6 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -2121,16 +2121,14 @@ static void lbmStartIO(struct lbuf * bp)
 
 	jfs_info("lbmStartIO");
 
-	bio = bio_alloc(GFP_NOFS, 1);
-	bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9);
-	bio_set_dev(bio, log->bdev);
+	bio = bio_new(log->bdev, bp->l_blkno << (log->l2bsize - 9),
+			REQ_OP_WRITE | REQ_SYNC, 0, 1, GFP_NOFS);
 
 	bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset);
 	BUG_ON(bio->bi_iter.bi_size != LOGPSIZE);
 
 	bio->bi_end_io = lbmIODone;
 	bio->bi_private = bp;
-	bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
 
 	/* check if journaling to disk has been disabled */
 	if (log->no_integrity) {
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 21/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_writepage
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (19 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 20/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmStartIO Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 22/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_readpage Chaitanya Kulkarni
                   ` (12 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/jfs/jfs_metapage.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 176580f54af9..3fa09d9a0b94 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -416,12 +416,11 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
 		}
 		len = min(xlen, (int)JFS_SBI(inode->i_sb)->nbperpage);
 
-		bio = bio_alloc(GFP_NOFS, 1);
-		bio_set_dev(bio, inode->i_sb->s_bdev);
-		bio->bi_iter.bi_sector = pblock << (inode->i_blkbits - 9);
+		bio = bio_new(inode->i_sb->s_bdev,
+			      pblock << (inode->i_blkbits - 9), REQ_OP_WRITE,
+			      0, 1, GFP_NOFS);
 		bio->bi_end_io = metapage_write_end_io;
 		bio->bi_private = page;
-		bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
 
 		/* Don't call bio_add_page yet, we may add to this vec */
 		bio_offset = offset;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 22/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_readpage
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (20 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 21/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_writepage Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 23/34] fs/mpage.c: use bio_new mpage_alloc Chaitanya Kulkarni
                   ` (11 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/jfs/jfs_metapage.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 3fa09d9a0b94..c7be3a2773bf 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -495,13 +495,11 @@ static int metapage_readpage(struct file *fp, struct page *page)
 			if (bio)
 				submit_bio(bio);
 
-			bio = bio_alloc(GFP_NOFS, 1);
-			bio_set_dev(bio, inode->i_sb->s_bdev);
-			bio->bi_iter.bi_sector =
-				pblock << (inode->i_blkbits - 9);
+			bio = bio_new(inode->i_sb->s_bdev,
+					pblock << (inode->i_blkbits - 9),
+					REQ_OP_READ, 0, 1, GFP_NOFS);
 			bio->bi_end_io = metapage_read_end_io;
 			bio->bi_private = page;
-			bio_set_op_attrs(bio, REQ_OP_READ, 0);
 			len = xlen << inode->i_blkbits;
 			offset = block_offset << inode->i_blkbits;
 			if (bio_add_page(bio, page, len, offset) < len)
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 23/34] fs/mpage.c: use bio_new mpage_alloc
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (21 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 22/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_readpage Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 24/34] fs/nilfs: use bio_new nilfs_alloc_seg_bio Chaitanya Kulkarni
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/mpage.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/mpage.c b/fs/mpage.c
index 830e6cc2a9e7..01725126e81f 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -68,25 +68,21 @@ static struct bio *mpage_bio_submit(int op, int op_flags, struct bio *bio)
 }
 
 static struct bio *
-mpage_alloc(struct block_device *bdev,
-		sector_t first_sector, int nr_vecs,
-		gfp_t gfp_flags)
+mpage_alloc(struct block_device *bdev, sector_t first_sector, int nr_vecs,
+	    gfp_t gfp_flags)
 {
 	struct bio *bio;
 
 	/* Restrict the given (page cache) mask for slab allocations */
 	gfp_flags &= GFP_KERNEL;
-	bio = bio_alloc(gfp_flags, nr_vecs);
+	bio = bio_new(bdev, first_sector, 0, 0, nr_vecs, gfp_flags);
 
 	if (bio == NULL && (current->flags & PF_MEMALLOC)) {
 		while (!bio && (nr_vecs /= 2))
-			bio = bio_alloc(gfp_flags, nr_vecs);
+			bio = bio_new(bdev, first_sector, 0, 0, nr_vecs,
+					gfp_flags);
 	}
 
-	if (bio) {
-		bio_set_dev(bio, bdev);
-		bio->bi_iter.bi_sector = first_sector;
-	}
 	return bio;
 }
 
@@ -304,9 +300,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
 				goto out;
 		}
 		args->bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-					min_t(int, args->nr_pages,
-					      BIO_MAX_PAGES),
-					gfp);
+					args->nr_pages, gfp);
 		if (args->bio == NULL)
 			goto confused;
 	}
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 24/34] fs/nilfs: use bio_new nilfs_alloc_seg_bio
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (22 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 23/34] fs/mpage.c: use bio_new mpage_alloc Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 25/34] ocfs/cluster: use bio_new in dm-log-writes Chaitanya Kulkarni
                   ` (9 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/nilfs2/segbuf.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 1e75417bfe6e..df352cab7a93 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -383,15 +383,9 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
 static struct bio *nilfs_alloc_seg_bio(struct the_nilfs *nilfs, sector_t start,
 				       int nr_vecs)
 {
-	struct bio *bio;
+	sector_t sect = start << (nilfs->ns_blocksize_bits - 9);
 
-	bio = bio_alloc(GFP_NOIO, nr_vecs);
-	if (likely(bio)) {
-		bio_set_dev(bio, nilfs->ns_bdev);
-		bio->bi_iter.bi_sector =
-			start << (nilfs->ns_blocksize_bits - 9);
-	}
-	return bio;
+	return bio_new(nilfs->ns_bdev, sect, 0, 0, nr_vecs, GFP_NOIO);
 }
 
 static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 25/34] ocfs/cluster: use bio_new in dm-log-writes
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (23 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 24/34] fs/nilfs: use bio_new nilfs_alloc_seg_bio Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 12:13   ` Joseph Qi
  2021-01-28  7:11 ` [RFC PATCH 26/34] xfs: use bio_new in xfs_rw_bdev Chaitanya Kulkarni
                   ` (8 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/ocfs2/cluster/heartbeat.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 0179a73a3fa2..b34518036446 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -515,12 +515,13 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
 	unsigned int cs = *current_slot;
 	struct bio *bio;
 	struct page *page;
+	sector_t sect = (reg->hr_start_block + cs) << (bits - 9);
 
 	/* Testing has shown this allocation to take long enough under
 	 * GFP_KERNEL that the local node can get fenced. It would be
 	 * nicest if we could pre-allocate these bios and avoid this
 	 * all together. */
-	bio = bio_alloc(GFP_ATOMIC, 16);
+	bio = bio_new(reg->hr_bdev, sect, op, op_flags, 16, GFP_ATOMIC);
 	if (!bio) {
 		mlog(ML_ERROR, "Could not alloc slots BIO!\n");
 		bio = ERR_PTR(-ENOMEM);
@@ -528,11 +529,8 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
 	}
 
 	/* Must put everything in 512 byte sectors for the bio... */
-	bio->bi_iter.bi_sector = (reg->hr_start_block + cs) << (bits - 9);
-	bio_set_dev(bio, reg->hr_bdev);
 	bio->bi_private = wc;
 	bio->bi_end_io = o2hb_bio_end_io;
-	bio_set_op_attrs(bio, op, op_flags);
 
 	vec_start = (cs << bits) % PAGE_SIZE;
 	while(cs < max_slots) {
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 26/34] xfs: use bio_new in xfs_rw_bdev
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (24 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 25/34] ocfs/cluster: use bio_new in dm-log-writes Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 17:21   ` Darrick J. Wong
  2021-01-28  7:11 ` [RFC PATCH 27/34] xfs: use bio_new in xfs_buf_ioapply_map Chaitanya Kulkarni
                   ` (7 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/xfs/xfs_bio_io.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/xfs/xfs_bio_io.c b/fs/xfs/xfs_bio_io.c
index e2148f2d5d6b..e4644f22ebe6 100644
--- a/fs/xfs/xfs_bio_io.c
+++ b/fs/xfs/xfs_bio_io.c
@@ -26,11 +26,8 @@ xfs_rw_bdev(
 	if (is_vmalloc && op == REQ_OP_WRITE)
 		flush_kernel_vmap_range(data, count);
 
-	bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left));
-	bio_set_dev(bio, bdev);
-	bio->bi_iter.bi_sector = sector;
-	bio->bi_opf = op | REQ_META | REQ_SYNC;
-
+	bio = bio_new(bdev, sector, op, REQ_META | REQ_SYNC, bio_max_vecs(left),
+		      GFP_KERNEL);
 	do {
 		struct page	*page = kmem_to_page(data);
 		unsigned int	off = offset_in_page(data);
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 27/34] xfs: use bio_new in xfs_buf_ioapply_map
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (25 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 26/34] xfs: use bio_new in xfs_rw_bdev Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 17:21   ` Darrick J. Wong
  2021-01-28  7:11 ` [RFC PATCH 28/34] zonefs: use bio_new Chaitanya Kulkarni
                   ` (6 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/xfs/xfs_buf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index f8400bbd6473..3ff6235e4f94 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1507,12 +1507,10 @@ xfs_buf_ioapply_map(
 	atomic_inc(&bp->b_io_remaining);
 	nr_pages = min(total_nr_pages, BIO_MAX_PAGES);
 
-	bio = bio_alloc(GFP_NOIO, nr_pages);
-	bio_set_dev(bio, bp->b_target->bt_bdev);
-	bio->bi_iter.bi_sector = sector;
+	bio = bio_new(bp->b_target->bt_bdev, sector, op, 0, nr_pages,
+		      GFP_NOIO);
 	bio->bi_end_io = xfs_buf_bio_end_io;
 	bio->bi_private = bp;
-	bio->bi_opf = op;
 
 	for (; size && nr_pages; nr_pages--, page_index++) {
 		int	rbytes, nbytes = PAGE_SIZE - offset;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 28/34] zonefs: use bio_new
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (26 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 27/34] xfs: use bio_new in xfs_buf_ioapply_map Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:25   ` Damien Le Moal
  2021-01-28  7:11 ` [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io Chaitanya Kulkarni
                   ` (5 subsequent siblings)
  33 siblings, 1 reply; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/zonefs/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index ab68e27bb322..620d67965a22 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -661,6 +661,7 @@ static const struct iomap_dio_ops zonefs_write_dio_ops = {
 
 static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
 {
+	unsigned int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE;
 	struct inode *inode = file_inode(iocb->ki_filp);
 	struct zonefs_inode_info *zi = ZONEFS_I(inode);
 	struct block_device *bdev = inode->i_sb->s_bdev;
@@ -678,15 +679,12 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
 	if (!nr_pages)
 		return 0;
 
-	bio = bio_alloc(GFP_NOFS, nr_pages);
+	bio = bio_new(bdev, zi->i_zsector, op, 0, GFP_NOFS, nr_pages);
 	if (!bio)
 		return -ENOMEM;
 
-	bio_set_dev(bio, bdev);
-	bio->bi_iter.bi_sector = zi->i_zsector;
 	bio->bi_write_hint = iocb->ki_hint;
 	bio->bi_ioprio = iocb->ki_ioprio;
-	bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE;
 	if (iocb->ki_flags & IOCB_DSYNC)
 		bio->bi_opf |= REQ_FUA;
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (27 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 28/34] zonefs: use bio_new Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28 10:21   ` Rafael J. Wysocki
  2021-02-17 22:02   ` Pavel Machek
  2021-01-28  7:11 ` [RFC PATCH 30/34] hfsplus: use bio_new in hfsplus_submit_bio() Chaitanya Kulkarni
                   ` (4 subsequent siblings)
  33 siblings, 2 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 kernel/power/swap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index c73f2e295167..e92e36c053a6 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -271,13 +271,12 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
 		struct hib_bio_batch *hb)
 {
 	struct page *page = virt_to_page(addr);
+	sector_t sect = page_off * (PAGE_SIZE >> 9);
 	struct bio *bio;
 	int error = 0;
 
-	bio = bio_alloc(GFP_NOIO | __GFP_HIGH, 1);
-	bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9);
-	bio_set_dev(bio, hib_resume_bdev);
-	bio_set_op_attrs(bio, op, op_flags);
+	bio = bio_new(hib_resume_bdev, sect, op, op_flags, 1,
+		      GFP_NOIO | __GFP_HIGH);
 
 	if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
 		pr_err("Adding page to bio failed at %llu\n",
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 30/34] hfsplus: use bio_new in hfsplus_submit_bio()
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (28 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 31/34] iomap: use bio_new in iomap_readpage_actor Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/hfsplus/wrapper.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c
index 0350dc7821bf..8341ee6c9b31 100644
--- a/fs/hfsplus/wrapper.c
+++ b/fs/hfsplus/wrapper.c
@@ -64,10 +64,7 @@ int hfsplus_submit_bio(struct super_block *sb, sector_t sector,
 	offset = start & (io_size - 1);
 	sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1);
 
-	bio = bio_alloc(GFP_NOIO, 1);
-	bio->bi_iter.bi_sector = sector;
-	bio_set_dev(bio, sb->s_bdev);
-	bio_set_op_attrs(bio, op, op_flags);
+	bio = bio_new(sb->s_bdev, sector, op, op_flags, 1, GFP_NOIO);
 
 	if (op != WRITE && data)
 		*data = (u8 *)buf + offset;
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 31/34] iomap: use bio_new in iomap_readpage_actor
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (29 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 30/34] hfsplus: use bio_new in hfsplus_submit_bio() Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 32/34] mm: use bio_new in __swap_writepage Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/iomap/buffered-io.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 16a1e82e3aeb..08d119b62cf5 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -241,6 +241,9 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 	struct page *page = ctx->cur_page;
 	struct iomap_page *iop = iomap_page_create(inode, page);
 	bool same_page = false, is_contig = false;
+	struct block_device *bdev = iomap->bdev;
+	unsigned opf = ctx->rac ? REQ_RAHEAD : 0;
+	unsigned op = REQ_OP_READ;
 	loff_t orig_pos = pos;
 	unsigned poff, plen;
 	sector_t sector;
@@ -285,19 +288,14 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 
 		if (ctx->rac) /* same as readahead_gfp_mask */
 			gfp |= __GFP_NORETRY | __GFP_NOWARN;
-		ctx->bio = bio_alloc(gfp, min(BIO_MAX_PAGES, nr_vecs));
+		ctx->bio = bio_new(bdev, sector, op, opf, gfp, nr_vecs);
 		/*
 		 * If the bio_alloc fails, try it again for a single page to
 		 * avoid having to deal with partial page reads.  This emulates
 		 * what do_mpage_readpage does.
 		 */
 		if (!ctx->bio)
-			ctx->bio = bio_alloc(orig_gfp, 1);
-		ctx->bio->bi_opf = REQ_OP_READ;
-		if (ctx->rac)
-			ctx->bio->bi_opf |= REQ_RAHEAD;
-		ctx->bio->bi_iter.bi_sector = sector;
-		bio_set_dev(ctx->bio, iomap->bdev);
+			ctx->bio = bio_new(bdev, sector, op, opf, orig_gfp, 1);
 		ctx->bio->bi_end_io = iomap_read_end_io;
 	}
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 32/34] mm: use bio_new in __swap_writepage
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (30 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 31/34] iomap: use bio_new in iomap_readpage_actor Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 33/34] mm: use bio_new in swap_readpage Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 34/34] mm: add swap_bio_new common bio helper Chaitanya Kulkarni
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 mm/page_io.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 92f7941c6d01..25b321489703 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -342,10 +342,8 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 		return 0;
 	}
 
-	bio = bio_alloc(GFP_NOIO, 1);
-	bio_set_dev(bio, sis->bdev);
-	bio->bi_iter.bi_sector = swap_page_sector(page);
-	bio->bi_opf = REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc);
+	bio = bio_alloc(sis->bdev, swap_page_sector(page), REQ_OP_WRITE,
+			REQ_SWAP | wbc_to_write_flags(wbc), 1, GFP_NOIO);
 	bio->bi_end_io = end_write_func;
 	bio_add_page(bio, page, thp_size(page), 0);
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 33/34] mm: use bio_new in swap_readpage
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (31 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 32/34] mm: use bio_new in __swap_writepage Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  2021-01-28  7:11 ` [RFC PATCH 34/34] mm: add swap_bio_new common bio helper Chaitanya Kulkarni
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 mm/page_io.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 25b321489703..7579485ccb5e 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -342,7 +342,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 		return 0;
 	}
 
-	bio = bio_alloc(sis->bdev, swap_page_sector(page), REQ_OP_WRITE,
+	bio = bio_new(sis->bdev, swap_page_sector(page), REQ_OP_WRITE,
 			REQ_SWAP | wbc_to_write_flags(wbc), 1, GFP_NOIO);
 	bio->bi_end_io = end_write_func;
 	bio_add_page(bio, page, thp_size(page), 0);
@@ -406,10 +406,8 @@ int swap_readpage(struct page *page, bool synchronous)
 	}
 
 	ret = 0;
-	bio = bio_alloc(GFP_KERNEL, 1);
-	bio_set_dev(bio, sis->bdev);
-	bio->bi_opf = REQ_OP_READ;
-	bio->bi_iter.bi_sector = swap_page_sector(page);
+	bio = bio_new(sis->bdev, swap_page_sector(page), REQ_OP_READ, 0, 1,
+			GFP_KERNEL);
 	bio->bi_end_io = end_swap_bio_read;
 	bio_add_page(bio, page, thp_size(page), 0);
 
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC PATCH 34/34] mm: add swap_bio_new common bio helper
  2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
                   ` (32 preceding siblings ...)
  2021-01-28  7:11 ` [RFC PATCH 33/34] mm: use bio_new in swap_readpage Chaitanya Kulkarni
@ 2021-01-28  7:11 ` Chaitanya Kulkarni
  33 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-28  7:11 UTC (permalink / raw)
  To: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, chaitanya.kulkarni, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	pavel, akpm, hare, gustavoars, tiwai, alex.shi, asml.silence,
	ming.lei, tj, osandov, bvanassche, jefflexu

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 mm/page_io.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 7579485ccb5e..cc30c9a0b0a7 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -287,6 +287,17 @@ static void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
 #define bio_associate_blkg_from_page(bio, page)		do { } while (0)
 #endif /* CONFIG_MEMCG && CONFIG_BLK_CGROUP */
 
+static inline struct bio *swap_bio_new(struct block_device *dev,
+		unsigned op, unsigned opf, gfp_t gfp, struct page *p,
+		bio_end_io_t *end_io)
+{
+	struct bio *bio = bio_new(dev, swap_page_sector(p), op, opf, 1, gfp);
+
+	bio->bi_end_io = end_io;
+	bio_add_page(bio, p, thp_size(p), 0);
+	return bio;
+}
+
 int __swap_writepage(struct page *page, struct writeback_control *wbc,
 		bio_end_io_t end_write_func)
 {
@@ -342,11 +353,9 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 		return 0;
 	}
 
-	bio = bio_new(sis->bdev, swap_page_sector(page), REQ_OP_WRITE,
-			REQ_SWAP | wbc_to_write_flags(wbc), 1, GFP_NOIO);
-	bio->bi_end_io = end_write_func;
-	bio_add_page(bio, page, thp_size(page), 0);
-
+	bio = swap_bio_new(sis->bdev, REQ_OP_WRITE,
+			REQ_SWAP | wbc_to_write_flags(wbc), GFP_KERNEL,
+			page, end_write_func);
 	bio_associate_blkg_from_page(bio, page);
 	count_swpout_vm_event(page);
 	set_page_writeback(page);
@@ -406,11 +415,8 @@ int swap_readpage(struct page *page, bool synchronous)
 	}
 
 	ret = 0;
-	bio = bio_new(sis->bdev, swap_page_sector(page), REQ_OP_READ, 0, 1,
-			GFP_KERNEL);
-	bio->bi_end_io = end_swap_bio_read;
-	bio_add_page(bio, page, thp_size(page), 0);
-
+	bio = swap_bio_new(sis->bdev, REQ_OP_READ, 0, GFP_KERNEL, page,
+			end_swap_bio_read);
 	disk = bio->bi_bdev->bd_disk;
 	/*
 	 * Keep this task valid during swap readpage because the oom killer may
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 02/34] block: introduce and use bio_new
  2021-01-28  7:11 ` [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
       [not found]     ` <DM6PR04MB4972DA86892CF4531440064F86BA9@DM6PR04MB4972.namprd04.prod.outlook.com>
  0 siblings, 2 replies; 48+ messages in thread
From: Damien Le Moal @ 2021-01-28  7:21 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-xfs, linux-fsdevel, dm-devel,
	linux-block, linux-kernel, drbd-dev, xen-devel, linux-nvme,
	linux-scsi, target-devel, linux-fscrypt, jfs-discussion,
	linux-nilfs, ocfs2-devel, linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, martin.petersen, viro, tytso, jaegeuk, ebiggers, djwong,
	shaggy, konishi.ryusuke, mark, jlbec, joseph.qi, Naohiro Aota,
	jth, rjw, len.brown, pavel, akpm, hare, gustavoars, tiwai,
	alex.shi, asml.silence, ming.lei, tj, osandov, bvanassche,
	jefflexu

On 2021/01/28 16:12, Chaitanya Kulkarni wrote:
> Introduce bio_new() helper and use it in blk-lib.c to allocate and
> initialize various non-optional or semi-optional members of the bio
> along with bio allocation done with bio_alloc(). Here we also calmp the
> max_bvecs for bio with BIO_MAX_PAGES before we pass to bio_alloc().
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  block/blk-lib.c     |  6 +-----
>  include/linux/bio.h | 25 +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index fb486a0bdb58..ec29415f00dd 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -14,17 +14,13 @@ 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);
> +	struct bio *new = bio_new(bdev, sect, op, opf, gfp, nr_pages);
>  
>  	if (bio) {
>  		bio_chain(bio, new);
>  		submit_bio(bio);
>  	}
>  
> -	new->bi_iter.bi_sector = sect;
> -	bio_set_dev(new, bdev);
> -	bio_set_op_attrs(new, op, opf);
> -
>  	return new;
>  }
>  
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index c74857cf1252..2a09ba100546 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -826,5 +826,30 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
>  	if (!is_sync_kiocb(kiocb))
>  		bio->bi_opf |= REQ_NOWAIT;
>  }
> +/**
> + * bio_new -	allcate and initialize new bio
> + * @bdev:	blockdev to issue discard for
> + * @sector:	start sector
> + * @op:		REQ_OP_XXX from enum req_opf
> + * @op_flags:	REQ_XXX from enum req_flag_bits
> + * @max_bvecs:	maximum bvec to be allocated for this bio
> + * @gfp_mask:	memory allocation flags (for bio_alloc)
> + *
> + * Description:
> + *    Allocates, initializes common members, and returns a new bio.
> + */
> +static inline struct bio *bio_new(struct block_device *bdev, sector_t sector,
> +				  unsigned int op, unsigned int op_flags,
> +				  unsigned int max_bvecs, gfp_t gfp_mask)
> +{
> +	unsigned nr_bvec = clamp_t(unsigned int, max_bvecs, 0, BIO_MAX_PAGES);
> +	struct bio *bio = bio_alloc(gfp_mask, nr_bvec);

I think that depending on the gfp_mask passed, bio can be NULL. So this should
be checked.

> +
> +	bio_set_dev(bio, bdev);
> +	bio->bi_iter.bi_sector = sector;
> +	bio_set_op_attrs(bio, op, op_flags);

This function is obsolete. Open code this.

> +
> +	return bio;
> +}
>  
>  #endif /* __LINUX_BIO_H */
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 28/34] zonefs: use bio_new
  2021-01-28  7:11 ` [RFC PATCH 28/34] zonefs: use bio_new Chaitanya Kulkarni
@ 2021-01-28  7:25   ` Damien Le Moal
  0 siblings, 0 replies; 48+ messages in thread
From: Damien Le Moal @ 2021-01-28  7:25 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-xfs, linux-fsdevel, dm-devel,
	linux-block, linux-kernel, drbd-dev, xen-devel, linux-nvme,
	linux-scsi, target-devel, linux-fscrypt, jfs-discussion,
	linux-nilfs, ocfs2-devel, linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, martin.petersen, viro, tytso, jaegeuk, ebiggers, djwong,
	shaggy, konishi.ryusuke, mark, jlbec, joseph.qi, Naohiro Aota,
	jth, rjw, len.brown, pavel, akpm, hare, gustavoars, tiwai,
	alex.shi, asml.silence, ming.lei, tj, osandov, bvanassche,
	jefflexu

On 2021/01/28 16:15, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  fs/zonefs/super.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index ab68e27bb322..620d67965a22 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -661,6 +661,7 @@ static const struct iomap_dio_ops zonefs_write_dio_ops = {
>  
>  static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
>  {
> +	unsigned int op = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE;

I do not see the point of adding this variable since it is used only for the
bio_new() call. Pass the op value directly.

>  	struct inode *inode = file_inode(iocb->ki_filp);
>  	struct zonefs_inode_info *zi = ZONEFS_I(inode);
>  	struct block_device *bdev = inode->i_sb->s_bdev;
> @@ -678,15 +679,12 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
>  	if (!nr_pages)
>  		return 0;
>  
> -	bio = bio_alloc(GFP_NOFS, nr_pages);
> +	bio = bio_new(bdev, zi->i_zsector, op, 0, GFP_NOFS, nr_pages);
>  	if (!bio)
>  		return -ENOMEM;
>  
> -	bio_set_dev(bio, bdev);
> -	bio->bi_iter.bi_sector = zi->i_zsector;
>  	bio->bi_write_hint = iocb->ki_hint;
>  	bio->bi_ioprio = iocb->ki_ioprio;
> -	bio->bi_opf = REQ_OP_ZONE_APPEND | REQ_SYNC | REQ_IDLE;
>  	if (iocb->ki_flags & IOCB_DSYNC)
>  		bio->bi_opf |= REQ_FUA;
>  
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 02/34] block: introduce and use bio_new
  2021-01-28  7:21   ` Damien Le Moal
@ 2021-01-28  7:27     ` Damien Le Moal
       [not found]     ` <DM6PR04MB4972DA86892CF4531440064F86BA9@DM6PR04MB4972.namprd04.prod.outlook.com>
  1 sibling, 0 replies; 48+ messages in thread
From: Damien Le Moal @ 2021-01-28  7:27 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-xfs, linux-fsdevel, dm-devel,
	linux-block, linux-kernel, drbd-dev, xen-devel, linux-nvme,
	linux-scsi, target-devel, linux-fscrypt, jfs-discussion,
	linux-nilfs, ocfs2-devel, linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, martin.petersen, viro, tytso, jaegeuk, ebiggers, djwong,
	shaggy, konishi.ryusuke, mark, jlbec, joseph.qi, Naohiro Aota,
	jth, rjw, len.brown, pavel, akpm, hare, gustavoars, tiwai,
	alex.shi, asml.silence, ming.lei, tj, osandov, bvanassche,
	jefflexu

On 2021/01/28 16:21, Damien Le Moal wrote:
> On 2021/01/28 16:12, Chaitanya Kulkarni wrote:
>> Introduce bio_new() helper and use it in blk-lib.c to allocate and
>> initialize various non-optional or semi-optional members of the bio
>> along with bio allocation done with bio_alloc(). Here we also calmp the
>> max_bvecs for bio with BIO_MAX_PAGES before we pass to bio_alloc().
>>
>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>> ---
>>  block/blk-lib.c     |  6 +-----
>>  include/linux/bio.h | 25 +++++++++++++++++++++++++
>>  2 files changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/block/blk-lib.c b/block/blk-lib.c
>> index fb486a0bdb58..ec29415f00dd 100644
>> --- a/block/blk-lib.c
>> +++ b/block/blk-lib.c
>> @@ -14,17 +14,13 @@ 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);
>> +	struct bio *new = bio_new(bdev, sect, op, opf, gfp, nr_pages);
>>  
>>  	if (bio) {
>>  		bio_chain(bio, new);
>>  		submit_bio(bio);
>>  	}
>>  
>> -	new->bi_iter.bi_sector = sect;
>> -	bio_set_dev(new, bdev);
>> -	bio_set_op_attrs(new, op, opf);
>> -
>>  	return new;
>>  }
>>  
>> diff --git a/include/linux/bio.h b/include/linux/bio.h
>> index c74857cf1252..2a09ba100546 100644
>> --- a/include/linux/bio.h
>> +++ b/include/linux/bio.h
>> @@ -826,5 +826,30 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
>>  	if (!is_sync_kiocb(kiocb))
>>  		bio->bi_opf |= REQ_NOWAIT;
>>  }
>> +/**
>> + * bio_new -	allcate and initialize new bio
>> + * @bdev:	blockdev to issue discard for
>> + * @sector:	start sector
>> + * @op:		REQ_OP_XXX from enum req_opf
>> + * @op_flags:	REQ_XXX from enum req_flag_bits
>> + * @max_bvecs:	maximum bvec to be allocated for this bio
>> + * @gfp_mask:	memory allocation flags (for bio_alloc)
>> + *
>> + * Description:
>> + *    Allocates, initializes common members, and returns a new bio.
>> + */
>> +static inline struct bio *bio_new(struct block_device *bdev, sector_t sector,
>> +				  unsigned int op, unsigned int op_flags,
>> +				  unsigned int max_bvecs, gfp_t gfp_mask)
>> +{
>> +	unsigned nr_bvec = clamp_t(unsigned int, max_bvecs, 0, BIO_MAX_PAGES);
>> +	struct bio *bio = bio_alloc(gfp_mask, nr_bvec);
> 
> I think that depending on the gfp_mask passed, bio can be NULL. So this should
> be checked.
> 
>> +
>> +	bio_set_dev(bio, bdev);
>> +	bio->bi_iter.bi_sector = sector;
>> +	bio_set_op_attrs(bio, op, op_flags);
> 
> This function is obsolete. Open code this.

And that also mean that you could remove one argument to bio_new(): combine op
and op_flags into "unsigned int opf"

> 
>> +
>> +	return bio;
>> +}
>>  
>>  #endif /* __LINUX_BIO_H */
>>
> 
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io
  2021-01-28  7:11 ` [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
  1 sibling, 0 replies; 48+ messages in thread
From: Rafael J. Wysocki @ 2021-01-28 10:21 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block,
	Linux Kernel Mailing List, drbd-dev, xen-devel, linux-nvme,
	open list:TARGET SUBSYSTEM, target-devel, linux-fscrypt,
	jfs-discussion, linux-nilfs, ocfs2-devel, Linux PM,
	Linux Memory Management List, Jens Axboe, Philipp Reisner,
	Lars Ellenberg, Konrad Rzeszutek Wilk, roger.pau, Minchan Kim,
	ngupta, Sergey Senozhatsky, Alasdair Kergon, Mike Snitzer,
	Christoph Hellwig, Sagi Grimberg, Martin K. Petersen, Al Viro,
	Ted Ts'o, jaegeuk, Eric Biggers, djwong, shaggy,
	konishi.ryusuke, Mark Fasheh, Joel Becker, Joseph Qi,
	damien.lemoal, naohiro.aota, jth, Rafael J. Wysocki, Len Brown,
	Pavel Machek, Andrew Morton, Hannes Reinecke,
	Gustavo A. R. Silva, Takashi Iwai, Alex Shi, asml.silence,
	Ming Lei, Tejun Heo, osandov, Bart Van Assche, jefflexu

On Thu, Jan 28, 2021 at 8:21 AM Chaitanya Kulkarni
<chaitanya.kulkarni@wdc.com> wrote:
>

Please explain in the changelog why making this change is a good idea.

> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  kernel/power/swap.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index c73f2e295167..e92e36c053a6 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -271,13 +271,12 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
>                 struct hib_bio_batch *hb)
>  {
>         struct page *page = virt_to_page(addr);
> +       sector_t sect = page_off * (PAGE_SIZE >> 9);
>         struct bio *bio;
>         int error = 0;
>
> -       bio = bio_alloc(GFP_NOIO | __GFP_HIGH, 1);
> -       bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9);
> -       bio_set_dev(bio, hib_resume_bdev);
> -       bio_set_op_attrs(bio, op, op_flags);
> +       bio = bio_new(hib_resume_bdev, sect, op, op_flags, 1,
> +                     GFP_NOIO | __GFP_HIGH);
>
>         if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
>                 pr_err("Adding page to bio failed at %llu\n",
> --
> 2.22.1
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 25/34] ocfs/cluster: use bio_new in dm-log-writes
  2021-01-28  7:11 ` [RFC PATCH 25/34] ocfs/cluster: use bio_new in dm-log-writes Chaitanya Kulkarni
@ 2021-01-28 12:13   ` Joseph Qi
  0 siblings, 0 replies; 48+ messages in thread
From: Joseph Qi @ 2021-01-28 12:13 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-xfs, linux-fsdevel, dm-devel,
	linux-block, linux-kernel, drbd-dev, xen-devel, linux-nvme,
	linux-scsi, target-devel, linux-fscrypt, jfs-discussion,
	linux-nilfs, ocfs2-devel, linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, martin.petersen, viro, tytso, jaegeuk, ebiggers, djwong,
	shaggy, konishi.ryusuke, mark, jlbec, damien.lemoal,
	naohiro.aota, jth, rjw, len.brown, pavel, akpm, hare, gustavoars,
	tiwai, alex.shi, asml.silence, ming.lei, tj, osandov, bvanassche,
	jefflexu

I think you send a wrong subject by mistake.

Thanks,
Joseph

On 1/28/21 3:11 PM, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  fs/ocfs2/cluster/heartbeat.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
> index 0179a73a3fa2..b34518036446 100644
> --- a/fs/ocfs2/cluster/heartbeat.c
> +++ b/fs/ocfs2/cluster/heartbeat.c
> @@ -515,12 +515,13 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
>  	unsigned int cs = *current_slot;
>  	struct bio *bio;
>  	struct page *page;
> +	sector_t sect = (reg->hr_start_block + cs) << (bits - 9);
>  
>  	/* Testing has shown this allocation to take long enough under
>  	 * GFP_KERNEL that the local node can get fenced. It would be
>  	 * nicest if we could pre-allocate these bios and avoid this
>  	 * all together. */
> -	bio = bio_alloc(GFP_ATOMIC, 16);
> +	bio = bio_new(reg->hr_bdev, sect, op, op_flags, 16, GFP_ATOMIC);
>  	if (!bio) {
>  		mlog(ML_ERROR, "Could not alloc slots BIO!\n");
>  		bio = ERR_PTR(-ENOMEM);
> @@ -528,11 +529,8 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
>  	}
>  
>  	/* Must put everything in 512 byte sectors for the bio... */
> -	bio->bi_iter.bi_sector = (reg->hr_start_block + cs) << (bits - 9);
> -	bio_set_dev(bio, reg->hr_bdev);
>  	bio->bi_private = wc;
>  	bio->bi_end_io = o2hb_bio_end_io;
> -	bio_set_op_attrs(bio, op, op_flags);
>  
>  	vec_start = (cs << bits) % PAGE_SIZE;
>  	while(cs < max_slots) {
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 19/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmRead
  2021-01-28  7:11 ` [RFC PATCH 19/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmRead Chaitanya Kulkarni
@ 2021-01-28 12:43   ` Dave Kleikamp
  0 siblings, 0 replies; 48+ messages in thread
From: Dave Kleikamp @ 2021-01-28 12:43 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-xfs, linux-fsdevel, dm-devel,
	linux-block, linux-kernel, drbd-dev, xen-devel, linux-nvme,
	linux-scsi, target-devel, linux-fscrypt, jfs-discussion,
	linux-nilfs, ocfs2-devel, linux-pm, linux-mm
  Cc: axboe, philipp.reisner, lars.ellenberg, konrad.wilk, roger.pau,
	minchan, ngupta, sergey.senozhatsky.work, agk, snitzer, hch,
	sagi, martin.petersen, viro, tytso, jaegeuk, ebiggers, djwong,
	shaggy, konishi.ryusuke, mark, jlbec, joseph.qi, damien.lemoal,
	naohiro.aota, jth, rjw, len.brown, pavel, akpm, hare, gustavoars,
	tiwai, alex.shi, asml.silence, ming.lei, tj, osandov, bvanassche,
	jefflexu

You probably don't need 4 patches to fs/jfs/. These can be combined into 
a single patch.

Dave

On 1/28/21 1:11 AM, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>   fs/jfs/jfs_logmgr.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
> index 9330eff210e0..4481f3e33a3f 100644
> --- a/fs/jfs/jfs_logmgr.c
> +++ b/fs/jfs/jfs_logmgr.c
> @@ -1979,17 +1979,14 @@ static int lbmRead(struct jfs_log * log, int pn, struct lbuf ** bpp)
>   
>   	bp->l_flag |= lbmREAD;
>   
> -	bio = bio_alloc(GFP_NOFS, 1);
> -
> -	bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9);
> -	bio_set_dev(bio, log->bdev);
> +	bio = bio_new(log->bdev, bp->l_blkno << (log->l2bsize - 9),
> +			REQ_OP_READ, 0, 1, GFP_NOFS);
>   
>   	bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset);
>   	BUG_ON(bio->bi_iter.bi_size != LOGPSIZE);
>   
>   	bio->bi_end_io = lbmIODone;
>   	bio->bi_private = bp;
> -	bio->bi_opf = REQ_OP_READ;
>   	/*check if journaling to disk has been disabled*/
>   	if (log->no_integrity) {
>   		bio->bi_iter.bi_size = 0;
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [Ocfs2-devel] [RFC PATCH 02/34] block: introduce and use bio_new
       [not found]     ` <DM6PR04MB4972DA86892CF4531440064F86BA9@DM6PR04MB4972.namprd04.prod.outlook.com>
@ 2021-01-28 16:47       ` Matthew Wilcox
  0 siblings, 0 replies; 48+ messages in thread
From: Matthew Wilcox @ 2021-01-28 16:47 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: Damien Le Moal, linux-xfs, linux-fsdevel, dm-devel, linux-block,
	linux-kernel, drbd-dev, xen-devel, linux-nvme, linux-scsi,
	target-devel, linux-fscrypt, jfs-discussion, linux-nilfs,
	ocfs2-devel, linux-pm, linux-mm, shaggy, sergey.senozhatsky.work,
	snitzer, len.brown, tiwai, djwong, gustavoars, pavel, alex.shi,
	agk, sagi, osandov, ebiggers, ngupta, Naohiro Aota, konrad.wilk,
	hare, ming.lei, viro, jefflexu, jaegeuk, konishi.ryusuke,
	bvanassche, axboe, jth, tytso, rjw, philipp.reisner, minchan, tj,
	lars.ellenberg, roger.pau, asml.silence


FYI your email is completely unreadable to those not using html.
I can't tell what you wrote and what Damien wrote.

On Thu, Jan 28, 2021 at 08:33:10AM +0000, Chaitanya Kulkarni wrote:
> On 1/27/21 11:21 PM, Damien Le Moal wrote:
> 
> On 2021/01/28 16:12, Chaitanya Kulkarni wrote:
> 
> 
> Introduce bio_new() helper and use it in blk-lib.c to allocate and
> initialize various non-optional or semi-optional members of the bio
> along with bio allocation done with bio_alloc(). Here we also calmp the
> max_bvecs for bio with BIO_MAX_PAGES before we pass to bio_alloc().
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com><mailto:chaitanya.kulkarni@wdc.com>
> ---
>  block/blk-lib.c     |  6 +-----
>  include/linux/bio.h | 25 +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index fb486a0bdb58..ec29415f00dd 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -14,17 +14,13 @@ 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);
> +       struct bio *new = bio_new(bdev, sect, op, opf, gfp, nr_pages);
> 
>         if (bio) {
>                 bio_chain(bio, new);
>                 submit_bio(bio);
>         }
> 
> -       new->bi_iter.bi_sector = sect;
> -       bio_set_dev(new, bdev);
> -       bio_set_op_attrs(new, op, opf);
> -
>         return new;
>  }
> 
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index c74857cf1252..2a09ba100546 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -826,5 +826,30 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
>         if (!is_sync_kiocb(kiocb))
>                 bio->bi_opf |= REQ_NOWAIT;
>  }
> +/**
> + * bio_new -   allcate and initialize new bio
> + * @bdev:      blockdev to issue discard for
> + * @sector:    start sector
> + * @op:                REQ_OP_XXX from enum req_opf
> + * @op_flags:  REQ_XXX from enum req_flag_bits
> + * @max_bvecs: maximum bvec to be allocated for this bio
> + * @gfp_mask:  memory allocation flags (for bio_alloc)
> + *
> + * Description:
> + *    Allocates, initializes common members, and returns a new bio.
> + */
> +static inline struct bio *bio_new(struct block_device *bdev, sector_t sector,
> +                                 unsigned int op, unsigned int op_flags,
> +                                 unsigned int max_bvecs, gfp_t gfp_mask)
> +{
> +       unsigned nr_bvec = clamp_t(unsigned int, max_bvecs, 0, BIO_MAX_PAGES);
> +       struct bio *bio = bio_alloc(gfp_mask, nr_bvec);
> 
> 
> I think that depending on the gfp_mask passed, bio can be NULL. So this should
> be checked.
> 
> 
> true, I'll add that check.
> 
> 
> 
> 
> +
> +       bio_set_dev(bio, bdev);
> +       bio->bi_iter.bi_sector = sector;
> +       bio_set_op_attrs(bio, op, op_flags);
> 
> 
> This function is obsolete. Open code this.
> 
> 
> true, will do.
> 
> 
> 
> 
> +
> +       return bio;
> +}
> 
>  #endif /* __LINUX_BIO_H */
> 
> 
> 
> Thanks for the comments Damien.

> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 17/34] iomap: use bio_new in iomap_dio_zero
  2021-01-28  7:11 ` [RFC PATCH 17/34] iomap: use bio_new in iomap_dio_zero Chaitanya Kulkarni
@ 2021-01-28 16:59   ` Darrick J. Wong
  0 siblings, 0 replies; 48+ messages in thread
From: Darrick J. Wong @ 2021-01-28 16:59 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm, axboe, philipp.reisner, lars.ellenberg,
	konrad.wilk, roger.pau, minchan, ngupta, sergey.senozhatsky.work,
	agk, snitzer, hch, sagi, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, shaggy, konishi.ryusuke, mark, jlbec, joseph.qi,
	damien.lemoal, naohiro.aota, jth, rjw, len.brown, pavel, akpm,
	hare, gustavoars, tiwai, alex.shi, asml.silence, ming.lei, tj,
	osandov, bvanassche, jefflexu

On Wed, Jan 27, 2021 at 11:11:16PM -0800, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

Looks ok to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/iomap/direct-io.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index ea1e8f696076..f6c557a1bd25 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -189,15 +189,13 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
>  	int flags = REQ_SYNC | REQ_IDLE;
>  	struct bio *bio;
>  
> -	bio = bio_alloc(GFP_KERNEL, 1);
> -	bio_set_dev(bio, iomap->bdev);
> -	bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
> +	bio = bio_new(iomap->bdev, iomap_sector(iomap, pos), REQ_OP_WRITE,
> +		      flags, 1, GFP_KERNEL);
>  	bio->bi_private = dio;
>  	bio->bi_end_io = iomap_dio_bio_end_io;
>  
>  	get_page(page);
>  	__bio_add_page(bio, page, len, 0);
> -	bio_set_op_attrs(bio, REQ_OP_WRITE, flags);
>  	iomap_dio_submit_bio(dio, iomap, bio, pos);
>  }
>  
> -- 
> 2.22.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 26/34] xfs: use bio_new in xfs_rw_bdev
  2021-01-28  7:11 ` [RFC PATCH 26/34] xfs: use bio_new in xfs_rw_bdev Chaitanya Kulkarni
@ 2021-01-28 17:21   ` Darrick J. Wong
  0 siblings, 0 replies; 48+ messages in thread
From: Darrick J. Wong @ 2021-01-28 17:21 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm, axboe, philipp.reisner, lars.ellenberg,
	konrad.wilk, roger.pau, minchan, ngupta, sergey.senozhatsky.work,
	agk, snitzer, hch, sagi, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, shaggy, konishi.ryusuke, mark, jlbec, joseph.qi,
	damien.lemoal, naohiro.aota, jth, rjw, len.brown, pavel, akpm,
	hare, gustavoars, tiwai, alex.shi, asml.silence, ming.lei, tj,
	osandov, bvanassche, jefflexu

On Wed, Jan 27, 2021 at 11:11:25PM -0800, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

Seems fine to me...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_bio_io.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bio_io.c b/fs/xfs/xfs_bio_io.c
> index e2148f2d5d6b..e4644f22ebe6 100644
> --- a/fs/xfs/xfs_bio_io.c
> +++ b/fs/xfs/xfs_bio_io.c
> @@ -26,11 +26,8 @@ xfs_rw_bdev(
>  	if (is_vmalloc && op == REQ_OP_WRITE)
>  		flush_kernel_vmap_range(data, count);
>  
> -	bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left));
> -	bio_set_dev(bio, bdev);
> -	bio->bi_iter.bi_sector = sector;
> -	bio->bi_opf = op | REQ_META | REQ_SYNC;
> -
> +	bio = bio_new(bdev, sector, op, REQ_META | REQ_SYNC, bio_max_vecs(left),
> +		      GFP_KERNEL);
>  	do {
>  		struct page	*page = kmem_to_page(data);
>  		unsigned int	off = offset_in_page(data);
> -- 
> 2.22.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 27/34] xfs: use bio_new in xfs_buf_ioapply_map
  2021-01-28  7:11 ` [RFC PATCH 27/34] xfs: use bio_new in xfs_buf_ioapply_map Chaitanya Kulkarni
@ 2021-01-28 17:21   ` Darrick J. Wong
  0 siblings, 0 replies; 48+ messages in thread
From: Darrick J. Wong @ 2021-01-28 17:21 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm, axboe, philipp.reisner, lars.ellenberg,
	konrad.wilk, roger.pau, minchan, ngupta, sergey.senozhatsky.work,
	agk, snitzer, hch, sagi, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, shaggy, konishi.ryusuke, mark, jlbec, joseph.qi,
	damien.lemoal, naohiro.aota, jth, rjw, len.brown, pavel, akpm,
	hare, gustavoars, tiwai, alex.shi, asml.silence, ming.lei, tj,
	osandov, bvanassche, jefflexu

On Wed, Jan 27, 2021 at 11:11:26PM -0800, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_buf.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index f8400bbd6473..3ff6235e4f94 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -1507,12 +1507,10 @@ xfs_buf_ioapply_map(
>  	atomic_inc(&bp->b_io_remaining);
>  	nr_pages = min(total_nr_pages, BIO_MAX_PAGES);
>  
> -	bio = bio_alloc(GFP_NOIO, nr_pages);
> -	bio_set_dev(bio, bp->b_target->bt_bdev);
> -	bio->bi_iter.bi_sector = sector;
> +	bio = bio_new(bp->b_target->bt_bdev, sector, op, 0, nr_pages,
> +		      GFP_NOIO);
>  	bio->bi_end_io = xfs_buf_bio_end_io;
>  	bio->bi_private = bp;
> -	bio->bi_opf = op;
>  
>  	for (; size && nr_pages; nr_pages--, page_index++) {
>  		int	rbytes, nbytes = PAGE_SIZE - offset;
> -- 
> 2.22.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 18/34] iomap: use bio_new in iomap_dio_bio_actor
  2021-01-28  7:11 ` [RFC PATCH 18/34] iomap: use bio_new in iomap_dio_bio_actor Chaitanya Kulkarni
@ 2021-01-28 17:24   ` Darrick J. Wong
  0 siblings, 0 replies; 48+ messages in thread
From: Darrick J. Wong @ 2021-01-28 17:24 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm, axboe, philipp.reisner, lars.ellenberg,
	konrad.wilk, roger.pau, minchan, ngupta, sergey.senozhatsky.work,
	agk, snitzer, hch, sagi, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, shaggy, konishi.ryusuke, mark, jlbec, joseph.qi,
	damien.lemoal, naohiro.aota, jth, rjw, len.brown, pavel, akpm,
	hare, gustavoars, tiwai, alex.shi, asml.silence, ming.lei, tj,
	osandov, bvanassche, jefflexu

On Wed, Jan 27, 2021 at 11:11:17PM -0800, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  fs/iomap/direct-io.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index f6c557a1bd25..0737192f7e5c 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -267,9 +267,8 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
>  			goto out;
>  		}
>  
> -		bio = bio_alloc(GFP_KERNEL, nr_pages);
> -		bio_set_dev(bio, iomap->bdev);
> -		bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
> +		bio = bio_new(iomap->bdev, iomap_sector(iomap, pos), 0, 0,
> +			      nr_pages, GFP_KERNEL);

op == 0?  It seems a little odd to me that we'd set the field to zero
and then construct bi_opf later.

It also strikes me as a little strange that bi_opf is combined from the
third and fourth parameters, but maybe some day you'll want to do some
parameter verification on debug kernels or something...?

--D

>  		bio->bi_write_hint = dio->iocb->ki_hint;
>  		bio->bi_ioprio = dio->iocb->ki_ioprio;
>  		bio->bi_private = dio;
> -- 
> 2.22.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io
  2021-01-28  7:11 ` [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
  1 sibling, 1 reply; 48+ messages in thread
From: Pavel Machek @ 2021-02-17 22:02 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm, axboe, philipp.reisner, lars.ellenberg,
	konrad.wilk, roger.pau, minchan, ngupta, sergey.senozhatsky.work,
	agk, snitzer, hch, sagi, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, damien.lemoal, naohiro.aota, jth, rjw, len.brown,
	akpm, hare, gustavoars, tiwai, alex.shi, asml.silence, ming.lei,
	tj, osandov, bvanassche, jefflexu

[-- Attachment #1: Type: text/plain, Size: 914 bytes --]

Hi!
> 
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index c73f2e295167..e92e36c053a6 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -271,13 +271,12 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
>  		struct hib_bio_batch *hb)
>  {
>  	struct page *page = virt_to_page(addr);
> +	sector_t sect = page_off * (PAGE_SIZE >> 9);
>  	struct bio *bio;
>  	int error = 0;
>  
> -	bio = bio_alloc(GFP_NOIO | __GFP_HIGH, 1);
> -	bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9);
> -	bio_set_dev(bio, hib_resume_bdev);
> -	bio_set_op_attrs(bio, op, op_flags);
> +	bio = bio_new(hib_resume_bdev, sect, op, op_flags, 1,
> +		      GFP_NOIO | __GFP_HIGH);
>  

C function with 6 arguments... dunno. Old version looks comparable or
even more readable...

Best regards,
							Pavel

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC PATCH 29/34] power/swap: use bio_new in hib_submit_io
  2021-02-17 22:02   ` Pavel Machek
@ 2021-02-18  1:28     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 48+ messages in thread
From: Chaitanya Kulkarni @ 2021-02-18  1:28 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-xfs, linux-fsdevel, dm-devel, linux-block, linux-kernel,
	drbd-dev, xen-devel, linux-nvme, linux-scsi, target-devel,
	linux-fscrypt, jfs-discussion, linux-nilfs, ocfs2-devel,
	linux-pm, linux-mm, axboe, philipp.reisner, lars.ellenberg,
	konrad.wilk, roger.pau, minchan, ngupta, sergey.senozhatsky.work,
	agk, snitzer, hch, sagi, martin.petersen, viro, tytso, jaegeuk,
	ebiggers, djwong, shaggy, konishi.ryusuke, mark, jlbec,
	joseph.qi, Damien Le Moal, Naohiro Aota, jth, rjw, len.brown,
	akpm, hare, gustavoars, tiwai, alex.shi, asml.silence, ming.lei,
	tj, osandov, bvanassche, jefflexu

On 2/17/21 14:03, Pavel Machek wrote:
> Hi!
>> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
>> index c73f2e295167..e92e36c053a6 100644
>> --- a/kernel/power/swap.c
>> +++ b/kernel/power/swap.c
>> @@ -271,13 +271,12 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
>>  		struct hib_bio_batch *hb)
>>  {
>>  	struct page *page = virt_to_page(addr);
>> +	sector_t sect = page_off * (PAGE_SIZE >> 9);
>>  	struct bio *bio;
>>  	int error = 0;
>>  
>> -	bio = bio_alloc(GFP_NOIO | __GFP_HIGH, 1);
>> -	bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9);
>> -	bio_set_dev(bio, hib_resume_bdev);
>> -	bio_set_op_attrs(bio, op, op_flags);
>> +	bio = bio_new(hib_resume_bdev, sect, op, op_flags, 1,
>> +		      GFP_NOIO | __GFP_HIGH);
>>  
> C function with 6 arguments... dunno. Old version looks comparable or
> even more readable...
>
> Best regards,
> 							Pavel
The library functions that are in the kernel tree which are used
in different file-systems and fabrics drivers do take 6 arguments.

Plus what is the point of duplicating code for mandatory
parameters all over the kernel ?


^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2021-02-18  1:29 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28  7:10 [RFC PATCH 00/34] block: introduce bio_new() Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 01/34] block: move common code into blk_next_bio() Chaitanya Kulkarni
2021-01-28  7:11 ` [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
     [not found]     ` <DM6PR04MB4972DA86892CF4531440064F86BA9@DM6PR04MB4972.namprd04.prod.outlook.com>
2021-01-28 16:47       ` [Ocfs2-devel] " Matthew Wilcox
2021-01-28  7:11 ` [RFC PATCH 03/34] drdb: use bio_new in drdb Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 04/34] drdb: use bio_new() in submit_one_flush Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 05/34] xen-blkback: use bio_new Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 06/34] zram: " Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 07/34] dm: use bio_new in dm-log-writes Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 08/34] dm-zoned: use bio_new in get_mblock_slow Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 09/34] dm-zoned: use bio_new in dmz_write_mblock Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 10/34] dm-zoned: use bio_new in dmz_rdwr_block Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 11/34] nvmet: use bio_new in nvmet_bdev_execute_rw Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 12/34] scsi: target/iblock: use bio_new Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 13/34] block: use bio_new in __blkdev_direct_IO Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 14/34] fs/buffer: use bio_new in submit_bh_wbc Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 15/34] fscrypt: use bio_new in fscrypt_zeroout_range Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 16/34] fs/direct-io: use bio_new in dio_bio_alloc Chaitanya Kulkarni
2021-01-28  7:11 ` [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 ` [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 ` [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 ` [RFC PATCH 20/34] fs/jfs/jfs_logmgr.c: use bio_new in lbmStartIO Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 21/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_writepage Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 22/34] fs/jfs/jfs_metapage.c: use bio_new in metapage_readpage Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 23/34] fs/mpage.c: use bio_new mpage_alloc Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 24/34] fs/nilfs: use bio_new nilfs_alloc_seg_bio Chaitanya Kulkarni
2021-01-28  7:11 ` [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 ` [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 ` [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 ` [RFC PATCH 28/34] zonefs: use bio_new Chaitanya Kulkarni
2021-01-28  7:25   ` Damien Le Moal
2021-01-28  7:11 ` [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 ` [RFC PATCH 30/34] hfsplus: use bio_new in hfsplus_submit_bio() Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 31/34] iomap: use bio_new in iomap_readpage_actor Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 32/34] mm: use bio_new in __swap_writepage Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 33/34] mm: use bio_new in swap_readpage Chaitanya Kulkarni
2021-01-28  7:11 ` [RFC PATCH 34/34] mm: add swap_bio_new common bio helper Chaitanya Kulkarni

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).