Skip to content

Commit a5b6244

Browse files
committed
Merge tag 'block-6.8-2024-02-10' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - Update a potentially stale firmware attribute (Maurizio) - Fixes for the recent verbose error logging (Keith, Chaitanya) - Protection information payload size fix for passthrough (Francis) - Fix for a queue freezing issue in virtblk (Yi) - blk-iocost underflow fix (Tejun) - blk-wbt task detection fix (Jan) * tag 'block-6.8-2024-02-10' of git://git.kernel.dk/linux: virtio-blk: Ensure no requests in virtqueues before deleting vqs. blk-iocost: Fix an UBSAN shift-out-of-bounds warning nvme: use ns->head->pi_size instead of t10_pi_tuple structure size nvme-core: fix comment to reflect right functions nvme: move passthrough logging attribute to head blk-wbt: Fix detection of dirty-throttled tasks nvme-host: fix the updating of the firmware version
2 parents a38ff5b + 5f63a49 commit a5b6244

File tree

10 files changed

+45
-32
lines changed

10 files changed

+45
-32
lines changed

block/blk-iocost.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,13 @@ static bool iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now)
13531353

13541354
lockdep_assert_held(&iocg->waitq.lock);
13551355

1356+
/*
1357+
* If the delay is set by another CPU, we may be in the past. No need to
1358+
* change anything if so. This avoids decay calculation underflow.
1359+
*/
1360+
if (time_before64(now->now, iocg->delay_at))
1361+
return false;
1362+
13561363
/* calculate the current delay in effect - 1/2 every second */
13571364
tdelta = now->now - iocg->delay_at;
13581365
if (iocg->delay)

block/blk-wbt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
163163
*/
164164
static bool wb_recent_wait(struct rq_wb *rwb)
165165
{
166-
struct bdi_writeback *wb = &rwb->rqos.disk->bdi->wb;
166+
struct backing_dev_info *bdi = rwb->rqos.disk->bdi;
167167

168-
return time_before(jiffies, wb->dirty_sleep + HZ);
168+
return time_before(jiffies, bdi->last_bdp_sleep + HZ);
169169
}
170170

