Skip to content

Commit 360e694

Browse files
committed
Merge tag 'block-6.5-2023-08-11' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - Fixes for request_queue state (Ming) - Another uuid quirk (August) - RCU poll fix for NVMe (Ming) - Fix for an IO stall with polled IO (me) - Fix for blk-iocost stats enable/disable accounting (Chengming) - Regression fix for large pages for zram (Christoph) * tag 'block-6.5-2023-08-11' of git://git.kernel.dk/linux: nvme: core: don't hold rcu read lock in nvme_ns_chr_uring_cmd_iopoll blk-iocost: fix queue stats accounting block: don't make REQ_POLLED imply REQ_NOWAIT block: get rid of unused plug->nowait flag zram: take device and not only bvec offset into account nvme-pci: add NVME_QUIRK_BOGUS_NID for Samsung PM9B1 256G and 512G nvme-rdma: fix potential unbalanced freeze & unfreeze nvme-tcp: fix potential unbalanced freeze & unfreeze nvme: fix possible hang when removing a controller during error recovery
2 parents 2e40ed2 + a7a7dab commit 360e694

File tree

11 files changed

+41
-33
lines changed

11 files changed

+41
-33
lines changed

block/blk-core.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,9 @@ void submit_bio_noacct(struct bio *bio)
722722
struct block_device *bdev = bio->bi_bdev;
723723
struct request_queue *q = bdev_get_queue(bdev);
724724
blk_status_t status = BLK_STS_IOERR;
725-
struct blk_plug *plug;
726725

727726
might_sleep();
728727

729-
plug = blk_mq_plug(bio);
730-
if (plug && plug->nowait)
731-
bio->bi_opf |= REQ_NOWAIT;
732-
733728
/*
734729
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
735730
* if queue does not support NOWAIT.
@@ -1059,7 +1054,6 @@ void blk_start_plug_nr_ios(struct blk_plug *plug, unsigned short nr_ios)
10591054
plug->rq_count = 0;
10601055
plug->multiple_queues = false;
10611056
plug->has_elevator = false;
1062-
plug->nowait = false;
10631057
INIT_LIST_HEAD(&plug->cb_list);
10641058

10651059
/*

block/blk-iocost.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,11 +3301,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
33013301
if (qos[QOS_MIN] > qos[QOS_MAX])
33023302
goto einval;
33033303

3304-
if (enable) {
3304+
if (enable && !ioc->enabled) {
33053305
blk_stat_enable_accounting(disk->queue);
33063306
blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue);
33073307
ioc->enabled = true;
3308-
} else {
3308+
} else if (!enable && ioc->enabled) {
3309+
blk_stat_disable_accounting(disk->queue);
33093310
blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue);
33103311
ioc->enabled = false;
33113312
}

block/fops.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,14 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,
358358
task_io_account_write(bio->bi_iter.bi_size);
359359
}
360360

361+
if (iocb->ki_flags & IOCB_NOWAIT)
362+
bio->bi_opf |= REQ_NOWAIT;
363+
361364
if (iocb->ki_flags & IOCB_HIPRI) {
362-
bio->bi_opf |= REQ_POLLED | REQ_NOWAIT;
365+
bio->bi_opf |= REQ_POLLED;
363366
submit_bio(bio);
364367
WRITE_ONCE(iocb->private, bio);
365368
} else {
366-
if (iocb->ki_flags & IOCB_NOWAIT)
367-
bio->bi_opf |= REQ_NOWAIT;
368369
submit_bio(bio);
369370
}
370371
return -EIOCBQUEUED;

drivers/block/zram/zram_drv.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,15 +1870,16 @@ static void zram_bio_discard(struct zram *zram, struct bio *bio)
18701870

18711871
static void zram_bio_read(struct zram *zram, struct bio *bio)
18721872
{
1873-
struct bvec_iter iter;
1874-
struct bio_vec bv;
1875-
unsigned long start_time;
1873+
unsigned long start_time = bio_start_io_acct(bio);
1874+
struct bvec_iter iter = bio->bi_iter;
18761875

1877-
start_time = bio_start_io_acct(bio);
1878-
bio_for_each_segment(bv, bio, iter) {
1876+
do {
18791877
u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
18801878
u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
18811879
SECTOR_SHIFT;
1880+
struct bio_vec bv = bio_iter_iovec(bio, iter);
1881+
1882+
bv.bv_len = min_t(u32, bv.bv_len, PAGE_SIZE - offset);
18821883

18831884
if (zram_bvec_read(zram, &bv, index, offset, bio) < 0) {
18841885
atomic64_inc(&zram->stats.failed_reads);
@@ -1890,22 +1891,26 @@ static void zram_bio_read(struct zram *zram, struct bio *bio)
18901891
zram_slot_lock(zram, index);
18911892
zram_accessed(zram, index);
18921893
zram_slot_unlock(zram, index);
1893-
}
1894+
1895+
bio_advance_iter_single(bio, &iter, bv.bv_len);
1896+
} while (iter.bi_size);
1897+
18941898
bio_end_io_acct(bio, start_time);
18951899
bio_endio(bio);
18961900
}
18971901

18981902
static void zram_bio_write(struct zram *zram, struct bio *bio)
18991903
{
1900-
struct bvec_iter iter;
1901-
struct bio_vec bv;
1902-
unsigned long start_time;
1904+
unsigned long start_time = bio_start_io_acct(bio);
1905+
struct bvec_iter iter = bio->bi_iter;
19031906

1904-
start_time = bio_start_io_acct(bio);
1905-
bio_for_each_segment(bv, bio, iter) {
1907+
do {
19061908
u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
19071909
u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
19081910
SECTOR_SHIFT;
1911+
struct bio_vec bv = bio_iter_iovec(bio, iter);
1912+
1913+
bv.bv_len = min_t(u32, bv.bv_len, PAGE_SIZE - offset);
19091914

19101915
if (zram_bvec_write(zram, &bv, index, offset, bio) < 0) {
19111916
atomic64_inc(&zram->stats.failed_writes);
@@ -1916,7 +1921,10 @@ static void zram_bio_write(struct zram *zram, struct bio *bio)
19161921
zram_slot_lock(zram, index);
19171922
zram_accessed(zram, index);
19181923
zram_slot_unlock(zram, index);
1919-
}
1924+
1925+
bio_advance_iter_single(bio, &iter, bv.bv_len);
1926+
} while (iter.bi_size);
1927+
19201928
bio_end_io_acct(bio, start_time);
19211929
bio_endio(bio);
19221930
}

drivers/nvme/host/core.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,12 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
39333933
*/
39343934
nvme_mpath_clear_ctrl_paths(ctrl);
39353935

