Skip to content

Commit ab2a7a3

Browse files
committed
Merge tag 'block-5.15-2021-10-01' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "A few block fixes for this release: - Revert a BFQ commit that causes breakage for people. Unfortunately it was auto-selected for stable as well, so now 5.14.7 suffers from it too. Hopefully stable will pick up this revert quickly too, so we can remove the issue on that end as well. - Add a quirk for Apple NVMe controllers, which due to their non-compliance broke due to the introduction of command sequences (Keith) - Use shifts in nbd, fixing a __divdi3 issue (Nick)" * tag 'block-5.15-2021-10-01' of git://git.kernel.dk/linux-block: nbd: use shifts rather than multiplies Revert "block, bfq: honor already-setup queue merges" nvme: add command id quirk for apple controllers
2 parents 65893b4 + 41e76c6 commit ab2a7a3

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

block/bfq-iosched.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,15 +2662,6 @@ bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq)
26622662
* are likely to increase the throughput.
26632663
*/
26642664
bfqq->new_bfqq = new_bfqq;
2665-
/*
2666-
* The above assignment schedules the following redirections:
2667-
* each time some I/O for bfqq arrives, the process that
2668-
* generated that I/O is disassociated from bfqq and
2669-
* associated with new_bfqq. Here we increases new_bfqq->ref
2670-
* in advance, adding the number of processes that are
2671-
* expected to be associated with new_bfqq as they happen to
2672-
* issue I/O.
2673-
*/
26742665
new_bfqq->ref += process_refs;
26752666
return new_bfqq;
26762667
}
@@ -2733,10 +2724,6 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
27332724
{
27342725
struct bfq_queue *in_service_bfqq, *new_bfqq;
27352726

2736-
/* if a merge has already been setup, then proceed with that first */
2737-
if (bfqq->new_bfqq)
2738-
return bfqq->new_bfqq;
2739-
27402727
/*
27412728
* Check delayed stable merge for rotational or non-queueing
27422729
* devs. For this branch to be executed, bfqq must not be
@@ -2838,6 +2825,9 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq,
28382825
if (bfq_too_late_for_merging(bfqq))
28392826
return NULL;
28402827

2828+
if (bfqq->new_bfqq)
2829+
return bfqq->new_bfqq;
2830+
28412831
if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq))
28422832
return NULL;
28432833

drivers/block/nbd.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,18 @@ struct nbd_config {
9797

9898
atomic_t recv_threads;
9999
wait_queue_head_t recv_wq;
100-
loff_t blksize;
100+
unsigned int blksize_bits;
101101
loff_t bytesize;
102102
#if IS_ENABLED(CONFIG_DEBUG_FS)
103103
struct dentry *dbg_dir;
104104
#endif
105105
};
106106

107+
static inline unsigned int nbd_blksize(struct nbd_config *config)
108+
{
109+
return 1u << config->blksize_bits;
110+
}
111+
107112
struct nbd_device {
108113
struct blk_mq_tag_set tag_set;
109114

@@ -146,7 +151,7 @@ static struct dentry *nbd_dbg_dir;
146151

147152
#define NBD_MAGIC 0x68797548
148153

149-
#define NBD_DEF_BLKSIZE 1024
154+
#define NBD_DEF_BLKSIZE_BITS 10
150155

151156
static unsigned int nbds_max = 16;
152157
static int max_part = 16;
@@ -317,12 +322,12 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
317322
loff_t blksize)
318323
{
319324
if (!blksize)
320-
blksize = NBD_DEF_BLKSIZE;
325+
blksize = 1u << NBD_DEF_BLKSIZE_BITS;
321326
if (blksize < 512 || blksize > PAGE_SIZE || !is_power_of_2(blksize))
322327
return -EINVAL;
323328

324329
nbd->config->bytesize = bytesize;
325-
nbd->config->blksize = blksize;
330+
nbd->config->blksize_bits = __ffs(blksize);
326331

327332
if (!nbd->task_recv)
328333
return 0;
@@ -1337,7 +1342,7 @@ static int nbd_start_device(struct nbd_device *nbd)
13371342
args->index = i;
13381343
queue_work(nbd->recv_workq, &args->work);
13391344
}
1340-
return nbd_set_size(nbd, config->bytesize, config->blksize);
1345+
return nbd_set_size(nbd, config->bytesize, nbd_blksize(config));
13411346
}
13421347

13431348
static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev)
@@ -1406,11 +1411,11 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
14061411
case NBD_SET_BLKSIZE:
14071412
return nbd_set_size(nbd, config->bytesize, arg);
14081413
case NBD_SET_SIZE:
1409-
return nbd_set_size(nbd, arg, config->blksize);
1414+
return nbd_set_size(nbd, arg, nbd_blksize(config));
14101415
case NBD_SET_SIZE_BLOCKS:
1411-
if (check_mul_overflow((loff_t)arg, config->blksize, &bytesize))
1416+
if (check_shl_overflow(arg, config->blksize_bits, &bytesize))
14121417
return -EINVAL;
1413-
return nbd_set_size(nbd, bytesize, config->blksize);
1418+
return nbd_set_size(nbd, bytesize, nbd_blksize(config));
14141419
case NBD_SET_TIMEOUT:
14151420
nbd_set_cmd_timeout(nbd, arg);
14161421
return 0;
@@ -1476,7 +1481,7 @@ static struct nbd_config *nbd_alloc_config(void)
14761481
atomic_set(&config->recv_threads, 0);
14771482
init_waitqueue_head(&config->recv_wq);
14781483
init_waitqueue_head(&config->conn_wait);
1479-
config->blksize = NBD_DEF_BLKSIZE;
1484+
config->blksize_bits = NBD_DEF_BLKSIZE_BITS;
14801485
atomic_set(&config->live_connections, 0);
14811486
try_module_get(THIS_MODULE);
14821487
return config;
@@ -1604,7 +1609,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd)
16041609
debugfs_create_file("tasks", 0444, dir, nbd, &nbd_dbg_tasks_fops);
16051610
debugfs_create_u64("size_bytes", 0444, dir, &config->bytesize);
16061611
debugfs_create_u32("timeout", 0444, dir, &nbd->tag_set.timeout);
1607-
debugfs_create_u64("blocksize", 0444, dir, &config->blksize);
1612+
debugfs_create_u32("blocksize_bits", 0444, dir, &config->blksize_bits);
16081613
debugfs_create_file("flags", 0444, dir, nbd, &nbd_dbg_flags_fops);
16091614

16101615
return 0;
@@ -1826,7 +1831,7 @@ nbd_device_policy[NBD_DEVICE_ATTR_MAX + 1] = {
18261831
static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd)
18271832
{
18281833
struct nbd_config *config = nbd->config;
1829-
u64 bsize = config->blksize;
1834+
u64 bsize = nbd_blksize(config);
18301835
u64 bytes = config->bytesize;
18311836

18321837
if (info->attrs[NBD_ATTR_SIZE_BYTES])
@@ -1835,7 +1840,7 @@ static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd)
18351840
if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES])
18361841
bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
18371842

1838-
if (bytes != config->bytesize || bsize != config->blksize)
1843+
if (bytes != config->bytesize || bsize != nbd_blksize(config))
18391844
return nbd_set_size(nbd, bytes, bsize);
18401845
return 0;
18411846
}

drivers/nvme/host/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ EXPORT_SYMBOL_GPL(nvme_cleanup_cmd);
978978
blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
979979
{
980980
struct nvme_command *cmd = nvme_req(req)->cmd;
981+
struct nvme_ctrl *ctrl = nvme_req(req)->ctrl;
981982
blk_status_t ret = BLK_STS_OK;
982983

983984
if (!(req->rq_flags & RQF_DONTPREP)) {
@@ -1026,7 +1027,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
10261027
return BLK_STS_IOERR;
10271028
}
10281029

1029-
nvme_req(req)->genctr++;
1030+
if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN))
1031+
nvme_req(req)->genctr++;
10301032
cmd->common.command_id = nvme_cid(req);
10311033
trace_nvme_setup_cmd(req, cmd);
10321034
return ret;

drivers/nvme/host/nvme.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ enum nvme_quirks {
138138
* 48 bits.
139139
*/
140140
NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16),
141+
142+
/*
143+
* The controller requires the command_id value be be limited, so skip
144+
* encoding the generation sequence number.
145+
*/
146+
NVME_QUIRK_SKIP_CID_GEN = (1 << 17),
141147
};
142148

143149
/*

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,8 @@ static const struct pci_device_id nvme_id_table[] = {
33693369
{ PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005),
33703370
.driver_data = NVME_QUIRK_SINGLE_VECTOR |
33713371
NVME_QUIRK_128_BYTES_SQES |
3372-
NVME_QUIRK_SHARED_TAGS },
3372+
NVME_QUIRK_SHARED_TAGS |
3373+
NVME_QUIRK_SKIP_CID_GEN },
33733374

33743375
{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
33753376
{ 0, }

0 commit comments

Comments
 (0)