tree:
https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git simple_copy
head: d6f32b90156624ae9dc06ef5873334a48e9b9806
commit: fcbd83ffa72af1eba12bcab1f34e0b956a563e02 [2/5] block: add simple copy support
config: x86_64-randconfig-a013-20210209 (attached as .config)
compiler: clang version 12.0.0 (
https://github.com/llvm/llvm-project
c9439ca36342fb6013187d0a69aef92736951476)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
#
https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?id...
git remote add chao-linux
https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git
git fetch --no-tags chao-linux simple_copy
git checkout fcbd83ffa72af1eba12bcab1f34e0b956a563e02
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
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:153:5: warning: no previous prototype for
function 'blk_copy_offload' [-Wmissing-prototypes]
int
blk_copy_offload(struct block_device *bdev, struct blk_copy_payload *payload,
^
block/blk-lib.c:153:1: note: declare 'static' if the function is not intended
to be used outside of this translation unit
int blk_copy_offload(struct block_device *bdev, struct blk_copy_payload *payload,
^
static
> block/blk-lib.c:180:5: warning: no previous prototype for
function 'blk_read_to_buf' [-Wmissing-prototypes]
int
blk_read_to_buf(struct block_device *bdev, struct blk_copy_payload *payload,
^
block/blk-lib.c:180:1: note: declare 'static' if the function is not intended
to be used outside of this translation unit
int blk_read_to_buf(struct block_device *bdev, struct blk_copy_payload *payload,
^
static
> block/blk-lib.c:235:5: warning: no previous prototype for
function 'blk_write_from_buf' [-Wmissing-prototypes]
int
blk_write_from_buf(struct block_device *bdev, void *buf, sector_t dest,
^
block/blk-lib.c:235:1: note: declare 'static' if the function is not intended
to be used outside of this translation unit
int blk_write_from_buf(struct block_device *bdev, void *buf, sector_t dest,
^
static
> block/blk-lib.c:258:5: warning: no previous prototype for
function 'blk_prepare_payload' [-Wmissing-prototypes]
int
blk_prepare_payload(struct block_device *bdev, int nr_srcs, struct range_entry *rlist,
^
block/blk-lib.c:258:1: note: declare 'static' if the function is not intended
to be used outside of this translation unit
int blk_prepare_payload(struct block_device *bdev, int nr_srcs, struct range_entry
*rlist,
^
static
4 warnings generated.
vim +/blk_copy_offload +153 block/blk-lib.c
152
153 int blk_copy_offload(struct block_device *bdev, struct
blk_copy_payload *payload,
154 sector_t dest, gfp_t gfp_mask)
155 {
156 struct bio *bio;
157 int ret, total_size;
158
159 bio = bio_alloc(gfp_mask, 1);
160 bio->bi_iter.bi_sector = dest;
161 bio->bi_opf = REQ_OP_COPY | REQ_NOMERGE;
162 bio_set_dev(bio, bdev);
163
164 total_size = struct_size(payload, range, payload->copy_range);
165 ret = bio_add_page(bio, virt_to_page(payload), total_size,
166 offset_in_page(payload));
167 if (ret != total_size) {
168 ret = -ENOMEM;
169 bio_put(bio);
170 goto err;
171 }
172
173 ret = submit_bio_wait(bio);
174 err:
175 bio_put(bio);
176 return ret;
177
178 }
179
180 int blk_read_to_buf(struct block_device *bdev, struct
blk_copy_payload *payload,
181 gfp_t gfp_mask, void **buf_p)
182 {
183 struct request_queue *q = bdev_get_queue(bdev);
184 struct bio *bio, *parent = NULL;
185 void *buf = NULL;
186 bool is_vmalloc;
187 int i, nr_srcs, copy_len, ret, cur_size, t_len = 0;
188
189 nr_srcs = payload->copy_range;
190 copy_len = payload->copy_size << SECTOR_SHIFT;
191
192 buf = kvmalloc(copy_len, gfp_mask);
193 if (!buf)
194 return -ENOMEM;
195 is_vmalloc = is_vmalloc_addr(buf);
196
197 for (i = 0; i < nr_srcs; i++) {
198 cur_size = payload->range[i].len << SECTOR_SHIFT;
199
200 bio = bio_map_kern(q, buf + t_len, cur_size, gfp_mask);
201 if (IS_ERR(bio)) {
202 ret = PTR_ERR(bio);
203 goto out;
204 }
205
206 bio->bi_iter.bi_sector = payload->range[i].src;
207 bio->bi_opf = REQ_OP_READ;
208 bio_set_dev(bio, bdev);
209 bio->bi_end_io = NULL;
210 bio->bi_private = NULL;
211
212 if (parent) {
213 bio_chain(parent, bio);
214 submit_bio(parent);
215 }
216
217 parent = bio;
218 t_len += cur_size;
219 }
220
221 ret = submit_bio_wait(bio);
222 bio_put(bio);
223 if (is_vmalloc)
224 invalidate_kernel_vmap_range(buf, copy_len);
225 if (ret)
226 goto out;
227
228 *buf_p = buf;
229 return 0;
230 out:
231 kvfree(buf);
232 return ret;
233 }
234
235 int blk_write_from_buf(struct block_device *bdev, void *buf,
sector_t dest,
236 int copy_len, gfp_t gfp_mask)
237 {
238 struct request_queue *q = bdev_get_queue(bdev);
239 struct bio *bio;
240 int ret;
241
242 bio = bio_map_kern(q, buf, copy_len, gfp_mask);
243 if (IS_ERR(bio)) {
244 ret = PTR_ERR(bio);
245 goto out;
246 }
247 bio_set_dev(bio, bdev);
248 bio->bi_opf = REQ_OP_WRITE;
249 bio->bi_iter.bi_sector = dest;
250
251 bio->bi_end_io = NULL;
252 ret = submit_bio_wait(bio);
253 bio_put(bio);
254 out:
255 return ret;
256 }
257
258 int blk_prepare_payload(struct block_device *bdev, int nr_srcs,
struct range_entry *rlist,
259 gfp_t gfp_mask, struct blk_copy_payload
**payload_p)
260 {
261
262 struct request_queue *q = bdev_get_queue(bdev);
263 struct blk_copy_payload *payload;
264 sector_t bs_mask;
265 sector_t src_sects, len = 0, total_len = 0;
266 int i, ret, total_size;
267
268 if (!q)
269 return -ENXIO;
270
271 if (!nr_srcs)
272 return -EINVAL;
273
274 if (bdev_read_only(bdev))
275 return -EPERM;
276
277 bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1;
278
279 total_size = struct_size(payload, range, nr_srcs);
280 payload = kmalloc(total_size, gfp_mask);
281 if (!payload)
282 return -ENOMEM;
283
284 for (i = 0; i < nr_srcs; i++) {
285 /* copy payload provided are in bytes */
286 src_sects = rlist[i].src;
287 if (src_sects & bs_mask) {
288 ret = -EINVAL;
289 goto err;
290 }
291 src_sects = src_sects >> SECTOR_SHIFT;
292
293 if (len & bs_mask) {
294 ret = -EINVAL;
295 goto err;
296 }
297
298 len = rlist[i].len >> SECTOR_SHIFT;
299
300 total_len += len;
301
302 WARN_ON_ONCE((src_sects << 9) > UINT_MAX);
303
304 payload->range[i].src = src_sects;
305 payload->range[i].len = len;
306 }
307
308 /* storing # of source ranges */
309 payload->copy_range = i;
310 /* storing copy len so far */
311 payload->copy_size = total_len;
312
313 *payload_p = payload;
314 return 0;
315 err:
316 kfree(payload);
317 return ret;
318 }
319
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org