3936+
/*
3937+
* Unquiesce io queues so any pending IO won't hang, especially
3938+
* those submitted from scan work
3939+
*/
3940+
nvme_unquiesce_io_queues(ctrl);
3941+
39363942
/* prevent racing with ns scanning */
39373943
flush_work(&ctrl->scan_work);
39383944

@@ -3942,10 +3948,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
39423948
* removing the namespaces' disks; fail all the queues now to avoid
39433949
* potentially having to clean up the failed sync later.
39443950
*/
3945-
if (ctrl->state == NVME_CTRL_DEAD) {
3951+
if (ctrl->state == NVME_CTRL_DEAD)
39463952
nvme_mark_namespaces_dead(ctrl);
3947-
nvme_unquiesce_io_queues(ctrl);
3948-
}
39493953

39503954
/* this is a no-op when called from the controller reset handler */
39513955
nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING_NOIO);

drivers/nvme/host/ioctl.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,9 @@ int nvme_ns_chr_uring_cmd_iopoll(struct io_uring_cmd *ioucmd,
786786
if (!(ioucmd->flags & IORING_URING_CMD_POLLED))
787787
return 0;
788788

789-
rcu_read_lock();
790789
req = READ_ONCE(ioucmd->cookie);
791790
if (req && blk_rq_is_poll(req))
792791
ret = blk_rq_poll(req, iob, poll_flags);
793-
rcu_read_unlock();
794792
return ret;
795793
}
796794
#ifdef CONFIG_NVME_MULTIPATH

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3402,7 +3402,8 @@ static const struct pci_device_id nvme_id_table[] = {
34023402
{ PCI_DEVICE(0x1d97, 0x2263), /* SPCC */
34033403
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
34043404
{ PCI_DEVICE(0x144d, 0xa80b), /* Samsung PM9B1 256G and 512G */
3405-
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
3405+
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES |
3406+
NVME_QUIRK_BOGUS_NID, },
34063407
{ PCI_DEVICE(0x144d, 0xa809), /* Samsung MZALQ256HBJD 256G */
34073408
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
34083409
{ PCI_DEVICE(0x144d, 0xa802), /* Samsung SM953 */

drivers/nvme/host/rdma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
883883
goto out_cleanup_tagset;
884884

885885
if (!new) {
886+
nvme_start_freeze(&ctrl->ctrl);
886887
nvme_unquiesce_io_queues(&ctrl->ctrl);
887888
if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) {
888889
/*
@@ -891,6 +892,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
891892
* to be safe.
892893
*/
893894
ret = -ENODEV;
895+
nvme_unfreeze(&ctrl->ctrl);
894896
goto out_wait_freeze_timed_out;
895897
}
896898
blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset,
@@ -940,7 +942,6 @@ static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
940942
bool remove)
941943
{
942944
if (ctrl->ctrl.queue_count > 1) {
943-
nvme_start_freeze(&ctrl->ctrl);
944945
nvme_quiesce_io_queues(&ctrl->ctrl);
945946
nvme_sync_io_queues(&ctrl->ctrl);
946947
nvme_rdma_stop_io_queues(ctrl);

drivers/nvme/host/tcp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
18681868
goto out_cleanup_connect_q;
18691869

18701870
if (!new) {
1871+
nvme_start_freeze(ctrl);
18711872
nvme_unquiesce_io_queues(ctrl);
18721873
if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) {
18731874
/*
@@ -1876,6 +1877,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
18761877
* to be safe.
18771878
*/
18781879
ret = -ENODEV;
1880+
nvme_unfreeze(ctrl);
18791881
goto out_wait_freeze_timed_out;
18801882
}
18811883
blk_mq_update_nr_hw_queues(ctrl->tagset,
@@ -1980,7 +1982,6 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
19801982
if (ctrl->queue_count <= 1)
19811983
return;
19821984
nvme_quiesce_admin_queue(ctrl);
1983-
nvme_start_freeze(ctrl);
19841985
nvme_quiesce_io_queues(ctrl);
19851986
nvme_sync_io_queues(ctrl);
19861987
nvme_tcp_stop_io_queues(ctrl);

include/linux/bio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static inline int bio_integrity_add_page(struct bio *bio, struct page *page,
791791
static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
792792
{
793793
bio->bi_opf |= REQ_POLLED;
794-
if (!is_sync_kiocb(kiocb))
794+
if (kiocb->ki_flags & IOCB_NOWAIT)
795795
bio->bi_opf |= REQ_NOWAIT;
796796
}
797797

0 commit comments

Comments
 (0)