aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-12 18:43:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-12 18:43:10 -0400
commit0fcc3ab23d7395f58e8ab0834e7913e2e4314a83 (patch)
treeebd4745696ad330e2da6873cea158d9d56aa661d /drivers
parentdeac8429d62ca19c1571853e2a18f60e760ee04c (diff)
parente84b83b9ee2187817cf895471675f1ccdf64cd53 (diff)
Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm fixes from Dan Williams: "Incremental fixes and a small feature addition on top of the main libnvdimm 4.12 pull request: - Geert noticed that tinyconfig was bloated by BLOCK selecting DAX. The size regression is fixed by moving all dax helpers into the dax-core and only specifying "select DAX" for FS_DAX and dax-capable drivers. He also asked for clarification of the NR_DEV_DAX config option which, on closer look, does not need to be a config option at all. Mike also throws in a DEV_DAX_PMEM fixup for good measure. - Ben's attention to detail on -stable patch submissions caught a case where the recent fixes to arch_copy_from_iter_pmem() missed a condition where we strand dirty data in the cache. This is tagged for -stable and will also be included in the rework of the pmem api to a proposed {memcpy,copy_user}_flushcache() interface for 4.13. - Vishal adds a feature that missed the initial pull due to pending review feedback. It allows the kernel to clear media errors when initializing a BTT (atomic sector update driver) instance on a pmem namespace. - Ross noticed that the dax_device + dax_operations conversion broke __dax_zero_page_range(). The nvdimm unit tests fail to check this path, but xfstests immediately trips over it. No excuse for missing this before submitting the 4.12 pull request. These all pass the nvdimm unit tests and an xfstests spot check. The set has received a build success notification from the kbuild robot" * 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: filesystem-dax: fix broken __dax_zero_page_range() conversion libnvdimm, btt: ensure that initializing metadata clears poison libnvdimm: add an atomic vs process context flag to rw_bytes x86, pmem: Fix cache flushing for iovec write < 8 bytes device-dax: kill NR_DEV_DAX block, dax: move "select DAX" from BLOCK to FS_DAX device-dax: Tell kbuild DEV_DAX_PMEM depends on DEV_DAX
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dax/Kconfig7
-rw-r--r--drivers/dax/super.c81
-rw-r--r--drivers/nvdimm/blk.c3
-rw-r--r--drivers/nvdimm/btt.c119
-rw-r--r--drivers/nvdimm/btt_devs.c2
-rw-r--r--drivers/nvdimm/claim.c6
-rw-r--r--drivers/nvdimm/nd.h1
-rw-r--r--drivers/nvdimm/pfn_devs.c4
8 files changed, 166 insertions, 57 deletions
diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig
index b7053eafd88e..b79aa8f7a497 100644
--- a/drivers/dax/Kconfig
+++ b/drivers/dax/Kconfig
@@ -19,7 +19,7 @@ config DEV_DAX
19 19
20config DEV_DAX_PMEM 20config DEV_DAX_PMEM
21 tristate "PMEM DAX: direct access to persistent memory" 21 tristate "PMEM DAX: direct access to persistent memory"
22 depends on LIBNVDIMM && NVDIMM_DAX 22 depends on LIBNVDIMM && NVDIMM_DAX && DEV_DAX
23 default DEV_DAX 23 default DEV_DAX
24 help 24 help
25 Support raw access to persistent memory. Note that this 25 Support raw access to persistent memory. Note that this
@@ -28,9 +28,4 @@ config DEV_DAX_PMEM
28 28
29 Say Y if unsure 29 Say Y if unsure
30 30
31config NR_DEV_DAX
32 int "Maximum number of Device-DAX instances"
33 default 32768
34 range 256 2147483647
35
36endif 31endif
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 465dcd7317d5..ebf43f531ada 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -14,16 +14,13 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/mount.h> 15#include <linux/mount.h>
16#include <linux/magic.h> 16#include <linux/magic.h>
17#include <linux/genhd.h>
17#include <linux/cdev.h> 18#include <linux/cdev.h>
18#include <linux/hash.h> 19#include <linux/hash.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
20#include <linux/dax.h> 21#include <linux/dax.h>
21#include <linux/fs.h> 22#include <linux/fs.h>
22 23
23static int nr_dax = CONFIG_NR_DEV_DAX;
24module_param(nr_dax, int, S_IRUGO);
25MODULE_PARM_DESC(nr_dax, "max number of dax device instances");
26
27static dev_t dax_devt; 24static dev_t dax_devt;
28DEFINE_STATIC_SRCU(dax_srcu); 25DEFINE_STATIC_SRCU(dax_srcu);
29static struct vfsmount *dax_mnt; 26static struct vfsmount *dax_mnt;
@@ -47,6 +44,75 @@ void dax_read_unlock(int id)
47} 44}
48EXPORT_SYMBOL_GPL(dax_read_unlock); 45EXPORT_SYMBOL_GPL(dax_read_unlock);
49 46
47int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
48 pgoff_t *pgoff)
49{
50 phys_addr_t phys_off = (get_start_sect(bdev) + sector) * 512;
51
52 if (pgoff)
53 *pgoff = PHYS_PFN(phys_off);
54 if (phys_off % PAGE_SIZE || size % PAGE_SIZE)
55 return -EINVAL;
56 return 0;
57}
58EXPORT_SYMBOL(bdev_dax_pgoff);
59
60/**
61 * __bdev_dax_supported() - Check if the device supports dax for filesystem
62 * @sb: The superblock of the device
63 * @blocksize: The block size of the device
64 *
65 * This is a library function for filesystems to check if the block device
66 * can be mounted with dax option.
67 *
68 * Return: negative errno if unsupported, 0 if supported.
69 */
70int __bdev_dax_supported(struct super_block *sb, int blocksize)
71{
72 struct block_device *bdev = sb->s_bdev;
73 struct dax_device *dax_dev;
74 pgoff_t pgoff;
75 int err, id;
76 void *kaddr;
77 pfn_t pfn;
78 long len;
79
80 if (blocksize != PAGE_SIZE) {
81 pr_err("VFS (%s): error: unsupported blocksize for dax\n",
82 sb->s_id);
83 return -EINVAL;
84 }
85
86 err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
87 if (err) {
88 pr_err("VFS (%s): error: unaligned partition for dax\n",
89 sb->s_id);
90 return err;
91 }
92
93 dax_dev = dax_get_by_host(bdev->bd_disk->disk_name);
94 if (!dax_dev) {
95 pr_err("VFS (%s): error: device does not support dax\n",
96 sb->s_id);
97 return -EOPNOTSUPP;
98 }
99
100 id = dax_read_lock();
101 len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn);
102 dax_read_unlock(id);
103
104 put_dax(dax_dev);
105
106 if (len < 1) {
107 pr_err("VFS (%s): error: dax access failed (%ld)",
108 sb->s_id, len);
109 return len < 0 ? len : -EIO;
110 }
111
112 return 0;
113}
114EXPORT_SYMBOL_GPL(__bdev_dax_supported);
115
50/** 116/**
51 * struct dax_device - anchor object for dax services 117 * struct dax_device - anchor object for dax services
52 * @inode: core vfs 118 * @inode: core vfs
@@ -261,7 +327,7 @@ struct dax_device *alloc_dax(void *private, const char *__host,
261 if (__host && !host) 327 if (__host && !host)
262 return NULL; 328 return NULL;
263 329
264 minor = ida_simple_get(&dax_minor_ida, 0, nr_dax, GFP_KERNEL); 330 minor = ida_simple_get(&dax_minor_ida, 0, MINORMASK+1, GFP_KERNEL);
265 if (minor < 0) 331 if (minor < 0)
266 goto err_minor; 332 goto err_minor;
267 333
@@ -405,8 +471,7 @@ static int __init dax_fs_init(void)
405 if (rc) 471 if (rc)
406 return rc; 472 return rc;
407 473
408 nr_dax = max(nr_dax, 256); 474 rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax");
409 rc = alloc_chrdev_region(&dax_devt, 0, nr_dax, "dax");
410 if (rc) 475 if (rc)
411 __dax_fs_exit(); 476 __dax_fs_exit();
412 return rc; 477 return rc;
@@ -414,7 +479,7 @@ static int __init dax_fs_init(void)
414 479
415static void __exit dax_fs_exit(void) 480static void __exit dax_fs_exit(void)
416{ 481{
417 unregister_chrdev_region(dax_devt, nr_dax); 482 unregister_chrdev_region(dax_devt, MINORMASK+1);
418 ida_destroy(&dax_minor_ida); 483 ida_destroy(&dax_minor_ida);
419 __dax_fs_exit(); 484 __dax_fs_exit();
420} 485}
diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c
index 9faaa9694d87..822198a75e96 100644
--- a/drivers/nvdimm/blk.c
+++ b/drivers/nvdimm/blk.c
@@ -218,7 +218,8 @@ static blk_qc_t nd_blk_make_request(struct request_queue *q, struct bio *bio)
218} 218}
219 219
220static int nsblk_rw_bytes(struct nd_namespace_common *ndns, 220static int nsblk_rw_bytes(struct nd_namespace_common *ndns,
221 resource_size_t offset, void *iobuf, size_t n, int rw) 221 resource_size_t offset, void *iobuf, size_t n, int rw,
222 unsigned long flags)
222{ 223{
223 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(&ndns->dev); 224 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(&ndns->dev);
224 struct nd_blk_region *ndbr = to_ndbr(nsblk); 225 struct nd_blk_region *ndbr = to_ndbr(nsblk);
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 368795aad5c9..983718b8fd9b 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -32,45 +32,53 @@ enum log_ent_request {
32}; 32};
33 33
34static int arena_read_bytes(struct arena_info *arena, resource_size_t offset, 34static int arena_read_bytes(struct arena_info *arena, resource_size_t offset,
35 void *buf, size_t n) 35 void *buf, size_t n, unsigned long flags)
36{ 36{
37 struct nd_btt *nd_btt = arena->nd_btt; 37 struct nd_btt *nd_btt = arena->nd_btt;
38 struct nd_namespace_common *ndns = nd_btt->ndns; 38 struct nd_namespace_common *ndns = nd_btt->ndns;
39 39
40 /* arena offsets are 4K from the base of the device */ 40 /* arena offsets are 4K from the base of the device */
41 offset += SZ_4K; 41 offset += SZ_4K;
42 return nvdimm_read_bytes(ndns, offset, buf, n); 42 return nvdimm_read_bytes(ndns, offset, buf, n, flags);
43} 43}
44 44
45static int arena_write_bytes(struct arena_info *arena, resource_size_t offset, 45static int arena_write_bytes(struct arena_info *arena, resource_size_t offset,
46 void *buf, size_t n) 46 void *buf, size_t n, unsigned long flags)
47{ 47{
48 struct nd_btt *nd_btt = arena->nd_btt; 48 struct nd_btt *nd_btt = arena->nd_btt;
49 struct nd_namespace_common *ndns = nd_btt->ndns; 49 struct nd_namespace_common *ndns = nd_btt->ndns;
50 50
51 /* arena offsets are 4K from the base of the device */ 51 /* arena offsets are 4K from the base of the device */
52 offset += SZ_4K; 52 offset += SZ_4K;
53 return nvdimm_write_bytes(ndns, offset, buf, n); 53 return nvdimm_write_bytes(ndns, offset, buf, n, flags);
54} 54}
55 55
56static int btt_info_write(struct arena_info *arena, struct btt_sb *super) 56static int btt_info_write(struct arena_info *arena, struct btt_sb *super)
57{ 57{
58 int ret; 58 int ret;
59 59
60 /*
61 * infooff and info2off should always be at least 512B aligned.
62 * We rely on that to make sure rw_bytes does error clearing
63 * correctly, so make sure that is the case.
64 */
65 WARN_ON_ONCE(!IS_ALIGNED(arena->infooff, 512));
66 WARN_ON_ONCE(!IS_ALIGNED(arena->info2off, 512));
67
60 ret = arena_write_bytes(arena, arena->info2off, super, 68 ret = arena_write_bytes(arena, arena->info2off, super,
61 sizeof(struct btt_sb)); 69 sizeof(struct btt_sb), 0);
62 if (ret) 70 if (ret)
63 return ret; 71 return ret;
64 72
65 return arena_write_bytes(arena, arena->infooff, super, 73 return arena_write_bytes(arena, arena->infooff, super,
66 sizeof(struct btt_sb)); 74 sizeof(struct btt_sb), 0);
67} 75}
68 76
69static int btt_info_read(struct arena_info *arena, struct btt_sb *super) 77static int btt_info_read(struct arena_info *arena, struct btt_sb *super)
70{ 78{
71 WARN_ON(!super); 79 WARN_ON(!super);
72 return arena_read_bytes(arena, arena->infooff, super, 80 return arena_read_bytes(arena, arena->infooff, super,
73 sizeof(struct btt_sb)); 81 sizeof(struct btt_sb), 0);
74} 82}
75 83
76/* 84/*
@@ -79,16 +87,17 @@ static int btt_info_read(struct arena_info *arena, struct btt_sb *super)
79 * mapping is in little-endian 87 * mapping is in little-endian
80 * mapping contains 'E' and 'Z' flags as desired 88 * mapping contains 'E' and 'Z' flags as desired
81 */ 89 */
82static int __btt_map_write(struct arena_info *arena, u32 lba, __le32 mapping) 90static int __btt_map_write(struct arena_info *arena, u32 lba, __le32 mapping,
91 unsigned long flags)
83{ 92{
84 u64 ns_off = arena->mapoff + (lba * MAP_ENT_SIZE); 93 u64 ns_off = arena->mapoff + (lba * MAP_ENT_SIZE);
85 94
86 WARN_ON(lba >= arena->external_nlba); 95 WARN_ON(lba >= arena->external_nlba);
87 return arena_write_bytes(arena, ns_off, &mapping, MAP_ENT_SIZE); 96 return arena_write_bytes(arena, ns_off, &mapping, MAP_ENT_SIZE, flags);
88} 97}
89 98
90static int btt_map_write(struct arena_info *arena, u32 lba, u32 mapping, 99static int btt_map_write(struct arena_info *arena, u32 lba, u32 mapping,
91 u32 z_flag, u32 e_flag) 100 u32 z_flag, u32 e_flag, unsigned long rwb_flags)
92{ 101{
93 u32 ze; 102 u32 ze;
94 __le32 mapping_le; 103 __le32 mapping_le;
@@ -127,11 +136,11 @@ static int btt_map_write(struct arena_info *arena, u32 lba, u32 mapping,
127 } 136 }
128 137
129 mapping_le = cpu_to_le32(mapping); 138 mapping_le = cpu_to_le32(mapping);
130 return __btt_map_write(arena, lba, mapping_le); 139 return __btt_map_write(arena, lba, mapping_le, rwb_flags);
131} 140}
132 141
133static int btt_map_read(struct arena_info *arena, u32 lba, u32 *mapping, 142static int btt_map_read(struct arena_info *arena, u32 lba, u32 *mapping,
134 int *trim, int *error) 143 int *trim, int *error, unsigned long rwb_flags)
135{ 144{
136 int ret; 145 int ret;
137 __le32 in; 146 __le32 in;
@@ -140,7 +149,7 @@ static int btt_map_read(struct arena_info *arena, u32 lba, u32 *mapping,
140 149
141 WARN_ON(lba >= arena->external_nlba); 150 WARN_ON(lba >= arena->external_nlba);
142 151
143 ret = arena_read_bytes(arena, ns_off, &in, MAP_ENT_SIZE); 152 ret = arena_read_bytes(arena, ns_off, &in, MAP_ENT_SIZE, rwb_flags);
144 if (ret) 153 if (ret)
145 return ret; 154 return ret;
146 155
@@ -189,7 +198,7 @@ static int btt_log_read_pair(struct arena_info *arena, u32 lane,
189 WARN_ON(!ent); 198 WARN_ON(!ent);
190 return arena_read_bytes(arena, 199 return arena_read_bytes(arena,
191 arena->logoff + (2 * lane * LOG_ENT_SIZE), ent, 200 arena->logoff + (2 * lane * LOG_ENT_SIZE), ent,
192 2 * LOG_ENT_SIZE); 201 2 * LOG_ENT_SIZE, 0);
193} 202}
194 203
195static struct dentry *debugfs_root; 204static struct dentry *debugfs_root;
@@ -335,7 +344,7 @@ static int btt_log_read(struct arena_info *arena, u32 lane,
335 * btt_flog_write is the wrapper for updating the freelist elements 344 * btt_flog_write is the wrapper for updating the freelist elements
336 */ 345 */
337static int __btt_log_write(struct arena_info *arena, u32 lane, 346static int __btt_log_write(struct arena_info *arena, u32 lane,
338 u32 sub, struct log_entry *ent) 347 u32 sub, struct log_entry *ent, unsigned long flags)
339{ 348{
340 int ret; 349 int ret;
341 /* 350 /*
@@ -350,13 +359,13 @@ static int __btt_log_write(struct arena_info *arena, u32 lane,
350 void *src = ent; 359 void *src = ent;
351 360
352 /* split the 16B write into atomic, durable halves */ 361 /* split the 16B write into atomic, durable halves */
353 ret = arena_write_bytes(arena, ns_off, src, log_half); 362 ret = arena_write_bytes(arena, ns_off, src, log_half, flags);
354 if (ret) 363 if (ret)
355 return ret; 364 return ret;
356 365
357 ns_off += log_half; 366 ns_off += log_half;
358 src += log_half; 367 src += log_half;
359 return arena_write_bytes(arena, ns_off, src, log_half); 368 return arena_write_bytes(arena, ns_off, src, log_half, flags);
360} 369}
361 370
362static int btt_flog_write(struct arena_info *arena, u32 lane, u32 sub, 371static int btt_flog_write(struct arena_info *arena, u32 lane, u32 sub,
@@ -364,7 +373,7 @@ static int btt_flog_write(struct arena_info *arena, u32 lane, u32 sub,
364{ 373{
365 int ret; 374 int ret;
366 375
367 ret = __btt_log_write(arena, lane, sub, ent); 376 ret = __btt_log_write(arena, lane, sub, ent, NVDIMM_IO_ATOMIC);
368 if (ret) 377 if (ret)
369 return ret; 378 return ret;
370 379
@@ -393,11 +402,19 @@ static int btt_map_init(struct arena_info *arena)
393 if (!zerobuf) 402 if (!zerobuf)
394 return -ENOMEM; 403 return -ENOMEM;
395 404
405 /*
406 * mapoff should always be at least 512B aligned. We rely on that to
407 * make sure rw_bytes does error clearing correctly, so make sure that
408 * is the case.
409 */
410 WARN_ON_ONCE(!IS_ALIGNED(arena->mapoff, 512));
411
396 while (mapsize) { 412 while (mapsize) {
397 size_t size = min(mapsize, chunk_size); 413 size_t size = min(mapsize, chunk_size);
398 414
415 WARN_ON_ONCE(size < 512);
399 ret = arena_write_bytes(arena, arena->mapoff + offset, zerobuf, 416 ret = arena_write_bytes(arena, arena->mapoff + offset, zerobuf,
400 size); 417 size, 0);
401 if (ret) 418 if (ret)
402 goto free; 419 goto free;
403 420
@@ -417,26 +434,50 @@ static int btt_map_init(struct arena_info *arena)
417 */ 434 */
418static int btt_log_init(struct arena_info *arena) 435static int btt_log_init(struct arena_info *arena)
419{ 436{
437 size_t logsize = arena->info2off - arena->logoff;
438 size_t chunk_size = SZ_4K, offset = 0;
439 struct log_entry log;
440 void *zerobuf;
420 int ret; 441 int ret;
421 u32 i; 442 u32 i;
422 struct log_entry log, zerolog;
423 443
424 memset(&zerolog, 0, sizeof(zerolog)); 444 zerobuf = kzalloc(chunk_size, GFP_KERNEL);
445 if (!zerobuf)
446 return -ENOMEM;
447 /*
448 * logoff should always be at least 512B aligned. We rely on that to
449 * make sure rw_bytes does error clearing correctly, so make sure that
450 * is the case.
451 */
452 WARN_ON_ONCE(!IS_ALIGNED(arena->logoff, 512));
453
454 while (logsize) {
455 size_t size = min(logsize, chunk_size);
456
457 WARN_ON_ONCE(size < 512);
458 ret = arena_write_bytes(arena, arena->logoff + offset, zerobuf,
459 size, 0);
460 if (ret)
461 goto free;
462
463 offset += size;
464 logsize -= size;
465 cond_resched();
466 }
425 467
426 for (i = 0; i < arena->nfree; i++) { 468 for (i = 0; i < arena->nfree; i++) {
427 log.lba = cpu_to_le32(i); 469 log.lba = cpu_to_le32(i);
428 log.old_map = cpu_to_le32(arena->external_nlba + i); 470 log.old_map = cpu_to_le32(arena->external_nlba + i);
429 log.new_map = cpu_to_le32(arena->external_nlba + i); 471 log.new_map = cpu_to_le32(arena->external_nlba + i);
430 log.seq = cpu_to_le32(LOG_SEQ_INIT); 472 log.seq = cpu_to_le32(LOG_SEQ_INIT);
431 ret = __btt_log_write(arena, i, 0, &log); 473 ret = __btt_log_write(arena, i, 0, &log, 0);
432 if (ret)
433 return ret;
434 ret = __btt_log_write(arena, i, 1, &zerolog);
435 if (ret) 474 if (ret)
436 return ret; 475 goto free;
437 } 476 }
438 477
439 return 0; 478 free:
479 kfree(zerobuf);
480 return ret;
440} 481}
441 482
442static int btt_freelist_init(struct arena_info *arena) 483static int btt_freelist_init(struct arena_info *arena)
@@ -470,7 +511,7 @@ static int btt_freelist_init(struct arena_info *arena)
470 511
471 /* Check if map recovery is needed */ 512 /* Check if map recovery is needed */
472 ret = btt_map_read(arena, le32_to_cpu(log_new.lba), &map_entry, 513 ret = btt_map_read(arena, le32_to_cpu(log_new.lba), &map_entry,
473 NULL, NULL); 514 NULL, NULL, 0);
474 if (ret) 515 if (ret)
475 return ret; 516 return ret;
476 if ((le32_to_cpu(log_new.new_map) != map_entry) && 517 if ((le32_to_cpu(log_new.new_map) != map_entry) &&
@@ -480,7 +521,7 @@ static int btt_freelist_init(struct arena_info *arena)
480 * to complete the map write. So fix up the map. 521 * to complete the map write. So fix up the map.
481 */ 522 */
482 ret = btt_map_write(arena, le32_to_cpu(log_new.lba), 523 ret = btt_map_write(arena, le32_to_cpu(log_new.lba),
483 le32_to_cpu(log_new.new_map), 0, 0); 524 le32_to_cpu(log_new.new_map), 0, 0, 0);
484 if (ret) 525 if (ret)
485 return ret; 526 return ret;
486 } 527 }
@@ -875,7 +916,7 @@ static int btt_data_read(struct arena_info *arena, struct page *page,
875 u64 nsoff = to_namespace_offset(arena, lba); 916 u64 nsoff = to_namespace_offset(arena, lba);
876 void *mem = kmap_atomic(page); 917 void *mem = kmap_atomic(page);
877 918
878 ret = arena_read_bytes(arena, nsoff, mem + off, len); 919 ret = arena_read_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC);
879 kunmap_atomic(mem); 920 kunmap_atomic(mem);
880 921
881 return ret; 922 return ret;
@@ -888,7 +929,7 @@ static int btt_data_write(struct arena_info *arena, u32 lba,
888 u64 nsoff = to_namespace_offset(arena, lba); 929 u64 nsoff = to_namespace_offset(arena, lba);
889 void *mem = kmap_atomic(page); 930 void *mem = kmap_atomic(page);
890 931
891 ret = arena_write_bytes(arena, nsoff, mem + off, len); 932 ret = arena_write_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC);
892 kunmap_atomic(mem); 933 kunmap_atomic(mem);
893 934
894 return ret; 935 return ret;
@@ -931,10 +972,12 @@ static int btt_rw_integrity(struct btt *btt, struct bio_integrity_payload *bip,
931 mem = kmap_atomic(bv.bv_page); 972 mem = kmap_atomic(bv.bv_page);
932 if (rw) 973 if (rw)
933 ret = arena_write_bytes(arena, meta_nsoff, 974 ret = arena_write_bytes(arena, meta_nsoff,
934 mem + bv.bv_offset, cur_len); 975 mem + bv.bv_offset, cur_len,
976 NVDIMM_IO_ATOMIC);
935 else 977 else
936 ret = arena_read_bytes(arena, meta_nsoff, 978 ret = arena_read_bytes(arena, meta_nsoff,
937 mem + bv.bv_offset, cur_len); 979 mem + bv.bv_offset, cur_len,
980 NVDIMM_IO_ATOMIC);
938 981
939 kunmap_atomic(mem); 982 kunmap_atomic(mem);
940 if (ret) 983 if (ret)
@@ -976,7 +1019,8 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
976 1019
977 cur_len = min(btt->sector_size, len); 1020 cur_len = min(btt->sector_size, len);
978 1021
979 ret = btt_map_read(arena, premap, &postmap, &t_flag, &e_flag); 1022 ret = btt_map_read(arena, premap, &postmap, &t_flag, &e_flag,
1023 NVDIMM_IO_ATOMIC);
980 if (ret) 1024 if (ret)
981 goto out_lane; 1025 goto out_lane;
982 1026
@@ -1006,7 +1050,7 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
1006 barrier(); 1050 barrier();
1007 1051
1008 ret = btt_map_read(arena, premap, &new_map, &t_flag, 1052 ret = btt_map_read(arena, premap, &new_map, &t_flag,
1009 &e_flag); 1053 &e_flag, NVDIMM_IO_ATOMIC);
1010 if (ret) 1054 if (ret)
1011 goto out_rtt; 1055 goto out_rtt;
1012 1056
@@ -1093,7 +1137,8 @@ static int btt_write_pg(struct btt *btt, struct bio_integrity_payload *bip,
1093 } 1137 }
1094 1138
1095 lock_map(arena, premap); 1139 lock_map(arena, premap);
1096 ret = btt_map_read(arena, premap, &old_postmap, NULL, NULL); 1140 ret = btt_map_read(arena, premap, &old_postmap, NULL, NULL,
1141 NVDIMM_IO_ATOMIC);
1097 if (ret) 1142 if (ret)
1098 goto out_map; 1143 goto out_map;
1099 if (old_postmap >= arena->internal_nlba) { 1144 if (old_postmap >= arena->internal_nlba) {
@@ -1110,7 +1155,7 @@ static int btt_write_pg(struct btt *btt, struct bio_integrity_payload *bip,
1110 if (ret) 1155 if (ret)
1111 goto out_map; 1156 goto out_map;
1112 1157
1113 ret = btt_map_write(arena, premap, new_postmap, 0, 0); 1158 ret = btt_map_write(arena, premap, new_postmap, 0, 0, 0);
1114 if (ret) 1159 if (ret)
1115 goto out_map; 1160 goto out_map;
1116 1161
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 4b76af2b8715..ae00dc0d9791 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -273,7 +273,7 @@ static int __nd_btt_probe(struct nd_btt *nd_btt,
273 if (!btt_sb || !ndns || !nd_btt) 273 if (!btt_sb || !ndns || !nd_btt)
274 return -ENODEV; 274 return -ENODEV;
275 275
276 if (nvdimm_read_bytes(ndns, SZ_4K, btt_sb, sizeof(*btt_sb))) 276 if (nvdimm_read_bytes(ndns, SZ_4K, btt_sb, sizeof(*btt_sb), 0))
277 return -ENXIO; 277 return -ENXIO;
278 278
279 if (nvdimm_namespace_capacity(ndns) < SZ_16M) 279 if (nvdimm_namespace_capacity(ndns) < SZ_16M)
diff --git a/drivers/nvdimm/claim.c b/drivers/nvdimm/claim.c
index 93d128da1c92..7ceb5fa4f2a1 100644
--- a/drivers/nvdimm/claim.c
+++ b/drivers/nvdimm/claim.c
@@ -228,7 +228,8 @@ u64 nd_sb_checksum(struct nd_gen_sb *nd_gen_sb)
228EXPORT_SYMBOL(nd_sb_checksum); 228EXPORT_SYMBOL(nd_sb_checksum);
229 229
230static int nsio_rw_bytes(struct nd_namespace_common *ndns, 230static int nsio_rw_bytes(struct nd_namespace_common *ndns,
231 resource_size_t offset, void *buf, size_t size, int rw) 231 resource_size_t offset, void *buf, size_t size, int rw,
232 unsigned long flags)
232{ 233{
233 struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev); 234 struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
234 unsigned int sz_align = ALIGN(size + (offset & (512 - 1)), 512); 235 unsigned int sz_align = ALIGN(size + (offset & (512 - 1)), 512);
@@ -259,7 +260,8 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
259 * work around this collision. 260 * work around this collision.
260 */ 261 */
261 if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512) 262 if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512)
262 && (!ndns->claim || !is_nd_btt(ndns->claim))) { 263 && !(flags & NVDIMM_IO_ATOMIC)
264 && !ndns->claim) {
263 long cleared; 265 long cleared;
264 266
265 cleared = nvdimm_clear_poison(&ndns->dev, 267 cleared = nvdimm_clear_poison(&ndns->dev,
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 77d032192bf7..03852d738eec 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -31,6 +31,7 @@ enum {
31 ND_MAX_LANES = 256, 31 ND_MAX_LANES = 256,
32 SECTOR_SHIFT = 9, 32 SECTOR_SHIFT = 9,
33 INT_LBASIZE_ALIGNMENT = 64, 33 INT_LBASIZE_ALIGNMENT = 64,
34 NVDIMM_IO_ATOMIC = 1,
34}; 35};
35 36
36struct nd_poison { 37struct nd_poison {
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 335c8175410b..a6c403600d19 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -357,7 +357,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
357 if (!is_nd_pmem(nd_pfn->dev.parent)) 357 if (!is_nd_pmem(nd_pfn->dev.parent))
358 return -ENODEV; 358 return -ENODEV;
359 359
360 if (nvdimm_read_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb))) 360 if (nvdimm_read_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0))
361 return -ENXIO; 361 return -ENXIO;
362 362
363 if (memcmp(pfn_sb->signature, sig, PFN_SIG_LEN) != 0) 363 if (memcmp(pfn_sb->signature, sig, PFN_SIG_LEN) != 0)
@@ -662,7 +662,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
662 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); 662 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb);
663 pfn_sb->checksum = cpu_to_le64(checksum); 663 pfn_sb->checksum = cpu_to_le64(checksum);
664 664
665 return nvdimm_write_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb)); 665 return nvdimm_write_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0);
666} 666}
667 667
668/* 668/*