Skip to content

Commit 0fa8dc4

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "A small collection of fixes that should go into this series. This contains: - NVMe pull request from Christoph, with various fixes for nvme proper and nvme-fc. - disable runtime PM for blk-mq for now. With scsi now defaulting to using blk-mq, this reared its head as an issue. Longer term we'll fix up runtime PM for blk-mq, for now just disable it to prevent a hang on laptop resume for some folks. - blk-mq CPU <-> hw queue map fix from Christoph. - xen/blkfront pull request from Konrad, with two small fixes for the blkfront driver. - a few fixups for nbd from Joseph. - a stable fix for pblk from Javier" * 'for-linus' of git://git.kernel.dk/linux-block: lightnvm: pblk: advance bio according to lba index nvme: validate admin queue before unquiesce nbd: clear disconnected on reconnect nvme-pci: fix HMB size calculation nvme-fc: revise TRADDR parsing nvme-fc: address target disconnect race conditions in fcp io submit nvme: fabrics commands should use the fctype field for data direction nvme: also provide a UUID in the WWID sysfs attribute xen/blkfront: always allocate grants first from per-queue persistent grants xen-blkfront: fix mq start/stop race blk-mq: map queues to all present CPUs block: disable runtime-pm for blk-mq xen-blkfront: Fix handling of non-supported operations nbd: only set sndtimeo if we have a timeout set nbd: take tx_lock before disconnecting nbd: allow multiple disconnects to be sent
2 parents a2d4875 + 75cb8e9 commit 0fa8dc4

File tree

13 files changed

+197
-138
lines changed

13 files changed

+197
-138
lines changed

block/blk-core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,6 +3421,10 @@ EXPORT_SYMBOL(blk_finish_plug);
34213421
*/
34223422
void blk_pm_runtime_init(struct request_queue *q, struct device *dev)
34233423
{
3424+
/* not support for RQF_PM and ->rpm_status in blk-mq yet */
3425+
if (q->mq_ops)
3426+
return;
3427+
34243428
q->dev = dev;
34253429
q->rpm_status = RPM_ACTIVE;
34263430
pm_runtime_set_autosuspend_delay(q->dev, -1);

block/blk-mq-cpumap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
static int cpu_to_queue_index(unsigned int nr_queues, const int cpu)
1818
{
1919
/*
20-
* Non online CPU will be mapped to queue index 0.
20+
* Non present CPU will be mapped to queue index 0.
2121
*/
22-
if (!cpu_online(cpu))
22+
if (!cpu_present(cpu))
2323
return 0;
2424
return cpu % nr_queues;
2525
}

drivers/block/nbd.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,8 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
908908
continue;
909909
}
910910
sk_set_memalloc(sock->sk);
911-
sock->sk->sk_sndtimeo = nbd->tag_set.timeout;
911+
if (nbd->tag_set.timeout)
912+
sock->sk->sk_sndtimeo = nbd->tag_set.timeout;
912913
atomic_inc(&config->recv_threads);
913914
refcount_inc(&nbd->config_refs);
914915
old = nsock->sock;
@@ -922,6 +923,8 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
922923
mutex_unlock(&nsock->tx_lock);
923924
sockfd_put(old);
924925

926+
clear_bit(NBD_DISCONNECTED, &config->runtime_flags);
927+
925928
/* We take the tx_mutex in an error path in the recv_work, so we
926929
* need to queue_work outside of the tx_mutex.
927930
*/
@@ -978,11 +981,15 @@ static void send_disconnects(struct nbd_device *nbd)
978981
int i, ret;
979982

980983
for (i = 0; i < config->num_connections; i++) {
984+
struct nbd_sock *nsock = config->socks[i];
985+
981986
iov_iter_kvec(&from, WRITE | ITER_KVEC, &iov, 1, sizeof(request));
987+
mutex_lock(&nsock->tx_lock);
982988
ret = sock_xmit(nbd, i, 1, &from, 0, NULL);
983989
if (ret <= 0)
984990
dev_err(disk_to_dev(nbd->disk),
985991
"Send disconnect failed %d\n", ret);
992+
mutex_unlock(&nsock->tx_lock);
986993
}
987994
}
988995

@@ -991,9 +998,8 @@ static int nbd_disconnect(struct nbd_device *nbd)
991998
struct nbd_config *config = nbd->config;
992999

9931000
dev_info(disk_to_dev(nbd->disk), "NBD_DISCONNECT\n");
994-
if (!test_and_set_bit(NBD_DISCONNECT_REQUESTED,
995-
&config->runtime_flags))
996-
send_disconnects(nbd);
1001+
set_bit(NBD_DISCONNECT_REQUESTED, &config->runtime_flags);
1002+
send_disconnects(nbd);
9971003
return 0;
9981004
}
9991005

