Skip to content

Commit b46beba

Browse files
committed
Merge branch 'for-5.18/drivers' into for-5.18/write-streams
* for-5.18/drivers: (51 commits) bcache: fixup multiple threads crash bcache: fixup bcache_dev_sectors_dirty_add() multithreaded CPU false sharing floppy: use memcpy_{to,from}_bvec drbd: use bvec_kmap_local in recv_dless_read drbd: use bvec_kmap_local in drbd_csum_bio bcache: use bvec_kmap_local in bio_csum nvdimm-btt: use bvec_kmap_local in btt_rw_integrity nvdimm-blk: use bvec_kmap_local in nd_blk_rw_integrity zram: use memcpy_from_bvec in zram_bvec_write zram: use memcpy_to_bvec in zram_bvec_read aoe: use bvec_kmap_local in bvcpy iss-simdisk: use bvec_kmap_local in simdisk_submit_bio nvme: check that EUI/GUID/UUID are globally unique nvme: check for duplicate identifiers earlier nvme: fix the check for duplicate unique identifiers nvme: cleanup __nvme_check_ids nvme: remove nssa from struct nvme_ctrl nvme: explicitly set non-error for directives nvme: expose cntrltype and dctype through sysfs nvme: send uevent on connection up ...
2 parents 13400b1 + a763706 commit b46beba

38 files changed

+635
-256
lines changed

arch/xtensa/platforms/iss/simdisk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ static void simdisk_submit_bio(struct bio *bio)
108108
sector_t sector = bio->bi_iter.bi_sector;
109109

110110
bio_for_each_segment(bvec, bio, iter) {
111-
char *buffer = kmap_atomic(bvec.bv_page) + bvec.bv_offset;
111+
char *buffer = bvec_kmap_local(&bvec);
112112
unsigned len = bvec.bv_len >> SECTOR_SHIFT;
113113

114114
simdisk_transfer(dev, sector, len, buffer,
115115
bio_data_dir(bio) == WRITE);
116116
sector += len;
117-
kunmap_atomic(buffer);
117+
kunmap_local(buffer);
118118
}
119119

120120
bio_endio(bio);

drivers/block/aoe/aoecmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,9 +1018,9 @@ bvcpy(struct sk_buff *skb, struct bio *bio, struct bvec_iter iter, long cnt)
10181018
iter.bi_size = cnt;
10191019

10201020
__bio_for_each_segment(bv, bio, iter, iter) {
1021-
char *p = kmap_atomic(bv.bv_page) + bv.bv_offset;
1021+
char *p = bvec_kmap_local(&bv);
10221022
skb_copy_bits(skb, soff, p, bv.bv_len);
1023-
kunmap_atomic(p);
1023+
kunmap_local(p);
10241024
soff += bv.bv_len;
10251025
}
10261026
}

drivers/block/drbd/drbd_receiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,10 +2017,10 @@ static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_req
20172017
D_ASSERT(peer_device->device, sector == bio->bi_iter.bi_sector);
20182018

20192019
bio_for_each_segment(bvec, bio, iter) {
2020-
void *mapped = kmap(bvec.bv_page) + bvec.bv_offset;
2020+
void *mapped = bvec_kmap_local(&bvec);
20212021
expect = min_t(int, data_size, bvec.bv_len);
20222022
err = drbd_recv_all_warn(peer_device->connection, mapped, expect);
2023-
kunmap(bvec.bv_page);
2023+
kunmap_local(mapped);
20242024
if (err)
20252025
return err;
20262026
data_size -= expect;

drivers/block/drbd/drbd_worker.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ void drbd_csum_bio(struct crypto_shash *tfm, struct bio *bio, void *digest)
326326
bio_for_each_segment(bvec, bio, iter) {
327327
u8 *src;
328328

329-
src = kmap_atomic(bvec.bv_page);
330-
crypto_shash_update(desc, src + bvec.bv_offset, bvec.bv_len);
331-
kunmap_atomic(src);
329+
src = bvec_kmap_local(&bvec);
330+
crypto_shash_update(desc, src, bvec.bv_len);
331+
kunmap_local(src);
332332

333333
/* REQ_OP_WRITE_SAME has only one segment,
334334
* checksum the payload only once. */

drivers/block/floppy.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,11 +2485,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
24852485
}
24862486

24872487
if (CT(raw_cmd->cmd[COMMAND]) == FD_READ)
2488-
memcpy_to_page(bv.bv_page, bv.bv_offset, dma_buffer,
2489-
size);
2488+
memcpy_to_bvec(&bv, dma_buffer);
24902489
else
2491-
memcpy_from_page(dma_buffer, bv.bv_page, bv.bv_offset,
2492-
size);
2490+
memcpy_from_bvec(dma_buffer, &bv);
24932491

24942492
remaining -= size;
24952493
dma_buffer += size;

drivers/block/loop.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include <linux/uaccess.h>
8787

8888
#define LOOP_IDLE_WORKER_TIMEOUT (60 * HZ)
89+
#define LOOP_DEFAULT_HW_Q_DEPTH (128)
8990

9091
static DEFINE_IDR(loop_index_idr);
9192
static DEFINE_MUTEX(loop_ctl_mutex);
@@ -309,12 +310,11 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos,
309310
* a.k.a. discard/zerorange.
310311
*/
311312
struct file *file = lo->lo_backing_file;
312-
struct request_queue *q = lo->lo_queue;
313313
int ret;
314314

315315
mode |= FALLOC_FL_KEEP_SIZE;
316316

317-
if (!blk_queue_discard(q)) {
317+
if (!blk_queue_discard(lo->lo_queue)) {
318318
ret = -EOPNOTSUPP;
319319
goto out;
320320
}
@@ -328,8 +328,7 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos,
328328

329329
static int lo_req_flush(struct loop_device *lo, struct request *rq)
330330
{
331-
struct file *file = lo->lo_backing_file;
332-
int ret = vfs_fsync(file, 0);
331+
int ret = vfs_fsync(lo->lo_backing_file, 0);
333332
if (unlikely(ret && ret != -EINVAL))
334333
ret = -EIO;
335334

@@ -681,33 +680,33 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
681680

682681
static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf)
683682
{
684-
return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_offset);
683+
return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_offset);
685684
}
686685

