diff mbox series

[05/15] block: fix not to apply bip information in blk_rq_bio_prep()

Message ID 20230503101048epcms2p61d61df1431955d9517c9939999ee3478@epcms2p6 (mailing list archive)
State New, archived
Headers show
Series Change the integrity configuration method in block | expand

Commit Message

Jinyoung Choi May 3, 2023, 10:10 a.m. UTC
When a request is initialized through the bio, bio's integrity
information is not reflected in the request.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>

Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
---
 include/linux/blk-mq.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

kernel test robot May 3, 2023, 12:56 p.m. UTC | #1
Hi Jinyoung,

kernel test robot noticed the following build errors:

[auto build test ERROR on axboe-block/for-next]
[also build test ERROR on mkp-scsi/for-next jejb-scsi/for-next linus/master v6.3 next-20230428]
[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/Jinyoung-CHOI/block-blk-integiry-add-helper-functions-for-bio_integrity_add_page/20230503-183015
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20230503101048epcms2p61d61df1431955d9517c9939999ee3478%40epcms2p6
patch subject: [PATCH 05/15] block: fix not to apply bip information in blk_rq_bio_prep()
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20230503/202305032008.NxgqlW9X-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/584edc6ae9cb23e8a778ee73d711b9143038a047
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jinyoung-CHOI/block-blk-integiry-add-helper-functions-for-bio_integrity_add_page/20230503-183015
        git checkout 584edc6ae9cb23e8a778ee73d711b9143038a047
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=um SUBARCH=i386 olddefconfig
        make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash arch/um/drivers/ block/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305032008.NxgqlW9X-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from arch/um/drivers/ubd_kern.c:27:
   include/linux/blk-mq.h: In function 'blk_rq_bio_prep':
>> include/linux/blk-mq.h:972:19: error: 'struct request' has no member named 'nr_integrity_segments'
     972 |                 rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
         |                   ^~
>> include/linux/blk-mq.h:972:63: warning: dereferencing 'void *' pointer
     972 |                 rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
         |                                                               ^~
>> include/linux/blk-mq.h:972:63: error: request for member 'bip_vcnt' in something not a structure or union


vim +972 include/linux/blk-mq.h

   962	
   963	static inline void blk_rq_bio_prep(struct request *rq, struct bio *bio,
   964			unsigned int nr_segs)
   965	{
   966		rq->nr_phys_segments = nr_segs;
   967		rq->__data_len = bio->bi_iter.bi_size;
   968		rq->bio = rq->biotail = bio;
   969		rq->ioprio = bio_prio(bio);
   970	
   971		if (bio_integrity(bio)) {
 > 972			rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
   973			rq->cmd_flags |= REQ_INTEGRITY;
   974		}
   975	}
   976
Christoph Hellwig May 3, 2023, 3:57 p.m. UTC | #2
On Wed, May 03, 2023 at 07:10:48PM +0900, Jinyoung CHOI wrote:
> When a request is initialized through the bio, bio's integrity
> information is not reflected in the request.

Uuh.  This looks like a pretty grave bug unless I'm missing something.
Can you:

 - submit this as a fix for 6.3 and -stable?
 - maybe find what broke this and add a fixes tag?
kernel test robot May 3, 2023, 5:23 p.m. UTC | #3
Hi Jinyoung,

kernel test robot noticed the following build errors:

[auto build test ERROR on axboe-block/for-next]
[also build test ERROR on mkp-scsi/for-next jejb-scsi/for-next linus/master v6.3 next-20230428]
[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/Jinyoung-CHOI/block-blk-integiry-add-helper-functions-for-bio_integrity_add_page/20230503-183015
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20230503101048epcms2p61d61df1431955d9517c9939999ee3478%40epcms2p6
patch subject: [PATCH 05/15] block: fix not to apply bip information in blk_rq_bio_prep()
config: riscv-randconfig-r042-20230503 (https://download.01.org/0day-ci/archive/20230504/202305040157.ZWiorthB-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b1465cd49efcbc114a75220b153f5a055ce7911f)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/584edc6ae9cb23e8a778ee73d711b9143038a047
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jinyoung-CHOI/block-blk-integiry-add-helper-functions-for-bio_integrity_add_page/20230503-183015
        git checkout 584edc6ae9cb23e8a778ee73d711b9143038a047
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash block/ drivers/mtd/ubi/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305040157.ZWiorthB-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from block/bdev.c:15:
   In file included from include/linux/blk-integrity.h:5:
>> include/linux/blk-mq.h:972:7: error: no member named 'nr_integrity_segments' in 'struct request'
                   rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
                   ~~  ^
>> include/linux/blk-mq.h:972:49: error: member reference base type 'void' is not a structure or union
                   rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
                                               ~~~~~~~~~~~~~~~~~~^ ~~~~~~~~
   2 errors generated.


vim +972 include/linux/blk-mq.h

   962	
   963	static inline void blk_rq_bio_prep(struct request *rq, struct bio *bio,
   964			unsigned int nr_segs)
   965	{
   966		rq->nr_phys_segments = nr_segs;
   967		rq->__data_len = bio->bi_iter.bi_size;
   968		rq->bio = rq->biotail = bio;
   969		rq->ioprio = bio_prio(bio);
   970	
   971		if (bio_integrity(bio)) {
 > 972			rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
   973			rq->cmd_flags |= REQ_INTEGRITY;
   974		}
   975	}
   976
kernel test robot May 3, 2023, 7:06 p.m. UTC | #4
Hi Jinyoung,

kernel test robot noticed the following build warnings:

[auto build test WARNING on axboe-block/for-next]
[also build test WARNING on mkp-scsi/for-next jejb-scsi/for-next linus/master v6.3 next-20230428]
[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/Jinyoung-CHOI/block-blk-integiry-add-helper-functions-for-bio_integrity_add_page/20230503-183015
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20230503101048epcms2p61d61df1431955d9517c9939999ee3478%40epcms2p6
patch subject: [PATCH 05/15] block: fix not to apply bip information in blk_rq_bio_prep()
config: hexagon-randconfig-r045-20230503 (https://download.01.org/0day-ci/archive/20230504/202305040206.hTkXRgzQ-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b1465cd49efcbc114a75220b153f5a055ce7911f)
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/intel-lab-lkp/linux/commit/584edc6ae9cb23e8a778ee73d711b9143038a047
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jinyoung-CHOI/block-blk-integiry-add-helper-functions-for-bio_integrity_add_page/20230503-183015
        git checkout 584edc6ae9cb23e8a778ee73d711b9143038a047
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/md/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305040206.hTkXRgzQ-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/md/md-bitmap.c:19:
   In file included from include/linux/blkdev.h:9:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/md/md-bitmap.c:19:
   In file included from include/linux/blkdev.h:9:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/md/md-bitmap.c:19:
   In file included from include/linux/blkdev.h:9:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   In file included from drivers/md/md-bitmap.c:31:
   In file included from include/trace/events/block.h:8:
   In file included from include/linux/blktrace_api.h:5:
   include/linux/blk-mq.h:972:7: error: no member named 'nr_integrity_segments' in 'struct request'
                   rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
                   ~~  ^
   include/linux/blk-mq.h:972:49: error: member reference base type 'void' is not a structure or union
                   rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
                                               ~~~~~~~~~~~~~~~~~~^ ~~~~~~~~
>> drivers/md/md-bitmap.c:2564:34: warning: result of comparison of constant 4294967296 with expression of type 'unsigned long' is always false [-Wtautological-constant-out-of-range-compare]
           if (BITS_PER_LONG > 32 && csize >= (1ULL << (BITS_PER_BYTE *
                                     ~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~
   7 warnings and 2 errors generated.


vim +2564 drivers/md/md-bitmap.c

43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2549  
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2550  static ssize_t
fd01b88c75a718 drivers/md/bitmap.c    NeilBrown             2011-10-11  2551  chunksize_store(struct mddev *mddev, const char *buf, size_t len)
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2552  {
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2553  	/* Can only be changed when no bitmap is active */
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2554  	int rv;
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2555  	unsigned long csize;
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2556  	if (mddev->bitmap)
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2557  		return -EBUSY;
b29bebd66dbd49 drivers/md/bitmap.c    Jingoo Han            2013-06-01  2558  	rv = kstrtoul(buf, 10, &csize);
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2559  	if (rv)
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2560  		return rv;
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2561  	if (csize < 512 ||
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2562  	    !is_power_of_2(csize))
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2563  		return -EINVAL;
4555211190798b drivers/md/md-bitmap.c Florian-Ewald Mueller 2022-10-25 @2564  	if (BITS_PER_LONG > 32 && csize >= (1ULL << (BITS_PER_BYTE *
4555211190798b drivers/md/md-bitmap.c Florian-Ewald Mueller 2022-10-25  2565  		sizeof(((bitmap_super_t *)0)->chunksize))))
4555211190798b drivers/md/md-bitmap.c Florian-Ewald Mueller 2022-10-25  2566  		return -EOVERFLOW;
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2567  	mddev->bitmap_info.chunksize = csize;
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2568  	return len;
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2569  }
43a705076e51c5 drivers/md/bitmap.c    NeilBrown             2009-12-14  2570
Jinyoung Choi May 4, 2023, 6:10 a.m. UTC | #5
>> When a request is initialized through the bio, bio's integrity
>> information is not reflected in the request.
>
>Uuh.  This looks like a pretty grave bug unless I'm missing something.
>Can you:
>
> - submit this as a fix for 6.3 and -stable?
> - maybe find what broke this and add a fixes tag?

Thanks for your review.

OK, I will check it and proceed.

I didn't confirm that I turned off the config and compiled it.
I will check it and upload in the next patch. sorry.

Best Regards,
Jinyoung.
diff mbox series

Patch

diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 1dacb2c81fdd..cdb95e090919 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -961,6 +961,11 @@  static inline void blk_rq_bio_prep(struct request *rq, struct bio *bio,
 	rq->__data_len = bio->bi_iter.bi_size;
 	rq->bio = rq->biotail = bio;
 	rq->ioprio = bio_prio(bio);
+
+	if (bio_integrity(bio)) {
+		rq->nr_integrity_segments = bio_integrity(bio)->bip_vcnt;
+		rq->cmd_flags |= REQ_INTEGRITY;
+	}
 }
 
 void blk_mq_hctx_set_fq_lock_class(struct blk_mq_hw_ctx *hctx,