Skip to content

Commit d4b7332

Browse files
committed
Merge tag 'block-6.1-2022-10-20' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Christoph: - fix nvme-hwmon for DMA non-cohehrent architectures (Serge Semin) - add a nvme-hwmong maintainer (Christoph Hellwig) - fix error pointer dereference in error handling (Dan Carpenter) - fix invalid memory reference in nvmet_subsys_attr_qid_max_show (Daniel Wagner) - don't limit the DMA segment size in nvme-apple (Russell King) - fix workqueue MEM_RECLAIM flushing dependency (Sagi Grimberg) - disable write zeroes on various Kingston SSDs (Xander Li) - fix a memory leak with block device tracing (Ye) - flexible-array fix for ublk (Yushan) - document the ublk recovery feature from this merge window (ZiyangZhang) - remove dead bfq variable in struct (Yuwei) - error handling rq clearing fix (Yu) - add an IRQ safety check for the cached bio freeing (Pavel) - drbd bio cloning fix (Christoph) * tag 'block-6.1-2022-10-20' of git://git.kernel.dk/linux: blktrace: remove unnessary stop block trace in 'blk_trace_shutdown' blktrace: fix possible memleak in '__blk_trace_remove' blktrace: introduce 'blk_trace_{start,stop}' helper bio: safeguard REQ_ALLOC_CACHE bio put block, bfq: remove unused variable for bfq_queue drbd: only clone bio if we have a backing device ublk_drv: use flexible-array member instead of zero-length array nvmet: fix invalid memory reference in nvmet_subsys_attr_qid_max_show nvmet: fix workqueue MEM_RECLAIM flushing dependency nvme-hwmon: kmalloc the NVME SMART log buffer nvme-hwmon: consistently ignore errors from nvme_hwmon_init nvme: add Guenther as nvme-hwmon maintainer nvme-apple: don't limit DMA segement size nvme-pci: disable write zeroes on various Kingston SSD nvme: fix error pointer dereference in error handling Documentation: document ublk user recovery feature blk-mq: fix null pointer dereference in blk_mq_clear_rq_mapping()
2 parents 294e73f + 2db9621 commit d4b7332

File tree

14 files changed

+135
-76
lines changed

14 files changed

+135
-76
lines changed

Documentation/block/ublk.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,42 @@ managing and controlling ublk devices with help of several control commands:
144144
For retrieving device info via ``ublksrv_ctrl_dev_info``. It is the server's
145145
responsibility to save IO target specific info in userspace.
146146

