Skip to content

Commit 47454ca

Browse files
committed
Merge tag 'block-5.12-2021-03-05' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - NVMe fixes: - more device quirks (Julian Einwag, Zoltán Böszörményi, Pascal Terjan) - fix a hwmon error return (Daniel Wagner) - fix the keep alive timeout initialization (Martin George) - ensure the model_number can't be changed on a used subsystem (Max Gurtovoy) - rsxx missing -EFAULT on copy_to_user() failure (Dan) - rsxx remove unused linux.h include (Tian) - kill unused RQF_SORTED (Jean) - updated outdated BFQ comments (Joseph) - revert work-around commit for bd_size_lock, since we removed the offending user in this merge window (Damien) * tag 'block-5.12-2021-03-05' of git://git.kernel.dk/linux-block: nvmet: model_number must be immutable once set nvme-fabrics: fix kato initialization nvme-hwmon: Return error code when registration fails nvme-pci: add quirks for Lexar 256GB SSD nvme-pci: mark Kingston SKC2000 as not supporting the deepest power state nvme-pci: mark Seagate Nytro XM1440 as QUIRK_NO_NS_DESC_LIST. rsxx: Return -EFAULT if copy_to_user() fails block/bfq: update comments and default value in docs for fifo_expire rsxx: remove unused including <linux/version.h> block: Drop leftover references to RQF_SORTED block: revert "block: fix bd_size_lock use"
2 parents f292e87 + a2b658e commit 47454ca

File tree

16 files changed

+75
-69
lines changed

16 files changed

+75
-69
lines changed

Documentation/block/bfq-iosched.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ fifo_expire_async
430430
-----------------
431431

432432
This parameter is used to set the timeout of asynchronous requests. Default
433-
value of this is 248ms.
433+
value of this is 250ms.
434434

435435
fifo_expire_sync
436436
----------------
437437

438438
This parameter is used to set the timeout of synchronous requests. Default
439-
value of this is 124ms. In case to favor synchronous requests over asynchronous
439+
value of this is 125ms. In case to favor synchronous requests over asynchronous
440440
one, this value should be decreased relative to fifo_expire_async.
441441

442442
low_latency

block/bfq-iosched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ BFQ_BFQQ_FNS(split_coop);
162162
BFQ_BFQQ_FNS(softrt_update);
163163
#undef BFQ_BFQQ_FNS \
164164

165-
/* Expiration time of sync (0) and async (1) requests, in ns. */
165+
/* Expiration time of async (0) and sync (1) requests, in ns. */
166166
static const u64 bfq_fifo_expire[2] = { NSEC_PER_SEC / 4, NSEC_PER_SEC / 8 };
167167

168168
/* Maximum backwards seek (magic number lifted from CFQ), in KiB. */