@@ -1074,7 +1080,9 @@ static int nbd_start_device(struct nbd_device *nbd)
10741080
return -ENOMEM;
10751081
}
10761082
sk_set_memalloc(config->socks[i]->sock->sk);
1077-
config->socks[i]->sock->sk->sk_sndtimeo = nbd->tag_set.timeout;
1083+
if (nbd->tag_set.timeout)
1084+
config->socks[i]->sock->sk->sk_sndtimeo =
1085+
nbd->tag_set.timeout;
10781086
atomic_inc(&config->recv_threads);
10791087
refcount_inc(&nbd->config_refs);
10801088
INIT_WORK(&args->work, recv_work);

drivers/block/xen-blkfront.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct blk_shadow {
111111
};
112112

113113
struct blkif_req {
114-
int error;
114+
blk_status_t error;
115115
};
116116

117117
static inline struct blkif_req *blkif_req(struct request *rq)
@@ -708,6 +708,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
708708
* existing persistent grants, or if we have to get new grants,
709709
* as there are not sufficiently many free.
710710
*/
711+
bool new_persistent_gnts = false;
711712
struct scatterlist *sg;
712713
int num_sg, max_grefs, num_grant;
713714

@@ -719,19 +720,21 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
719720
*/
720721
max_grefs += INDIRECT_GREFS(max_grefs);
721722

722-
/*
723-
* We have to reserve 'max_grefs' grants because persistent
724-
* grants are shared by all rings.
725-
*/
726-
if (max_grefs > 0)
727-
if (gnttab_alloc_grant_references(max_grefs, &setup.gref_head) < 0) {
723+
/* Check if we have enough persistent grants to allocate a requests */
724+
if (rinfo->persistent_gnts_c < max_grefs) {
725+
new_persistent_gnts = true;
726+
727+
if (gnttab_alloc_grant_references(
728+
max_grefs - rinfo->persistent_gnts_c,
729+
&setup.gref_head) < 0) {
728730
gnttab_request_free_callback(
729731
&rinfo->callback,
730732
blkif_restart_queue_callback,
731733
rinfo,
732-
max_grefs);
734+
max_grefs - rinfo->persistent_gnts_c);
733735
return 1;
734736
}
737+
}
735738

736739
/* Fill out a communications ring structure. */
737740
id = blkif_ring_get_request(rinfo, req, &ring_req);
@@ -832,7 +835,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
832835
if (unlikely(require_extra_req))
833836
rinfo->shadow[extra_id].req = *extra_ring_req;
834837

835-
if (max_grefs > 0)
838+
if (new_persistent_gnts)
836839
gnttab_free_grant_references(setup.gref_head);
837840

838841
return 0;
@@ -906,8 +909,8 @@ static blk_status_t blkif_queue_rq(struct blk_mq_hw_ctx *hctx,
906909
return BLK_STS_IOERR;
907910

908911
out_busy:
909-
spin_unlock_irqrestore(&rinfo->ring_lock, flags);
910912
blk_mq_stop_hw_queue(hctx);
913+
spin_unlock_irqrestore(&rinfo->ring_lock, flags);
911914
return BLK_STS_RESOURCE;
912915
}
913916

