linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/9] block: use right accessor to read nr_sects
@ 2019-07-08 18:47 Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 1/9] block: add a helper function to read nr_setcs Chaitanya Kulkarni
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

Hi,

In the blk-zoned, bcache, f2fs, target-pscsi, xen and blktrace
implementation block device->hd_part->number of sectors field is
accessed directly without any appropriate locking or accessor function. 
There is an existing accessor function present in the in 
include/linux/genhd.h which should be used to read the
bdev->hd_part->nr_sects.

From ${KERN_DIR}/include/linux/genhd.h:-
<snip>
714 /*
715  * Any access of part->nr_sects which is not protected by partition
716  * bd_mutex or gendisk bdev bd_mutex, should be done using this
717  * accessor function.
718  *
719  * Code written along the lines of i_size_read() and i_size_write().
720  * CONFIG_PREEMPT case optimizes the case of UP kernel with preemption
721  * on.
722  */
723 static inline sector_t part_nr_sects_read(struct hd_struct *part)
724 {
<snip>

This patch series introduces a helper function on the top of the
part_nr_sects_read() and removes the all direct accesses to the
bdev->hd_part->nr_sects.

This series is based on :-

1. Repo :-
   git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git.
2. Branch :- for-next.

Please consider this for 5.3.

Changes from V3:-

1. Get rid of the comment in the 1st patch for helper. (Bart)

Chaitanya Kulkarni (9):
  block: add a helper function to read nr_setcs
  blk-zoned: update blkdev_nr_zones() with helper
  blk-zoned: update blkdev_report_zone() with helper
  blk-zoned: update blkdev_reset_zones() with helper
  bcache: update cached_dev_init() with helper
  f2fs: use helper in init_blkz_info()
  blktrace: use helper in blk_trace_setup_lba()
  target/pscsi: use helper in pscsi_get_blocks()
  xen/blkback: use helper in vbd_sz()

 block/blk-zoned.c                  | 12 ++++++------
 drivers/block/xen-blkback/common.h |  2 +-
 drivers/md/bcache/super.c          |  2 +-
 drivers/target/target_core_pscsi.c |  2 +-
 fs/f2fs/super.c                    |  2 +-
 include/linux/blkdev.h             |  5 +++++
 kernel/trace/blktrace.c            |  2 +-
 7 files changed, 16 insertions(+), 11 deletions(-)

-- 
2.17.0


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

* [PATCH V4 1/9] block: add a helper function to read nr_setcs
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-12  1:59   ` Martin K. Petersen
  2019-07-08 18:47 ` [PATCH V4 2/9] blk-zoned: update blkdev_nr_zones() with helper Chaitanya Kulkarni
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch introduces helper function to read the number of sectors
from struct block_device->bd_part member. For more details Please refer
to the comment in the include/linux/genhd.h for part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 include/linux/blkdev.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0c482371c8b3..578383712093 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1464,6 +1464,11 @@ static inline void put_dev_sector(Sector p)
 	put_page(p.v);
 }
 
+static inline sector_t bdev_nr_sects(struct block_device *bdev)
+{
+	return part_nr_sects_read(bdev->bd_part);
+}
+
 int kblockd_schedule_work(struct work_struct *work);
 int kblockd_schedule_work_on(int cpu, struct work_struct *work);
 int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
-- 
2.17.0


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

* [PATCH V4 2/9] blk-zoned: update blkdev_nr_zones() with helper
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 1/9] block: add a helper function to read nr_setcs Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 3/9] blk-zoned: update blkdev_report_zone() " Chaitanya Kulkarni
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the blkdev_nr_zones() with newly introduced helper
function to read the nr_sects from block device's hd_parts with the
help if part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 block/blk-zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index ae7e91bd0618..5051db35c3fd 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -90,7 +90,7 @@ unsigned int blkdev_nr_zones(struct block_device *bdev)
 	if (!blk_queue_is_zoned(q))
 		return 0;
 
-	return __blkdev_nr_zones(q, bdev->bd_part->nr_sects);
+	return __blkdev_nr_zones(q, bdev_nr_sects(bdev));
 }
 EXPORT_SYMBOL_GPL(blkdev_nr_zones);
 
-- 
2.17.0


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