687686
static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf)
688687
{
689-
return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit);
688+
return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit);
690689
}
691690

692691
static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf)
693692
{
694693
int autoclear = (lo->lo_flags & LO_FLAGS_AUTOCLEAR);
695694

696-
return sprintf(buf, "%s\n", autoclear ? "1" : "0");
695+
return sysfs_emit(buf, "%s\n", autoclear ? "1" : "0");
697696
}
698697

699698
static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf)
700699
{
701700
int partscan = (lo->lo_flags & LO_FLAGS_PARTSCAN);
702701

703-
return sprintf(buf, "%s\n", partscan ? "1" : "0");
702+
return sysfs_emit(buf, "%s\n", partscan ? "1" : "0");
704703
}
705704

706705
static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf)
707706
{
708707
int dio = (lo->lo_flags & LO_FLAGS_DIRECT_IO);
709708

710-
return sprintf(buf, "%s\n", dio ? "1" : "0");
709+
return sysfs_emit(buf, "%s\n", dio ? "1" : "0");
711710
}
712711

713712
LOOP_ATTR_RO(backing_file);
@@ -1261,7 +1260,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
12611260
if (size_changed && lo->lo_device->bd_inode->i_mapping->nrpages) {
12621261
/* If any pages were dirtied after invalidate_bdev(), try again */
12631262
err = -EAGAIN;
1264-
pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
1263+
pr_warn("%s: loop%d (%s) still has dirty pages (nrpages=%lu)\n",
12651264
__func__, lo->lo_number, lo->lo_file_name,
12661265
lo->lo_device->bd_inode->i_mapping->nrpages);
12671266
goto out_unfreeze;
@@ -1481,7 +1480,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
14811480
/* invalidate_bdev should have truncated all the pages */
14821481
if (lo->lo_device->bd_inode->i_mapping->nrpages) {
14831482
err = -EAGAIN;
1484-
pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
1483+
pr_warn("%s: loop%d (%s) still has dirty pages (nrpages=%lu)\n",
14851484
__func__, lo->lo_number, lo->lo_file_name,
14861485
lo->lo_device->bd_inode->i_mapping->nrpages);
14871486
goto out_unfreeze;
@@ -1786,6 +1785,24 @@ module_param(max_loop, int, 0444);
17861785
MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
17871786
module_param(max_part, int, 0444);
17881787
MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
1788+
1789+
static int hw_queue_depth = LOOP_DEFAULT_HW_Q_DEPTH;
1790+
1791+
static int loop_set_hw_queue_depth(const char *s, const struct kernel_param *p)
1792+
{
1793+
int ret = kstrtoint(s, 10, &hw_queue_depth);
1794+
1795+
return (ret || (hw_queue_depth < 1)) ? -EINVAL : 0;
1796+
}
1797+
1798+
static const struct kernel_param_ops loop_hw_qdepth_param_ops = {
1799+
.set = loop_set_hw_queue_depth,
1800+
.get = param_get_int,
1801+
};
1802+
1803+
device_param_cb(hw_queue_depth, &loop_hw_qdepth_param_ops, &hw_queue_depth, 0444);
1804+
MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 128");
1805+
17891806
MODULE_LICENSE("GPL");
17901807
MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
17911808

@@ -1980,7 +1997,7 @@ static int loop_add(int i)
19801997

19811998
lo->tag_set.ops = &loop_mq_ops;
19821999
lo->tag_set.nr_hw_queues = 1;
1983-
lo->tag_set.queue_depth = 128;
2000+
lo->tag_set.queue_depth = hw_queue_depth;
19842001
lo->tag_set.numa_node = NUMA_NO_NODE;
19852002
lo->tag_set.cmd_size = sizeof(struct loop_cmd);
19862003
lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING |

drivers/block/null_blk/main.c

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,10 @@ static ssize_t nullb_device_power_store(struct config_item *item,
431431
if (!dev->power && newp) {
432432
if (test_and_set_bit(NULLB_DEV_FL_UP, &dev->flags))
433433
return count;
434-
if (null_add_dev(dev)) {
434+
ret = null_add_dev(dev);
435+
if (ret) {
435436
clear_bit(NULLB_DEV_FL_UP, &dev->flags);
436-
return -ENOMEM;
437+
return ret;
437438
}
438439

439440
set_bit(NULLB_DEV_FL_CONFIGURED, &dev->flags);
@@ -719,26 +720,25 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)
719720
return NULL;
720721
}
721722

722-
static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, int can_wait)
723+
static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, struct bio *bio)
723724
{
724725
struct nullb_cmd *cmd;
725726
DEFINE_WAIT(wait);
726727

727-
cmd = __alloc_cmd(nq);
728-
if (cmd || !can_wait)
729-
return cmd;
730-
731728
do {
732-
prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE);
729+
/*
730+
* This avoids multiple return statements, multiple calls to
731+
* __alloc_cmd() and a fast path call to prepare_to_wait().
732+
*/
733733
cmd = __alloc_cmd(nq);
734-
if (cmd)
735-
break;
736-
734+
if (cmd) {
735+
cmd->bio = bio;
736+
return cmd;
737+
}
738+
prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE);
737739
io_schedule();
740+
finish_wait(&nq->wait, &wait);
738741
} while (1);
739-
740-
finish_wait(&nq->wait, &wait);
741-
return cmd;
742742
}
743743

