Skip to content

Commit 91a2620

Browse files
committed
Merge tag 'for-linus-20180309' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - a xen-blkfront fix from Bhavesh with a multiqueue fix when detaching/re-attaching - a few important NVMe fixes, including a revert for a sysfs fix that caused some user space confusion - two bcache fixes by way of Michael Lyle - a loop regression fix, fixing an issue with lost writes on DAX. * tag 'for-linus-20180309' of git://git.kernel.dk/linux-block: loop: Fix lost writes caused by missing flag nvme_fc: rework sqsize handling nvme-fabrics: Ignore nr_io_queues option for discovery controllers xen-blkfront: move negotiate_mq to cover all cases of new VBDs Revert "nvme: create 'slaves' and 'holders' entries for hidden controllers" bcache: don't attach backing with duplicate UUID bcache: fix crashes in duplicate cache device register nvme: pci: pass max vectors as num_possible_cpus() to pci_alloc_irq_vectors nvme-pci: Fix EEH failure on ppc
2 parents b3b25b1 + 1d03757 commit 91a2620

File tree

9 files changed

+60
-73
lines changed

9 files changed

+60
-73
lines changed

drivers/block/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
266266
struct iov_iter i;
267267
ssize_t bw;
268268

269-
iov_iter_bvec(&i, ITER_BVEC, bvec, 1, bvec->bv_len);
269+
iov_iter_bvec(&i, ITER_BVEC | WRITE, bvec, 1, bvec->bv_len);
270270

271271
file_start_write(file);
272272
bw = vfs_iter_write(file, &i, ppos, 0);

drivers/block/xen-blkfront.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ static DEFINE_SPINLOCK(minor_lock);
262262

263263
static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo);
264264
static void blkfront_gather_backend_features(struct blkfront_info *info);
265+
static int negotiate_mq(struct blkfront_info *info);
265266