* [PATCH V4 3/9] blk-zoned: update blkdev_report_zone() with helper
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 1/9] block: add a helper function to read nr_setcs Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 2/9] blk-zoned: update blkdev_nr_zones() with helper Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 4/9] blk-zoned: update blkdev_reset_zones() " Chaitanya Kulkarni
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the blkdev_report_zone(s)() with newly introduced
helper function to read the nr_sects from block device's hd_parts with
the help of part_nr_sects_read().

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

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 5051db35c3fd..9faf4488339d 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -106,7 +106,7 @@ static bool blkdev_report_zone(struct block_device *bdev, struct blk_zone *rep)
 		return false;
 
 	rep->start -= offset;
-	if (rep->start + rep->len > bdev->bd_part->nr_sects)
+	if (rep->start + rep->len > bdev_nr_sects(bdev))
 		return false;
 
 	if (rep->type == BLK_ZONE_TYPE_CONVENTIONAL)
@@ -176,13 +176,13 @@ int blkdev_report_zones(struct block_device *bdev, sector_t sector,
 	if (WARN_ON_ONCE(!bdev->bd_disk->fops->report_zones))
 		return -EOPNOTSUPP;
 
-	if (!*nr_zones || sector >= bdev->bd_part->nr_sects) {
+	if (!*nr_zones || sector >= bdev_nr_sects(bdev)) {
 		*nr_zones = 0;
 		return 0;
 	}
 
 	nrz = min(*nr_zones,
-		  __blkdev_nr_zones(q, bdev->bd_part->nr_sects - sector));
+		  __blkdev_nr_zones(q, bdev_nr_sects(bdev) - sector));
 	ret = blk_report_zones(bdev->bd_disk, get_start_sect(bdev) + sector,
 			       zones, &nrz, gfp_mask);
 	if (ret)
-- 
2.17.0


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

* [PATCH V4 4/9] blk-zoned: update blkdev_reset_zones() with helper
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2019-07-08 18:47 ` [PATCH V4 3/9] blk-zoned: update blkdev_report_zone() " Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 5/9] bcache: update cached_dev_init() " Chaitanya Kulkarni
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the blkdev_reset_zones() with newly introduced
helper function to read the nr_sects from block device's hd_parts with
the help of part_nr_sects_read().

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

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 9faf4488339d..e7f2874b5d37 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -229,7 +229,7 @@ int blkdev_reset_zones(struct block_device *bdev,
 	if (bdev_read_only(bdev))
 		return -EPERM;
 
-	if (!nr_sectors || end_sector > bdev->bd_part->nr_sects)
+	if (!nr_sectors || end_sector > bdev_nr_sects(bdev))
 		/* Out of range */
 		return -EINVAL;
 
@@ -239,7 +239,7 @@ int blkdev_reset_zones(struct block_device *bdev,
 		return -EINVAL;
 
 	if ((nr_sectors & (zone_sectors - 1)) &&
-	    end_sector != bdev->bd_part->nr_sects)
+	    end_sector != bdev_nr_sects(bdev))
 		return -EINVAL;
 
 	blk_start_plug(&plug);
-- 
2.17.0


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

* [PATCH V4 5/9] bcache: update cached_dev_init() with helper
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2019-07-08 18:47 ` [PATCH V4 4/9] blk-zoned: update blkdev_reset_zones() " Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 6/9] f2fs: use helper in init_blkz_info() Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

In the bcache when initializing the cached device we don't actually
use any sort of locking when reading the number of sectors from the
part. This patch updates the cached_dev_init() with newly introduced
helper function to read the nr_sects from block device's hd_parts with
the help of part_nr_sects_read().

Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/md/bcache/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 26e374fbf57c..024c52d11b0f 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1302,7 +1302,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
 			q->limits.raid_partial_stripes_expensive;
 
 	ret = bcache_device_init(&dc->disk, block_size,
-			 dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
+			 bdev_nr_sects(dc->bdev) - dc->sb.data_offset);
 	if (ret)
 		return ret;
 
-- 
2.17.0


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

* [PATCH V4 6/9] f2fs: use helper in init_blkz_info()
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
                   ` (4 preceding siblings ...)
  2019-07-08 18:47 ` [PATCH V4 5/9] bcache: update cached_dev_init() " Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 7/9] blktrace: use helper in blk_trace_setup_lba() Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the init_blkz_info() with newly introduced helper
function to read the nr_sects from block device's hd_parts with the
help of part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 fs/f2fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 6b959bbb336a..24e2848afcf5 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2798,7 +2798,7 @@ static int init_percpu_info(struct f2fs_sb_info *sbi)
 static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
 {
 	struct block_device *bdev = FDEV(devi).bdev;
-	sector_t nr_sectors = bdev->bd_part->nr_sects;
+	sector_t nr_sectors = bdev_nr_sects(bdev);
 	sector_t sector = 0;
 	struct blk_zone *zones;
 	unsigned int i, nr_zones;
-- 
2.17.0


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

* [PATCH V4 7/9] blktrace: use helper in blk_trace_setup_lba()
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
                   ` (5 preceding siblings ...)
  2019-07-08 18:47 ` [PATCH V4 6/9] f2fs: use helper in init_blkz_info() Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 8/9] target/pscsi: use helper in pscsi_get_blocks() Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 9/9] xen/blkback: use helper in vbd_sz() Chaitanya Kulkarni
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the blk_trace_setup_lba() with newly introduced
helper function to read the nr_sects from block device's hd_parts with
the help of part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 kernel/trace/blktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index e1c6d79fb4cc..35ff49503b85 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -461,7 +461,7 @@ static void blk_trace_setup_lba(struct blk_trace *bt,
 
 	if (part) {
 		bt->start_lba = part->start_sect;
-		bt->end_lba = part->start_sect + part->nr_sects;
+		bt->end_lba = part->start_sect + bdev_nr_sects(bdev);
 	} else {
 		bt->start_lba = 0;
 		bt->end_lba = -1ULL;
-- 
2.17.0


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

* [PATCH V4 8/9] target/pscsi: use helper in pscsi_get_blocks()
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
                   ` (6 preceding siblings ...)
  2019-07-08 18:47 ` [PATCH V4 7/9] blktrace: use helper in blk_trace_setup_lba() Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-08 18:47 ` [PATCH V4 9/9] xen/blkback: use helper in vbd_sz() Chaitanya Kulkarni
  8 siblings, 0 replies; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the pscsi_get_blocks() with newly introduced helper
function to read the nr_sects from block device's hd_parts with the
help of part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/target/target_core_pscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index c9d92b3e777d..da481edab2de 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1030,7 +1030,7 @@ static sector_t pscsi_get_blocks(struct se_device *dev)
 	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
 
 	if (pdv->pdv_bd && pdv->pdv_bd->bd_part)
-		return pdv->pdv_bd->bd_part->nr_sects;
+		return bdev_nr_sects(pdv->pdv_bd);
 
 	return 0;
 }
-- 
2.17.0


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

* [PATCH V4 9/9] xen/blkback: use helper in vbd_sz()
  2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
                   ` (7 preceding siblings ...)
  2019-07-08 18:47 ` [PATCH V4 8/9] target/pscsi: use helper in pscsi_get_blocks() Chaitanya Kulkarni
@ 2019-07-08 18:47 ` Chaitanya Kulkarni
  2019-07-15 10:36   ` Roger Pau Monné
  8 siblings, 1 reply; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-08 18:47 UTC (permalink / raw)
  To: linux-block
  Cc: colyli, linux-bcache, linux-btrace, xen-devel, kent.overstreet,
	yuchao0, jaegeuk, damien.lemoal, konrad.wilk, roger.pau,
	bvanassche, linux-scsi, Chaitanya Kulkarni

This patch updates the vbd_sz() macro with newly introduced helper
function to read the nr_sects from block device's hd_parts with the
help of part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/block/xen-blkback/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 1d3002d773f7..f96cb8d1cb99 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -359,7 +359,7 @@ struct pending_req {
 
 
 #define vbd_sz(_v)	((_v)->bdev->bd_part ? \
-			 (_v)->bdev->bd_part->nr_sects : \
+			  bdev_nr_sects((_v)->bdev) : \
 			  get_capacity((_v)->bdev->bd_disk))
 
 #define xen_blkif_get(_b) (atomic_inc(&(_b)->refcnt))
-- 
2.17.0


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

* Re: [PATCH V4 1/9] block: add a helper function to read nr_setcs
  2019-07-08 18:47 ` [PATCH V4 1/9] block: add a helper function to read nr_setcs Chaitanya Kulkarni
@ 2019-07-12  1:59   ` Martin K. Petersen
  2019-07-12 16:09     ` Chaitanya Kulkarni
  0 siblings, 1 reply; 14+ messages in thread
From: Martin K. Petersen @ 2019-07-12  1:59 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-block, colyli, linux-bcache, linux-btrace, xen-devel,
	kent.overstreet, yuchao0, jaegeuk, damien.lemoal, konrad.wilk,
	roger.pau, bvanassche, linux-scsi


Hi Chaitanya,

> +static inline sector_t bdev_nr_sects(struct block_device *bdev)
> +{
> +	return part_nr_sects_read(bdev->bd_part);
> +}

Can bdev end up being NULL in any of the call sites?

Otherwise no objections.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH V4 1/9] block: add a helper function to read nr_setcs
  2019-07-12  1:59   ` Martin K. Petersen
@ 2019-07-12 16:09     ` Chaitanya Kulkarni
  2019-07-17  2:28       ` Martin K. Petersen
  0 siblings, 1 reply; 14+ messages in thread
From: Chaitanya Kulkarni @ 2019-07-12 16:09 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: linux-block, colyli, linux-bcache, linux-btrace, xen-devel,
	kent.overstreet, yuchao0, jaegeuk, Damien Le Moal, konrad.wilk,
	roger.pau, bvanassche, linux-scsi

On 7/11/19 6:59 PM, Martin K. Petersen wrote:
> Hi Chaitanya,
>
>> +static inline sector_t bdev_nr_sects(struct block_device *bdev)
>> +{
>> +	return part_nr_sects_read(bdev->bd_part);
>> +}
> Can bdev end up being NULL in any of the call sites?
>
> Otherwise no objections.
>
Thanks for mentioning that. Initial version which was not posted had
that check.

This series just replaces the existing accesses without changing anything.

So if any of the exiting code has that bug then it will blow up nicely.

For future callers I don't mind adding a new check and resend the series.

Would you prefer adding a check  ?



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

* Re: [PATCH V4 9/9] xen/blkback: use helper in vbd_sz()
  2019-07-08 18:47 ` [PATCH V4 9/9] xen/blkback: use helper in vbd_sz() Chaitanya Kulkarni
@ 2019-07-15 10:36   ` Roger Pau Monné
  0 siblings, 0 replies; 14+ messages in thread
From: Roger Pau Monné @ 2019-07-15 10:36 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-block, colyli, linux-bcache, linux-btrace, xen-devel,
	kent.overstreet, yuchao0, jaegeuk, damien.lemoal, konrad.wilk,
	bvanassche, linux-scsi

On Mon, Jul 08, 2019 at 11:47:11AM -0700, Chaitanya Kulkarni wrote:
> This patch updates the vbd_sz() macro with newly introduced helper
> function to read the nr_sects from block device's hd_parts with the
> help of part_nr_sects_read().
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.

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

* Re: [PATCH V4 1/9] block: add a helper function to read nr_setcs
  2019-07-12 16:09     ` Chaitanya Kulkarni
@ 2019-07-17  2:28       ` Martin K. Petersen
  0 siblings, 0 replies; 14+ messages in thread
From: Martin K. Petersen @ 2019-07-17  2:28 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: Martin K. Petersen, linux-block, colyli, linux-bcache,
	linux-btrace, xen-devel, kent.overstreet, yuchao0, jaegeuk,
	Damien Le Moal, konrad.wilk, roger.pau, bvanassche, linux-scsi


Chaitanya,

> This series just replaces the existing accesses without changing
> anything.
>
> So if any of the exiting code has that bug then it will blow up
> nicely.
>
> For future callers I don't mind adding a new check and resend the
> series.
>
> Would you prefer adding a check ?

I checked your call sites and they look fine. Also, I don't think
returning a capacity of 0 on error is going to help us much.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2019-07-17  2:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 18:47 [PATCH V4 0/9] block: use right accessor to read nr_sects Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 1/9] block: add a helper function to read nr_setcs Chaitanya Kulkarni
2019-07-12  1:59   ` Martin K. Petersen
2019-07-12 16:09     ` Chaitanya Kulkarni
2019-07-17  2:28       ` Martin K. Petersen
2019-07-08 18:47 ` [PATCH V4 2/9] blk-zoned: update blkdev_nr_zones() with helper Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 3/9] blk-zoned: update blkdev_report_zone() " Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 4/9] blk-zoned: update blkdev_reset_zones() " Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 5/9] bcache: update cached_dev_init() " Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 6/9] f2fs: use helper in init_blkz_info() Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 7/9] blktrace: use helper in blk_trace_setup_lba() Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 8/9] target/pscsi: use helper in pscsi_get_blocks() Chaitanya Kulkarni
2019-07-08 18:47 ` [PATCH V4 9/9] xen/blkback: use helper in vbd_sz() Chaitanya Kulkarni
2019-07-15 10:36   ` Roger Pau Monné

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