Skip to content

Commit ee0c8a9

Browse files
committed
Merge tag 'block-6.7-2023-12-01' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - Invalid namespace identification error handling (Marizio Ewan, Keith) - Fabrics keep-alive tuning (Mark) - Fix for a bad error check regression in bcache (Markus) - Fix for a performance regression with O_DIRECT (Ming) - Fix for a flush related deadlock (Ming) - Make the read-only warn on per-partition (Yu) * tag 'block-6.7-2023-12-01' of git://git.kernel.dk/linux: nvme-core: check for too small lba shift blk-mq: don't count completed flush data request as inflight in case of quiesce block: Document the role of the two attribute groups block: warn once for each partition in bio_check_ro() block: move .bd_inode into 1st cacheline of block_device nvme: check for valid nvme_identify_ns() before using it nvme-core: fix a memory leak in nvme_ns_info_from_identify() nvme: fine-tune sending of first keep-alive bcache: revert replacing IS_ERR_OR_NULL with IS_ERR
2 parents abd792f + 8ad3ac9 commit ee0c8a9

File tree

6 files changed

+58
-12
lines changed

6 files changed

+58
-12
lines changed

block/blk-core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,17 @@ static inline void bio_check_ro(struct bio *bio)
501501
if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) {
502502
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
503503
return;
504-
pr_warn_ratelimited("Trying to write to read-only block-device %pg\n",
505-
bio->bi_bdev);
506-
/* Older lvm-tools actually trigger this */
504+
505+
if (bio->bi_bdev->bd_ro_warned)
506+
return;
507+
508+
bio->bi_bdev->bd_ro_warned = true;
509+
/*
510+
* Use ioctl to set underlying disk of raid/dm to read-only
511+
* will trigger this.
512+
*/
513+
pr_warn("Trying to write to read-only block-device %pg\n",
514+
bio->bi_bdev);
507515
}
508516
}
509517

block/blk-mq.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,14 +1512,26 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q,
15121512
}
15131513
EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list);
15141514

