All of lore.kernel.org
 help / color / mirror / Atom feed
* [isilence:iou/discard 13/13] block/ioctl.c:206 blkdev_cmd_queue_discard() error: we previously assumed 'bio' could be null (see line 199)
@ 2024-07-31 15:25 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2024-07-31 15:25 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Pavel Begunkov <asml.silence@gmail.com>

tree:   https://github.com/isilence/linux iou/discard
head:   444b80e47399c01839870b7d75c968fc0e438b29
commit: 444b80e47399c01839870b7d75c968fc0e438b29 [13/13] block: implement io_uring discard cmd
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-161-20240730 (https://download.01.org/0day-ci/archive/20240731/202407312305.YVmb427T-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202407312305.YVmb427T-lkp@intel.com/

smatch warnings:
block/ioctl.c:206 blkdev_cmd_queue_discard() error: we previously assumed 'bio' could be null (see line 199)

vim +/bio +206 block/ioctl.c

d30a2605be9d51 David Woodhouse 2008-08-11  175  
444b80e47399c0 Pavel Begunkov  2024-07-20  176  int blkdev_cmd_queue_discard(struct io_uring_cmd *cmd,
444b80e47399c0 Pavel Begunkov  2024-07-20  177  			     uint64_t start, uint64_t len, bool nowait,
444b80e47399c0 Pavel Begunkov  2024-07-20  178  			     void (*end_io)(struct bio *))
444b80e47399c0 Pavel Begunkov  2024-07-20  179  {
444b80e47399c0 Pavel Begunkov  2024-07-20  180  	struct file *file = cmd->file;
444b80e47399c0 Pavel Begunkov  2024-07-20  181  	struct block_device *bdev = I_BDEV(file->f_mapping->host);
444b80e47399c0 Pavel Begunkov  2024-07-20  182  	sector_t sector = start >> SECTOR_SHIFT;
444b80e47399c0 Pavel Begunkov  2024-07-20  183  	sector_t nr_sects = len >> SECTOR_SHIFT;
444b80e47399c0 Pavel Begunkov  2024-07-20  184  	struct bio *prev = NULL, *bio;
444b80e47399c0 Pavel Begunkov  2024-07-20  185  	int err;
444b80e47399c0 Pavel Begunkov  2024-07-20  186  
444b80e47399c0 Pavel Begunkov  2024-07-20  187  	err = blk_check_discard(bdev, file_to_blk_mode(file), start, len);
444b80e47399c0 Pavel Begunkov  2024-07-20  188  	if (err)
444b80e47399c0 Pavel Begunkov  2024-07-20  189  		return err;
444b80e47399c0 Pavel Begunkov  2024-07-20  190  
444b80e47399c0 Pavel Begunkov  2024-07-20  191  	err = filemap_invalidate_pages(bdev->bd_mapping, start,
444b80e47399c0 Pavel Begunkov  2024-07-20  192  					start + len - 1, nowait);
444b80e47399c0 Pavel Begunkov  2024-07-20  193  	if (err)
444b80e47399c0 Pavel Begunkov  2024-07-20  194  		return err;
444b80e47399c0 Pavel Begunkov  2024-07-20  195  
444b80e47399c0 Pavel Begunkov  2024-07-20  196  	while (1) {
444b80e47399c0 Pavel Begunkov  2024-07-20  197  		bio = blk_alloc_discard_bio(bdev, &sector, &nr_sects,
444b80e47399c0 Pavel Begunkov  2024-07-20  198  					    GFP_KERNEL);
444b80e47399c0 Pavel Begunkov  2024-07-20 @199  		if (!bio)
444b80e47399c0 Pavel Begunkov  2024-07-20  200  			break;
444b80e47399c0 Pavel Begunkov  2024-07-20  201  		if (nowait)
444b80e47399c0 Pavel Begunkov  2024-07-20  202  			bio->bi_opf |= REQ_NOWAIT;
444b80e47399c0 Pavel Begunkov  2024-07-20  203  		prev = bio_chain_and_submit(prev, bio);
444b80e47399c0 Pavel Begunkov  2024-07-20  204  	}
444b80e47399c0 Pavel Begunkov  2024-07-20  205  
444b80e47399c0 Pavel Begunkov  2024-07-20 @206  	bio->bi_private = cmd;
444b80e47399c0 Pavel Begunkov  2024-07-20  207  	bio->bi_end_io = end_io;
444b80e47399c0 Pavel Begunkov  2024-07-20  208  
444b80e47399c0 Pavel Begunkov  2024-07-20  209  	if (nr_sects) {
444b80e47399c0 Pavel Begunkov  2024-07-20  210  		bio->bi_status = BLK_STS_AGAIN;
444b80e47399c0 Pavel Begunkov  2024-07-20  211  		bio_put(bio);
444b80e47399c0 Pavel Begunkov  2024-07-20  212  		return -EIOCBQUEUED;
444b80e47399c0 Pavel Begunkov  2024-07-20  213  	}
444b80e47399c0 Pavel Begunkov  2024-07-20  214  	submit_bio(bio);
444b80e47399c0 Pavel Begunkov  2024-07-20  215  	return -EIOCBQUEUED;
444b80e47399c0 Pavel Begunkov  2024-07-20  216  }
444b80e47399c0 Pavel Begunkov  2024-07-20  217  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* [isilence:iou/discard 13/13] block/ioctl.c:206 blkdev_cmd_queue_discard() error: we previously assumed 'bio' could be null (see line 199)
@ 2024-07-31 16:05 Dan Carpenter
  2024-08-02 12:00 ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-07-31 16:05 UTC (permalink / raw)
  To: oe-kbuild, Pavel Begunkov; +Cc: lkp, oe-kbuild-all

tree:   https://github.com/isilence/linux iou/discard
head:   444b80e47399c01839870b7d75c968fc0e438b29
commit: 444b80e47399c01839870b7d75c968fc0e438b29 [13/13] block: implement io_uring discard cmd
config: x86_64-randconfig-161-20240730 (https://download.01.org/0day-ci/archive/20240731/202407312305.YVmb427T-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202407312305.YVmb427T-lkp@intel.com/

smatch warnings:
block/ioctl.c:206 blkdev_cmd_queue_discard() error: we previously assumed 'bio' could be null (see line 199)

vim +/bio +206 block/ioctl.c

444b80e47399c0 Pavel Begunkov  2024-07-20  176  int blkdev_cmd_queue_discard(struct io_uring_cmd *cmd,
444b80e47399c0 Pavel Begunkov  2024-07-20  177  			     uint64_t start, uint64_t len, bool nowait,
444b80e47399c0 Pavel Begunkov  2024-07-20  178  			     void (*end_io)(struct bio *))
444b80e47399c0 Pavel Begunkov  2024-07-20  179  {
444b80e47399c0 Pavel Begunkov  2024-07-20  180  	struct file *file = cmd->file;
444b80e47399c0 Pavel Begunkov  2024-07-20  181  	struct block_device *bdev = I_BDEV(file->f_mapping->host);
444b80e47399c0 Pavel Begunkov  2024-07-20  182  	sector_t sector = start >> SECTOR_SHIFT;
444b80e47399c0 Pavel Begunkov  2024-07-20  183  	sector_t nr_sects = len >> SECTOR_SHIFT;
444b80e47399c0 Pavel Begunkov  2024-07-20  184  	struct bio *prev = NULL, *bio;
444b80e47399c0 Pavel Begunkov  2024-07-20  185  	int err;
444b80e47399c0 Pavel Begunkov  2024-07-20  186  
444b80e47399c0 Pavel Begunkov  2024-07-20  187  	err = blk_check_discard(bdev, file_to_blk_mode(file), start, len);
444b80e47399c0 Pavel Begunkov  2024-07-20  188  	if (err)
444b80e47399c0 Pavel Begunkov  2024-07-20  189  		return err;
444b80e47399c0 Pavel Begunkov  2024-07-20  190  
444b80e47399c0 Pavel Begunkov  2024-07-20  191  	err = filemap_invalidate_pages(bdev->bd_mapping, start,
444b80e47399c0 Pavel Begunkov  2024-07-20  192  					start + len - 1, nowait);
444b80e47399c0 Pavel Begunkov  2024-07-20  193  	if (err)
444b80e47399c0 Pavel Begunkov  2024-07-20  194  		return err;
444b80e47399c0 Pavel Begunkov  2024-07-20  195  
444b80e47399c0 Pavel Begunkov  2024-07-20  196  	while (1) {
444b80e47399c0 Pavel Begunkov  2024-07-20  197  		bio = blk_alloc_discard_bio(bdev, &sector, &nr_sects,
444b80e47399c0 Pavel Begunkov  2024-07-20  198  					    GFP_KERNEL);
444b80e47399c0 Pavel Begunkov  2024-07-20 @199  		if (!bio)
444b80e47399c0 Pavel Begunkov  2024-07-20  200  			break;

If we hit this break

444b80e47399c0 Pavel Begunkov  2024-07-20  201  		if (nowait)
444b80e47399c0 Pavel Begunkov  2024-07-20  202  			bio->bi_opf |= REQ_NOWAIT;
444b80e47399c0 Pavel Begunkov  2024-07-20  203  		prev = bio_chain_and_submit(prev, bio);
444b80e47399c0 Pavel Begunkov  2024-07-20  204  	}
444b80e47399c0 Pavel Begunkov  2024-07-20  205  
444b80e47399c0 Pavel Begunkov  2024-07-20 @206  	bio->bi_private = cmd;
                                                        ^^^^^
We are dead

444b80e47399c0 Pavel Begunkov  2024-07-20  207  	bio->bi_end_io = end_io;
444b80e47399c0 Pavel Begunkov  2024-07-20  208  
444b80e47399c0 Pavel Begunkov  2024-07-20  209  	if (nr_sects) {
444b80e47399c0 Pavel Begunkov  2024-07-20  210  		bio->bi_status = BLK_STS_AGAIN;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


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

* Re: [isilence:iou/discard 13/13] block/ioctl.c:206 blkdev_cmd_queue_discard() error: we previously assumed 'bio' could be null (see line 199)
  2024-07-31 16:05 Dan Carpenter
@ 2024-08-02 12:00 ` Pavel Begunkov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2024-08-02 12:00 UTC (permalink / raw)
  To: Dan Carpenter, oe-kbuild; +Cc: lkp, oe-kbuild-all

On 7/31/24 17:05, Dan Carpenter wrote:
...
> 444b80e47399c0 Pavel Begunkov  2024-07-20  196  	while (1) {
> 444b80e47399c0 Pavel Begunkov  2024-07-20  197  		bio = blk_alloc_discard_bio(bdev, &sector, &nr_sects,
> 444b80e47399c0 Pavel Begunkov  2024-07-20  198  					    GFP_KERNEL);
> 444b80e47399c0 Pavel Begunkov  2024-07-20 @199  		if (!bio)
> 444b80e47399c0 Pavel Begunkov  2024-07-20  200  			break;
> 
> If we hit this break
> 
> 444b80e47399c0 Pavel Begunkov  2024-07-20  201  		if (nowait)
> 444b80e47399c0 Pavel Begunkov  2024-07-20  202  			bio->bi_opf |= REQ_NOWAIT;
> 444b80e47399c0 Pavel Begunkov  2024-07-20  203  		prev = bio_chain_and_submit(prev, bio);
> 444b80e47399c0 Pavel Begunkov  2024-07-20  204  	}
> 444b80e47399c0 Pavel Begunkov  2024-07-20  205
> 444b80e47399c0 Pavel Begunkov  2024-07-20 @206  	bio->bi_private = cmd;
>                                                          ^^^^^
> We are dead

Right, thanks for letting know


> 444b80e47399c0 Pavel Begunkov  2024-07-20  207  	bio->bi_end_io = end_io;
> 444b80e47399c0 Pavel Begunkov  2024-07-20  208
> 444b80e47399c0 Pavel Begunkov  2024-07-20  209  	if (nr_sects) {
> 444b80e47399c0 Pavel Begunkov  2024-07-20  210  		bio->bi_status = BLK_STS_AGAIN;

-- 
Pavel Begunkov

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

end of thread, other threads:[~2024-08-02 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 15:25 [isilence:iou/discard 13/13] block/ioctl.c:206 blkdev_cmd_queue_discard() error: we previously assumed 'bio' could be null (see line 199) kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2024-07-31 16:05 Dan Carpenter
2024-08-02 12:00 ` Pavel Begunkov

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.