171171
static inline struct rq_wait *get_rq_wait(struct rq_wb *rwb,

drivers/block/virtio_blk.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,14 +1593,15 @@ static int virtblk_freeze(struct virtio_device *vdev)
15931593
{
15941594
struct virtio_blk *vblk = vdev->priv;
15951595

1596+
/* Ensure no requests in virtqueues before deleting vqs. */
1597+
blk_mq_freeze_queue(vblk->disk->queue);
1598+
15961599
/* Ensure we don't receive any more interrupts */
15971600
virtio_reset_device(vdev);
15981601

15991602
/* Make sure no work handler is accessing the device. */
16001603
flush_work(&vblk->config_work);
16011604

1602-
blk_mq_quiesce_queue(vblk->disk->queue);
1603-
16041605
vdev->config->del_vqs(vdev);
16051606
kfree(vblk->vqs);
16061607

@@ -1618,7 +1619,7 @@ static int virtblk_restore(struct virtio_device *vdev)
16181619

16191620
virtio_device_ready(vdev);
16201621

1621-
blk_mq_unquiesce_queue(vblk->disk->queue);
1622+
blk_mq_unfreeze_queue(vblk->disk->queue);
16221623
return 0;
16231624
}
16241625
#endif

drivers/nvme/host/core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ void nvme_init_request(struct request *req, struct nvme_command *cmd)
713713
if (req->q->queuedata) {
714714
struct nvme_ns *ns = req->q->disk->private_data;
715715

716-
logging_enabled = ns->passthru_err_log_enabled;
716+
logging_enabled = ns->head->passthru_err_log_enabled;
717717
req->timeout = NVME_IO_TIMEOUT;
718718
} else { /* no queuedata implies admin queue */
719719
logging_enabled = nr->ctrl->passthru_err_log_enabled;
@@ -3696,7 +3696,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
36963696

36973697
ns->disk = disk;
36983698
ns->queue = disk->queue;
3699-
ns->passthru_err_log_enabled = false;
37003699

37013700
if (ctrl->opts && ctrl->opts->data_digest)
37023701
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
@@ -3762,8 +3761,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
37623761

37633762
/*
37643763
* Set ns->disk->device->driver_data to ns so we can access
3765-
* ns->logging_enabled in nvme_passthru_err_log_enabled_store() and
3766-
* nvme_passthru_err_log_enabled_show().
3764+
* ns->head->passthru_err_log_enabled in
3765+
* nvme_io_passthru_err_log_enabled_[store | show]().
37673766
*/
37683767
dev_set_drvdata(disk_to_dev(ns->disk), ns);
37693768

@@ -4191,6 +4190,7 @@ static bool nvme_ctrl_pp_status(struct nvme_ctrl *ctrl)
41914190
static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
41924191
{
41934192
struct nvme_fw_slot_info_log *log;
4193+
u8 next_fw_slot, cur_fw_slot;
41944194

41954195
log = kmalloc(sizeof(*log), GFP_KERNEL);
41964196
if (!log)
@@ -4202,13 +4202,15 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
42024202
goto out_free_log;
42034203
}
42044204

4205-
if (log->afi & 0x70 || !(log->afi & 0x7)) {
4205+
cur_fw_slot = log->afi & 0x7;
4206+
next_fw_slot = (log->afi & 0x70) >> 4;
4207+
if (!cur_fw_slot || (next_fw_slot && (cur_fw_slot != next_fw_slot))) {
42064208
dev_info(ctrl->device,
42074209
"Firmware is activated after next Controller Level Reset\n");
42084210
goto out_free_log;
42094211
}
42104212

4211-
memcpy(ctrl->subsys->firmware_rev, &log->frs[(log->afi & 0x7) - 1],
4213+
memcpy(ctrl->subsys->firmware_rev, &log->frs[cur_fw_slot - 1],
42124214
sizeof(ctrl->subsys->firmware_rev));
42134215

42144216
out_free_log:

drivers/nvme/host/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
228228
length = (io.nblocks + 1) << ns->head->lba_shift;
229229

230230
if ((io.control & NVME_RW_PRINFO_PRACT) &&
231-
ns->head->ms == sizeof(struct t10_pi_tuple)) {
231+
(ns->head->ms == ns->head->pi_size)) {
232232
/*
233233
* Protection information is stripped/inserted by the
234234
* controller.

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ struct nvme_ns_head {
455455
struct list_head entry;
456456
struct kref ref;
457457
bool shared;
458+
bool passthru_err_log_enabled;
458459
int instance;
459460
struct nvme_effects_log *effects;
460461
u64 nuse;
@@ -523,7 +524,6 @@ struct nvme_ns {
523524
struct device cdev_device;
524525

525526
struct nvme_fault_inject fault_inject;
526-
bool passthru_err_log_enabled;
527527
};
528528

529529
/* NVMe ns supports metadata actions by the controller (generate/strip) */

drivers/nvme/host/sysfs.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
4848
struct device_attribute *attr, const char *buf, size_t count)
4949
{
5050
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
51-
int err;
5251
bool passthru_err_log_enabled;
52+
int err;
5353

5454
err = kstrtobool(buf, &passthru_err_log_enabled);
5555
if (err)
@@ -60,25 +60,34 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
6060
return count;
6161
}
6262

63+
static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
64+
{
65+
struct gendisk *disk = dev_to_disk(dev);
66+
67+
if (nvme_disk_is_ns_head(disk))
68+
return disk->private_data;
69+
return nvme_get_ns_from_dev(dev)->head;
70+
}
71+
6372
static ssize_t nvme_io_passthru_err_log_enabled_show(struct device *dev,
6473
struct device_attribute *attr, char *buf)
6574
{
66-
struct nvme_ns *n = dev_get_drvdata(dev);
75+
struct nvme_ns_head *head = dev_to_ns_head(dev);
6776

68-
return sysfs_emit(buf, n->passthru_err_log_enabled ? "on\n" : "off\n");
77+
return sysfs_emit(buf, head->passthru_err_log_enabled ? "on\n" : "off\n");
6978
}
7079

7180
static ssize_t nvme_io_passthru_err_log_enabled_store(struct device *dev,
7281
struct device_attribute *attr, const char *buf, size_t count)
7382
{
74-
struct nvme_ns *ns = dev_get_drvdata(dev);
75-
int err;
83+
struct nvme_ns_head *head = dev_to_ns_head(dev);
7684
bool passthru_err_log_enabled;
85+
int err;
7786

7887
err = kstrtobool(buf, &passthru_err_log_enabled);
7988
if (err)
8089
return -EINVAL;
81-
ns->passthru_err_log_enabled = passthru_err_log_enabled;
90+
head->passthru_err_log_enabled = passthru_err_log_enabled;
8291

8392
return count;
8493
}
@@ -91,15 +100,6 @@ static struct device_attribute dev_attr_io_passthru_err_log_enabled = \
91100
__ATTR(passthru_err_log_enabled, S_IRUGO | S_IWUSR, \
92101
nvme_io_passthru_err_log_enabled_show, nvme_io_passthru_err_log_enabled_store);
93102

94-
static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
95-
{
96-
struct gendisk *disk = dev_to_disk(dev);
97-
98-
if (nvme_disk_is_ns_head(disk))
99-
return disk->private_data;
100-
return nvme_get_ns_from_dev(dev)->head;
101-
}
102-
103103
static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
104104
char *buf)
105105
{

include/linux/backing-dev-defs.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ struct bdi_writeback {
141141
struct delayed_work dwork; /* work item used for writeback */
142142
struct delayed_work bw_dwork; /* work item used for bandwidth estimate */
143143

144-
unsigned long dirty_sleep; /* last wait */
145-
146144
struct list_head bdi_node; /* anchored at bdi->wb_list */
147145

148146
#ifdef CONFIG_CGROUP_WRITEBACK
@@ -179,6 +177,11 @@ struct backing_dev_info {
179177
* any dirty wbs, which is depended upon by bdi_has_dirty().
180178
*/
181179
atomic_long_t tot_write_bandwidth;
180+
/*
181+
* Jiffies when last process was dirty throttled on this bdi. Used by
182+
* blk-wbt.
183+
*/
184+
unsigned long last_bdp_sleep;
182185

183186
struct bdi_writeback wb; /* the root writeback info for this bdi */
184187
struct list_head wb_list; /* list of all wbs */

mm/backing-dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
436436
INIT_LIST_HEAD(&wb->work_list);
437437
INIT_DELAYED_WORK(&wb->dwork, wb_workfn);
438438
INIT_DELAYED_WORK(&wb->bw_dwork, wb_update_bandwidth_workfn);
439-
wb->dirty_sleep = jiffies;
440439

441440
err = fprop_local_init_percpu(&wb->completions, gfp);
442441
if (err)
@@ -921,6 +920,7 @@ int bdi_init(struct backing_dev_info *bdi)
921920
INIT_LIST_HEAD(&bdi->bdi_list);
922921
INIT_LIST_HEAD(&bdi->wb_list);
923922
init_waitqueue_head(&bdi->wb_waitq);
923+
bdi->last_bdp_sleep = jiffies;
924924

925925
return cgwb_bdi_init(bdi);
926926
}

mm/page-writeback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
19211921
break;
19221922
}
19231923
__set_current_state(TASK_KILLABLE);
1924-
wb->dirty_sleep = now;
1924+
bdi->last_bdp_sleep = jiffies;
19251925
io_schedule_timeout(pause);
19261926

19271927
current->dirty_paused_when = now + pause;

0 commit comments

Comments
 (0)