744744
static void end_cmd(struct nullb_cmd *cmd)
@@ -777,24 +777,22 @@ static void null_complete_rq(struct request *rq)
777777
end_cmd(blk_mq_rq_to_pdu(rq));
778778
}
779779

780-
static struct nullb_page *null_alloc_page(gfp_t gfp_flags)
780+
static struct nullb_page *null_alloc_page(void)
781781
{
782782
struct nullb_page *t_page;
783783

784-
t_page = kmalloc(sizeof(struct nullb_page), gfp_flags);
784+
t_page = kmalloc(sizeof(struct nullb_page), GFP_NOIO);
785785
if (!t_page)
786-
goto out;
786+
return NULL;
787787

788-
t_page->page = alloc_pages(gfp_flags, 0);
789-
if (!t_page->page)
790-
goto out_freepage;
788+
t_page->page = alloc_pages(GFP_NOIO, 0);
789+
if (!t_page->page) {
790+
kfree(t_page);
791+
return NULL;
792+
}
791793

792794
memset(t_page->bitmap, 0, sizeof(t_page->bitmap));
793795
return t_page;
794-
out_freepage:
795-
kfree(t_page);
796-
out:
797-
return NULL;
798796
}
799797

800798
static void null_free_page(struct nullb_page *t_page)
@@ -932,7 +930,7 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
932930

933931
spin_unlock_irq(&nullb->lock);
934932

935-
t_page = null_alloc_page(GFP_NOIO);
933+
t_page = null_alloc_page();
936934
if (!t_page)
937935
goto out_lock;
938936

@@ -1476,12 +1474,8 @@ static void null_submit_bio(struct bio *bio)
14761474
sector_t nr_sectors = bio_sectors(bio);
14771475
struct nullb *nullb = bio->bi_bdev->bd_disk->private_data;
14781476
struct nullb_queue *nq = nullb_to_queue(nullb);
1479-
struct nullb_cmd *cmd;
1480-
1481-
cmd = alloc_cmd(nq, 1);
1482-
cmd->bio = bio;
14831477

1484-
null_handle_cmd(cmd, sector, nr_sectors, bio_op(bio));
1478+
null_handle_cmd(alloc_cmd(nq, bio), sector, nr_sectors, bio_op(bio));
14851479
}
14861480

14871481
static bool should_timeout_request(struct request *rq)

drivers/block/rnbd/rnbd-clt.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ MODULE_LICENSE("GPL");
2323

2424
static int rnbd_client_major;
2525
static DEFINE_IDA(index_ida);
26-
static DEFINE_MUTEX(ida_lock);
2726
static DEFINE_MUTEX(sess_lock);
2827
static LIST_HEAD(sess_list);
2928

