Skip to content

Commit a86f106

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "Four small fixes. Three of them fix the same error in NVMe, in loop, fc, and rdma respectively. The last fix from Ming fixes a regression in this series, where our bvec gap logic was wrong and causes an oops on NVMe for certain conditions" * 'for-linus' of git://git.kernel.dk/linux-block: block: fix bio_will_gap() for first bvec with offset nvme-fc: Fix sqsize wrong assignment based on ctrl MQES capability nvme-rdma: Fix sqsize wrong assignment based on ctrl MQES capability nvme-loop: Fix sqsize wrong assignment based on ctrl MQES capability
2 parents 11c994d + 5a8d75a commit a86f106

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

drivers/nvme/host/fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ nvme_fc_configure_admin_queue(struct nvme_fc_ctrl *ctrl)
20232023
}
20242024

20252025
ctrl->ctrl.sqsize =
2026-
min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize);
2026+
min_t(int, NVME_CAP_MQES(ctrl->cap), ctrl->ctrl.sqsize);
20272027

20282028
error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap);
20292029
if (error)

drivers/nvme/host/rdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl)
16061606
}
16071607

16081608
ctrl->ctrl.sqsize =
1609-
min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize);
1609+
min_t(int, NVME_CAP_MQES(ctrl->cap), ctrl->ctrl.sqsize);
16101610

16111611
error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap);
16121612
if (error)

drivers/nvme/target/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl)
392392
}
393393

394394
ctrl->ctrl.sqsize =
395-
min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize);
395+
min_t(int, NVME_CAP_MQES(ctrl->cap), ctrl->ctrl.sqsize);
396396

397397
error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap);
398398
if (error)

include/linux/blkdev.h

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,12 +1672,36 @@ static inline bool bios_segs_mergeable(struct request_queue *q,
16721672
return true;
16731673
}
16741674

1675-
static inline bool bio_will_gap(struct request_queue *q, struct bio *prev,
1676-
struct bio *next)
1675+
static inline bool bio_will_gap(struct request_queue *q,
1676+
struct request *prev_rq,
1677+
struct bio *prev,
1678+
struct bio *next)
16771679
{
16781680
if (bio_has_data(prev) && queue_virt_boundary(q)) {
16791681
struct bio_vec pb, nb;
16801682

1683+
/*
1684+
* don't merge if the 1st bio starts with non-zero
1685+
* offset, otherwise it is quite difficult to respect
1686+
* sg gap limit. We work hard to merge a huge number of small
1687+
* single bios in case of mkfs.
1688+
*/
1689+
if (prev_rq)
1690+
bio_get_first_bvec(prev_rq->bio, &pb);
1691+
else
1692+
bio_get_first_bvec(prev, &pb);
1693+
if (pb.bv_offset)
1694+
return true;
1695+
1696+
/*
1697+
* We don't need to worry about the situation that the
1698+
* merged segment ends in unaligned virt boundary:
1699+
*
1700+
* - if 'pb' ends aligned, the merged segment ends aligned
1701+
* - if 'pb' ends unaligned, the next bio must include
1702+
* one single bvec of 'nb', otherwise the 'nb' can't
1703+
* merge with 'pb'
1704+
*/
16811705
bio_get_last_bvec(prev, &pb);
16821706
bio_get_first_bvec(next, &nb);
16831707

@@ -1690,12 +1714,12 @@ static inline bool bio_will_gap(struct request_queue *q, struct bio *prev,
16901714

16911715
static inline bool req_gap_back_merge(struct request *req, struct bio *bio)
16921716
{
1693-
return bio_will_gap(req->q, req->biotail, bio);
1717+
return bio_will_gap(req->q, req, req->biotail, bio);
16941718
}
16951719

16961720
static inline bool req_gap_front_merge(struct request *req, struct bio *bio)
16971721
{
1698-
return bio_will_gap(req->q, bio, req->bio);
1722+
return bio_will_gap(req->q, NULL, bio, req->bio);
16991723
}
17001724

17011725
int kblockd_schedule_work(struct work_struct *work);

0 commit comments

Comments
 (0)