Skip to content

Commit 35ebee7

Browse files
committed
Merge tag 'block-6.19-20251211' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux
Pull block fixes from Jens Axboe: - Always initialize DMA state, fixing a potentially nasty issue on the block side - btrfs zoned write fix with cached zone reports - Fix corruption issues in bcache with chained bio's, and further make it clear that the chained IO handler is simply a marker, it's not code meant to be executed - Kill old code dealing with synchronous IO polling in the block layer, that has been dead for a long time. Only async polling is supported these days - Fix a lockdep issue in tag_set management, moving it to RCU - Fix an issue with ublks bio_vec iteration - Don't unconditionally enforce blocking issue of ublk control commands, allow some of them with non-blocking issue as they do not block * tag 'block-6.19-20251211' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux: blk-mq-dma: always initialize dma state blk-mq: delete task running check in blk_hctx_poll() block: fix cached zone reports on devices with native zone append block: Use RCU in blk_mq_[un]quiesce_tagset() instead of set->tag_list_lock ublk: don't mutate struct bio_vec in iteration block: prohibit calls to bio_chain_endio bcache: fix improper use of bi_end_io ublk: allow non-blocking ctrl cmds in IO_URING_F_NONBLOCK issue
2 parents 14df4eb + a0750fa commit 35ebee7

File tree

6 files changed

+41
-31
lines changed

6 files changed

+41
-31
lines changed

block/bio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,13 @@ static struct bio *__bio_chain_endio(struct bio *bio)
321321
return parent;
322322
}
323323

324+
/*
325+
* This function should only be used as a flag and must never be called.
326+
* If execution reaches here, it indicates a serious programming error.
327+
*/
324328
static void bio_chain_endio(struct bio *bio)
325329
{
326-
bio_endio(__bio_chain_endio(bio));
330+
BUG();
327331
}
328332

329333
/**

block/blk-mq-dma.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ static bool blk_dma_map_iter_start(struct request *req, struct device *dma_dev,
199199
if (blk_can_dma_map_iova(req, dma_dev) &&
200200
dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
201201
return blk_rq_dma_map_iova(req, dma_dev, state, iter, &vec);
202+
memset(state, 0, sizeof(*state));
202203
return blk_dma_map_direct(req, dma_dev, iter, &vec);
203204
}
204205

block/blk-mq.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ void blk_mq_quiesce_tagset(struct blk_mq_tag_set *set)
336336
{
337337
struct request_queue *q;
338338

339-
mutex_lock(&set->tag_list_lock);
340-
list_for_each_entry(q, &set->tag_list, tag_set_list) {
339+
rcu_read_lock();
340+
list_for_each_entry_rcu(q, &set->tag_list, tag_set_list) {
341341
if (!blk_queue_skip_tagset_quiesce(q))
342342
blk_mq_quiesce_queue_nowait(q);
343343
}
344-
mutex_unlock(&set->tag_list_lock);
344+
rcu_read_unlock();
345345

346346
blk_mq_wait_quiesce_done(set);
347347
}
@@ -351,12 +351,12 @@ void blk_mq_unquiesce_tagset(struct blk_mq_tag_set *set)
351351
{
352352
struct request_queue *q;
353353

354-
mutex_lock(&set->tag_list_lock);
355-
list_for_each_entry(q, &set->tag_list, tag_set_list) {
354+
rcu_read_lock();
355+
list_for_each_entry_rcu(q, &set->tag_list, tag_set_list) {
356356
if (!blk_queue_skip_tagset_quiesce(q))
357357
blk_mq_unquiesce_queue(q);
358358
}
359-
mutex_unlock(&set->tag_list_lock);
359+
rcu_read_unlock();
360360
}
361361
EXPORT_SYMBOL_GPL(blk_mq_unquiesce_tagset);
362362

@@ -4311,15 +4311,14 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)
43114311
struct blk_mq_tag_set *set = q->tag_set;
43124312

43134313
mutex_lock(&set->tag_list_lock);
4314-
list_del(&q->tag_set_list);
4314+
list_del_rcu(&q->tag_set_list);
43154315
if (list_is_singular(&set->tag_list)) {
43164316
/* just transitioned to unshared */
43174317
set->flags &= ~BLK_MQ_F_TAG_QUEUE_SHARED;
43184318
/* update existing queue */
43194319
blk_mq_update_tag_set_shared(set, false);
43204320
}
43214321
mutex_unlock(&set->tag_list_lock);
4322-
INIT_LIST_HEAD(&q->tag_set_list);
43234322
}
43244323

43254324
static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
@@ -4338,7 +4337,7 @@ static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
43384337
}
43394338
if (set->flags & BLK_MQ_F_TAG_QUEUE_SHARED)
43404339
queue_set_hctx_shared(q, true);
4341-
list_add_tail(&q->tag_set_list, &set->tag_list);
4340+
list_add_tail_rcu(&q->tag_set_list, &set->tag_list);
43424341