@@ -55,9 +54,7 @@ static void rnbd_clt_put_dev(struct rnbd_clt_dev *dev)
5554
if (!refcount_dec_and_test(&dev->refcount))
5655
return;
5756

58-
mutex_lock(&ida_lock);
59-
ida_simple_remove(&index_ida, dev->clt_device_id);
60-
mutex_unlock(&ida_lock);
57+
ida_free(&index_ida, dev->clt_device_id);
6158
kfree(dev->hw_queues);
6259
kfree(dev->pathname);
6360
rnbd_clt_put_sess(dev->sess);
@@ -87,7 +84,6 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev,
8784
dev->discard_granularity = le32_to_cpu(rsp->discard_granularity);
8885
dev->discard_alignment = le32_to_cpu(rsp->discard_alignment);
8986
dev->secure_discard = le16_to_cpu(rsp->secure_discard);
90-
dev->rotational = rsp->rotational;
9187
dev->wc = !!(rsp->cache_policy & RNBD_WRITEBACK);
9288
dev->fua = !!(rsp->cache_policy & RNBD_FUA);
9389

@@ -1262,9 +1258,9 @@ find_and_get_or_create_sess(const char *sessname,
12621258
struct rtrs_clt_ops rtrs_ops;
12631259

12641260
sess = find_or_create_sess(sessname, &first);
1265-
if (sess == ERR_PTR(-ENOMEM))
1261+
if (sess == ERR_PTR(-ENOMEM)) {
12661262
return ERR_PTR(-ENOMEM);
1267-
else if ((nr_poll_queues && !first) || (!nr_poll_queues && sess->nr_poll_queues)) {
1263+
} else if ((nr_poll_queues && !first) || (!nr_poll_queues && sess->nr_poll_queues)) {
12681264
/*
12691265
* A device MUST have its own session to use the polling-mode.
12701266
* It must fail to map new device with the same session.
@@ -1410,8 +1406,10 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)
14101406
dev->read_only = false;
14111407
}
14121408

1413-
if (!dev->rotational)
1414-
blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue);
1409+
/*
1410+
* Network device does not need rotational
1411+
*/
1412+
blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue);
14151413
err = add_disk(dev->gd);
14161414
if (err)
14171415
blk_cleanup_disk(dev->gd);
@@ -1459,10 +1457,8 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,
14591457
goto out_alloc;
14601458
}
14611459

1462-
mutex_lock(&ida_lock);
1463-
ret = ida_simple_get(&index_ida, 0, 1 << (MINORBITS - RNBD_PART_BITS),
1464-
GFP_KERNEL);
1465-
mutex_unlock(&ida_lock);
1460+
ret = ida_alloc_max(&index_ida, 1 << (MINORBITS - RNBD_PART_BITS),
1461+
GFP_KERNEL);
14661462
if (ret < 0) {
14671463
pr_err("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n",
14681464
pathname, sess->sessname, ret);
@@ -1610,13 +1606,13 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname,
16101606
}
16111607

16121608
rnbd_clt_info(dev,
1613-
"map_device: Device mapped as %s (nsectors: %zu, logical_block_size: %d, physical_block_size: %d, max_write_same_sectors: %d, max_discard_sectors: %d, discard_granularity: %d, discard_alignment: %d, secure_discard: %d, max_segments: %d, max_hw_sectors: %d, rotational: %d, wc: %d, fua: %d)\n",
1609+
"map_device: Device mapped as %s (nsectors: %zu, logical_block_size: %d, physical_block_size: %d, max_write_same_sectors: %d, max_discard_sectors: %d, discard_granularity: %d, discard_alignment: %d, secure_discard: %d, max_segments: %d, max_hw_sectors: %d, wc: %d, fua: %d)\n",
16141610
dev->gd->disk_name, dev->nsectors,
16151611
dev->logical_block_size, dev->physical_block_size,
16161612
dev->max_write_same_sectors, dev->max_discard_sectors,
16171613
dev->discard_granularity, dev->discard_alignment,
16181614
dev->secure_discard, dev->max_segments,
1619-
dev->max_hw_sectors, dev->rotational, dev->wc, dev->fua);
1615+
dev->max_hw_sectors, dev->wc, dev->fua);
16201616

16211617
mutex_unlock(&dev->lock);
16221618
rnbd_clt_put_sess(sess);

drivers/block/rnbd/rnbd-clt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ struct rnbd_clt_dev {
118118
enum rnbd_access_mode access_mode;
119119
u32 nr_poll_queues;
120120
bool read_only;
121-
bool rotational;
122121
bool wc;
123122
bool fua;
124123
u32 max_hw_sectors;

0 commit comments

Comments
 (0)