147+
- ``UBLK_CMD_START_USER_RECOVERY``
148+
149+
This command is valid if ``UBLK_F_USER_RECOVERY`` feature is enabled. This
150+
command is accepted after the old process has exited, ublk device is quiesced
151+
and ``/dev/ublkc*`` is released. User should send this command before he starts
152+
a new process which re-opens ``/dev/ublkc*``. When this command returns, the
153+
ublk device is ready for the new process.
154+
155+
- ``UBLK_CMD_END_USER_RECOVERY``
156+
157+
This command is valid if ``UBLK_F_USER_RECOVERY`` feature is enabled. This
158+
command is accepted after ublk device is quiesced and a new process has
159+
opened ``/dev/ublkc*`` and get all ublk queues be ready. When this command
160+
returns, ublk device is unquiesced and new I/O requests are passed to the
161+
new process.
162+
163+
- user recovery feature description
164+
165+
Two new features are added for user recovery: ``UBLK_F_USER_RECOVERY`` and
166+
``UBLK_F_USER_RECOVERY_REISSUE``.
167+
168+
With ``UBLK_F_USER_RECOVERY`` set, after one ubq_daemon(ublk server's io
169+
handler) is dying, ublk does not delete ``/dev/ublkb*`` during the whole
170+
recovery stage and ublk device ID is kept. It is ublk server's
171+
responsibility to recover the device context by its own knowledge.
172+
Requests which have not been issued to userspace are requeued. Requests
173+
which have been issued to userspace are aborted.
174+
175+
With ``UBLK_F_USER_RECOVERY_REISSUE`` set, after one ubq_daemon(ublk
176+
server's io handler) is dying, contrary to ``UBLK_F_USER_RECOVERY``,
177+
requests which have been issued to userspace are requeued and will be
178+
re-issued to the new process after handling ``UBLK_CMD_END_USER_RECOVERY``.
179+
``UBLK_F_USER_RECOVERY_REISSUE`` is designed for backends who tolerate
180+
double-write since the driver may issue the same I/O request twice. It
181+
might be useful to a read-only FS or a VM backend.
182+
147183
Data plane
148184
----------
149185

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14713,6 +14713,12 @@ F: drivers/nvme/target/auth.c
1471314713
F: drivers/nvme/target/fabrics-cmd-auth.c
1471414714
F: include/linux/nvme-auth.h
1471514715

14716+
NVM EXPRESS HARDWARE MONITORING SUPPORT
14717+
M: Guenter Roeck <[email protected]>
14718+
14719+
S: Supported
14720+
F: drivers/nvme/host/hwmon.c
14721+
1471614722
NVM EXPRESS FC TRANSPORT DRIVERS
1471714723
M: James Smart <[email protected]>
1471814724

block/bfq-iosched.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,8 @@ struct bfq_queue {
369369
unsigned long split_time; /* time of last split */
370370

371371
unsigned long first_IO_time; /* time of first I/O for this queue */
372-
373372
unsigned long creation_time; /* when this queue is created */
374373

375-
/* max service rate measured so far */
376-
u32 max_service_rate;
377-
378374
/*
379375
* Pointer to the waker queue for this queue, i.e., to the
380376
* queue Q such that this queue happens to get new I/O right

block/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ void bio_put(struct bio *bio)
741741
return;
742742
}
743743

744-
if (bio->bi_opf & REQ_ALLOC_CACHE) {
744+
if ((bio->bi_opf & REQ_ALLOC_CACHE) && !WARN_ON_ONCE(in_interrupt())) {
745745
struct bio_alloc_cache *cache;
746746

747747
bio_uninit(bio);

block/blk-mq.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,8 +3112,11 @@ static void blk_mq_clear_rq_mapping(struct blk_mq_tags *drv_tags,
31123112
struct page *page;
31133113
unsigned long flags;
31143114

3115-
/* There is no need to clear a driver tags own mapping */
3116-
if (drv_tags == tags)
3115+
/*
3116+
* There is no need to clear mapping if driver tags is not initialized
3117+
* or the mapping belongs to the driver tags.
3118+
*/
3119+
if (!drv_tags || drv_tags == tags)
31173120
return;
31183121

31193122
list_for_each_entry(page, &tags->page_list, lru) {

drivers/block/drbd/drbd_req.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ static struct drbd_request *drbd_req_new(struct drbd_device *device, struct bio
3030
return NULL;
3131
memset(req, 0, sizeof(*req));
3232

33-
req->private_bio = bio_alloc_clone(device->ldev->backing_bdev, bio_src,
34-
GFP_NOIO, &drbd_io_bio_set);
35-
req->private_bio->bi_private = req;
36-
req->private_bio->bi_end_io = drbd_request_endio;
37-
3833
req->rq_state = (bio_data_dir(bio_src) == WRITE ? RQ_WRITE : 0)
3934
| (bio_op(bio_src) == REQ_OP_WRITE_ZEROES ? RQ_ZEROES : 0)
4035
| (bio_op(bio_src) == REQ_OP_DISCARD ? RQ_UNMAP : 0);
@@ -1219,9 +1214,12 @@ drbd_request_prepare(struct drbd_device *device, struct bio *bio)
12191214
/* Update disk stats */
12201215
req->start_jif = bio_start_io_acct(req->master_bio);
12211216

1222-
if (!get_ldev(device)) {
1223-
bio_put(req->private_bio);
1224-
req->private_bio = NULL;
1217+
if (get_ldev(device)) {
1218+
req->private_bio = bio_alloc_clone(device->ldev->backing_bdev,
1219+
bio, GFP_NOIO,
1220+
&drbd_io_bio_set);
1221+
req->private_bio->bi_private = req;
1222+
req->private_bio->bi_end_io = drbd_request_endio;
12251223
}
12261224

12271225
/* process discards always from our submitter thread */

drivers/block/ublk_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct ublk_queue {
124124
bool force_abort;
125125
unsigned short nr_io_ready; /* how many ios setup */
126126
struct ublk_device *dev;
127-
struct ublk_io ios[0];
127+
struct ublk_io ios[];
128128
};
129129

130130
#define UBLK_DAEMON_MONITOR_PERIOD (5 * HZ)

drivers/nvme/host/apple.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,8 @@ static void apple_nvme_reset_work(struct work_struct *work)
10391039
dma_max_mapping_size(anv->dev) >> 9);
10401040
anv->ctrl.max_segments = NVME_MAX_SEGS;
10411041

1042+
dma_set_max_seg_size(anv->dev, 0xffffffff);
1043+
10421044
/*
10431045
* Enable NVMMU and linear submission queues.
10441046
* While we could keep those disabled and pretend this is slightly

drivers/nvme/host/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,8 +3262,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
32623262
return ret;
32633263

32643264
if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) {
3265+
/*
3266+
* Do not return errors unless we are in a controller reset,
3267+
* the controller works perfectly fine without hwmon.
3268+
*/
32653269
ret = nvme_hwmon_init(ctrl);
3266-
if (ret < 0)
3270+
if (ret == -EINTR)
32673271
return ret;
32683272
}
32693273

@@ -4846,7 +4850,7 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
48464850
return 0;
48474851

48484852
out_cleanup_admin_q:
4849-
blk_mq_destroy_queue(ctrl->fabrics_q);
4853+
blk_mq_destroy_queue(ctrl->admin_q);
48504854
out_free_tagset:
48514855
blk_mq_free_tag_set(ctrl->admin_tagset);
48524856
return ret;

drivers/nvme/host/hwmon.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
struct nvme_hwmon_data {
1414
struct nvme_ctrl *ctrl;
15-
struct nvme_smart_log log;
15+
struct nvme_smart_log *log;
1616
struct mutex read_lock;
1717
};
1818

@@ -60,14 +60,14 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under,
6060
static int nvme_hwmon_get_smart_log(struct nvme_hwmon_data *data)
6161
{
6262
return nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
63-
NVME_CSI_NVM, &data->log, sizeof(data->log), 0);
63+
NVME_CSI_NVM, data->log, sizeof(*data->log), 0);
6464
}
6565

6666
static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
6767
u32 attr, int channel, long *val)
6868
{
6969
struct nvme_hwmon_data *data = dev_get_drvdata(dev);
70-
struct nvme_smart_log *log = &data->log;
70+
struct nvme_smart_log *log = data->log;
7171
int temp;
7272
int err;
7373

@@ -163,7 +163,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
163163
case hwmon_temp_max:
164164
case hwmon_temp_min:
165165
if ((!channel && data->ctrl->wctemp) ||
166-
(channel && data->log.temp_sensor[channel - 1])) {
166+
(channel && data->log->temp_sensor[channel - 1])) {
167167
if (data->ctrl->quirks &
168168
NVME_QUIRK_NO_TEMP_THRESH_CHANGE)
169169
return 0444;
@@ -176,7 +176,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
176176
break;
177177
case hwmon_temp_input:
178178
case hwmon_temp_label:
179-
if (!channel || data->log.temp_sensor[channel - 1])
179+
if (!channel || data->log->temp_sensor[channel - 1])
180180
return 0444;
181181
break;
182182
default:
@@ -230,28 +230,39 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
230230

231231
data = kzalloc(sizeof(*data), GFP_KERNEL);
232232
if (!data)
233-
return 0;
233+
return -ENOMEM;
234+
235+
data->log = kzalloc(sizeof(*data->log), GFP_KERNEL);
236+
if (!data->log) {
237+
err = -ENOMEM;
238+
goto err_free_data;
239+
}
234240

235241
data->ctrl = ctrl;
236242
mutex_init(&data->read_lock);
237243

238244
err = nvme_hwmon_get_smart_log(data);
239245
if (err) {
240246
dev_warn(dev, "Failed to read smart log (error %d)\n", err);
241-
kfree(data);
242-
return err;
247+
goto err_free_log;
243248
}
244249

245250
hwmon = hwmon_device_register_with_info(dev, "nvme",
246251
data, &nvme_hwmon_chip_info,
247252
NULL);
248253
if (IS_ERR(hwmon)) {
249254
dev_warn(dev, "Failed to instantiate hwmon device\n");
250-
kfree(data);
251-
return PTR_ERR(hwmon);
255+
err = PTR_ERR(hwmon);
256+
goto err_free_log;
252257
}
253258
ctrl->hwmon_device = hwmon;
254259
return 0;
260+
261+
err_free_log:
262+
kfree(data->log);
263+
err_free_data:
264+
kfree(data);
265+
return err;
255266
}
256267

257268
void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
@@ -262,6 +273,7 @@ void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
262273

263274
hwmon_device_unregister(ctrl->hwmon_device);
264275
ctrl->hwmon_device = NULL;
276+
kfree(data->log);
265277
kfree(data);
266278
}
267279
}

0 commit comments

Comments
 (0)