tree:
git://git.infradead.org/users/hch/block.git bio_alloc-cleanup
head: 152c964c974a6e3bf0dd15a8d100c075087d5186
commit: 89f38ab8450d4776525013f6284bfb89c8041b1c [9/13] block: pass a block_device and opf
to blk_next_bio
config: nios2-randconfig-s031-20220112
(
https://download.01.org/0day-ci/archive/20220112/202201122158.lSVu9LM1-lk...)
compiler: nios2-linux-gcc (GCC) 11.2.0
reproduce:
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
git remote add hch-block
git://git.infradead.org/users/hch/block.git
git fetch --no-tags hch-block bio_alloc-cleanup
git checkout 89f38ab8450d4776525013f6284bfb89c8041b1c
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2
SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
block/blk-lib.c: In function '__blkdev_issue_discard':
> block/blk-lib.c:19:22: warning: variable 'op' set but not
used [-Wunused-but-set-variable]
19 | unsigned int op;
| ^~
vim +/op +19 block/blk-lib.c
f31e7e4022841c Dmitry Monakhov 2010-04-28 12
38f252553300ee Christoph Hellwig 2016-04-16 13 int __blkdev_issue_discard(struct
block_device *bdev, sector_t sector,
288dab8a35a0bd Christoph Hellwig 2016-06-09 14 sector_t nr_sects, gfp_t gfp_mask, int
flags,
469e3216e20a39 Mike Christie 2016-06-05 15 struct bio **biop)
f31e7e4022841c Dmitry Monakhov 2010-04-28 16 {
f31e7e4022841c Dmitry Monakhov 2010-04-28 17 struct request_queue *q =
bdev_get_queue(bdev);
38f252553300ee Christoph Hellwig 2016-04-16 18 struct bio *bio = *biop;
ef295ecf090d3e Christoph Hellwig 2016-10-28 @19 unsigned int op;
9b15d109a6b2c0 Coly Li 2020-07-17 20 sector_t bs_mask, part_offset = 0;
f31e7e4022841c Dmitry Monakhov 2010-04-28 21
f31e7e4022841c Dmitry Monakhov 2010-04-28 22 if (!q)
f31e7e4022841c Dmitry Monakhov 2010-04-28 23 return -ENXIO;
288dab8a35a0bd Christoph Hellwig 2016-06-09 24
a13553c7773750 Ilya Dryomov 2018-01-11 25 if (bdev_read_only(bdev))
a13553c7773750 Ilya Dryomov 2018-01-11 26 return -EPERM;
a13553c7773750 Ilya Dryomov 2018-01-11 27
288dab8a35a0bd Christoph Hellwig 2016-06-09 28 if (flags & BLKDEV_DISCARD_SECURE)
{
288dab8a35a0bd Christoph Hellwig 2016-06-09 29 if (!blk_queue_secure_erase(q))
f31e7e4022841c Dmitry Monakhov 2010-04-28 30 return -EOPNOTSUPP;
288dab8a35a0bd Christoph Hellwig 2016-06-09 31 op = REQ_OP_SECURE_ERASE;
288dab8a35a0bd Christoph Hellwig 2016-06-09 32 } else {
f31e7e4022841c Dmitry Monakhov 2010-04-28 33 if (!blk_queue_discard(q))
f31e7e4022841c Dmitry Monakhov 2010-04-28 34 return -EOPNOTSUPP;
288dab8a35a0bd Christoph Hellwig 2016-06-09 35 op = REQ_OP_DISCARD;
288dab8a35a0bd Christoph Hellwig 2016-06-09 36 }
f31e7e4022841c Dmitry Monakhov 2010-04-28 37
b35fd7422c2f8e Coly Li 2020-08-06 38 /* In case the discard granularity
isn't set by buggy device driver */
b35fd7422c2f8e Coly Li 2020-08-06 39 if
(WARN_ON_ONCE(!q->limits.discard_granularity)) {
b35fd7422c2f8e Coly Li 2020-08-06 40 char dev_name[BDEVNAME_SIZE];
b35fd7422c2f8e Coly Li 2020-08-06 41
b35fd7422c2f8e Coly Li 2020-08-06 42 bdevname(bdev, dev_name);
b35fd7422c2f8e Coly Li 2020-08-06 43 pr_err_ratelimited("%s: Error:
discard_granularity is 0.\n", dev_name);
b35fd7422c2f8e Coly Li 2020-08-06 44 return -EOPNOTSUPP;
b35fd7422c2f8e Coly Li 2020-08-06 45 }
b35fd7422c2f8e Coly Li 2020-08-06 46
28b2be203e5a09 Darrick J. Wong 2016-10-11 47 bs_mask =
(bdev_logical_block_size(bdev) >> 9) - 1;
28b2be203e5a09 Darrick J. Wong 2016-10-11 48 if ((sector | nr_sects) & bs_mask)
28b2be203e5a09 Darrick J. Wong 2016-10-11 49 return -EINVAL;
28b2be203e5a09 Darrick J. Wong 2016-10-11 50
ba5d73851e7184 Ming Lei 2018-10-29 51 if (!nr_sects)
ba5d73851e7184 Ming Lei 2018-10-29 52 return -EINVAL;
a22c4d7e34402c Ming Lin 2015-10-22 53
9b15d109a6b2c0 Coly Li 2020-07-17 54 /* In case the discard request is in a
partition */
fa01b1e9733fd5 Christoph Hellwig 2020-09-03 55 if (bdev_is_partition(bdev))
29ff57c61094e7 Christoph Hellwig 2020-11-24 56 part_offset = bdev->bd_start_sect;
9b15d109a6b2c0 Coly Li 2020-07-17 57
ba5d73851e7184 Ming Lei 2018-10-29 58 while (nr_sects) {
9b15d109a6b2c0 Coly Li 2020-07-17 59 sector_t granularity_aligned_lba,
req_sects;
9b15d109a6b2c0 Coly Li 2020-07-17 60 sector_t sector_mapped = sector +
part_offset;
9b15d109a6b2c0 Coly Li 2020-07-17 61
9b15d109a6b2c0 Coly Li 2020-07-17 62 granularity_aligned_lba =
round_up(sector_mapped,
9b15d109a6b2c0 Coly Li 2020-07-17 63 q->limits.discard_granularity
>> SECTOR_SHIFT);
9b15d109a6b2c0 Coly Li 2020-07-17 64
9b15d109a6b2c0 Coly Li 2020-07-17 65 /*
9b15d109a6b2c0 Coly Li 2020-07-17 66 * Check whether the discard bio
starts at a discard_granularity
9b15d109a6b2c0 Coly Li 2020-07-17 67 * aligned LBA,
9b15d109a6b2c0 Coly Li 2020-07-17 68 * - If no: set
(granularity_aligned_lba - sector_mapped) to
9b15d109a6b2c0 Coly Li 2020-07-17 69 * bi_size of the first split bio,
then the second bio will
9b15d109a6b2c0 Coly Li 2020-07-17 70 * start at a discard_granularity
aligned LBA on the device.
9b15d109a6b2c0 Coly Li 2020-07-17 71 * - If yes: use
bio_aligned_discard_max_sectors() as the max
9b15d109a6b2c0 Coly Li 2020-07-17 72 * possible bi_size of the first
split bio. Then when this bio
9b15d109a6b2c0 Coly Li 2020-07-17 73 * is split in device drive, the
split ones are very probably
9b15d109a6b2c0 Coly Li 2020-07-17 74 * to be aligned to
discard_granularity of the device's queue.
9b15d109a6b2c0 Coly Li 2020-07-17 75 */
9b15d109a6b2c0 Coly Li 2020-07-17 76 if (granularity_aligned_lba ==
sector_mapped)
9b15d109a6b2c0 Coly Li 2020-07-17 77 req_sects = min_t(sector_t,
nr_sects,
9b15d109a6b2c0 Coly Li 2020-07-17 78
bio_aligned_discard_max_sectors(q));
9b15d109a6b2c0 Coly Li 2020-07-17 79 else
9b15d109a6b2c0 Coly Li 2020-07-17 80 req_sects = min_t(sector_t,
nr_sects,
9b15d109a6b2c0 Coly Li 2020-07-17 81 granularity_aligned_lba -
sector_mapped);
c6e666345e1b79 Paolo Bonzini 2012-08-02 82
4800bf7bc8c725 Dave Chinner 2018-11-14 83 WARN_ON_ONCE((req_sects << 9)
> UINT_MAX);
4800bf7bc8c725 Dave Chinner 2018-11-14 84
89f38ab8450d47 Christoph Hellwig 2022-01-11 85 bio = blk_next_bio(bio, bdev, 0, 0,
gfp_mask);
4f024f3797c43c Kent Overstreet 2013-10-11 86 bio->bi_iter.bi_sector = sector;
4f024f3797c43c Kent Overstreet 2013-10-11 87 bio->bi_iter.bi_size = req_sects
<< 9;
ba5d73851e7184 Ming Lei 2018-10-29 88 sector += req_sects;
c6e666345e1b79 Paolo Bonzini 2012-08-02 89 nr_sects -= req_sects;
f31e7e4022841c Dmitry Monakhov 2010-04-28 90
c8123f8c9cb517 Jens Axboe 2014-02-12 91 /*
c8123f8c9cb517 Jens Axboe 2014-02-12 92 * We can loop for a long time in
here, if someone does
c8123f8c9cb517 Jens Axboe 2014-02-12 93 * full device discards (like mkfs).
Be nice and allow
c8123f8c9cb517 Jens Axboe 2014-02-12 94 * us to schedule out to avoid
softlocking if preempt
c8123f8c9cb517 Jens Axboe 2014-02-12 95 * is disabled.
c8123f8c9cb517 Jens Axboe 2014-02-12 96 */
c8123f8c9cb517 Jens Axboe 2014-02-12 97 cond_resched();
5dba3089ed03f8 Lukas Czerner 2011-05-06 98 }
38f252553300ee Christoph Hellwig 2016-04-16 99
38f252553300ee Christoph Hellwig 2016-04-16 100 *biop = bio;
38f252553300ee Christoph Hellwig 2016-04-16 101 return 0;
38f252553300ee Christoph Hellwig 2016-04-16 102 }
38f252553300ee Christoph Hellwig 2016-04-16 103 EXPORT_SYMBOL(__blkdev_issue_discard);
38f252553300ee Christoph Hellwig 2016-04-16 104
:::::: The code at line 19 was first introduced by commit
:::::: ef295ecf090d3e86e5b742fc6ab34f1122a43773 block: better op and flags encoding
:::::: TO: Christoph Hellwig <hch(a)lst.de>
:::::: CC: Jens Axboe <axboe(a)fb.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org