Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+208 -136
+1 -1
arch/x86/include/asm/pmem.h
··· 98 98 99 99 if (bytes < 8) { 100 100 if (!IS_ALIGNED(dest, 4) || (bytes != 4)) 101 - arch_wb_cache_pmem(addr, 1); 101 + arch_wb_cache_pmem(addr, bytes); 102 102 } else { 103 103 if (!IS_ALIGNED(dest, 8)) { 104 104 dest = ALIGN(dest, boot_cpu_data.x86_clflush_size);
-1
block/Kconfig
··· 6 6 default y 7 7 select SBITMAP 8 8 select SRCU 9 - select DAX 10 9 help 11 10 Provide block layer support for the kernel. 12 11
+1 -6
drivers/dax/Kconfig
··· 19 19 20 20 config DEV_DAX_PMEM 21 21 tristate "PMEM DAX: direct access to persistent memory" 22 - depends on LIBNVDIMM && NVDIMM_DAX 22 + depends on LIBNVDIMM && NVDIMM_DAX && DEV_DAX 23 23 default DEV_DAX 24 24 help 25 25 Support raw access to persistent memory. Note that this ··· 27 27 libnvdimm sub-system. 28 28 29 29 Say Y if unsure 30 - 31 - config NR_DEV_DAX 32 - int "Maximum number of Device-DAX instances" 33 - default 32768 34 - range 256 2147483647 35 30 36 31 endif
+73 -8
drivers/dax/super.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/mount.h> 16 16 #include <linux/magic.h> 17 + #include <linux/genhd.h> 17 18 #include <linux/cdev.h> 18 19 #include <linux/hash.h> 19 20 #include <linux/slab.h> 20 21 #include <linux/dax.h> 21 22 #include <linux/fs.h> 22 - 23 - static int nr_dax = CONFIG_NR_DEV_DAX; 24 - module_param(nr_dax, int, S_IRUGO); 25 - MODULE_PARM_DESC(nr_dax, "max number of dax device instances"); 26 23 27 24 static dev_t dax_devt; 28 25 DEFINE_STATIC_SRCU(dax_srcu); ··· 43 46 srcu_read_unlock(&dax_srcu, id); 44 47 } 45 48 EXPORT_SYMBOL_GPL(dax_read_unlock); 49 + 50 + int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size, 51 + pgoff_t *pgoff) 52 + { 53 + phys_addr_t phys_off = (get_start_sect(bdev) + sector) * 512; 54 + 55 + if (pgoff) 56 + *pgoff = PHYS_PFN(phys_off); 57 + if (phys_off % PAGE_SIZE || size % PAGE_SIZE) 58 + return -EINVAL; 59 + return 0; 60 + } 61 + EXPORT_SYMBOL(bdev_dax_pgoff); 62 + 63 + /** 64 + * __bdev_dax_supported() - Check if the device supports dax for filesystem 65 + * @sb: The superblock of the device 66 + * @blocksize: The block size of the device 67 + * 68 + * This is a library function for filesystems to check if the block device 69 + * can be mounted with dax option. 70 + * 71 + * Return: negative errno if unsupported, 0 if supported. 72 + */ 73 + int __bdev_dax_supported(struct super_block *sb, int blocksize) 74 + { 75 + struct block_device *bdev = sb->s_bdev; 76 + struct dax_device *dax_dev; 77 + pgoff_t pgoff; 78 + int err, id; 79 + void *kaddr; 80 + pfn_t pfn; 81 + long len; 82 + 83 + if (blocksize != PAGE_SIZE) { 84 + pr_err("VFS (%s): error: unsupported blocksize for dax\n", 85 + sb->s_id); 86 + return -EINVAL; 87 + } 88 + 89 + err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); 90 + if (err) { 91 + pr_err("VFS (%s): error: unaligned partition for dax\n", 92 + sb->s_id); 93 + return err; 94 + } 95 + 96 + dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 97 + if (!dax_dev) { 98 + pr_err("VFS (%s): error: device does not support dax\n", 99 + sb->s_id); 100 + return -EOPNOTSUPP; 101 + } 102 + 103 + id = dax_read_lock(); 104 + len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); 105 + dax_read_unlock(id); 106 + 107 + put_dax(dax_dev); 108 + 109 + if (len < 1) { 110 + pr_err("VFS (%s): error: dax access failed (%ld)", 111 + sb->s_id, len); 112 + return len < 0 ? len : -EIO; 113 + } 114 + 115 + return 0; 116 + } 117 + EXPORT_SYMBOL_GPL(__bdev_dax_supported); 46 118 47 119 /** 48 120 * struct dax_device - anchor object for dax services ··· 327 261 if (__host && !host) 328 262 return NULL; 329 263 330 - minor = ida_simple_get(&dax_minor_ida, 0, nr_dax, GFP_KERNEL); 264 + minor = ida_simple_get(&dax_minor_ida, 0, MINORMASK+1, GFP_KERNEL); 331 265 if (minor < 0) 332 266 goto err_minor; 333 267 ··· 471 405 if (rc) 472 406 return rc; 473 407 474 - nr_dax = max(nr_dax, 256); 475 - rc = alloc_chrdev_region(&dax_devt, 0, nr_dax, "dax"); 408 + rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax"); 476 409 if (rc) 477 410 __dax_fs_exit(); 478 411 return rc; ··· 479 414 480 415 static void __exit dax_fs_exit(void) 481 416 { 482 - unregister_chrdev_region(dax_devt, nr_dax); 417 + unregister_chrdev_region(dax_devt, MINORMASK+1); 483 418 ida_destroy(&dax_minor_ida); 484 419 __dax_fs_exit(); 485 420 }
+2 -1
drivers/nvdimm/blk.c
··· 218 218 } 219 219 220 220 static 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 224 struct nd_namespace_blk *nsblk = to_nd_namespace_blk(&ndns->dev); 224 225 struct nd_blk_region *ndbr = to_ndbr(nsblk);
+82 -37
drivers/nvdimm/btt.c
··· 32 32 }; 33 33 34 34 static 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 37 struct nd_btt *nd_btt = arena->nd_btt; 38 38 struct nd_namespace_common *ndns = nd_btt->ndns; 39 39 40 40 /* arena offsets are 4K from the base of the device */ 41 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 45 45 static 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 48 struct nd_btt *nd_btt = arena->nd_btt; 49 49 struct nd_namespace_common *ndns = nd_btt->ndns; 50 50 51 51 /* arena offsets are 4K from the base of the device */ 52 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 56 56 static int btt_info_write(struct arena_info *arena, struct btt_sb *super) 57 57 { 58 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 68 ret = arena_write_bytes(arena, arena->info2off, super, 61 - sizeof(struct btt_sb)); 69 + sizeof(struct btt_sb), 0); 62 70 if (ret) 63 71 return ret; 64 72 65 73 return arena_write_bytes(arena, arena->infooff, super, 66 - sizeof(struct btt_sb)); 74 + sizeof(struct btt_sb), 0); 67 75 } 68 76 69 77 static int btt_info_read(struct arena_info *arena, struct btt_sb *super) 70 78 { 71 79 WARN_ON(!super); 72 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 /* ··· 87 79 * mapping is in little-endian 88 80 * mapping contains 'E' and 'Z' flags as desired 89 81 */ 90 - static int __btt_map_write(struct arena_info *arena, u32 lba, __le32 mapping) 82 + static int __btt_map_write(struct arena_info *arena, u32 lba, __le32 mapping, 83 + unsigned long flags) 91 84 { 92 85 u64 ns_off = arena->mapoff + (lba * MAP_ENT_SIZE); 93 86 94 87 WARN_ON(lba >= arena->external_nlba); 95 - return arena_write_bytes(arena, ns_off, &mapping, MAP_ENT_SIZE); 88 + return arena_write_bytes(arena, ns_off, &mapping, MAP_ENT_SIZE, flags); 96 89 } 97 90 98 91 static int btt_map_write(struct arena_info *arena, u32 lba, u32 mapping, 99 - u32 z_flag, u32 e_flag) 92 + u32 z_flag, u32 e_flag, unsigned long rwb_flags) 100 93 { 101 94 u32 ze; 102 95 __le32 mapping_le; ··· 136 127 } 137 128 138 129 mapping_le = cpu_to_le32(mapping); 139 - return __btt_map_write(arena, lba, mapping_le); 130 + return __btt_map_write(arena, lba, mapping_le, rwb_flags); 140 131 } 141 132 142 133 static int btt_map_read(struct arena_info *arena, u32 lba, u32 *mapping, 143 - int *trim, int *error) 134 + int *trim, int *error, unsigned long rwb_flags) 144 135 { 145 136 int ret; 146 137 __le32 in; ··· 149 140 150 141 WARN_ON(lba >= arena->external_nlba); 151 142 152 - ret = arena_read_bytes(arena, ns_off, &in, MAP_ENT_SIZE); 143 + ret = arena_read_bytes(arena, ns_off, &in, MAP_ENT_SIZE, rwb_flags); 153 144 if (ret) 154 145 return ret; 155 146 ··· 198 189 WARN_ON(!ent); 199 190 return arena_read_bytes(arena, 200 191 arena->logoff + (2 * lane * LOG_ENT_SIZE), ent, 201 - 2 * LOG_ENT_SIZE); 192 + 2 * LOG_ENT_SIZE, 0); 202 193 } 203 194 204 195 static struct dentry *debugfs_root; ··· 344 335 * btt_flog_write is the wrapper for updating the freelist elements 345 336 */ 346 337 static int __btt_log_write(struct arena_info *arena, u32 lane, 347 - u32 sub, struct log_entry *ent) 338 + u32 sub, struct log_entry *ent, unsigned long flags) 348 339 { 349 340 int ret; 350 341 /* ··· 359 350 void *src = ent; 360 351 361 352 /* split the 16B write into atomic, durable halves */ 362 - ret = arena_write_bytes(arena, ns_off, src, log_half); 353 + ret = arena_write_bytes(arena, ns_off, src, log_half, flags); 363 354 if (ret) 364 355 return ret; 365 356 366 357 ns_off += log_half; 367 358 src += log_half; 368 - return arena_write_bytes(arena, ns_off, src, log_half); 359 + return arena_write_bytes(arena, ns_off, src, log_half, flags); 369 360 } 370 361 371 362 static int btt_flog_write(struct arena_info *arena, u32 lane, u32 sub, ··· 373 364 { 374 365 int ret; 375 366 376 - ret = __btt_log_write(arena, lane, sub, ent); 367 + ret = __btt_log_write(arena, lane, sub, ent, NVDIMM_IO_ATOMIC); 377 368 if (ret) 378 369 return ret; 379 370 ··· 402 393 if (!zerobuf) 403 394 return -ENOMEM; 404 395 396 + /* 397 + * mapoff should always be at least 512B aligned. We rely on that to 398 + * make sure rw_bytes does error clearing correctly, so make sure that 399 + * is the case. 400 + */ 401 + WARN_ON_ONCE(!IS_ALIGNED(arena->mapoff, 512)); 402 + 405 403 while (mapsize) { 406 404 size_t size = min(mapsize, chunk_size); 407 405 406 + WARN_ON_ONCE(size < 512); 408 407 ret = arena_write_bytes(arena, arena->mapoff + offset, zerobuf, 409 - size); 408 + size, 0); 410 409 if (ret) 411 410 goto free; 412 411 ··· 434 417 */ 435 418 static int btt_log_init(struct arena_info *arena) 436 419 { 420 + size_t logsize = arena->info2off - arena->logoff; 421 + size_t chunk_size = SZ_4K, offset = 0; 422 + struct log_entry log; 423 + void *zerobuf; 437 424 int ret; 438 425 u32 i; 439 - struct log_entry log, zerolog; 440 426 441 - memset(&zerolog, 0, sizeof(zerolog)); 427 + zerobuf = kzalloc(chunk_size, GFP_KERNEL); 428 + if (!zerobuf) 429 + return -ENOMEM; 430 + /* 431 + * logoff should always be at least 512B aligned. We rely on that to 432 + * make sure rw_bytes does error clearing correctly, so make sure that 433 + * is the case. 434 + */ 435 + WARN_ON_ONCE(!IS_ALIGNED(arena->logoff, 512)); 436 + 437 + while (logsize) { 438 + size_t size = min(logsize, chunk_size); 439 + 440 + WARN_ON_ONCE(size < 512); 441 + ret = arena_write_bytes(arena, arena->logoff + offset, zerobuf, 442 + size, 0); 443 + if (ret) 444 + goto free; 445 + 446 + offset += size; 447 + logsize -= size; 448 + cond_resched(); 449 + } 442 450 443 451 for (i = 0; i < arena->nfree; i++) { 444 452 log.lba = cpu_to_le32(i); 445 453 log.old_map = cpu_to_le32(arena->external_nlba + i); 446 454 log.new_map = cpu_to_le32(arena->external_nlba + i); 447 455 log.seq = cpu_to_le32(LOG_SEQ_INIT); 448 - ret = __btt_log_write(arena, i, 0, &log); 456 + ret = __btt_log_write(arena, i, 0, &log, 0); 449 457 if (ret) 450 - return ret; 451 - ret = __btt_log_write(arena, i, 1, &zerolog); 452 - if (ret) 453 - return ret; 458 + goto free; 454 459 } 455 460 456 - return 0; 461 + free: 462 + kfree(zerobuf); 463 + return ret; 457 464 } 458 465 459 466 static int btt_freelist_init(struct arena_info *arena) ··· 511 470 512 471 /* Check if map recovery is needed */ 513 472 ret = btt_map_read(arena, le32_to_cpu(log_new.lba), &map_entry, 514 - NULL, NULL); 473 + NULL, NULL, 0); 515 474 if (ret) 516 475 return ret; 517 476 if ((le32_to_cpu(log_new.new_map) != map_entry) && ··· 521 480 * to complete the map write. So fix up the map. 522 481 */ 523 482 ret = btt_map_write(arena, le32_to_cpu(log_new.lba), 524 - le32_to_cpu(log_new.new_map), 0, 0); 483 + le32_to_cpu(log_new.new_map), 0, 0, 0); 525 484 if (ret) 526 485 return ret; 527 486 } ··· 916 875 u64 nsoff = to_namespace_offset(arena, lba); 917 876 void *mem = kmap_atomic(page); 918 877 919 - ret = arena_read_bytes(arena, nsoff, mem + off, len); 878 + ret = arena_read_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC); 920 879 kunmap_atomic(mem); 921 880 922 881 return ret; ··· 929 888 u64 nsoff = to_namespace_offset(arena, lba); 930 889 void *mem = kmap_atomic(page); 931 890 932 - ret = arena_write_bytes(arena, nsoff, mem + off, len); 891 + ret = arena_write_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC); 933 892 kunmap_atomic(mem); 934 893 935 894 return ret; ··· 972 931 mem = kmap_atomic(bv.bv_page); 973 932 if (rw) 974 933 ret = arena_write_bytes(arena, meta_nsoff, 975 - mem + bv.bv_offset, cur_len); 934 + mem + bv.bv_offset, cur_len, 935 + NVDIMM_IO_ATOMIC); 976 936 else 977 937 ret = arena_read_bytes(arena, meta_nsoff, 978 - mem + bv.bv_offset, cur_len); 938 + mem + bv.bv_offset, cur_len, 939 + NVDIMM_IO_ATOMIC); 979 940 980 941 kunmap_atomic(mem); 981 942 if (ret) ··· 1019 976 1020 977 cur_len = min(btt->sector_size, len); 1021 978 1022 - ret = btt_map_read(arena, premap, &postmap, &t_flag, &e_flag); 979 + ret = btt_map_read(arena, premap, &postmap, &t_flag, &e_flag, 980 + NVDIMM_IO_ATOMIC); 1023 981 if (ret) 1024 982 goto out_lane; 1025 983 ··· 1050 1006 barrier(); 1051 1007 1052 1008 ret = btt_map_read(arena, premap, &new_map, &t_flag, 1053 - &e_flag); 1009 + &e_flag, NVDIMM_IO_ATOMIC); 1054 1010 if (ret) 1055 1011 goto out_rtt; 1056 1012 ··· 1137 1093 } 1138 1094 1139 1095 lock_map(arena, premap); 1140 - ret = btt_map_read(arena, premap, &old_postmap, NULL, NULL); 1096 + ret = btt_map_read(arena, premap, &old_postmap, NULL, NULL, 1097 + NVDIMM_IO_ATOMIC); 1141 1098 if (ret) 1142 1099 goto out_map; 1143 1100 if (old_postmap >= arena->internal_nlba) { ··· 1155 1110 if (ret) 1156 1111 goto out_map; 1157 1112 1158 - ret = btt_map_write(arena, premap, new_postmap, 0, 0); 1113 + ret = btt_map_write(arena, premap, new_postmap, 0, 0, 0); 1159 1114 if (ret) 1160 1115 goto out_map; 1161 1116
+1 -1
drivers/nvdimm/btt_devs.c
··· 273 273 if (!btt_sb || !ndns || !nd_btt) 274 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 277 return -ENXIO; 278 278 279 279 if (nvdimm_namespace_capacity(ndns) < SZ_16M)
+4 -2
drivers/nvdimm/claim.c
··· 228 228 EXPORT_SYMBOL(nd_sb_checksum); 229 229 230 230 static 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 234 struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev); 234 235 unsigned int sz_align = ALIGN(size + (offset & (512 - 1)), 512); ··· 260 259 * work around this collision. 261 260 */ 262 261 if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512) 263 - && (!ndns->claim || !is_nd_btt(ndns->claim))) { 262 + && !(flags & NVDIMM_IO_ATOMIC) 263 + && !ndns->claim) { 264 264 long cleared; 265 265 266 266 cleared = nvdimm_clear_poison(&ndns->dev,
+1
drivers/nvdimm/nd.h
··· 31 31 ND_MAX_LANES = 256, 32 32 SECTOR_SHIFT = 9, 33 33 INT_LBASIZE_ALIGNMENT = 64, 34 + NVDIMM_IO_ATOMIC = 1, 34 35 }; 35 36 36 37 struct nd_poison {
+2 -2
drivers/nvdimm/pfn_devs.c
··· 357 357 if (!is_nd_pmem(nd_pfn->dev.parent)) 358 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 361 return -ENXIO; 362 362 363 363 if (memcmp(pfn_sb->signature, sig, PFN_SIG_LEN) != 0) ··· 662 662 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); 663 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 /*
+1
fs/Kconfig
··· 39 39 depends on MMU 40 40 depends on !(ARM || MIPS || SPARC) 41 41 select FS_IOMAP 42 + select DAX 42 43 help 43 44 Direct Access (DAX) can be used on memory-backed block devices. 44 45 If the block device supports DAX and the filesystem supports DAX,
-66
fs/block_dev.c
··· 717 717 } 718 718 EXPORT_SYMBOL_GPL(bdev_write_page); 719 719 720 - int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size, 721 - pgoff_t *pgoff) 722 - { 723 - phys_addr_t phys_off = (get_start_sect(bdev) + sector) * 512; 724 - 725 - if (pgoff) 726 - *pgoff = PHYS_PFN(phys_off); 727 - if (phys_off % PAGE_SIZE || size % PAGE_SIZE) 728 - return -EINVAL; 729 - return 0; 730 - } 731 - EXPORT_SYMBOL(bdev_dax_pgoff); 732 - 733 - /** 734 - * bdev_dax_supported() - Check if the device supports dax for filesystem 735 - * @sb: The superblock of the device 736 - * @blocksize: The block size of the device 737 - * 738 - * This is a library function for filesystems to check if the block device 739 - * can be mounted with dax option. 740 - * 741 - * Return: negative errno if unsupported, 0 if supported. 742 - */ 743 - int bdev_dax_supported(struct super_block *sb, int blocksize) 744 - { 745 - struct block_device *bdev = sb->s_bdev; 746 - struct dax_device *dax_dev; 747 - pgoff_t pgoff; 748 - int err, id; 749 - void *kaddr; 750 - pfn_t pfn; 751 - long len; 752 - 753 - if (blocksize != PAGE_SIZE) { 754 - vfs_msg(sb, KERN_ERR, "error: unsupported blocksize for dax"); 755 - return -EINVAL; 756 - } 757 - 758 - err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); 759 - if (err) { 760 - vfs_msg(sb, KERN_ERR, "error: unaligned partition for dax"); 761 - return err; 762 - } 763 - 764 - dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 765 - if (!dax_dev) { 766 - vfs_msg(sb, KERN_ERR, "error: device does not support dax"); 767 - return -EOPNOTSUPP; 768 - } 769 - 770 - id = dax_read_lock(); 771 - len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); 772 - dax_read_unlock(id); 773 - 774 - put_dax(dax_dev); 775 - 776 - if (len < 1) { 777 - vfs_msg(sb, KERN_ERR, 778 - "error: dax access failed (%ld)", len); 779 - return len < 0 ? len : -EIO; 780 - } 781 - 782 - return 0; 783 - } 784 - EXPORT_SYMBOL_GPL(bdev_dax_supported); 785 - 786 720 /* 787 721 * pseudo-fs 788 722 */
+2 -2
fs/dax.c
··· 993 993 void *kaddr; 994 994 pfn_t pfn; 995 995 996 - rc = bdev_dax_pgoff(bdev, sector, size, &pgoff); 996 + rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); 997 997 if (rc) 998 998 return rc; 999 999 1000 1000 id = dax_read_lock(); 1001 - rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, 1001 + rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, 1002 1002 &pfn); 1003 1003 if (rc < 0) { 1004 1004 dax_read_unlock(id);
+1
fs/ext2/super.c
··· 32 32 #include <linux/log2.h> 33 33 #include <linux/quotaops.h> 34 34 #include <linux/uaccess.h> 35 + #include <linux/dax.h> 35 36 #include "ext2.h" 36 37 #include "xattr.h" 37 38 #include "acl.h"
+1
fs/ext4/super.c
··· 37 37 #include <linux/ctype.h> 38 38 #include <linux/log2.h> 39 39 #include <linux/crc16.h> 40 + #include <linux/dax.h> 40 41 #include <linux/cleancache.h> 41 42 #include <linux/uaccess.h> 42 43
+1
fs/xfs/xfs_super.c
··· 52 52 #include "xfs_reflink.h" 53 53 54 54 #include <linux/namei.h> 55 + #include <linux/dax.h> 55 56 #include <linux/init.h> 56 57 #include <linux/slab.h> 57 58 #include <linux/mount.h>
-2
include/linux/blkdev.h
··· 1947 1947 extern int bdev_read_page(struct block_device *, sector_t, struct page *); 1948 1948 extern int bdev_write_page(struct block_device *, sector_t, struct page *, 1949 1949 struct writeback_control *); 1950 - extern int bdev_dax_supported(struct super_block *, int); 1951 - int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); 1952 1950 #else /* CONFIG_BLOCK */ 1953 1951 1954 1952 struct block_device;
+28 -2
include/linux/dax.h
··· 18 18 void **, pfn_t *); 19 19 }; 20 20 21 + int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); 22 + #if IS_ENABLED(CONFIG_FS_DAX) 23 + int __bdev_dax_supported(struct super_block *sb, int blocksize); 24 + static inline int bdev_dax_supported(struct super_block *sb, int blocksize) 25 + { 26 + return __bdev_dax_supported(sb, blocksize); 27 + } 28 + #else 29 + static inline int bdev_dax_supported(struct super_block *sb, int blocksize) 30 + { 31 + return -EOPNOTSUPP; 32 + } 33 + #endif 34 + 35 + #if IS_ENABLED(CONFIG_DAX) 36 + struct dax_device *dax_get_by_host(const char *host); 37 + void put_dax(struct dax_device *dax_dev); 38 + #else 39 + static inline struct dax_device *dax_get_by_host(const char *host) 40 + { 41 + return NULL; 42 + } 43 + 44 + static inline void put_dax(struct dax_device *dax_dev) 45 + { 46 + } 47 + #endif 48 + 21 49 int dax_read_lock(void); 22 50 void dax_read_unlock(int id); 23 - struct dax_device *dax_get_by_host(const char *host); 24 51 struct dax_device *alloc_dax(void *private, const char *host, 25 52 const struct dax_operations *ops); 26 - void put_dax(struct dax_device *dax_dev); 27 53 bool dax_alive(struct dax_device *dax_dev); 28 54 void kill_dax(struct dax_device *dax_dev); 29 55 void *dax_get_private(struct dax_device *dax_dev);
+7 -5
include/linux/nd.h
··· 48 48 struct device dev; 49 49 struct device *claim; 50 50 int (*rw_bytes)(struct nd_namespace_common *, resource_size_t offset, 51 - void *buf, size_t size, int rw); 51 + void *buf, size_t size, int rw, unsigned long flags); 52 52 }; 53 53 54 54 static inline struct nd_namespace_common *to_ndns(struct device *dev) ··· 134 134 * @buf is up-to-date upon return from this routine. 135 135 */ 136 136 static inline int nvdimm_read_bytes(struct nd_namespace_common *ndns, 137 - resource_size_t offset, void *buf, size_t size) 137 + resource_size_t offset, void *buf, size_t size, 138 + unsigned long flags) 138 139 { 139 - return ndns->rw_bytes(ndns, offset, buf, size, READ); 140 + return ndns->rw_bytes(ndns, offset, buf, size, READ, flags); 140 141 } 141 142 142 143 /** ··· 153 152 * to media is handled internal to the @ndns driver, if at all. 154 153 */ 155 154 static inline int nvdimm_write_bytes(struct nd_namespace_common *ndns, 156 - resource_size_t offset, void *buf, size_t size) 155 + resource_size_t offset, void *buf, size_t size, 156 + unsigned long flags) 157 157 { 158 - return ndns->rw_bytes(ndns, offset, buf, size, WRITE); 158 + return ndns->rw_bytes(ndns, offset, buf, size, WRITE, flags); 159 159 } 160 160 161 161 #define MODULE_ALIAS_ND_DEVICE(type) \