Skip to content

Commit f187b9b

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: remove bio_add_zone_append_page
This is only used by the nvmet zns passthrough code, which can trivially just use bio_add_pc_page and do the sanity check for the max zone append limit itself. All future zoned file systems should follow the btrfs lead and let the upper layers fill up bios unlimited by hardware constraints and split them to the limits in the I/O submission handler. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent cafd00d commit f187b9b

File tree

3 files changed

+13
-43
lines changed

3 files changed

+13
-43
lines changed

block/bio.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,39 +1064,6 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio,
10641064
}
10651065
EXPORT_SYMBOL(bio_add_pc_page);
10661066

1067-
/**
1068-
* bio_add_zone_append_page - attempt to add page to zone-append bio
1069-
* @bio: destination bio
1070-
* @page: page to add
1071-
* @len: vec entry length
1072-
* @offset: vec entry offset
1073-
*
1074-
* Attempt to add a page to the bio_vec maplist of a bio that will be submitted
1075-
* for a zone-append request. This can fail for a number of reasons, such as the
1076-
* bio being full or the target block device is not a zoned block device or
1077-
* other limitations of the target block device. The target block device must
1078-
* allow bio's up to PAGE_SIZE, so it is always possible to add a single page
1079-
* to an empty bio.
1080-
*
1081-
* Returns: number of bytes added to the bio, or 0 in case of a failure.
1082-
*/
1083-
int bio_add_zone_append_page(struct bio *bio, struct page *page,
1084-
unsigned int len, unsigned int offset)
1085-
{
1086-
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
1087-
bool same_page = false;
1088-
1089-
if (WARN_ON_ONCE(bio_op(bio) != REQ_OP_ZONE_APPEND))
1090-
return 0;
1091-
1092-
if (WARN_ON_ONCE(!bdev_is_zoned(bio->bi_bdev)))
1093-
return 0;
1094-
1095-
return bio_add_hw_page(q, bio, page, len, offset,
1096-
queue_max_zone_append_sectors(q), &same_page);
1097-
}
1098-
EXPORT_SYMBOL_GPL(bio_add_zone_append_page);
1099-
11001067
/**
11011068
* __bio_add_page - add page(s) to a bio in a new segment
11021069
* @bio: destination bio

drivers/nvme/target/zns.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,21 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
537537
u16 status = NVME_SC_SUCCESS;
538538
unsigned int total_len = 0;
539539
struct scatterlist *sg;
540+
u32 data_len = nvmet_rw_data_len(req);
540541
struct bio *bio;
541542
int sg_cnt;
542543

543544
/* Request is completed on len mismatch in nvmet_check_transter_len() */
544545
if (!nvmet_check_transfer_len(req, nvmet_rw_data_len(req)))
545546
return;
546547

548+
if (data_len >
549+
bdev_max_zone_append_sectors(req->ns->bdev) << SECTOR_SHIFT) {
550+
req->error_loc = offsetof(struct nvme_rw_command, length);
551+
status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
552+
goto out;
553+
}
554+
547555
if (!req->sg_cnt) {
548556
nvmet_req_complete(req, 0);
549557
return;
@@ -576,20 +584,17 @@ void nvmet_bdev_execute_zone_append(struct nvmet_req *req)
576584
bio->bi_opf |= REQ_FUA;
577585

578586
for_each_sg(req->sg, sg, req->sg_cnt, sg_cnt) {
579-
struct page *p = sg_page(sg);
580-
unsigned int l = sg->length;
581-
unsigned int o = sg->offset;
582-
unsigned int ret;
587+
unsigned int len = sg->length;
583588

584-
ret = bio_add_zone_append_page(bio, p, l, o);
585-
if (ret != sg->length) {
589+
if (bio_add_pc_page(bdev_get_queue(bio->bi_bdev), bio,
590+
sg_page(sg), len, sg->offset) != len) {
586591
status = NVME_SC_INTERNAL;
587592
goto out_put_bio;
588593
}
589-
total_len += sg->length;
594+
total_len += len;
590595
}
591596

592-
if (total_len != nvmet_rw_data_len(req)) {
597+
if (total_len != data_len) {
593598
status = NVME_SC_INTERNAL | NVME_STATUS_DNR;
594599
goto out_put_bio;
595600
}

include/linux/bio.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,6 @@ bool __must_check bio_add_folio(struct bio *bio, struct folio *folio,
418418
size_t len, size_t off);
419419
extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
420420
unsigned int, unsigned int);
421-
int bio_add_zone_append_page(struct bio *bio, struct page *page,
422-
unsigned int len, unsigned int offset);
423421
void __bio_add_page(struct bio *bio, struct page *page,
424422
unsigned int len, unsigned int off);
425423
void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,

0 commit comments

Comments
 (0)