linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks
@ 2021-09-10  6:44 Xu Wang
  2021-09-10  9:33 ` Chaitanya Kulkarni
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Xu Wang @ 2021-09-10  6:44 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel

The request_queue pointer returned from bdev_get_queue() shall
never be NULL, so the NULL checks are unnecessary, just remove them.

Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
Changes since v2:
- Make the q variable assignment together with declaration.
---
 block/blk-zoned.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 1d0c76c18fc5..a406ead05ab7 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -346,17 +346,13 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 {
 	void __user *argp = (void __user *)arg;
 	struct zone_report_args args;
-	struct request_queue *q;
+	struct request_queue *q = dev_get_queue(bdev);
 	struct blk_zone_report rep;
 	int ret;
 
 	if (!argp)
 		return -EINVAL;
 
-	q = bdev_get_queue(bdev);
-	if (!q)
-		return -ENXIO;
-
 	if (!blk_queue_is_zoned(q))
 		return -ENOTTY;
 
@@ -403,7 +399,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 			   unsigned int cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
-	struct request_queue *q;
+	struct request_queue *q = bdev_get_queue(bdev);
 	struct blk_zone_range zrange;
 	enum req_opf op;
 	int ret;
@@ -411,10 +407,6 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!argp)
 		return -EINVAL;
 
-	q = bdev_get_queue(bdev);
-	if (!q)
-		return -ENXIO;
-
 	if (!blk_queue_is_zoned(q))
 		return -ENOTTY;
 
-- 
2.17.1


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

* Re: [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks
  2021-09-10  6:44 [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks Xu Wang
@ 2021-09-10  9:33 ` Chaitanya Kulkarni
  2021-09-10  9:45 ` kernel test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2021-09-10  9:33 UTC (permalink / raw)
  To: Xu Wang, axboe; +Cc: linux-block, linux-kernel

On 9/9/21 11:44 PM, Xu Wang wrote:
> External email: Use caution opening links or attachments
> 
> 
> The request_queue pointer returned from bdev_get_queue() shall
> never be NULL, so the NULL checks are unnecessary, just remove them.
> 
> Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> Changes since v2:
> - Make the q variable assignment together with declaration.
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>



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

* Re: [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks
  2021-09-10  6:44 [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks Xu Wang
  2021-09-10  9:33 ` Chaitanya Kulkarni
@ 2021-09-10  9:45 ` kernel test robot
  2021-09-10 11:45 ` kernel test robot
  2021-09-10 14:04 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-09-10  9:45 UTC (permalink / raw)
  To: Xu Wang, axboe; +Cc: kbuild-all, linux-block, linux-kernel

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

Hi Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on v5.14 next-20210910]
[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]

url:    https://github.com/0day-ci/linux/commits/Xu-Wang/blk-zoned-Remove-needless-request_queue-NULL-pointer-checks/20210910-144721
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: microblaze-randconfig-r023-20210910 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/bc1beb73948b721209a36db7693ed7a621037757
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xu-Wang/blk-zoned-Remove-needless-request_queue-NULL-pointer-checks/20210910-144721
        git checkout bc1beb73948b721209a36db7693ed7a621037757
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=microblaze 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   block/blk-zoned.c: In function 'blkdev_report_zones_ioctl':
>> block/blk-zoned.c:349:35: error: implicit declaration of function 'dev_get_queue'; did you mean 'bdev_get_queue'? [-Werror=implicit-function-declaration]
     349 |         struct request_queue *q = dev_get_queue(bdev);
         |                                   ^~~~~~~~~~~~~
         |                                   bdev_get_queue
>> block/blk-zoned.c:349:35: error: initialization of 'struct request_queue *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
   cc1: all warnings being treated as errors


vim +349 block/blk-zoned.c

   339	
   340	/*
   341	 * BLKREPORTZONE ioctl processing.
   342	 * Called from blkdev_ioctl.
   343	 */
   344	int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
   345				      unsigned int cmd, unsigned long arg)
   346	{
   347		void __user *argp = (void __user *)arg;
   348		struct zone_report_args args;
 > 349		struct request_queue *q = dev_get_queue(bdev);
   350		struct blk_zone_report rep;
   351		int ret;
   352	
   353		if (!argp)
   354			return -EINVAL;
   355	
   356		if (!blk_queue_is_zoned(q))
   357			return -ENOTTY;
   358	
   359		if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
   360			return -EFAULT;
   361	
   362		if (!rep.nr_zones)
   363			return -EINVAL;
   364	
   365		args.zones = argp + sizeof(struct blk_zone_report);
   366		ret = blkdev_report_zones(bdev, rep.sector, rep.nr_zones,
   367					  blkdev_copy_zone_to_user, &args);
   368		if (ret < 0)
   369			return ret;
   370	
   371		rep.nr_zones = ret;
   372		rep.flags = BLK_ZONE_REP_CAPACITY;
   373		if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report)))
   374			return -EFAULT;
   375		return 0;
   376	}
   377	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35188 bytes --]

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

