Skip to content

Commit da0af3c

Browse files
committed
Merge tag 'block-6.3-2023-04-06' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - Ensure that ublk always reads the whole sqe upfront (me) - Fix for a block size probing issue with ublk (Ming) - Fix for the bio based polling (Keith) - NVMe pull request via Christoph: - fix discard support without oncs (Keith Busch) - Partition scan error handling regression fix (Yu) * tag 'block-6.3-2023-04-06' of git://git.kernel.dk/linux: block: don't set GD_NEED_PART_SCAN if scan partition failed block: ublk: make sure that block size is set correctly ublk: read any SQE values upfront nvme: fix discard support without oncs blk-mq: directly poll requests
2 parents d3f05a4 + 3723091 commit da0af3c

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

block/blk-mq.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,16 +1359,14 @@ bool blk_rq_is_poll(struct request *rq)
13591359
return false;
13601360
if (rq->mq_hctx->type != HCTX_TYPE_POLL)
13611361
return false;
1362-
if (WARN_ON_ONCE(!rq->bio))
1363-
return false;
13641362
return true;
13651363
}
13661364
EXPORT_SYMBOL_GPL(blk_rq_is_poll);
13671365

13681366
static void blk_rq_poll_completion(struct request *rq, struct completion *wait)
13691367
{
13701368
do {
1371-
bio_poll(rq->bio, NULL, 0);
1369+
blk_mq_poll(rq->q, blk_rq_to_qc(rq), NULL, 0);
13721370
cond_resched();
13731371
} while (!completion_done(wait));
13741372
}

block/genhd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
368368
if (disk->open_partitions)
369369
return -EBUSY;
370370

371-
set_bit(GD_NEED_PART_SCAN, &disk->state);
372371
/*
373372
* If the device is opened exclusively by current thread already, it's
374373
* safe to scan partitons, otherwise, use bd_prepare_to_claim() to
@@ -381,12 +380,19 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
381380
return ret;
382381
}
383382

383+
set_bit(GD_NEED_PART_SCAN, &disk->state);
384384
bdev = blkdev_get_by_dev(disk_devt(disk), mode & ~FMODE_EXCL, NULL);
385385
if (IS_ERR(bdev))
386386
ret = PTR_ERR(bdev);
387387
else
388388
blkdev_put(bdev, mode & ~FMODE_EXCL);
389389

390+
/*
391+
* If blkdev_get_by_dev() failed early, GD_NEED_PART_SCAN is still set,
392+
* and this will cause that re-assemble partitioned raid device will
393+
* creat partition for underlying disk.
394+
*/
395+
clear_bit(GD_NEED_PART_SCAN, &disk->state);
390396
if (!(mode & FMODE_EXCL))
391397
bd_abort_claiming(disk->part0, disk_scan_partitions);
392398
return ret;

drivers/block/ublk_drv.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int ublk_validate_params(const struct ublk_device *ub)
246246
if (ub->params.types & UBLK_PARAM_TYPE_BASIC) {
247247
const struct ublk_param_basic *p = &ub->params.basic;
248248

249-
if (p->logical_bs_shift > PAGE_SHIFT)
249+
if (p->logical_bs_shift > PAGE_SHIFT || p->logical_bs_shift < 9)
250250
return -EINVAL;
251251

252252
if (p->logical_bs_shift > p->physical_bs_shift)
@@ -1261,9 +1261,10 @@ static void ublk_handle_need_get_data(struct ublk_device *ub, int q_id,
12611261
ublk_queue_cmd(ubq, req);
12621262
}
12631263

1264-
static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
1264+
static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
1265+
unsigned int issue_flags,
1266+
struct ublksrv_io_cmd *ub_cmd)
12651267
{
1266-
struct ublksrv_io_cmd *ub_cmd = (struct ublksrv_io_cmd *)cmd->cmd;
12671268
struct ublk_device *ub = cmd->file->private_data;
12681269
struct ublk_queue *ubq;
12691270
struct ublk_io *io;
@@ -1362,6 +1363,23 @@ static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
13621363
return -EIOCBQUEUED;
13631364
}
13641365

1366+
static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
1367+
{
1368+
struct ublksrv_io_cmd *ub_src = (struct ublksrv_io_cmd *) cmd->cmd;
1369+
struct ublksrv_io_cmd ub_cmd;
1370+
1371+
/*
1372+
* Not necessary for async retry, but let's keep it simple and always
1373+
* copy the values to avoid any potential reuse.
1374+
*/
1375+
ub_cmd.q_id = READ_ONCE(ub_src->q_id);
1376+
ub_cmd.tag = READ_ONCE(ub_src->tag);
1377+
ub_cmd.result = READ_ONCE(ub_src->result);
1378+
ub_cmd.addr = READ_ONCE(ub_src->addr);
1379+
1380+
return __ublk_ch_uring_cmd(cmd, issue_flags, &ub_cmd);
1381+
}
1382+
13651383
static const struct file_operations ublk_ch_fops = {
13661384
.owner = THIS_MODULE,
13671385
.open = ublk_ch_open,
@@ -1952,6 +1970,8 @@ static int ublk_ctrl_set_params(struct ublk_device *ub,
19521970
/* clear all we don't support yet */
19531971
ub->params.types &= UBLK_PARAM_TYPE_ALL;
19541972
ret = ublk_validate_params(ub);
1973+
if (ret)
1974+
ub->params.types = 0;
19551975
}
19561976
mutex_unlock(&ub->mutex);
19571977

drivers/nvme/host/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,9 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
16741674
struct request_queue *queue = disk->queue;
16751675
u32 size = queue_logical_block_size(queue);
16761676

1677+
if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns, UINT_MAX))
1678+
ctrl->max_discard_sectors = nvme_lba_to_sect(ns, ctrl->dmrsl);
1679+
16771680
if (ctrl->max_discard_sectors == 0) {
16781681
blk_queue_max_discard_sectors(queue, 0);
16791682
return;
@@ -1688,9 +1691,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
16881691
if (queue->limits.max_discard_sectors)
16891692
return;
16901693

1691-
if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns, UINT_MAX))
1692-
ctrl->max_discard_sectors = nvme_lba_to_sect(ns, ctrl->dmrsl);
1693-
16941694
blk_queue_max_discard_sectors(queue, ctrl->max_discard_sectors);
16951695
blk_queue_max_discard_segments(queue, ctrl->max_discard_segments);
16961696

0 commit comments

Comments
 (0)