43434342
mutex_unlock(&set->tag_list_lock);
43444343
}
@@ -5193,27 +5192,19 @@ EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);
51935192
static int blk_hctx_poll(struct request_queue *q, struct blk_mq_hw_ctx *hctx,
51945193
struct io_comp_batch *iob, unsigned int flags)
51955194
{
5196-
long state = get_current_state();
51975195
int ret;
51985196

51995197
do {
52005198
ret = q->mq_ops->poll(hctx, iob);
5201-
if (ret > 0) {
5202-
__set_current_state(TASK_RUNNING);
5199+
if (ret > 0)
52035200
return ret;
5204-
}
5205-
5206-
if (signal_pending_state(state, current))
5207-
__set_current_state(TASK_RUNNING);
5208-
if (task_is_running(current))
5201+
if (task_sigpending(current))
52095202
return 1;
5210-
52115203
if (ret < 0 || (flags & BLK_POLL_ONESHOT))
52125204
break;
52135205
cpu_relax();
52145206
} while (!need_resched());
52155207

5216-
__set_current_state(TASK_RUNNING);
52175208
return 0;
52185209
}
52195210

block/blk-zoned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ static int blk_revalidate_seq_zone(struct blk_zone *zone, unsigned int idx,
21002100
* we have a zone write plug for such zone if the device has a zone
21012101
* write plug hash table.
21022102
*/
2103-
if (!queue_emulates_zone_append(disk->queue) || !disk->zone_wplugs_hash)
2103+
if (!disk->zone_wplugs_hash)
21042104
return 0;
21052105

21062106
wp_offset = disk_zone_wplug_sync_wp_offset(disk, zone);

drivers/block/ublk_drv.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ static size_t ublk_copy_user_pages(const struct request *req,
926926
size_t done = 0;
927927

928928
rq_for_each_segment(bv, req, iter) {
929+
unsigned len;
929930
void *bv_buf;
930931
size_t copied;
931932

@@ -934,18 +935,17 @@ static size_t ublk_copy_user_pages(const struct request *req,
934935
continue;
935936
}
936937

937-
bv.bv_offset += offset;
938-
bv.bv_len -= offset;
939-
bv_buf = bvec_kmap_local(&bv);
938+
len = bv.bv_len - offset;
939+
bv_buf = kmap_local_page(bv.bv_page) + bv.bv_offset + offset;
940940
if (dir == ITER_DEST)
941-
copied = copy_to_iter(bv_buf, bv.bv_len, uiter);
941+
copied = copy_to_iter(bv_buf, len, uiter);
942942
else
943-
copied = copy_from_iter(bv_buf, bv.bv_len, uiter);
943+
copied = copy_from_iter(bv_buf, len, uiter);
944944

945945
kunmap_local(bv_buf);
946946

947947
done += copied;
948-
if (copied < bv.bv_len)
948+
if (copied < len)
949949
break;
950950

951951
offset = 0;
@@ -3673,6 +3673,19 @@ static int ublk_ctrl_uring_cmd_permission(struct ublk_device *ub,
36733673
return ret;
36743674
}
36753675

3676+
static bool ublk_ctrl_uring_cmd_may_sleep(u32 cmd_op)
3677+
{
3678+
switch (_IOC_NR(cmd_op)) {
3679+
case UBLK_CMD_GET_QUEUE_AFFINITY:
3680+
case UBLK_CMD_GET_DEV_INFO:
3681+
case UBLK_CMD_GET_DEV_INFO2:
3682+
case _IOC_NR(UBLK_U_CMD_GET_FEATURES):
3683+
return false;
3684+
default:
3685+
return true;
3686+
}
3687+
}
3688+
36763689
static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd,
36773690
unsigned int issue_flags)
36783691
{
@@ -3681,7 +3694,8 @@ static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd,
36813694
u32 cmd_op = cmd->cmd_op;
36823695
int ret = -EINVAL;
36833696

3684-
if (issue_flags & IO_URING_F_NONBLOCK)
3697+
if (ublk_ctrl_uring_cmd_may_sleep(cmd_op) &&
3698+
issue_flags & IO_URING_F_NONBLOCK)
36853699
return -EAGAIN;
36863700

36873701
ublk_ctrl_cmd_dump(cmd);

drivers/md/bcache/request.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ static void detached_dev_end_io(struct bio *bio)
11041104
}
11051105

11061106
kfree(ddip);
1107-
bio->bi_end_io(bio);
1107+
bio_endio(bio);
11081108
}
11091109

11101110
static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
@@ -1121,7 +1121,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
11211121
ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
11221122
if (!ddip) {
11231123
bio->bi_status = BLK_STS_RESOURCE;
1124-
bio->bi_end_io(bio);
1124+
bio_endio(bio);
11251125
return;
11261126
}
11271127

@@ -1136,7 +1136,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
11361136

11371137
if ((bio_op(bio) == REQ_OP_DISCARD) &&
11381138
!bdev_max_discard_sectors(dc->bdev))
1139-
bio->bi_end_io(bio);
1139+
detached_dev_end_io(bio);
11401140
else
11411141
submit_bio_noacct(bio);
11421142
}

0 commit comments

Comments
 (0)