All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH 3/3] block: fops: handle IOCB_USE_PI in direct IO
Date: Fri, 29 Oct 2021 23:19:08 +0800	[thread overview]
Message-ID: <202110292330.BTXOXuLW-lkp@intel.com> (raw)

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

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211028112406.101314-4-a.buev@yadro.com>
References: <20211028112406.101314-4-a.buev@yadro.com>
TO: "Alexander V. Buev" <a.buev@yadro.com>
TO: linux-block(a)vger.kernel.org
CC: Jens Axboe <axboe@kernel.dk>
CC: Christoph Hellwig <hch@lst.de>
CC: "Martin K . Petersen" <martin.petersen@oracle.com>
CC: Mikhail Malygin <m.malygin@yadro.com>
CC: linux(a)yadro.com
CC: "Alexander V. Buev" <a.buev@yadro.com>

Hi "Alexander,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.15-rc7]
[cannot apply to axboe-block/for-next hch-configfs/for-next next-20211029]
[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/Alexander-V-Buev/implement-direct-IO-with-integrity/20211028-193652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 1fc596a56b334f4d593a2b49e5ff55af6aaa0816
:::::: branch date: 28 hours ago
:::::: commit date: 28 hours ago
config: i386-randconfig-c001-20211028 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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/48606c737ef4eeab1fd098ed57d9966dd73b97c3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alexander-V-Buev/implement-direct-IO-with-integrity/20211028-193652
        git checkout 48606c737ef4eeab1fd098ed57d9966dd73b97c3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
                                               ^
   include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
           return IS_ERR_VALUE((unsigned long)ptr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ntfs/dir.c:1222:6: note: Returning from 'IS_ERR'
           if (IS_ERR(bmp_vi)) {
               ^~~~~~~~~~~~~~
   fs/ntfs/dir.c:1222:2: note: Taking false branch
           if (IS_ERR(bmp_vi)) {
           ^
   fs/ntfs/dir.c:1230:15: note: Assuming the condition is false
           if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) {
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   fs/ntfs/dir.c:1230:2: note: Taking false branch
           if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) {
           ^
   fs/ntfs/dir.c:1239:2: note: Taking false branch
           ntfs_debug("Reading bitmap with page index 0x%llx, bit ofs 0x%llx",
           ^
   fs/ntfs/debug.h:39:2: note: expanded from macro 'ntfs_debug'
           if (0)                                                          \
           ^
   fs/ntfs/dir.c:1239:2: note: Loop condition is false.  Exiting loop
           ntfs_debug("Reading bitmap with page index 0x%llx, bit ofs 0x%llx",
           ^
   fs/ntfs/debug.h:37:35: note: expanded from macro 'ntfs_debug'
   #define ntfs_debug(fmt, ...)                                            \
                                                                           ^
   fs/ntfs/dir.c:1245:6: note: Calling 'IS_ERR'
           if (IS_ERR(bmp_page)) {
               ^~~~~~~~~~~~~~~~
   include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
           return IS_ERR_VALUE((unsigned long)ptr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ntfs/dir.c:1245:6: note: Returning from 'IS_ERR'
           if (IS_ERR(bmp_page)) {
               ^~~~~~~~~~~~~~~~
   fs/ntfs/dir.c:1245:2: note: Taking false branch
           if (IS_ERR(bmp_page)) {
           ^
   fs/ntfs/dir.c:1253:2: note: Loop condition is false. Execution continues on line 1272
           while (!(bmp[cur_bmp_pos >> 3] & (1 << (cur_bmp_pos & 7)))) {
           ^
   fs/ntfs/dir.c:1272:2: note: Taking false branch
           ntfs_debug("Handling index buffer 0x%llx.",
           ^
   fs/ntfs/debug.h:39:2: note: expanded from macro 'ntfs_debug'
           if (0)                                                          \
           ^
   fs/ntfs/dir.c:1272:2: note: Loop condition is false.  Exiting loop
           ntfs_debug("Handling index buffer 0x%llx.",
           ^
   fs/ntfs/debug.h:37:35: note: expanded from macro 'ntfs_debug'
   #define ntfs_debug(fmt, ...)                                            \
                                                                           ^
   fs/ntfs/dir.c:1275:6: note: Assuming the condition is false
           if ((prev_ia_pos & (s64)PAGE_MASK) !=
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ntfs/dir.c:1275:2: note: Taking false branch
           if ((prev_ia_pos & (s64)PAGE_MASK) !=
           ^
   fs/ntfs/dir.c:1297:2: note: Null pointer value stored to 'ia'
           ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_MASK &
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/ntfs/dir.c:1300:15: note: 'ia' is >= 'kaddr'
           if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_SIZE)) {
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   fs/ntfs/dir.c:1300:15: note: Left side of '||' is false
           if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_SIZE)) {
                        ^
   fs/ntfs/dir.c:1300:2: note: Taking false branch
           if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_SIZE)) {
           ^
   fs/ntfs/dir.c:1306:36: note: Access to field 'magic' results in a dereference of a null pointer (loaded from variable 'ia')
           if (unlikely(!ntfs_is_indx_record(ia->magic))) {
                                             ^
   fs/ntfs/layout.h:139:50: note: expanded from macro 'ntfs_is_indx_record'
   #define ntfs_is_indx_record(x)          ( ntfs_is_magic (x, INDX) )
                                                            ^
   fs/ntfs/layout.h:124:45: note: expanded from macro 'ntfs_is_magic'
   #define ntfs_is_magic(x, m)     __ntfs_is_magic(x, magic_##m)
                                                   ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
>> block/fops.c:294:24: warning: Access to field 'iov_base' results in a dereference of an undefined pointer value (loaded from variable 'pi_iov') [clang-analyzer-core.NullDereference]
                           _pi_iov.iov_base =  pi_iov->iov_base;
                                               ^~~~~~
   block/fops.c:200:16: note: 'pi_iov' declared without an initial value
           struct iovec *pi_iov, _pi_iov;
                         ^~~~~~
   block/fops.c:201:17: note: Assuming the condition is true
           bool is_poll = (iocb->ki_flags & IOCB_HIPRI) != 0;
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   block/fops.c:207:6: note: Assuming the condition is false
           if (iocb->ki_flags & IOCB_USE_PI) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   block/fops.c:207:2: note: Taking false branch
           if (iocb->ki_flags & IOCB_USE_PI) {
           ^
   block/fops.c:233:6: note: Assuming the condition is false
           if ((pos | iov_iter_alignment(iter)) &
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   block/fops.c:233:2: note: Taking false branch
           if ((pos | iov_iter_alignment(iter)) &
           ^
   block/fops.c:239:8: note: Left side of '&&' is false
           dio = container_of(bio, struct blkdev_dio, bio);
                 ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   block/fops.c:239:8: note: Taking false branch
           dio = container_of(bio, struct blkdev_dio, bio);
                 ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   block/fops.c:239:8: note: Loop condition is false.  Exiting loop
           dio = container_of(bio, struct blkdev_dio, bio);
                 ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   block/fops.c:241:11: note: Field 'is_sync' is false
           if (dio->is_sync) {
                    ^
   block/fops.c:241:2: note: Taking false branch
           if (dio->is_sync) {
           ^
   block/fops.c:250:22: note: 'is_read' is false
           dio->should_dirty = is_read && iter_is_iovec(iter);
                               ^~~~~~~
   block/fops.c:250:30: note: Left side of '&&' is false
           dio->should_dirty = is_read && iter_is_iovec(iter);
                                       ^
   block/fops.c:256:7: note: 'is_poll' is true
           if (!is_poll)
                ^~~~~~~
   block/fops.c:256:2: note: Taking false branch
           if (!is_poll)
           ^
   block/fops.c:259:2: note: Loop condition is true.  Entering loop body
           for (;;) {
           ^
   block/fops.c:260:3: note: Assuming 'bdev' is equal to field 'bi_bdev'
                   bio_set_dev(bio, bdev);
                   ^
   include/linux/bio.h:495:6: note: expanded from macro 'bio_set_dev'
           if ((bio)->bi_bdev != (bdev))                   \
               ^~~~~~~~~~~~~~~~~~~~~~~~
   block/fops.c:260:3: note: Taking false branch
                   bio_set_dev(bio, bdev);
                   ^
   include/linux/bio.h:495:2: note: expanded from macro 'bio_set_dev'
           if ((bio)->bi_bdev != (bdev))                   \
           ^
   block/fops.c:260:3: note: Loop condition is false.  Exiting loop
                   bio_set_dev(bio, bdev);
                   ^
   include/linux/bio.h:492:36: note: expanded from macro 'bio_set_dev'
   #define bio_set_dev(bio, bdev)                          \

vim +294 block/fops.c

cd82cca7ebfe9c Christoph Hellwig 2021-09-07  190  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  191  static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  192  		unsigned int nr_pages)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  193  {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  194  	struct file *file = iocb->ki_filp;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  195  	struct inode *inode = bdev_file_inode(file);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  196  	struct block_device *bdev = I_BDEV(inode);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  197  	struct blk_plug plug;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  198  	struct blkdev_dio *dio;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  199  	struct bio *bio;
48606c737ef4ee Alexander V. Buev 2021-10-28  200  	struct iovec *pi_iov, _pi_iov;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  201  	bool is_poll = (iocb->ki_flags & IOCB_HIPRI) != 0;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  202  	bool is_read = (iov_iter_rw(iter) == READ), is_sync;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  203  	loff_t pos = iocb->ki_pos;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  204  	blk_qc_t qc = BLK_QC_T_NONE;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  205  	int ret = 0;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  206  
48606c737ef4ee Alexander V. Buev 2021-10-28  207  	if (iocb->ki_flags & IOCB_USE_PI) {
48606c737ef4ee Alexander V. Buev 2021-10-28  208  		struct blk_integrity *bi = blk_get_integrity(bdev->bd_disk);
48606c737ef4ee Alexander V. Buev 2021-10-28  209  		unsigned int intervals;
48606c737ef4ee Alexander V. Buev 2021-10-28  210  
48606c737ef4ee Alexander V. Buev 2021-10-28  211  		/* Last iovec contains protection information. */
48606c737ef4ee Alexander V. Buev 2021-10-28  212  		if (!iter->nr_segs)
48606c737ef4ee Alexander V. Buev 2021-10-28  213  			return -EINVAL;
48606c737ef4ee Alexander V. Buev 2021-10-28  214  
48606c737ef4ee Alexander V. Buev 2021-10-28  215  		iter->nr_segs--;
48606c737ef4ee Alexander V. Buev 2021-10-28  216  		pi_iov = (struct iovec *)(iter->iov + iter->nr_segs);
48606c737ef4ee Alexander V. Buev 2021-10-28  217  
48606c737ef4ee Alexander V. Buev 2021-10-28  218  		/* TODO: seems iter is in charge of this check ? */
48606c737ef4ee Alexander V. Buev 2021-10-28  219  		if (pi_iov->iov_len > iter->count)
48606c737ef4ee Alexander V. Buev 2021-10-28  220  			return -EINVAL;
48606c737ef4ee Alexander V. Buev 2021-10-28  221  
48606c737ef4ee Alexander V. Buev 2021-10-28  222  		iter->count -= pi_iov->iov_len;
48606c737ef4ee Alexander V. Buev 2021-10-28  223  
48606c737ef4ee Alexander V. Buev 2021-10-28  224  		intervals = bio_integrity_intervals(bi, iter->count >> 9);
48606c737ef4ee Alexander V. Buev 2021-10-28  225  		if (unlikely(intervals * bi->tuple_size > pi_iov->iov_len)) {
48606c737ef4ee Alexander V. Buev 2021-10-28  226  			pr_err("Integrity & data size mismatch data=%lu integrity=%u intervals=%u tupple=%u",
48606c737ef4ee Alexander V. Buev 2021-10-28  227  				iter->count, (unsigned int)pi_iov->iov_len,
48606c737ef4ee Alexander V. Buev 2021-10-28  228  				intervals, bi->tuple_size);
48606c737ef4ee Alexander V. Buev 2021-10-28  229  				return -EINVAL;
48606c737ef4ee Alexander V. Buev 2021-10-28  230  		}
48606c737ef4ee Alexander V. Buev 2021-10-28  231  	}
48606c737ef4ee Alexander V. Buev 2021-10-28  232  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  233  	if ((pos | iov_iter_alignment(iter)) &
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  234  	    (bdev_logical_block_size(bdev) - 1))
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  235  		return -EINVAL;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  236  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  237  	bio = bio_alloc_kiocb(iocb, nr_pages, &blkdev_dio_pool);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  238  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  239  	dio = container_of(bio, struct blkdev_dio, bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  240  	dio->is_sync = is_sync = is_sync_kiocb(iocb);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  241  	if (dio->is_sync) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  242  		dio->waiter = current;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  243  		bio_get(bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  244  	} else {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  245  		dio->iocb = iocb;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  246  	}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  247  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  248  	dio->size = 0;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  249  	dio->multi_bio = false;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  250  	dio->should_dirty = is_read && iter_is_iovec(iter);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  251  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  252  	/*
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  253  	 * Don't plug for HIPRI/polled IO, as those should go straight
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  254  	 * to issue
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  255  	 */
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  256  	if (!is_poll)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  257  		blk_start_plug(&plug);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  258  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  259  	for (;;) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  260  		bio_set_dev(bio, bdev);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  261  		bio->bi_iter.bi_sector = pos >> 9;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  262  		bio->bi_write_hint = iocb->ki_hint;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  263  		bio->bi_private = dio;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  264  		bio->bi_end_io = blkdev_bio_end_io;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  265  		bio->bi_ioprio = iocb->ki_ioprio;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  266  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  267  		ret = bio_iov_iter_get_pages(bio, iter);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  268  		if (unlikely(ret)) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  269  			bio->bi_status = BLK_STS_IOERR;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  270  			bio_endio(bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  271  			break;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  272  		}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  273  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  274  		if (is_read) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  275  			bio->bi_opf = REQ_OP_READ;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  276  			if (dio->should_dirty)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  277  				bio_set_pages_dirty(bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  278  		} else {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  279  			bio->bi_opf = dio_bio_write_op(iocb);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  280  			task_io_account_write(bio->bi_iter.bi_size);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  281  		}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  282  		if (iocb->ki_flags & IOCB_NOWAIT)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  283  			bio->bi_opf |= REQ_NOWAIT;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  284  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  285  		dio->size += bio->bi_iter.bi_size;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  286  		pos += bio->bi_iter.bi_size;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  287  
48606c737ef4ee Alexander V. Buev 2021-10-28  288  		/* in case we can't add all data to one bio */
48606c737ef4ee Alexander V. Buev 2021-10-28  289  		/* we must split integrity too */
48606c737ef4ee Alexander V. Buev 2021-10-28  290  
48606c737ef4ee Alexander V. Buev 2021-10-28  291  		if (iocb->ki_flags & IOCB_USE_PI) {
48606c737ef4ee Alexander V. Buev 2021-10-28  292  			struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
48606c737ef4ee Alexander V. Buev 2021-10-28  293  
48606c737ef4ee Alexander V. Buev 2021-10-28 @294  			_pi_iov.iov_base =  pi_iov->iov_base;
48606c737ef4ee Alexander V. Buev 2021-10-28  295  			_pi_iov.iov_base += bio_integrity_bytes(bi, (dio->size-bio->bi_iter.bi_size) >> 9);
48606c737ef4ee Alexander V. Buev 2021-10-28  296  			_pi_iov.iov_len  = bio_integrity_bytes(bi, bio->bi_iter.bi_size >> 9);
48606c737ef4ee Alexander V. Buev 2021-10-28  297  		}
48606c737ef4ee Alexander V. Buev 2021-10-28  298  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  299  		nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  300  		if (!nr_pages) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  301  			bool polled = false;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  302  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  303  			if (iocb->ki_flags & IOCB_HIPRI) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  304  				bio_set_polled(bio, iocb);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  305  				polled = true;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  306  			}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  307  
48606c737ef4ee Alexander V. Buev 2021-10-28  308  			/* Add protection information to bio */
48606c737ef4ee Alexander V. Buev 2021-10-28  309  			if (iocb->ki_flags & IOCB_USE_PI) {
48606c737ef4ee Alexander V. Buev 2021-10-28  310  				ret = bio_integrity_add_pi_iovec(bio, &_pi_iov);
48606c737ef4ee Alexander V. Buev 2021-10-28  311  				if (ret) {
48606c737ef4ee Alexander V. Buev 2021-10-28  312  					bio->bi_status = BLK_STS_IOERR;
48606c737ef4ee Alexander V. Buev 2021-10-28  313  					bio_endio(bio);
48606c737ef4ee Alexander V. Buev 2021-10-28  314  					break;
48606c737ef4ee Alexander V. Buev 2021-10-28  315  				}
48606c737ef4ee Alexander V. Buev 2021-10-28  316  			}
48606c737ef4ee Alexander V. Buev 2021-10-28  317  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  318  			qc = submit_bio(bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  319  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  320  			if (polled)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  321  				WRITE_ONCE(iocb->ki_cookie, qc);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  322  			break;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  323  		}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  324  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  325  		if (!dio->multi_bio) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  326  			/*
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  327  			 * AIO needs an extra reference to ensure the dio
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  328  			 * structure which is embedded into the first bio
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  329  			 * stays around.
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  330  			 */
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  331  			if (!is_sync)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  332  				bio_get(bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  333  			dio->multi_bio = true;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  334  			atomic_set(&dio->ref, 2);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  335  		} else {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  336  			atomic_inc(&dio->ref);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  337  		}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  338  
48606c737ef4ee Alexander V. Buev 2021-10-28  339  
48606c737ef4ee Alexander V. Buev 2021-10-28  340  		if (iocb->ki_flags & IOCB_USE_PI) {
48606c737ef4ee Alexander V. Buev 2021-10-28  341  			ret = bio_integrity_add_pi_iovec(bio, &_pi_iov);
48606c737ef4ee Alexander V. Buev 2021-10-28  342  			if (ret) {
48606c737ef4ee Alexander V. Buev 2021-10-28  343  				bio->bi_status = BLK_STS_IOERR;
48606c737ef4ee Alexander V. Buev 2021-10-28  344  				bio_endio(bio);
48606c737ef4ee Alexander V. Buev 2021-10-28  345  				break;
48606c737ef4ee Alexander V. Buev 2021-10-28  346  			}
48606c737ef4ee Alexander V. Buev 2021-10-28  347  		}
48606c737ef4ee Alexander V. Buev 2021-10-28  348  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  349  		submit_bio(bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  350  		bio = bio_alloc(GFP_KERNEL, nr_pages);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  351  	}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  352  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  353  	if (!is_poll)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  354  		blk_finish_plug(&plug);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  355  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  356  	if (!is_sync)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  357  		return -EIOCBQUEUED;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  358  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  359  	for (;;) {
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  360  		set_current_state(TASK_UNINTERRUPTIBLE);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  361  		if (!READ_ONCE(dio->waiter))
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  362  			break;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  363  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  364  		if (!(iocb->ki_flags & IOCB_HIPRI) ||
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  365  		    !blk_poll(bdev_get_queue(bdev), qc, true))
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  366  			blk_io_schedule();
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  367  	}
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  368  	__set_current_state(TASK_RUNNING);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  369  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  370  	if (!ret)
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  371  		ret = blk_status_to_errno(dio->bio.bi_status);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  372  	if (likely(!ret))
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  373  		ret = dio->size;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  374  
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  375  	bio_put(&dio->bio);
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  376  	return ret;
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  377  }
cd82cca7ebfe9c Christoph Hellwig 2021-09-07  378  

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

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

             reply	other threads:[~2021-10-29 15:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 15:19 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-28 11:24 [PATCH 0/3] implement direct IO with integrity Alexander V. Buev
2021-10-28 11:24 ` [PATCH 3/3] block: fops: handle IOCB_USE_PI in direct IO Alexander V. Buev
2021-10-28 15:17   ` Christoph Hellwig
2021-10-29  9:04   ` kernel test robot
2021-10-29  9:04     ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202110292330.BTXOXuLW-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.