266267
static int get_id_from_freelist(struct blkfront_ring_info *rinfo)
267268
{
@@ -1774,11 +1775,18 @@ static int talk_to_blkback(struct xenbus_device *dev,
17741775
unsigned int i, max_page_order;
17751776
unsigned int ring_page_order;
17761777

1778+
if (!info)
1779+
return -ENODEV;
1780+
17771781
max_page_order = xenbus_read_unsigned(info->xbdev->otherend,
17781782
"max-ring-page-order", 0);
17791783
ring_page_order = min(xen_blkif_max_ring_order, max_page_order);
17801784
info->nr_ring_pages = 1 << ring_page_order;
17811785

1786+
err = negotiate_mq(info);
1787+
if (err)
1788+
goto destroy_blkring;
1789+
17821790
for (i = 0; i < info->nr_rings; i++) {
17831791
struct blkfront_ring_info *rinfo = &info->rinfo[i];
17841792

@@ -1978,11 +1986,6 @@ static int blkfront_probe(struct xenbus_device *dev,
19781986
}
19791987

19801988
info->xbdev = dev;
1981-
err = negotiate_mq(info);
1982-
if (err) {
1983-
kfree(info);
1984-
return err;
1985-
}
19861989

19871990
mutex_init(&info->mutex);
19881991
info->vdevice = vdevice;
@@ -2099,10 +2102,6 @@ static int blkfront_resume(struct xenbus_device *dev)
20992102

21002103
blkif_free(info, info->connected == BLKIF_STATE_CONNECTED);
21012104

2102-
err = negotiate_mq(info);
2103-
if (err)
2104-
return err;
2105-
21062105
err = talk_to_blkback(dev, info);
21072106
if (!err)
21082107
blk_mq_update_nr_hw_queues(&info->tag_set, info->nr_rings);

drivers/md/bcache/super.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
963963
uint32_t rtime = cpu_to_le32(get_seconds());
964964
struct uuid_entry *u;
965965
char buf[BDEVNAME_SIZE];
966+
struct cached_dev *exist_dc, *t;
966967

967968
bdevname(dc->bdev, buf);
968969

@@ -987,6 +988,16 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
987988
return -EINVAL;
988989
}
989990

991+
/* Check whether already attached */
992+
list_for_each_entry_safe(exist_dc, t, &c->cached_devs, list) {
993+
if (!memcmp(dc->sb.uuid, exist_dc->sb.uuid, 16)) {
994+
pr_err("Tried to attach %s but duplicate UUID already attached",
995+
buf);
996+
997+
return -EINVAL;
998+
}
999+
}
1000+
9901001
u = uuid_find(c, dc->sb.uuid);
9911002

9921003
if (u &&
@@ -1204,7 +1215,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
12041215

12051216
return;
12061217
err:
1207-
pr_notice("error opening %s: %s", bdevname(bdev, name), err);
1218+
pr_notice("error %s: %s", bdevname(bdev, name), err);
12081219
bcache_device_stop(&dc->disk);
12091220
}
12101221

@@ -1883,6 +1894,8 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
18831894
const char *err = NULL; /* must be set for any error case */
18841895
int ret = 0;
18851896

1897+
bdevname(bdev, name);
1898+
18861899
memcpy(&ca->sb, sb, sizeof(struct cache_sb));
18871900
ca->bdev = bdev;
18881901
ca->bdev->bd_holder = ca;
@@ -1891,11 +1904,12 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
18911904
bio_first_bvec_all(&ca->sb_bio)->bv_page = sb_page;
18921905
get_page(sb_page);
18931906

1894-
if (blk_queue_discard(bdev_get_queue(ca->bdev)))
1907+
if (blk_queue_discard(bdev_get_queue(bdev)))
18951908
ca->discard = CACHE_DISCARD(&ca->sb);
18961909

18971910
ret = cache_alloc(ca);
18981911
if (ret != 0) {
1912+
blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
18991913
if (ret == -ENOMEM)
19001914
err = "cache_alloc(): -ENOMEM";
19011915
else
@@ -1918,14 +1932,14 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
19181932
goto out;
19191933
}
19201934

1921-
pr_info("registered cache device %s", bdevname(bdev, name));
1935+
pr_info("registered cache device %s", name);
19221936

19231937
out:
19241938
kobject_put(&ca->kobj);
19251939

19261940
err:
19271941
if (err)
1928-
pr_notice("error opening %s: %s", bdevname(bdev, name), err);
1942+
pr_notice("error %s: %s", name, err);
19291943

19301944
return ret;
19311945
}
@@ -2014,6 +2028,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
20142028
if (err)
20152029
goto err_close;
20162030

2031+
err = "failed to register device";
20172032
if (SB_IS_BDEV(sb)) {
20182033
struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
20192034
if (!dc)
@@ -2028,7 +2043,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
20282043
goto err_close;
20292044

20302045
if (register_cache(sb, sb_page, bdev, ca) != 0)
2031-
goto err_close;
2046+
goto err;
20322047
}
20332048
out:
20342049
if (sb_page)
@@ -2041,7 +2056,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
20412056
err_close:
20422057
blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
20432058
err:
2044-
pr_info("error opening %s: %s", path, err);
2059+
pr_info("error %s: %s", path, err);
20452060
ret = -EINVAL;
20462061
goto out;
20472062
}

drivers/nvme/host/core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
30333033
ns->disk->disk_name);
30343034

30353035
nvme_mpath_add_disk(ns->head);
3036-
nvme_mpath_add_disk_links(ns);
30373036
return;
30383037
out_unlink_ns:
30393038
mutex_lock(&ctrl->subsys->lock);
@@ -3053,7 +3052,6 @@ static void nvme_ns_remove(struct nvme_ns *ns)
30533052
return;
30543053

30553054
if (ns->disk && ns->disk->flags & GENHD_FL_UP) {
3056-
nvme_mpath_remove_disk_links(ns);
30573055
sysfs_remove_group(&disk_to_dev(ns->disk)->kobj,
30583056
&nvme_ns_id_attr_group);
30593057
if (ns->ndev)

drivers/nvme/host/fabrics.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
650650
ret = -EINVAL;
651651
goto out;
652652
}
653+
if (opts->discovery_nqn) {
654+
pr_debug("Ignoring nr_io_queues value for discovery controller\n");
655+
break;
656+
}
657+
653658
opts->nr_io_queues = min_t(unsigned int,
654659
num_online_cpus(), token);
655660
break;

