Re: [PATCH v9 5/9] block: Make bio_iov_iter_get_pages() respect bio_required_sector_alignment()

From: kernel test robot
Date: Fri Jun 04 2021 - 18:54:04 EST


Hi Satya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on ext4/dev f2fs/dev-test linus/master v5.13-rc4 next-20210604]
[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/Satya-Tangirala/add-support-for-direct-I-O-with-fscrypt-using-blk-crypto/20210605-051023
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: um-x86_64_defconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/eea1225f680da16dce01bfb2914b9e8b78de298d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Satya-Tangirala/add-support-for-direct-I-O-with-fscrypt-using-blk-crypto/20210605-051023
git checkout eea1225f680da16dce01bfb2914b9e8b78de298d
# save the attached .config to linux build tree
make W=1 ARCH=um SUBARCH=x86_64

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

All errors (new ones prefixed by >>):

In file included from include/linux/kernel.h:14,
from include/asm-generic/bug.h:20,
from ./arch/um/include/generated/asm/bug.h:1,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from block/bio.c:5:
block/bio.c: In function 'bio_iov_iter_get_pages':
>> block/bio.c:1131:10: error: implicit declaration of function 'bio_required_sector_alignment' [-Werror=implicit-function-declaration]
1131 | bio_required_sector_alignment(bio));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/math.h:14:46: note: in definition of macro '__round_mask'
14 | #define __round_mask(x, y) ((__typeof__(x))((y)-1))
| ^
block/bio.c:1130:20: note: in expansion of macro 'round_down'
1130 | aligned_sectors = round_down(bio_sectors(bio),
| ^~~~~~~~~~
cc1: some warnings being treated as errors


vim +/bio_required_sector_alignment +1131 block/bio.c

1083
1084 /**
1085 * bio_iov_iter_get_pages - add user or kernel pages to a bio
1086 * @bio: bio to add pages to
1087 * @iter: iov iterator describing the region to be added
1088 *
1089 * This takes either an iterator pointing to user memory, or one pointing to
1090 * kernel pages (BVEC iterator). If we're adding user pages, we pin them and
1091 * map them into the kernel. On IO completion, the caller should put those
1092 * pages. For bvec based iterators bio_iov_iter_get_pages() uses the provided
1093 * bvecs rather than copying them. Hence anyone issuing kiocb based IO needs
1094 * to ensure the bvecs and pages stay referenced until the submitted I/O is
1095 * completed by a call to ->ki_complete() or returns with an error other than
1096 * -EIOCBQUEUED. The caller needs to check if the bio is flagged BIO_NO_PAGE_REF
1097 * on IO completion. If it isn't, then pages should be released.
1098 *
1099 * The function tries, but does not guarantee, to pin as many pages as
1100 * fit into the bio, or are requested in @iter, whatever is smaller. If
1101 * MM encounters an error pinning the requested pages, it stops. Error
1102 * is returned only if 0 pages could be pinned. It also ensures that the number
1103 * of sectors added to the bio is aligned to bio_required_sector_alignment().
1104 *
1105 * It's intended for direct IO, so doesn't do PSI tracking, the caller is
1106 * responsible for setting BIO_WORKINGSET if necessary.
1107 */
1108 int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
1109 {
1110 int ret = 0;
1111 unsigned int aligned_sectors;
1112
1113 if (iov_iter_is_bvec(iter)) {
1114 if (bio_op(bio) == REQ_OP_ZONE_APPEND)
1115 return bio_iov_bvec_set_append(bio, iter);
1116 return bio_iov_bvec_set(bio, iter);
1117 }
1118
1119 do {
1120 if (bio_op(bio) == REQ_OP_ZONE_APPEND)
1121 ret = __bio_iov_append_get_pages(bio, iter);
1122 else
1123 ret = __bio_iov_iter_get_pages(bio, iter);
1124 } while (!ret && iov_iter_count(iter) && !bio_full(bio, 0));
1125
1126 /*
1127 * Ensure that number of sectors in bio is aligned to
1128 * bio_required_sector_align()
1129 */
1130 aligned_sectors = round_down(bio_sectors(bio),
> 1131 bio_required_sector_alignment(bio));
1132 iov_iter_revert(iter, (bio_sectors(bio) - aligned_sectors) << SECTOR_SHIFT);
1133 bio_truncate(bio, aligned_sectors << SECTOR_SHIFT);
1134
1135 /* don't account direct I/O as memory stall */
1136 bio_clear_flag(bio, BIO_WORKINGSET);
1137 return bio->bi_vcnt ? 0 : ret;
1138 }
1139 EXPORT_SYMBOL_GPL(bio_iov_iter_get_pages);
1140

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

Attachment: .config.gz
Description: application/gzip