diff mbox series

[V3,1/9] block: add a helper function to read nr_setcs

Message ID 20190702174236.3332-2-chaitanya.kulkarni@wdc.com (mailing list archive)
State Superseded
Headers show
Series block: use right accessor to read nr_sects | expand

Commit Message

Chaitanya Kulkarni July 2, 2019, 5:42 p.m. UTC
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 | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Minwoo Im July 3, 2019, 12:19 a.m. UTC | #1
On 19-07-02 10:42:27, Chaitanya Kulkarni wrote:
> 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().

Without bd_mutex locked, this helper seems useful to have.

Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Bart Van Assche July 3, 2019, 3:03 p.m. UTC | #2
On 7/2/19 10:42 AM, Chaitanya Kulkarni wrote:
> +/* Helper function to read the bdev->bd_part->nr_sects */
> +static inline sector_t bdev_nr_sects(struct block_device *bdev)
> +{
> +	return part_nr_sects_read(bdev->bd_part);
> +}

Is the comment above bdev_nr_sects() really useful or should it be left out?

Thanks,

Bart.
diff mbox series

Patch

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 592669bcc536..be7ee5a0b0dd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1475,6 +1475,12 @@  static inline void put_dev_sector(Sector p)
 	put_page(p.v);
 }
 
+/* Helper function to read the bdev->bd_part->nr_sects */
+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);