drivers/nvme/host/fc.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
12061206
sizeof(struct fcnvme_lsdesc_cr_assoc_cmd));
12071207

12081208
assoc_rqst->assoc_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
1209-
assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
1209+
assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize - 1);
12101210
/* Linux supports only Dynamic controllers */
12111211
assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
12121212
uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
@@ -1321,7 +1321,7 @@ nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
13211321
sizeof(struct fcnvme_lsdesc_cr_conn_cmd));
13221322
conn_rqst->connect_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
13231323
conn_rqst->connect_cmd.qid = cpu_to_be16(queue->qnum);
1324-
conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize);
1324+
conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize - 1);
13251325

13261326
lsop->queue = queue;
13271327
lsreq->rqstaddr = conn_rqst;
@@ -2481,11 +2481,11 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
24812481
goto out_free_tag_set;
24822482
}
24832483

2484-
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2484+
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
24852485
if (ret)
24862486
goto out_cleanup_blk_queue;
24872487

2488-
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2488+
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
24892489
if (ret)
24902490
goto out_delete_hw_queues;
24912491

@@ -2532,11 +2532,11 @@ nvme_fc_reinit_io_queues(struct nvme_fc_ctrl *ctrl)
25322532
if (ret)
25332533
goto out_free_io_queues;
25342534

2535-
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2535+
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
25362536
if (ret)
25372537
goto out_free_io_queues;
25382538

2539-
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2539+
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
25402540
if (ret)
25412541
goto out_delete_hw_queues;
25422542

@@ -2632,13 +2632,12 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
26322632
nvme_fc_init_queue(ctrl, 0);
26332633

26342634
ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0,
2635-
NVME_AQ_BLK_MQ_DEPTH);
2635+
NVME_AQ_DEPTH);
26362636
if (ret)
26372637
goto out_free_queue;
26382638

26392639
ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0],
2640-
NVME_AQ_BLK_MQ_DEPTH,
2641-
(NVME_AQ_BLK_MQ_DEPTH / 4));
2640+
NVME_AQ_DEPTH, (NVME_AQ_DEPTH / 4));
26422641
if (ret)
26432642
goto out_delete_hw_queue;
26442643

@@ -2666,7 +2665,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
26662665
}
26672666

26682667
ctrl->ctrl.sqsize =
2669-
min_t(int, NVME_CAP_MQES(ctrl->ctrl.cap) + 1, ctrl->ctrl.sqsize);
2668+
min_t(int, NVME_CAP_MQES(ctrl->ctrl.cap), ctrl->ctrl.sqsize);
26702669

26712670
ret = nvme_enable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap);
26722671
if (ret)
@@ -2699,6 +2698,14 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
26992698
opts->queue_size = ctrl->ctrl.maxcmd;
27002699
}
27012700

2701+
if (opts->queue_size > ctrl->ctrl.sqsize + 1) {
2702+
/* warn if sqsize is lower than queue_size */
2703+
dev_warn(ctrl->ctrl.device,
2704+
"queue_size %zu > ctrl sqsize %u, clamping down\n",
2705+
opts->queue_size, ctrl->ctrl.sqsize + 1);
2706+
opts->queue_size = ctrl->ctrl.sqsize + 1;
2707+
}
2708+
27022709
ret = nvme_fc_init_aen_ops(ctrl);
27032710
if (ret)
27042711
goto out_term_aen_ops;

drivers/nvme/host/multipath.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,6 @@ void nvme_mpath_add_disk(struct nvme_ns_head *head)
210210
mutex_unlock(&head->subsys->lock);
211211
}
212212