* Re: [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks
  2021-09-10  6:44 [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks Xu Wang
  2021-09-10  9:33 ` Chaitanya Kulkarni
  2021-09-10  9:45 ` kernel test robot
@ 2021-09-10 11:45 ` kernel test robot
  2021-09-10 14:04 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-09-10 11:45 UTC (permalink / raw)
  To: Xu Wang, axboe; +Cc: llvm, kbuild-all, linux-block, linux-kernel

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

Hi Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on v5.14 next-20210910]
[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]

url:    https://github.com/0day-ci/linux/commits/Xu-Wang/blk-zoned-Remove-needless-request_queue-NULL-pointer-checks/20210910-144721
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: hexagon-randconfig-r045-20210910 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/bc1beb73948b721209a36db7693ed7a621037757
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xu-Wang/blk-zoned-Remove-needless-request_queue-NULL-pointer-checks/20210910-144721
        git checkout bc1beb73948b721209a36db7693ed7a621037757
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=hexagon 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> block/blk-zoned.c:349:28: error: implicit declaration of function 'dev_get_queue' [-Werror,-Wimplicit-function-declaration]
           struct request_queue *q = dev_get_queue(bdev);
                                     ^
   block/blk-zoned.c:349:28: note: did you mean 'bdev_get_queue'?
   include/linux/blkdev.h:897:37: note: 'bdev_get_queue' declared here
   static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
                                       ^
>> block/blk-zoned.c:349:24: error: incompatible integer to pointer conversion initializing 'struct request_queue *' with an expression of type 'int' [-Werror,-Wint-conversion]
           struct request_queue *q = dev_get_queue(bdev);
                                 ^   ~~~~~~~~~~~~~~~~~~~
   2 errors generated.


vim +/dev_get_queue +349 block/blk-zoned.c

   339	
   340	/*
   341	 * BLKREPORTZONE ioctl processing.
   342	 * Called from blkdev_ioctl.
   343	 */
   344	int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
   345				      unsigned int cmd, unsigned long arg)
   346	{
   347		void __user *argp = (void __user *)arg;
   348		struct zone_report_args args;
 > 349		struct request_queue *q = dev_get_queue(bdev);
   350		struct blk_zone_report rep;
   351		int ret;
   352	
   353		if (!argp)
   354			return -EINVAL;
   355	
   356		if (!blk_queue_is_zoned(q))
   357			return -ENOTTY;
   358	
   359		if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
   360			return -EFAULT;
   361	
   362		if (!rep.nr_zones)
   363			return -EINVAL;
   364	
   365		args.zones = argp + sizeof(struct blk_zone_report);
   366		ret = blkdev_report_zones(bdev, rep.sector, rep.nr_zones,
   367					  blkdev_copy_zone_to_user, &args);
   368		if (ret < 0)
   369			return ret;
   370	
   371		rep.nr_zones = ret;
   372		rep.flags = BLK_ZONE_REP_CAPACITY;
   373		if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report)))
   374			return -EFAULT;
   375		return 0;
   376	}
   377	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 26307 bytes --]

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

* Re: [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks
  2021-09-10  6:44 [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks Xu Wang
                   ` (2 preceding siblings ...)
  2021-09-10 11:45 ` kernel test robot
@ 2021-09-10 14:04 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-09-10 14:04 UTC (permalink / raw)
  To: Xu Wang, axboe; +Cc: llvm, kbuild-all, linux-block, linux-kernel

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

Hi Xu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on block/for-next]
[also build test WARNING on v5.14 next-20210910]
[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]

url:    https://github.com/0day-ci/linux/commits/Xu-Wang/blk-zoned-Remove-needless-request_queue-NULL-pointer-checks/20210910-144721
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: i386-randconfig-a006-20210910 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/bc1beb73948b721209a36db7693ed7a621037757
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xu-Wang/blk-zoned-Remove-needless-request_queue-NULL-pointer-checks/20210910-144721
        git checkout bc1beb73948b721209a36db7693ed7a621037757
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   block/blk-zoned.c:349:28: error: implicit declaration of function 'dev_get_queue' [-Werror,-Wimplicit-function-declaration]
           struct request_queue *q = dev_get_queue(bdev);
                                     ^
   block/blk-zoned.c:349:28: note: did you mean 'bdev_get_queue'?
   include/linux/blkdev.h:897:37: note: 'bdev_get_queue' declared here
   static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
                                       ^
>> block/blk-zoned.c:349:24: warning: incompatible integer to pointer conversion initializing 'struct request_queue *' with an expression of type 'int' [-Wint-conversion]
           struct request_queue *q = dev_get_queue(bdev);
                                 ^   ~~~~~~~~~~~~~~~~~~~
   1 warning and 1 error generated.


vim +349 block/blk-zoned.c

   339	
   340	/*
   341	 * BLKREPORTZONE ioctl processing.
   342	 * Called from blkdev_ioctl.
   343	 */
   344	int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
   345				      unsigned int cmd, unsigned long arg)
   346	{
   347		void __user *argp = (void __user *)arg;
   348		struct zone_report_args args;
 > 349		struct request_queue *q = dev_get_queue(bdev);
   350		struct blk_zone_report rep;
   351		int ret;
   352	
   353		if (!argp)
   354			return -EINVAL;
   355	
   356		if (!blk_queue_is_zoned(q))
   357			return -ENOTTY;
   358	
   359		if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
   360			return -EFAULT;
   361	
   362		if (!rep.nr_zones)
   363			return -EINVAL;
   364	
   365		args.zones = argp + sizeof(struct blk_zone_report);
   366		ret = blkdev_report_zones(bdev, rep.sector, rep.nr_zones,
   367					  blkdev_copy_zone_to_user, &args);
   368		if (ret < 0)
   369			return ret;
   370	
   371		rep.nr_zones = ret;
   372		rep.flags = BLK_ZONE_REP_CAPACITY;
   373		if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report)))
   374			return -EFAULT;
   375		return 0;
   376	}
   377	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40682 bytes --]

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

end of thread, other threads:[~2021-09-10 14:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  6:44 [PATCH v2] blk-zoned: Remove needless request_queue NULL pointer checks Xu Wang
2021-09-10  9:33 ` Chaitanya Kulkarni
2021-09-10  9:45 ` kernel test robot
2021-09-10 11:45 ` kernel test robot
2021-09-10 14:04 ` kernel test robot

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