@@ -1616,7 +1619,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
16161619
if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
16171620
printk(KERN_WARNING "blkfront: %s: %s op failed\n",
16181621
info->gd->disk_name, op_name(bret->operation));
1619-
blkif_req(req)->error = -EOPNOTSUPP;
1622+
blkif_req(req)->error = BLK_STS_NOTSUPP;
16201623
}
16211624
if (unlikely(bret->status == BLKIF_RSP_ERROR &&
16221625
rinfo->shadow[id].req.u.rw.nr_segments == 0)) {

drivers/lightnvm/pblk-rb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ unsigned int pblk_rb_read_to_bio(struct pblk_rb *rb, struct nvm_rq *rqd,
657657
* be directed to disk.
658658
*/
659659
int pblk_rb_copy_to_bio(struct pblk_rb *rb, struct bio *bio, sector_t lba,
660-
struct ppa_addr ppa, int bio_iter)
660+
struct ppa_addr ppa, int bio_iter, bool advanced_bio)
661661
{
662662
struct pblk *pblk = container_of(rb, struct pblk, rwb);
663663
struct pblk_rb_entry *entry;
@@ -694,7 +694,7 @@ int pblk_rb_copy_to_bio(struct pblk_rb *rb, struct bio *bio, sector_t lba,
694694
* filled with data from the cache). If part of the data resides on the
695695
* media, we will read later on
696696
*/
697-
if (unlikely(!bio->bi_iter.bi_idx))
697+
if (unlikely(!advanced_bio))
698698
bio_advance(bio, bio_iter * PBLK_EXPOSED_PAGE_SIZE);
699699

700700
data = bio_data(bio);

drivers/lightnvm/pblk-read.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@
2626
*/
2727
static int pblk_read_from_cache(struct pblk *pblk, struct bio *bio,
2828
sector_t lba, struct ppa_addr ppa,
29-
int bio_iter)
29+
int bio_iter, bool advanced_bio)
3030
{
3131
#ifdef CONFIG_NVM_DEBUG
3232
/* Callers must ensure that the ppa points to a cache address */
3333
BUG_ON(pblk_ppa_empty(ppa));
3434
BUG_ON(!pblk_addr_in_cache(ppa));
3535
#endif
3636

37-
return pblk_rb_copy_to_bio(&pblk->rwb, bio, lba, ppa, bio_iter);
37+
return pblk_rb_copy_to_bio(&pblk->rwb, bio, lba, ppa,
38+
bio_iter, advanced_bio);
3839
}
3940

4041
static void pblk_read_ppalist_rq(struct pblk *pblk, struct nvm_rq *rqd,
@@ -44,7 +45,7 @@ static void pblk_read_ppalist_rq(struct pblk *pblk, struct nvm_rq *rqd,
4445
struct ppa_addr ppas[PBLK_MAX_REQ_ADDRS];
4546
sector_t blba = pblk_get_lba(bio);
4647
int nr_secs = rqd->nr_ppas;
47-
int advanced_bio = 0;
48+
bool advanced_bio = false;
4849
int i, j = 0;
4950

5051
/* logic error: lba out-of-bounds. Ignore read request */
@@ -62,19 +63,26 @@ static void pblk_read_ppalist_rq(struct pblk *pblk, struct nvm_rq *rqd,
6263
retry:
6364
if (pblk_ppa_empty(p)) {
6465
WARN_ON(test_and_set_bit(i, read_bitmap));
65-
continue;
66+
67+
if (unlikely(!advanced_bio)) {
68+
bio_advance(bio, (i) * PBLK_EXPOSED_PAGE_SIZE);
69+
advanced_bio = true;
70+
}
71+
72+
goto next;
6673
}
6774

6875
/* Try to read from write buffer. The address is later checked
6976
* on the write buffer to prevent retrieving overwritten data.
7077
*/
7178
if (pblk_addr_in_cache(p)) {
72-
if (!pblk_read_from_cache(pblk, bio, lba, p, i)) {
79+
if (!pblk_read_from_cache(pblk, bio, lba, p, i,
80+
advanced_bio)) {
7381
pblk_lookup_l2p_seq(pblk, &p, lba, 1);
7482
goto retry;
7583
}
7684
WARN_ON(test_and_set_bit(i, read_bitmap));
77-
advanced_bio = 1;
85+
advanced_bio = true;
7886
#ifdef CONFIG_NVM_DEBUG
7987
atomic_long_inc(&pblk->cache_reads);
8088
#endif
@@ -83,6 +91,7 @@ static void pblk_read_ppalist_rq(struct pblk *pblk, struct nvm_rq *rqd,
8391
rqd->ppa_list[j++] = p;
8492
}
8593

94+
next:
8695
if (advanced_bio)
8796
bio_advance(bio, PBLK_EXPOSED_PAGE_SIZE);
8897
}
@@ -282,7 +291,7 @@ static void pblk_read_rq(struct pblk *pblk, struct nvm_rq *rqd,
282291
* write buffer to prevent retrieving overwritten data.
283292
*/
284293
if (pblk_addr_in_cache(ppa)) {
285-
if (!pblk_read_from_cache(pblk, bio, lba, ppa, 0)) {
294+
if (!pblk_read_from_cache(pblk, bio, lba, ppa, 0, 1)) {
286295
pblk_lookup_l2p_seq(pblk, &ppa, lba, 1);
287296
goto retry;
288297
}

drivers/lightnvm/pblk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ unsigned int pblk_rb_read_to_bio_list(struct pblk_rb *rb, struct bio *bio,
670670
struct list_head *list,
671671
unsigned int max);
672672
int pblk_rb_copy_to_bio(struct pblk_rb *rb, struct bio *bio, sector_t lba,
673-
struct ppa_addr ppa, int bio_iter);
673+
struct ppa_addr ppa, int bio_iter, bool advanced_bio);
674674
unsigned int pblk_rb_read_commit(struct pblk_rb *rb, unsigned int entries);
675675

676676
unsigned int pblk_rb_sync_init(struct pblk_rb *rb, unsigned long *flags);

drivers/nvme/host/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,9 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
19951995
int serial_len = sizeof(ctrl->serial);
19961996
int model_len = sizeof(ctrl->model);
19971997

1998+
if (!uuid_is_null(&ns->uuid))
1999+
return sprintf(buf, "uuid.%pU\n", &ns->uuid);
2000+
19982001
if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
19992002
return sprintf(buf, "eui.%16phN\n", ns->nguid);
20002003

@@ -2709,7 +2712,8 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
27092712
mutex_lock(&ctrl->namespaces_mutex);
27102713

27112714
/* Forcibly unquiesce queues to avoid blocking dispatch */
2712-
blk_mq_unquiesce_queue(ctrl->admin_q);
2715+
if (ctrl->admin_q)
2716+
blk_mq_unquiesce_queue(ctrl->admin_q);
27132717

27142718
list_for_each_entry(ns, &ctrl->namespaces, list) {
27152719
/*

0 commit comments

Comments
 (0)