block/blk-mq-debugfs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ static const char *const cmd_flag_name[] = {
292292

293293
#define RQF_NAME(name) [ilog2((__force u32)RQF_##name)] = #name
294294
static const char *const rqf_name[] = {
295-
RQF_NAME(SORTED),
296295
RQF_NAME(STARTED),
297296
RQF_NAME(SOFTBARRIER),
298297
RQF_NAME(FLUSH_SEQ),

block/blk-mq-sched.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq)
385385
EXPORT_SYMBOL_GPL(blk_mq_sched_try_insert_merge);
386386

387387
static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
388-
bool has_sched,
389388
struct request *rq)
390389
{
391390
/*
@@ -402,9 +401,6 @@ static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
402401
if ((rq->rq_flags & RQF_FLUSH_SEQ) || blk_rq_is_passthrough(rq))
403402
return true;
404403

405-
if (has_sched)
406-
rq->rq_flags |= RQF_SORTED;
407-
408404
return false;
409405
}
410406

@@ -418,7 +414,7 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
418414

419415
WARN_ON(e && (rq->tag != BLK_MQ_NO_TAG));
420416

421-
if (blk_mq_sched_bypass_insert(hctx, !!e, rq)) {
417+
if (blk_mq_sched_bypass_insert(hctx, rq)) {
422418
/*
423419
* Firstly normal IO request is inserted to scheduler queue or
424420
* sw queue, meantime we add flush request to dispatch queue(

block/genhd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ static void disk_release_events(struct gendisk *disk);
4545
void set_capacity(struct gendisk *disk, sector_t sectors)
4646
{
4747
struct block_device *bdev = disk->part0;
48-
unsigned long flags;
4948

50-
spin_lock_irqsave(&bdev->bd_size_lock, flags);
49+
spin_lock(&bdev->bd_size_lock);
5150
i_size_write(bdev->bd_inode, (loff_t)sectors << SECTOR_SHIFT);
52-
spin_unlock_irqrestore(&bdev->bd_size_lock, flags);
51+
spin_unlock(&bdev->bd_size_lock);
5352
}
5453
EXPORT_SYMBOL(set_capacity);
5554

block/partitions/core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ static int (*check_part[])(struct parsed_partitions *) = {
8888

8989
static void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors)
9090
{
91-
unsigned long flags;
92-
93-
spin_lock_irqsave(&bdev->bd_size_lock, flags);
91+
spin_lock(&bdev->bd_size_lock);
9492
i_size_write(bdev->bd_inode, (loff_t)sectors << SECTOR_SHIFT);
95-
spin_unlock_irqrestore(&bdev->bd_size_lock, flags);
93+
spin_unlock(&bdev->bd_size_lock);
9694
}
9795

9896
static struct parsed_partitions *allocate_partitions(struct gendisk *hd)

drivers/block/rsxx/core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,17 @@ static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
165165
{
166166
struct rsxx_cardinfo *card = file_inode(fp)->i_private;
167167
char *buf;
168-
ssize_t st;
168+
int st;
169169

170170
buf = kzalloc(cnt, GFP_KERNEL);
171171
if (!buf)
172172
return -ENOMEM;
173173

174174
st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1);
175-
if (!st)
176-
st = copy_to_user(ubuf, buf, cnt);
175+
if (!st) {
176+
if (copy_to_user(ubuf, buf, cnt))
177+
st = -EFAULT;
178+
}
177179
kfree(buf);
178180
if (st)
179181
return st;

drivers/block/rsxx/rsxx_priv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#ifndef __RSXX_PRIV_H__
1212
#define __RSXX_PRIV_H__
1313

14-
#include <linux/version.h>
1514
#include <linux/semaphore.h>
1615

1716
#include <linux/fs.h>

drivers/nvme/host/fabrics.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
630630
opts->queue_size = NVMF_DEF_QUEUE_SIZE;
631631
opts->nr_io_queues = num_online_cpus();
632632
opts->reconnect_delay = NVMF_DEF_RECONNECT_DELAY;
633-
opts->kato = NVME_DEFAULT_KATO;
633+
opts->kato = 0;
634634
opts->duplicate_connect = false;
635635
opts->fast_io_fail_tmo = NVMF_DEF_FAIL_FAST_TMO;
636636
opts->hdr_digest = false;
@@ -893,6 +893,9 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
893893
opts->nr_write_queues = 0;
894894
opts->nr_poll_queues = 0;
895895
opts->duplicate_connect = true;
896+
} else {
897+
if (!opts->kato)
898+
opts->kato = NVME_DEFAULT_KATO;
896899
}
897900
if (ctrl_loss_tmo < 0) {
898901
opts->max_reconnects = -1;

drivers/nvme/host/hwmon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
248248
if (IS_ERR(hwmon)) {
249249
dev_warn(dev, "Failed to instantiate hwmon device\n");
250250
kfree(data);
251+
return PTR_ERR(hwmon);
251252
}
252253
ctrl->hwmon_device = hwmon;
253254
return 0;

drivers/nvme/host/pci.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,8 @@ static const struct pci_device_id nvme_id_table[] = {
32343234
{ PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */
32353235
.driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
32363236
{ PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */
3237-
.driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
3237+
.driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY |
3238+
NVME_QUIRK_NO_NS_DESC_LIST, },
32383239
{ PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */
32393240
.driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
32403241
{ PCI_DEVICE(0x1c58, 0x0023), /* WDC SN200 adapter */
@@ -3248,6 +3249,9 @@ static const struct pci_device_id nvme_id_table[] = {
32483249
NVME_QUIRK_IGNORE_DEV_SUBNQN, },
32493250
{ PCI_DEVICE(0x1987, 0x5016), /* Phison E16 */
32503251
.driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
3252+
{ PCI_DEVICE(0x1b4b, 0x1092), /* Lexar 256 GB SSD */
3253+
.driver_data = NVME_QUIRK_NO_NS_DESC_LIST |
3254+
NVME_QUIRK_IGNORE_DEV_SUBNQN, },
32513255
{ PCI_DEVICE(0x1d1d, 0x1f1f), /* LighNVM qemu device */
32523256
.driver_data = NVME_QUIRK_LIGHTNVM, },
32533257
{ PCI_DEVICE(0x1d1d, 0x2807), /* CNEX WL */
@@ -3265,6 +3269,8 @@ static const struct pci_device_id nvme_id_table[] = {
32653269
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
32663270
{ PCI_DEVICE(0x1d97, 0x2263), /* SPCC */
32673271
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
3272+
{ PCI_DEVICE(0x2646, 0x2262), /* KINGSTON SKC2000 NVMe SSD */
3273+
.driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
32683274
{ PCI_DEVICE(0x2646, 0x2263), /* KINGSTON A2000 NVMe SSD */
32693275
.driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
32703276
{ PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0061),

drivers/nvme/target/admin-cmd.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,27 +313,40 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
313313
nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR);
314314
}
315315

316-
static void nvmet_id_set_model_number(struct nvme_id_ctrl *id,
317-
struct nvmet_subsys *subsys)
316+
static u16 nvmet_set_model_number(struct nvmet_subsys *subsys)
318317
{
319-
const char *model = NVMET_DEFAULT_CTRL_MODEL;
320-
struct nvmet_subsys_model *subsys_model;
318+
u16 status = 0;
319+
320+
mutex_lock(&subsys->lock);
321+
if (!subsys->model_number) {
322+
subsys->model_number =
323+
kstrdup(NVMET_DEFAULT_CTRL_MODEL, GFP_KERNEL);
324+
if (!subsys->model_number)
325+
status = NVME_SC_INTERNAL;
326+
}
327+
mutex_unlock(&subsys->lock);
321328

322-
rcu_read_lock();
323-
subsys_model = rcu_dereference(subsys->model);
324-
if (subsys_model)
325-
model = subsys_model->number;
326-
memcpy_and_pad(id->mn, sizeof(id->mn), model, strlen(model), ' ');
327-
rcu_read_unlock();
329+
return status;
328330
}
329331

330332
static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
331333
{
332334
struct nvmet_ctrl *ctrl = req->sq->ctrl;
335+
struct nvmet_subsys *subsys = ctrl->subsys;
333336
struct nvme_id_ctrl *id;
334337
u32 cmd_capsule_size;
335338
u16 status = 0;
336339

340+
/*
341+
* If there is no model number yet, set it now. It will then remain
342+
* stable for the life time of the subsystem.
343+
*/
344+
if (!subsys->model_number) {
345+
status = nvmet_set_model_number(subsys);
346+
if (status)
347+
goto out;
348+
}
349+
337350
id = kzalloc(sizeof(*id), GFP_KERNEL);
338351
if (!id) {
339352
status = NVME_SC_INTERNAL;
@@ -347,7 +360,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
347360
memset(id->sn, ' ', sizeof(id->sn));
348361
bin2hex(id->sn, &ctrl->subsys->serial,
349362
min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2));
350-
nvmet_id_set_model_number(id, ctrl->subsys);
363+
memcpy_and_pad(id->mn, sizeof(id->mn), subsys->model_number,
364+
strlen(subsys->model_number), ' ');
351365
memcpy_and_pad(id->fr, sizeof(id->fr),
352366
UTS_RELEASE, strlen(UTS_RELEASE), ' ');
353367

drivers/nvme/target/configfs.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,16 +1118,12 @@ static ssize_t nvmet_subsys_attr_model_show(struct config_item *item,
11181118
char *page)
11191119
{
11201120
struct nvmet_subsys *subsys = to_subsys(item);
1121-
struct nvmet_subsys_model *subsys_model;
1122-
char *model = NVMET_DEFAULT_CTRL_MODEL;
11231121
int ret;
11241122

1125-
rcu_read_lock();
1126-
subsys_model = rcu_dereference(subsys->model);
1127-
if (subsys_model)
1128-
model = subsys_model->number;
1129-
ret = snprintf(page, PAGE_SIZE, "%s\n", model);
1130-
rcu_read_unlock();
1123+
mutex_lock(&subsys->lock);
1124+
ret = snprintf(page, PAGE_SIZE, "%s\n", subsys->model_number ?
1125+
subsys->model_number : NVMET_DEFAULT_CTRL_MODEL);
1126+
mutex_unlock(&subsys->lock);
11311127

11321128
return ret;
11331129
}
@@ -1138,14 +1134,17 @@ static bool nvmet_is_ascii(const char c)
11381134
return c >= 0x20 && c <= 0x7e;
11391135
}
11401136

1141-
static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
1142-
const char *page, size_t count)
1137+
static ssize_t nvmet_subsys_attr_model_store_locked(struct nvmet_subsys *subsys,
1138+
const char *page, size_t count)
11431139
{
1144-
struct nvmet_subsys *subsys = to_subsys(item);
1145-
struct nvmet_subsys_model *new_model;
1146-
char *new_model_number;
11471140
int pos = 0, len;
11481141

1142+
if (subsys->model_number) {
1143+
pr_err("Can't set model number. %s is already assigned\n",
1144+
subsys->model_number);
1145+
return -EINVAL;
1146+
}
1147+
11491148
len = strcspn(page, "\n");
11501149
if (!len)
11511150
return -EINVAL;
@@ -1155,28 +1154,25 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
11551154
return -EINVAL;
11561155
}
11571156

1158-
new_model_number = kmemdup_nul(page, len, GFP_KERNEL);
1159-
if (!new_model_number)
1157+
subsys->model_number = kmemdup_nul(page, len, GFP_KERNEL);
1158+
if (!subsys->model_number)
11601159
return -ENOMEM;
1160+
return count;
1161+
}
11611162

1162-
new_model = kzalloc(sizeof(*new_model) + len + 1, GFP_KERNEL);
1163-
if (!new_model) {
1164-
kfree(new_model_number);
1165-
return -ENOMEM;
1166-
}
1167-
memcpy(new_model->number, new_model_number, len);
1163+
static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
1164+
const char *page, size_t count)
1165+
{
1166+
struct nvmet_subsys *subsys = to_subsys(item);
1167+
ssize_t ret;
11681168

11691169
down_write(&nvmet_config_sem);
11701170
mutex_lock(&subsys->lock);
1171-
new_model = rcu_replace_pointer(subsys->model, new_model,
1172-
mutex_is_locked(&subsys->lock));
1171+
ret = nvmet_subsys_attr_model_store_locked(subsys, page, count);
11731172
mutex_unlock(&subsys->lock);
11741173
up_write(&nvmet_config_sem);
11751174

1176-
kfree_rcu(new_model, rcuhead);
1177-
kfree(new_model_number);
1178-
1179-
return count;
1175+
return ret;
11801176
}
11811177
CONFIGFS_ATTR(nvmet_subsys_, attr_model);
11821178

drivers/nvme/target/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ static void nvmet_subsys_free(struct kref *ref)
15321532
nvmet_passthru_subsys_free(subsys);
15331533

15341534
kfree(subsys->subsysnqn);
1535-
kfree_rcu(subsys->model, rcuhead);
1535+
kfree(subsys->model_number);
15361536
kfree(subsys);
15371537
}
15381538

drivers/nvme/target/nvmet.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,6 @@ struct nvmet_ctrl {
208208
bool pi_support;
209209
};
210210

211-
struct nvmet_subsys_model {
212-
struct rcu_head rcuhead;
213-
char number[];
214-
};
215-
216211
struct nvmet_subsys {
217212
enum nvme_subsys_type type;
218213

@@ -242,7 +237,7 @@ struct nvmet_subsys {
242237
struct config_group namespaces_group;
243238
struct config_group allowed_hosts_group;
244239

245-
struct nvmet_subsys_model __rcu *model;
240+
char *model_number;
246241

247242
#ifdef CONFIG_NVME_TARGET_PASSTHRU
248243
struct nvme_ctrl *passthru_ctrl;

include/linux/blkdev.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ typedef void (rq_end_io_fn)(struct request *, blk_status_t);
6565
* request flags */
6666
typedef __u32 __bitwise req_flags_t;
6767

68-
/* elevator knows about this request */
69-
#define RQF_SORTED ((__force req_flags_t)(1 << 0))
7068
/* drive already may have started this one */
7169
#define RQF_STARTED ((__force req_flags_t)(1 << 1))
7270
/* may not be passed by ioscheduler */

0 commit comments

Comments
 (0)