All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-block@vger.kernel.org
Cc: colyli@suse.de, linux-bcache@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-btrace@vger.kernel.org,
	kent.overstreet@gmail.com, jaegeuk@kernel.org,
	damien.lemoal@wdc.com,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH 0/8] block: use right accessor to read nr_sects
Date: Thu, 13 Jun 2019 07:59:47 -0700	[thread overview]
Message-ID: <20190613145955.4813-1-chaitanya.kulkarni@wdc.com> (raw)

Hi,

In the current block layer implementation including drivers and fs
there are some places in the code where block device->hd_part->number
of sectors is accessed directly without any locking. There is an
existing accessor function present in the include/linux/genhd.h
which should be used to read the bdev->hd_part->nr_sects
with the help of appropriate locking.

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() with expected rcu locking and removes the direct
accesses to the bdev->hd_part->nr_sects.

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

Regards,
Chaitanya

Chaitanya Kulkarni (8):
  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
  target/pscsi: use helper in pscsi_get_blocks()
  f2fs: use helper in init_blkz_info()
  blktrace: use helper in blk_trace_setup_lba()

 block/blk-zoned.c                  | 12 ++++++------
 drivers/md/bcache/super.c          |  2 +-
 drivers/target/target_core_pscsi.c |  2 +-
 fs/f2fs/super.c                    |  2 +-
 include/linux/blkdev.h             | 12 ++++++++++++
 kernel/trace/blktrace.c            |  2 +-
 6 files changed, 22 insertions(+), 10 deletions(-)

-- 
2.19.1


WARNING: multiple messages have this Message-ID (diff)
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-block@vger.kernel.org
Cc: colyli@suse.de, linux-bcache@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-btrace@vger.kernel.org,
	kent.overstreet@gmail.com, jaegeuk@kernel.org,
	damien.lemoal@wdc.com,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH 0/8] block: use right accessor to read nr_sects
Date: Thu, 13 Jun 2019 14:59:47 +0000	[thread overview]
Message-ID: <20190613145955.4813-1-chaitanya.kulkarni@wdc.com> (raw)

Hi,

In the current block layer implementation including drivers and fs
there are some places in the code where block device->hd_part->number
of sectors is accessed directly without any locking. There is an
existing accessor function present in the include/linux/genhd.h
which should be used to read the bdev->hd_part->nr_sects
with the help of appropriate locking.

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() with expected rcu locking and removes the direct
accesses to the bdev->hd_part->nr_sects.

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

Regards,
Chaitanya

Chaitanya Kulkarni (8):
  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
  target/pscsi: use helper in pscsi_get_blocks()
  f2fs: use helper in init_blkz_info()
  blktrace: use helper in blk_trace_setup_lba()

 block/blk-zoned.c                  | 12 ++++++------
 drivers/md/bcache/super.c          |  2 +-
 drivers/target/target_core_pscsi.c |  2 +-
 fs/f2fs/super.c                    |  2 +-
 include/linux/blkdev.h             | 12 ++++++++++++
 kernel/trace/blktrace.c            |  2 +-
 6 files changed, 22 insertions(+), 10 deletions(-)

-- 
2.19.1

             reply	other threads:[~2019-06-13 15:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 14:59 Chaitanya Kulkarni [this message]
2019-06-13 14:59 ` [PATCH 0/8] block: use right accessor to read nr_sects Chaitanya Kulkarni
2019-06-13 14:59 ` [PATCH 1/8] block: add a helper function to read nr_setcs Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 15:31   ` Bart Van Assche
2019-06-13 15:31     ` Bart Van Assche
2019-06-13 16:07     ` Douglas Gilbert
2019-06-13 16:07       ` Douglas Gilbert
2019-06-13 16:28       ` James Bottomley
2019-06-13 16:28         ` James Bottomley
2019-06-13 19:26         ` Douglas Gilbert
2019-06-13 19:26           ` Douglas Gilbert
2019-06-13 20:29           ` James Bottomley
2019-06-13 20:29             ` James Bottomley
2019-06-13 16:07     ` Chaitanya Kulkarni
2019-06-13 14:59 ` [PATCH 2/8] blk-zoned: update blkdev_nr_zones() with helper Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 14:59 ` [PATCH 3/8] blk-zoned: update blkdev_report_zone() " Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 14:59 ` [PATCH 4/8] blk-zoned: update blkdev_reset_zones() " Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 14:59 ` [PATCH 5/8] bcache: update cached_dev_init() " Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 14:59 ` [COMPILE TESTED PATCH 6/8] target/pscsi: use helper in pscsi_get_blocks() Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 15:36   ` Bart Van Assche
2019-06-13 15:36     ` Bart Van Assche
2019-06-13 16:08     ` Chaitanya Kulkarni
2019-06-13 14:59 ` [COMPILE TESTED PATCH 7/8] f2fs: use helper in init_blkz_info() Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni
2019-06-13 14:59 ` [PATCH 8/8] blktrace: use helper in blk_trace_setup_lba() Chaitanya Kulkarni
2019-06-13 14:59   ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190613145955.4813-1-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=colyli@suse.de \
    --cc=damien.lemoal@wdc.com \
    --cc=jaegeuk@kernel.org \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrace@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.