213-
void nvme_mpath_add_disk_links(struct nvme_ns *ns)
214-
{
215-
struct kobject *slave_disk_kobj, *holder_disk_kobj;
216-
217-
if (!ns->head->disk)
218-
return;
219-
220-
slave_disk_kobj = &disk_to_dev(ns->disk)->kobj;
221-
if (sysfs_create_link(ns->head->disk->slave_dir, slave_disk_kobj,
222-
kobject_name(slave_disk_kobj)))
223-
return;
224-
225-
holder_disk_kobj = &disk_to_dev(ns->head->disk)->kobj;
226-
if (sysfs_create_link(ns->disk->part0.holder_dir, holder_disk_kobj,
227-
kobject_name(holder_disk_kobj)))
228-
sysfs_remove_link(ns->head->disk->slave_dir,
229-
kobject_name(slave_disk_kobj));
230-
}
231-
232213
void nvme_mpath_remove_disk(struct nvme_ns_head *head)
233214
{
234215
if (!head->disk)
@@ -243,14 +224,3 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
243224
blk_cleanup_queue(head->disk->queue);
244225
put_disk(head->disk);
245226
}
246-
247-
void nvme_mpath_remove_disk_links(struct nvme_ns *ns)
248-
{
249-
if (!ns->head->disk)
250-
return;
251-
252-
sysfs_remove_link(ns->disk->part0.holder_dir,
253-
kobject_name(&disk_to_dev(ns->head->disk)->kobj));
254-
sysfs_remove_link(ns->head->disk->slave_dir,
255-
kobject_name(&disk_to_dev(ns->disk)->kobj));
256-
}

drivers/nvme/host/nvme.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ bool nvme_req_needs_failover(struct request *req, blk_status_t error);
410410
void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
411411
int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
412412
void nvme_mpath_add_disk(struct nvme_ns_head *head);
413-
void nvme_mpath_add_disk_links(struct nvme_ns *ns);
414413
void nvme_mpath_remove_disk(struct nvme_ns_head *head);
415-
void nvme_mpath_remove_disk_links(struct nvme_ns *ns);
416414

417415
static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
418416
{
@@ -454,12 +452,6 @@ static inline void nvme_mpath_add_disk(struct nvme_ns_head *head)
454452
static inline void nvme_mpath_remove_disk(struct nvme_ns_head *head)
455453
{
456454
}
457-
static inline void nvme_mpath_add_disk_links(struct nvme_ns *ns)
458-
{
459-
}
460-
static inline void nvme_mpath_remove_disk_links(struct nvme_ns *ns)
461-
{
462-
}
463455
static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
464456
{
465457
}

drivers/nvme/host/pci.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,12 +1153,6 @@ static bool nvme_should_reset(struct nvme_dev *dev, u32 csts)
11531153
if (!(csts & NVME_CSTS_CFS) && !nssro)
11541154
return false;
11551155

1156-
/* If PCI error recovery process is happening, we cannot reset or
1157-
* the recovery mechanism will surely fail.
1158-
*/
1159-
if (pci_channel_offline(to_pci_dev(dev->dev)))
1160-
return false;
1161-
11621156
return true;
11631157
}
11641158

@@ -1189,6 +1183,13 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
11891183
struct nvme_command cmd;
11901184
u32 csts = readl(dev->bar + NVME_REG_CSTS);
11911185

1186+
/* If PCI error recovery process is happening, we cannot reset or
1187+
* the recovery mechanism will surely fail.
1188+
*/
1189+
mb();
1190+
if (pci_channel_offline(to_pci_dev(dev->dev)))
1191+
return BLK_EH_RESET_TIMER;
1192+
11921193
/*
11931194
* Reset immediately if the controller is failed
11941195
*/
@@ -1913,7 +1914,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
19131914
int result, nr_io_queues;
19141915
unsigned long size;
19151916

1916-
nr_io_queues = num_present_cpus();
1917+
nr_io_queues = num_possible_cpus();
19171918
result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues);
19181919
if (result < 0)
19191920
return result;

0 commit comments

Comments
 (0)