* [PATCH] block: remove more NULL checks after bdev_get_queue()
@ 2023-02-02 9:11 ` Juhyung Park
2023-02-02 9:33 ` Johannes Thumshirn
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Juhyung Park @ 2023-02-02 9:11 UTC (permalink / raw)
To: linux-block; +Cc: axboe, Juhyung Park
bdev_get_queue() never returns NULL. Several commits [1][2] have been made
before to remove such superfluous checks, but some still remained.
[1] commit ec9fd2a13d74 ("blk-lib: don't check bdev_get_queue() NULL check")
[2] commit fea127b36c93 ("block: remove superfluous check for request queue in bdev_is_zoned()")
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
---
block/blk-zoned.c | 4 ----
include/linux/blkdev.h | 7 +------
kernel/trace/blktrace.c | 6 +-----
3 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 614b575be899..40a3e59fb8e0 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -342,8 +342,6 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
return -EINVAL;
q = bdev_get_queue(bdev);
- if (!q)
- return -ENXIO;
if (!bdev_is_zoned(bdev))
return -ENOTTY;
@@ -400,8 +398,6 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
return -EINVAL;
q = bdev_get_queue(bdev);
- if (!q)
- return -ENXIO;
if (!bdev_is_zoned(bdev))
return -ENOTTY;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b9637d63e6f0..89dd9b02b45b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1276,12 +1276,7 @@ static inline bool bdev_nowait(struct block_device *bdev)
static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
{
- struct request_queue *q = bdev_get_queue(bdev);
-
- if (q)
- return blk_queue_zoned_model(q);
-
- return BLK_ZONED_NONE;
+ return blk_queue_zoned_model(bdev_get_queue(bdev));
}
static inline bool bdev_is_zoned(struct block_device *bdev)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 918a7d12df8f..e5e8963d6808 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -729,14 +729,10 @@ EXPORT_SYMBOL_GPL(blk_trace_startstop);
**/
int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
{
- struct request_queue *q;
+ struct request_queue *q = bdev_get_queue(bdev);
int ret, start = 0;
char b[BDEVNAME_SIZE];
- q = bdev_get_queue(bdev);
- if (!q)
- return -ENXIO;
-
mutex_lock(&q->debugfs_mutex);
switch (cmd) {
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] block: remove more NULL checks after bdev_get_queue()
2023-02-02 9:11 ` [PATCH] block: remove more NULL checks after bdev_get_queue() Juhyung Park
@ 2023-02-02 9:33 ` Johannes Thumshirn
2023-02-02 11:56 ` Pankaj Raghav
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2023-02-02 9:33 UTC (permalink / raw)
To: Juhyung Park, linux-block@vger.kernel.org; +Cc: axboe@kernel.dk
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: remove more NULL checks after bdev_get_queue()
2023-02-02 9:11 ` [PATCH] block: remove more NULL checks after bdev_get_queue() Juhyung Park
2023-02-02 9:33 ` Johannes Thumshirn
@ 2023-02-02 11:56 ` Pankaj Raghav
2023-02-02 17:42 ` Chaitanya Kulkarni
2023-02-03 0:04 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: Pankaj Raghav @ 2023-02-02 11:56 UTC (permalink / raw)
To: Juhyung Park; +Cc: linux-block, axboe, Pankaj Raghav
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
On Thu, Feb 02, 2023 at 06:11:51PM +0900, Juhyung Park wrote:
> bdev_get_queue() never returns NULL. Several commits [1][2] have been made
> before to remove such superfluous checks, but some still remained.
>
> [1] commit ec9fd2a13d74 ("blk-lib: don't check bdev_get_queue() NULL check")
> [2] commit fea127b36c93 ("block: remove superfluous check for request queue in bdev_is_zoned()")
>
> Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Looks good,
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: remove more NULL checks after bdev_get_queue()
2023-02-02 9:11 ` [PATCH] block: remove more NULL checks after bdev_get_queue() Juhyung Park
2023-02-02 9:33 ` Johannes Thumshirn
2023-02-02 11:56 ` Pankaj Raghav
@ 2023-02-02 17:42 ` Chaitanya Kulkarni
2023-02-03 0:04 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2023-02-02 17:42 UTC (permalink / raw)
To: Juhyung Park, linux-block@vger.kernel.org; +Cc: axboe@kernel.dk
On 2/2/23 01:11, Juhyung Park wrote:
> bdev_get_queue() never returns NULL. Several commits [1][2] have been made
> before to remove such superfluous checks, but some still remained.
>
> [1] commit ec9fd2a13d74 ("blk-lib: don't check bdev_get_queue() NULL check")
> [2] commit fea127b36c93 ("block: remove superfluous check for request queue in bdev_is_zoned()")
>
> Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: remove more NULL checks after bdev_get_queue()
2023-02-02 9:11 ` [PATCH] block: remove more NULL checks after bdev_get_queue() Juhyung Park
` (2 preceding siblings ...)
2023-02-02 17:42 ` Chaitanya Kulkarni
@ 2023-02-03 0:04 ` kernel test robot
2023-02-03 2:45 ` Juhyung Park
3 siblings, 1 reply; 6+ messages in thread
From: kernel test robot @ 2023-02-03 0:04 UTC (permalink / raw)
To: Juhyung Park, linux-block; +Cc: oe-kbuild-all, axboe, Juhyung Park
Hi Juhyung,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on axboe-block/for-next]
[also build test WARNING on linus/master v6.2-rc6 next-20230202]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Juhyung-Park/block-remove-more-NULL-checks-after-bdev_get_queue/20230202-171443
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link: https://lore.kernel.org/r/20230202091151.855784-1-qkrwngud825%40gmail.com
patch subject: [PATCH] block: remove more NULL checks after bdev_get_queue()
config: x86_64-rhel-8.3-func (https://download.01.org/0day-ci/archive/20230203/202302030733.TVNhMvP4-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/f62253701c6bf771227300ca8c572c778c2670bb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Juhyung-Park/block-remove-more-NULL-checks-after-bdev_get_queue/20230202-171443
git checkout f62253701c6bf771227300ca8c572c778c2670bb
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
block/blk-zoned.c: In function 'blkdev_report_zones_ioctl':
>> block/blk-zoned.c:337:31: warning: variable 'q' set but not used [-Wunused-but-set-variable]
337 | struct request_queue *q;
| ^
block/blk-zoned.c: In function 'blkdev_zone_mgmt_ioctl':
block/blk-zoned.c:392:31: warning: variable 'q' set but not used [-Wunused-but-set-variable]
392 | struct request_queue *q;
| ^
vim +/q +337 block/blk-zoned.c
d41003513e61dd Christoph Hellwig 2019-11-11 327
56c4bddb970658 Bart Van Assche 2018-03-08 328 /*
3ed05a987e0f63 Shaun Tancheff 2016-10-18 329 * BLKREPORTZONE ioctl processing.
3ed05a987e0f63 Shaun Tancheff 2016-10-18 330 * Called from blkdev_ioctl.
3ed05a987e0f63 Shaun Tancheff 2016-10-18 331 */
3ed05a987e0f63 Shaun Tancheff 2016-10-18 332 int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
3ed05a987e0f63 Shaun Tancheff 2016-10-18 333 unsigned int cmd, unsigned long arg)
3ed05a987e0f63 Shaun Tancheff 2016-10-18 334 {
3ed05a987e0f63 Shaun Tancheff 2016-10-18 335 void __user *argp = (void __user *)arg;
d41003513e61dd Christoph Hellwig 2019-11-11 336 struct zone_report_args args;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 @337 struct request_queue *q;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 338 struct blk_zone_report rep;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 339 int ret;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 340
3ed05a987e0f63 Shaun Tancheff 2016-10-18 341 if (!argp)
3ed05a987e0f63 Shaun Tancheff 2016-10-18 342 return -EINVAL;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 343
3ed05a987e0f63 Shaun Tancheff 2016-10-18 344 q = bdev_get_queue(bdev);
3ed05a987e0f63 Shaun Tancheff 2016-10-18 345
edd1dbc83b1de3 Christoph Hellwig 2022-07-06 346 if (!bdev_is_zoned(bdev))
3ed05a987e0f63 Shaun Tancheff 2016-10-18 347 return -ENOTTY;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 348
3ed05a987e0f63 Shaun Tancheff 2016-10-18 349 if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
3ed05a987e0f63 Shaun Tancheff 2016-10-18 350 return -EFAULT;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 351
3ed05a987e0f63 Shaun Tancheff 2016-10-18 352 if (!rep.nr_zones)
3ed05a987e0f63 Shaun Tancheff 2016-10-18 353 return -EINVAL;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 354
d41003513e61dd Christoph Hellwig 2019-11-11 355 args.zones = argp + sizeof(struct blk_zone_report);
d41003513e61dd Christoph Hellwig 2019-11-11 356 ret = blkdev_report_zones(bdev, rep.sector, rep.nr_zones,
d41003513e61dd Christoph Hellwig 2019-11-11 357 blkdev_copy_zone_to_user, &args);
d41003513e61dd Christoph Hellwig 2019-11-11 358 if (ret < 0)
3ed05a987e0f63 Shaun Tancheff 2016-10-18 359 return ret;
d41003513e61dd Christoph Hellwig 2019-11-11 360
d41003513e61dd Christoph Hellwig 2019-11-11 361 rep.nr_zones = ret;
82394db7383d33 Matias Bjørling 2020-06-29 362 rep.flags = BLK_ZONE_REP_CAPACITY;
d41003513e61dd Christoph Hellwig 2019-11-11 363 if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report)))
d41003513e61dd Christoph Hellwig 2019-11-11 364 return -EFAULT;
d41003513e61dd Christoph Hellwig 2019-11-11 365 return 0;
3ed05a987e0f63 Shaun Tancheff 2016-10-18 366 }
3ed05a987e0f63 Shaun Tancheff 2016-10-18 367
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: remove more NULL checks after bdev_get_queue()
2023-02-03 0:04 ` kernel test robot
@ 2023-02-03 2:45 ` Juhyung Park
0 siblings, 0 replies; 6+ messages in thread
From: Juhyung Park @ 2023-02-03 2:45 UTC (permalink / raw)
To: kernel test robot
Cc: linux-block, oe-kbuild-all, axboe, johannes.thumshirn, p.raghav,
kch
Welp, didn't have it build-tested with W=1 and it somehow didn't warn
me without it.
Just posted v2:
https://lore.kernel.org/all/20230203024029.48260-1-qkrwngud825@gmail.com/T/#u
Sorry for the inconvenience!
Thanks,
On Fri, Feb 3, 2023 at 9:05 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Juhyung,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on axboe-block/for-next]
> [also build test WARNING on linus/master v6.2-rc6 next-20230202]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Juhyung-Park/block-remove-more-NULL-checks-after-bdev_get_queue/20230202-171443
> base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
> patch link: https://lore.kernel.org/r/20230202091151.855784-1-qkrwngud825%40gmail.com
> patch subject: [PATCH] block: remove more NULL checks after bdev_get_queue()
> config: x86_64-rhel-8.3-func (https://download.01.org/0day-ci/archive/20230203/202302030733.TVNhMvP4-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
> reproduce (this is a W=1 build):
> # https://github.com/intel-lab-lkp/linux/commit/f62253701c6bf771227300ca8c572c778c2670bb
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Juhyung-Park/block-remove-more-NULL-checks-after-bdev_get_queue/20230202-171443
> git checkout f62253701c6bf771227300ca8c572c778c2670bb
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> make W=1 O=build_dir ARCH=x86_64 olddefconfig
> make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> block/blk-zoned.c: In function 'blkdev_report_zones_ioctl':
> >> block/blk-zoned.c:337:31: warning: variable 'q' set but not used [-Wunused-but-set-variable]
> 337 | struct request_queue *q;
> | ^
> block/blk-zoned.c: In function 'blkdev_zone_mgmt_ioctl':
> block/blk-zoned.c:392:31: warning: variable 'q' set but not used [-Wunused-but-set-variable]
> 392 | struct request_queue *q;
> | ^
>
>
> vim +/q +337 block/blk-zoned.c
>
> d41003513e61dd Christoph Hellwig 2019-11-11 327
> 56c4bddb970658 Bart Van Assche 2018-03-08 328 /*
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 329 * BLKREPORTZONE ioctl processing.
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 330 * Called from blkdev_ioctl.
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 331 */
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 332 int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 333 unsigned int cmd, unsigned long arg)
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 334 {
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 335 void __user *argp = (void __user *)arg;
> d41003513e61dd Christoph Hellwig 2019-11-11 336 struct zone_report_args args;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 @337 struct request_queue *q;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 338 struct blk_zone_report rep;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 339 int ret;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 340
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 341 if (!argp)
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 342 return -EINVAL;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 343
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 344 q = bdev_get_queue(bdev);
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 345
> edd1dbc83b1de3 Christoph Hellwig 2022-07-06 346 if (!bdev_is_zoned(bdev))
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 347 return -ENOTTY;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 348
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 349 if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 350 return -EFAULT;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 351
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 352 if (!rep.nr_zones)
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 353 return -EINVAL;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 354
> d41003513e61dd Christoph Hellwig 2019-11-11 355 args.zones = argp + sizeof(struct blk_zone_report);
> d41003513e61dd Christoph Hellwig 2019-11-11 356 ret = blkdev_report_zones(bdev, rep.sector, rep.nr_zones,
> d41003513e61dd Christoph Hellwig 2019-11-11 357 blkdev_copy_zone_to_user, &args);
> d41003513e61dd Christoph Hellwig 2019-11-11 358 if (ret < 0)
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 359 return ret;
> d41003513e61dd Christoph Hellwig 2019-11-11 360
> d41003513e61dd Christoph Hellwig 2019-11-11 361 rep.nr_zones = ret;
> 82394db7383d33 Matias Bjørling 2020-06-29 362 rep.flags = BLK_ZONE_REP_CAPACITY;
> d41003513e61dd Christoph Hellwig 2019-11-11 363 if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report)))
> d41003513e61dd Christoph Hellwig 2019-11-11 364 return -EFAULT;
> d41003513e61dd Christoph Hellwig 2019-11-11 365 return 0;
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 366 }
> 3ed05a987e0f63 Shaun Tancheff 2016-10-18 367
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-03 2:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20230202115655eucas1p173ffc747caa69a038e1e86357caf0cb5@eucas1p1.samsung.com>
2023-02-02 9:11 ` [PATCH] block: remove more NULL checks after bdev_get_queue() Juhyung Park
2023-02-02 9:33 ` Johannes Thumshirn
2023-02-02 11:56 ` Pankaj Raghav
2023-02-02 17:42 ` Chaitanya Kulkarni
2023-02-03 0:04 ` kernel test robot
2023-02-03 2:45 ` Juhyung Park
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).