Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\bio.c Create Date:2022-07-28 16:55:53
Last Modify:2020-03-17 23:13:58 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:_copy_user_iov - copy user data to bio*@q: destination block queue*@map_data: pointer to the rq_map_data holding pages (if necessary)*@iter: iovec iterator*@gfp_mask: memory allocation flags* Prepares and returns a bio for indirect user io, bouncing data

Proto:struct bio *bio_copy_user_iov(struct request_queue *q, struct rq_map_data *map_data, struct iov_iter *iter, gfp_t gfp_mask)

Type:struct bio

Parameter:

TypeParameterName
struct request_queue *q
struct rq_map_data *map_data
struct iov_iter *iter
gfp_tgfp_mask
1281  i = 0
1283  len = count
1284  offset = If map_data Then offset_in_page(offset) Else 0
1286  bmd = bio_alloc_map_data(iter, gfp_mask)
1287  If Not bmd Then Return ERR_PTR( - ENOMEM)
1295  is_our_pages = If map_data Then 0 Else 1
1297  nr_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE)
1298  If nr_pages > BIO_MAX_PAGES Then nr_pages = BIO_MAX_PAGES
1301  ret = -ENOMEM
1302  bio = bio_kmalloc(gfp_mask, nr_pages)
1303  If Not bio Then Go to out_bmd
1306  ret = 0
1308  If map_data Then
1309  nr_pages = 1 << page_order
1310  i = offset / PAGE_SIZE
1312  When len cycle
1313  bytes = PAGE_SIZE
1315  bytes -= offset
1317  If bytes > len Then bytes = len
1320  If map_data Then
1321  If i == nr_entries * nr_pages Then
1322  ret = -ENOMEM
1323  Break
1326  page = pages[i / nr_pages]
1327  page += i % nr_pages
1329  i++
1330  Else
1332  If Not page Then
1333  ret = -ENOMEM
1334  Break
1338  If bio_add_pc_page(q, bio, page, bytes, offset) < bytes Then
1339  If Not map_data Then __free_page(page)
1341  Break
1344  len -= bytes
1345  offset = 0
1348  If ret Then Go to cleanup
1351  If map_data Then offset += residual I/O count
1357  If iov_iter_rw(iter) == WRITE && ( Not map_data || Not null_mapped ) || map_data && from_user Then
1359  ret = _copy_from_iter - copy all pages from iov_iter to bio*@bio: The &struct bio which describes the I/O as destination*@iter: iov_iter as source* Copy all pages from iov_iter to bio.* Returns 0 on success, or error on failure.
1360  If ret Then Go to cleanup
1362  Else
1363  If is_our_pages Then zero_fill_bio(bio)
1365  iov_iter_advance(iter, residual I/O count )
1368  bi_private = bmd
1369  If map_data && null_mapped Then bio_set_flag(bio, BIO_NULL_MAPPED)
1371  Return bio
1372  cleanup :
1373  If Not map_data Then bio_free_pages(bio)
1375  _put - release a reference to a bio*@bio: bio to release reference to* Description:* Put a reference to a &struct bio, either one you have gotten with* bio_alloc, bio_get or bio_clone_*. The last put of a bio will free it.
1376  out_bmd :
1377  kfree(bmd)
1378  Return ERR_PTR(ret)
Caller
NameDescribe
__blk_rq_map_user_iov