1515+
static bool blk_is_flush_data_rq(struct request *rq)
1516+
{
1517+
return (rq->rq_flags & RQF_FLUSH_SEQ) && !is_flush_rq(rq);
1518+
}
1519+
15151520
static bool blk_mq_rq_inflight(struct request *rq, void *priv)
15161521
{
15171522
/*
15181523
* If we find a request that isn't idle we know the queue is busy
15191524
* as it's checked in the iter.
15201525
* Return false to stop the iteration.
1526+
*
1527+
* In case of queue quiesce, if one flush data request is completed,
1528+
* don't count it as inflight given the flush sequence is suspended,
1529+
* and the original flush data request is invisible to driver, just
1530+
* like other pending requests because of quiesce
15211531
*/
1522-
if (blk_mq_request_started(rq)) {
1532+
if (blk_mq_request_started(rq) && !(blk_queue_quiesced(rq->q) &&
1533+
blk_is_flush_data_rq(rq) &&
1534+
blk_mq_request_completed(rq))) {
15231535
bool *busy = priv;
15241536

15251537
*busy = true;

block/blk-sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
615615
QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
616616
#endif
617617

618+
/* Common attributes for bio-based and request-based queues. */
618619
static struct attribute *queue_attrs[] = {
619620
&queue_ra_entry.attr,
620621
&queue_max_hw_sectors_entry.attr,
@@ -659,6 +660,7 @@ static struct attribute *queue_attrs[] = {
659660
NULL,
660661
};
661662

663+
/* Request-based queue attributes that are not relevant for bio-based queues. */
662664
static struct attribute *blk_mq_queue_attrs[] = {
663665
&queue_requests_entry.attr,
664666
&elv_iosched_entry.attr,

drivers/md/bcache/btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
15221522
bch_keylist_free(&keylist);
15231523

15241524
for (i = 0; i < nodes; i++)
1525-
if (!IS_ERR(new_nodes[i])) {
1525+
if (!IS_ERR_OR_NULL(new_nodes[i])) {
15261526
btree_node_free(new_nodes[i]);
15271527
rw_unlock(true, new_nodes[i]);
15281528
}

drivers/nvme/host/core.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,8 +1192,16 @@ static unsigned long nvme_keep_alive_work_period(struct nvme_ctrl *ctrl)
11921192

11931193
static void nvme_queue_keep_alive_work(struct nvme_ctrl *ctrl)
11941194
{
1195-
queue_delayed_work(nvme_wq, &ctrl->ka_work,
1196-
nvme_keep_alive_work_period(ctrl));
1195+
unsigned long now = jiffies;
1196+
unsigned long delay = nvme_keep_alive_work_period(ctrl);
1197+
unsigned long ka_next_check_tm = ctrl->ka_last_check_time + delay;
1198+
1199+
if (time_after(now, ka_next_check_tm))
1200+
delay = 0;
1201+
else
1202+
delay = ka_next_check_tm - now;
1203+
1204+
queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
11971205
}
11981206

11991207
static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
@@ -1479,7 +1487,8 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
14791487
if (id->ncap == 0) {
14801488
/* namespace not allocated or attached */
14811489
info->is_removed = true;
1482-
return -ENODEV;
1490+
ret = -ENODEV;
1491+
goto error;
14831492
}
14841493

14851494
info->anagrpid = id->anagrpid;
@@ -1497,8 +1506,10 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
14971506
!memchr_inv(ids->nguid, 0, sizeof(ids->nguid)))
14981507
memcpy(ids->nguid, id->nguid, sizeof(ids->nguid));
14991508
}
1509+
1510+
error:
15001511
kfree(id);
1501-
return 0;
1512+
return ret;
15021513
}
15031514

15041515
static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,
@@ -1890,9 +1901,10 @@ static void nvme_update_disk_info(struct gendisk *disk,
18901901

18911902
/*
18921903
* The block layer can't support LBA sizes larger than the page size
1893-
* yet, so catch this early and don't allow block I/O.
1904+
* or smaller than a sector size yet, so catch this early and don't
1905+
* allow block I/O.
18941906
*/
1895-
if (ns->lba_shift > PAGE_SHIFT) {
1907+
if (ns->lba_shift > PAGE_SHIFT || ns->lba_shift < SECTOR_SHIFT) {
18961908
capacity = 0;
18971909
bs = (1 << 9);
18981910
}
@@ -2029,6 +2041,13 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
20292041
if (ret)
20302042
return ret;
20312043

2044+
if (id->ncap == 0) {
2045+
/* namespace not allocated or attached */
2046+
info->is_removed = true;
2047+
ret = -ENODEV;
2048+
goto error;
2049+
}
2050+
20322051
blk_mq_freeze_queue(ns->disk->queue);
20332052
lbaf = nvme_lbaf_index(id->flbas);
20342053
ns->lba_shift = id->lbaf[lbaf].ds;
@@ -2090,6 +2109,8 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
20902109
set_bit(NVME_NS_READY, &ns->flags);
20912110
ret = 0;
20922111
}
2112+
2113+
error:
20932114
kfree(id);
20942115
return ret;
20952116
}
@@ -4471,6 +4492,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
44714492
INIT_DELAYED_WORK(&ctrl->failfast_work, nvme_failfast_work);
44724493
memset(&ctrl->ka_cmd, 0, sizeof(ctrl->ka_cmd));
44734494
ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
4495+
ctrl->ka_last_check_time = jiffies;
44744496

44754497
BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
44764498
PAGE_SIZE);

include/linux/blk_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ struct block_device {
4949
bool bd_write_holder;
5050
bool bd_has_submit_bio;
5151
dev_t bd_dev;
52+
struct inode *bd_inode; /* will die */
53+
5254
atomic_t bd_openers;
5355
spinlock_t bd_size_lock; /* for bd_inode->i_size updates */
54-
struct inode * bd_inode; /* will die */
5556
void * bd_claiming;
5657
void * bd_holder;
5758
const struct blk_holder_ops *bd_holder_ops;
@@ -69,6 +70,7 @@ struct block_device {
6970
#ifdef CONFIG_FAIL_MAKE_REQUEST
7071
bool bd_make_it_fail;
7172
#endif
73+
bool bd_ro_warned;
7274
/*
7375
* keep this out-of-line as it's both big and not needed in the fast
7476
* path

0 commit comments

Comments
 (0)