All of lore.kernel.org
 help / color / mirror / Atom feed
* [isilence:rw-dmabuf-v5 7/16] block/blk-merge.c:388 bio_split_io_at() warn: missing unwind goto?
@ 2026-08-02 13:33 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-08-02 13:33 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 rw-dmabuf-v5
head:   830cd62ae8958351a9fcd6d663dea3430921f95b
commit: e26aefbcb383be7092dc76343ce745013e671334 [7/16] block: introduce dma map backed bio type
:::::: branch date: 22 hours ago
:::::: commit date: 22 hours ago
config: i386-randconfig-r072-20260802 (https://download.01.org/0day-ci/archive/20260802/202608022100.WFQa1Sj3-lkp@intel.com/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
smatch: v0.5.0-9187-g5189e3fb

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/202608022100.WFQa1Sj3-lkp@intel.com/

smatch warnings:
block/blk-merge.c:388 bio_split_io_at() warn: missing unwind goto?
block/blk-merge.c:388 bio_split_io_at() warn: missing unwind goto?
block/blk-merge.c:388 bio_split_io_at() warn: missing unwind goto?

vim +388 block/blk-merge.c

e26aefbcb383be Pavel Begunkov    2025-06-25  344  
dad7758459bc60 Bart Van Assche   2019-08-01  345  /**
fec2e705729dc9 Keith Busch       2025-08-27  346   * bio_split_io_at - check if and where to split a bio
dad7758459bc60 Bart Van Assche   2019-08-01  347   * @bio:  [in] bio to be split
c55ddd9082f757 Christoph Hellwig 2022-07-27  348   * @lim:  [in] queue limits to split based on
dad7758459bc60 Bart Van Assche   2019-08-01  349   * @segs: [out] number of segments in the bio with the first half of the sectors
a85b36375b05f7 Christoph Hellwig 2022-07-27  350   * @max_bytes: [in] maximum number of bytes per bio
fec2e705729dc9 Keith Busch       2025-08-27  351   * @len_align_mask: [in] length alignment mask for each vector
dad7758459bc60 Bart Van Assche   2019-08-01  352   *
b35243a447b9fe Christoph Hellwig 2024-08-26  353   * Find out if @bio needs to be split to fit the queue limits in @lim and a
b35243a447b9fe Christoph Hellwig 2024-08-26  354   * maximum size of @max_bytes.  Returns a negative error number if @bio can't be
b35243a447b9fe Christoph Hellwig 2024-08-26  355   * split, 0 if the bio doesn't have to be split, or a positive sector offset if
b35243a447b9fe Christoph Hellwig 2024-08-26  356   * @bio needs to be split.
dad7758459bc60 Bart Van Assche   2019-08-01  357   */
fec2e705729dc9 Keith Busch       2025-08-27  358  int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,
fec2e705729dc9 Keith Busch       2025-08-27  359  		unsigned *segs, unsigned max_bytes, unsigned len_align_mask)
54efd50bfd873e Kent Overstreet   2015-04-23  360  {
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  361  	struct bio_crypt_ctx *bc = bio_crypt_ctx(bio);
5014c311baa2b2 Jens Axboe        2015-09-02  362  	struct bio_vec bv, bvprv, *bvprvp = NULL;
2f6b2565d43cdb Keith Busch       2025-10-14  363  	unsigned nsegs = 0, bytes = 0, gaps = 0;
54efd50bfd873e Kent Overstreet   2015-04-23  364  	struct bvec_iter iter;
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  365  	unsigned start_align_mask = lim->dma_alignment;
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  366  
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  367  	if (bc) {
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  368  		start_align_mask |= (bc->bc_key->crypto_cfg.data_unit_size - 1);
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  369  		len_align_mask |= (bc->bc_key->crypto_cfg.data_unit_size - 1);
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  370  	}
54efd50bfd873e Kent Overstreet   2015-04-23  371  
e26aefbcb383be Pavel Begunkov    2025-06-25  372  	if (op_is_dmabuf(bio->bi_opf)) {
e26aefbcb383be Pavel Begunkov    2025-06-25  373  		int ret;
e26aefbcb383be Pavel Begunkov    2025-06-25  374  
e26aefbcb383be Pavel Begunkov    2025-06-25  375  		ret = bio_split_io_at_dmabuf(bio, lim, &nsegs, max_bytes,
e26aefbcb383be Pavel Begunkov    2025-06-25  376  					     len_align_mask, start_align_mask);
e26aefbcb383be Pavel Begunkov    2025-06-25  377  		if (ret < 0)
e26aefbcb383be Pavel Begunkov    2025-06-25  378  			return ret;
e26aefbcb383be Pavel Begunkov    2025-06-25  379  		if (!ret)
e26aefbcb383be Pavel Begunkov    2025-06-25  380  			goto out;
e26aefbcb383be Pavel Begunkov    2025-06-25  381  		bytes = ret;
e26aefbcb383be Pavel Begunkov    2025-06-25  382  		goto split;
e26aefbcb383be Pavel Begunkov    2025-06-25  383  	}
e26aefbcb383be Pavel Begunkov    2025-06-25  384  
dcebd755926b0f Ming Lei          2019-02-15  385  	bio_for_each_bvec(bv, bio, iter) {
66e5a11d2ed6d5 Christoph Hellwig 2026-01-09  386  		if (bv.bv_offset & start_align_mask ||
fec2e705729dc9 Keith Busch       2025-08-27  387  		    bv.bv_len & len_align_mask)
fec2e705729dc9 Keith Busch       2025-08-27 @388  			return -EINVAL;
fec2e705729dc9 Keith Busch       2025-08-27  389  
54efd50bfd873e Kent Overstreet   2015-04-23  390  		/*
54efd50bfd873e Kent Overstreet   2015-04-23  391  		 * If the queue doesn't support SG gaps and adding this
54efd50bfd873e Kent Overstreet   2015-04-23  392  		 * offset would create a gap, disallow it.
54efd50bfd873e Kent Overstreet   2015-04-23  393  		 */
2f6b2565d43cdb Keith Busch       2025-10-14  394  		if (bvprvp) {
2f6b2565d43cdb Keith Busch       2025-10-14  395  			if (bvec_gap_to_prev(lim, bvprvp, bv.bv_offset))
54efd50bfd873e Kent Overstreet   2015-04-23  396  				goto split;
2f6b2565d43cdb Keith Busch       2025-10-14  397  			gaps |= bvec_seg_gap(bvprvp, &bv);
2f6b2565d43cdb Keith Busch       2025-10-14  398  		}
54efd50bfd873e Kent Overstreet   2015-04-23  399  
c55ddd9082f757 Christoph Hellwig 2022-07-27  400  		if (nsegs < lim->max_segments &&
67927d22015060 Keith Busch       2022-06-10  401  		    bytes + bv.bv_len <= max_bytes &&
5c5028ee594ce5 Keith Busch       2025-10-20  402  		    bv.bv_offset + bv.bv_len <= lim->max_fast_segment_size) {
708b25b344fd9b Bart Van Assche   2019-08-01  403  			nsegs++;
67927d22015060 Keith Busch       2022-06-10  404  			bytes += bv.bv_len;
c55ddd9082f757 Christoph Hellwig 2022-07-27  405  		} else {
c55ddd9082f757 Christoph Hellwig 2022-07-27  406  			if (bvec_split_segs(lim, &bv, &nsegs, &bytes,
c55ddd9082f757 Christoph Hellwig 2022-07-27  407  					lim->max_segments, max_bytes))
e36f6204288088 Keith Busch       2016-01-12  408  				goto split;
e36f6204288088 Keith Busch       2016-01-12  409  		}
e36f6204288088 Keith Busch       2016-01-12  410  
54efd50bfd873e Kent Overstreet   2015-04-23  411  		bvprv = bv;
578270bfbd2803 Ming Lei          2015-11-24  412  		bvprvp = &bvprv;
54efd50bfd873e Kent Overstreet   2015-04-23  413  	}
54efd50bfd873e Kent Overstreet   2015-04-23  414  
e26aefbcb383be Pavel Begunkov    2025-06-25  415  out:
d627065d884699 Christoph Hellwig 2019-06-06  416  	*segs = nsegs;
2f6b2565d43cdb Keith Busch       2025-10-14  417  	bio->bi_bvec_gap_bit = ffs(gaps);
b35243a447b9fe Christoph Hellwig 2024-08-26  418  	return 0;
54efd50bfd873e Kent Overstreet   2015-04-23  419  split:
b35243a447b9fe Christoph Hellwig 2024-08-26  420  	if (bio->bi_opf & REQ_ATOMIC)
b35243a447b9fe Christoph Hellwig 2024-08-26  421  		return -EINVAL;
b35243a447b9fe Christoph Hellwig 2024-08-26  422  
9cea62b2cbabff Jens Axboe        2023-01-04  423  	/*
9cea62b2cbabff Jens Axboe        2023-01-04  424  	 * We can't sanely support splitting for a REQ_NOWAIT bio. End it
9cea62b2cbabff Jens Axboe        2023-01-04  425  	 * with EAGAIN if splitting is required and return an error pointer.
9cea62b2cbabff Jens Axboe        2023-01-04  426  	 */
b35243a447b9fe Christoph Hellwig 2024-08-26  427  	if (bio->bi_opf & REQ_NOWAIT)
b35243a447b9fe Christoph Hellwig 2024-08-26  428  		return -EAGAIN;
9cea62b2cbabff Jens Axboe        2023-01-04  429  
bdced438acd83a Ming Lei          2015-10-20  430  	*segs = nsegs;
cc29e1bf0d63f7 Jeffle Xu         2020-11-26  431  
67927d22015060 Keith Busch       2022-06-10  432  	/*
67927d22015060 Keith Busch       2022-06-10  433  	 * Individual bvecs might not be logical block aligned. Round down the
67927d22015060 Keith Busch       2022-06-10  434  	 * split size so that each bio is properly block size aligned, even if
67927d22015060 Keith Busch       2022-06-10  435  	 * we do not use the full hardware limits.
fec2e705729dc9 Keith Busch       2025-08-27  436  	 *
fec2e705729dc9 Keith Busch       2025-08-27  437  	 * It is possible to submit a bio that can't be split into a valid io:
fec2e705729dc9 Keith Busch       2025-08-27  438  	 * there may either be too many discontiguous vectors for the max
fec2e705729dc9 Keith Busch       2025-08-27  439  	 * segments limit, or contain virtual boundary gaps without having a
fec2e705729dc9 Keith Busch       2025-08-27  440  	 * valid block sized split. A zero byte result means one of those
fec2e705729dc9 Keith Busch       2025-08-27  441  	 * conditions occured.
67927d22015060 Keith Busch       2022-06-10  442  	 */
7ecd2cd4fae3e8 Christoph Hellwig 2024-11-04  443  	bytes = ALIGN_DOWN(bytes, bio_split_alignment(bio, lim));
fec2e705729dc9 Keith Busch       2025-08-27  444  	if (!bytes)
fec2e705729dc9 Keith Busch       2025-08-27  445  		return -EINVAL;
67927d22015060 Keith Busch       2022-06-10  446  
cc29e1bf0d63f7 Jeffle Xu         2020-11-26  447  	/*
cc29e1bf0d63f7 Jeffle Xu         2020-11-26  448  	 * Bio splitting may cause subtle trouble such as hang when doing sync
cc29e1bf0d63f7 Jeffle Xu         2020-11-26  449  	 * iopoll in direct IO routine. Given performance gain of iopoll for
cc29e1bf0d63f7 Jeffle Xu         2020-11-26  450  	 * big IO can be trival, disable iopoll when split needed.
cc29e1bf0d63f7 Jeffle Xu         2020-11-26  451  	 */
6ce913fe3eee14 Christoph Hellwig 2021-10-12  452  	bio_clear_polled(bio);
2f6b2565d43cdb Keith Busch       2025-10-14  453  	bio->bi_bvec_gap_bit = ffs(gaps);
b35243a447b9fe Christoph Hellwig 2024-08-26  454  	return bytes >> SECTOR_SHIFT;
54efd50bfd873e Kent Overstreet   2015-04-23  455  }
fec2e705729dc9 Keith Busch       2025-08-27  456  EXPORT_SYMBOL_GPL(bio_split_io_at);
54efd50bfd873e Kent Overstreet   2015-04-23  457  

:::::: The code at line 388 was first introduced by commit
:::::: fec2e705729dc93de5399d8b139e4746805c3d81 block: check for valid bio while splitting

:::::: TO: Keith Busch <kbusch@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-02 13:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 13:33 [isilence:rw-dmabuf-v5 7/16] block/blk-merge.c:388 bio_split_io_at() warn: missing unwind goto? kernel test robot

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.