summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-05 21:49:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-05 21:49:20 -0400
commit53ef7d0e208fa38c3f63d287e0c3ab174f1e1235 (patch)
tree7d437edf73ef6deb0d77ce291aa25f041837d056 /drivers/block
parentc6a677c6f37bb7abc85ba7e3465e82b9f7eb1d91 (diff)
parent736163671bcb163fc82600b46c83dfa89d532d95 (diff)
Merge tag 'libnvdimm-for-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Dan Williams: "The bulk of this has been in multiple -next releases. There were a few late breaking fixes and small features that got added in the last couple days, but the whole set has received a build success notification from the kbuild robot. Change summary: - Region media error reporting: A libnvdimm region device is the parent to one or more namespaces. To date, media errors have been reported via the "badblocks" attribute attached to pmem block devices for namespaces in "raw" or "memory" mode. Given that namespaces can be in "device-dax" or "btt-sector" mode this new interface reports media errors generically, i.e. independent of namespace modes or state. This subsequently allows userspace tooling to craft "ACPI 6.1 Section 9.20.7.6 Function Index 4 - Clear Uncorrectable Error" requests and submit them via the ioctl path for NVDIMM root bus devices. - Introduce 'struct dax_device' and 'struct dax_operations': Prompted by a request from Linus and feedback from Christoph this allows for dax capable drivers to publish their own custom dax operations. This fixes the broken assumption that all dax operations are related to a persistent memory device, and makes it easier for other architectures and platforms to add customized persistent memory support. - 'libnvdimm' core updates: A new "deep_flush" sysfs attribute is available for storage appliance applications to manually trigger memory controllers to drain write-pending buffers that would otherwise be flushed automatically by the platform ADR (asynchronous-DRAM-refresh) mechanism at a power loss event. Support for "locked" DIMMs is included to prevent namespaces from surfacing when the namespace label data area is locked. Finally, fixes for various reported deadlocks and crashes, also tagged for -stable. - ACPI / nfit driver updates: General updates of the nfit driver to add DSM command overrides, ACPI 6.1 health state flags support, DSM payload debug available by default, and various fixes. Acknowledgements that came after the branch was pushed: - commmit 565851c972b5 "device-dax: fix sysfs attribute deadlock": Tested-by: Yi Zhang <yizhan@redhat.com> - commit 23f498448362 "libnvdimm: rework region badblocks clearing" Tested-by: Toshi Kani <toshi.kani@hpe.com>" * tag 'libnvdimm-for-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: (52 commits) libnvdimm, pfn: fix 'npfns' vs section alignment libnvdimm: handle locked label storage areas libnvdimm: convert NDD_ flags to use bitops, introduce NDD_LOCKED brd: fix uninitialized use of brd->dax_dev block, dax: use correct format string in bdev_dax_supported device-dax: fix sysfs attribute deadlock libnvdimm: restore "libnvdimm: band aid btt vs clear poison locking" libnvdimm: fix nvdimm_bus_lock() vs device_lock() ordering libnvdimm: rework region badblocks clearing acpi, nfit: kill ACPI_NFIT_DEBUG libnvdimm: fix clear length of nvdimm_forget_poison() libnvdimm, pmem: fix a NULL pointer BUG in nd_pmem_notify libnvdimm, region: sysfs trigger for nvdimm_flush() libnvdimm: fix phys_addr for nvdimm_clear_poison x86, dax, pmem: remove indirection around memcpy_from_pmem() block: remove block_device_operations ->direct_access() block, dax: convert bdev_dax_supported() to dax_direct_access() filesystem-dax: convert to dax_direct_access() Revert "block: use DAX for partition table reads" ext2, ext4, xfs: retrieve dax_device for iomap operations ...
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/Kconfig1
-rw-r--r--drivers/block/brd.c48
2 files changed, 38 insertions, 11 deletions
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index d545abbd5378..8ddc98279c8f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -323,6 +323,7 @@ config BLK_DEV_SX8
323 323
324config BLK_DEV_RAM 324config BLK_DEV_RAM
325 tristate "RAM block device support" 325 tristate "RAM block device support"
326 select DAX if BLK_DEV_RAM_DAX
326 ---help--- 327 ---help---
327 Saying Y here will allow you to use a portion of your RAM memory as 328 Saying Y here will allow you to use a portion of your RAM memory as
328 a block device, so that you can make file systems on it, read and 329 a block device, so that you can make file systems on it, read and
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 4ec84d504780..57b574f2f66a 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -21,6 +21,7 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#ifdef CONFIG_BLK_DEV_RAM_DAX 22#ifdef CONFIG_BLK_DEV_RAM_DAX
23#include <linux/pfn_t.h> 23#include <linux/pfn_t.h>
24#include <linux/dax.h>
24#endif 25#endif
25 26
26#include <linux/uaccess.h> 27#include <linux/uaccess.h>
@@ -41,6 +42,9 @@ struct brd_device {
41 42
42 struct request_queue *brd_queue; 43 struct request_queue *brd_queue;
43 struct gendisk *brd_disk; 44 struct gendisk *brd_disk;
45#ifdef CONFIG_BLK_DEV_RAM_DAX
46 struct dax_device *dax_dev;
47#endif
44 struct list_head brd_list; 48 struct list_head brd_list;
45 49
46 /* 50 /*
@@ -326,30 +330,38 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector,
326} 330}
327 331
328#ifdef CONFIG_BLK_DEV_RAM_DAX 332#ifdef CONFIG_BLK_DEV_RAM_DAX
329static long brd_direct_access(struct block_device *bdev, sector_t sector, 333static long __brd_direct_access(struct brd_device *brd, pgoff_t pgoff,
330 void **kaddr, pfn_t *pfn, long size) 334 long nr_pages, void **kaddr, pfn_t *pfn)
331{ 335{
332 struct brd_device *brd = bdev->bd_disk->private_data;
333 struct page *page; 336 struct page *page;
334 337
335 if (!brd) 338 if (!brd)
336 return -ENODEV; 339 return -ENODEV;
337 page = brd_insert_page(brd, sector); 340 page = brd_insert_page(brd, PFN_PHYS(pgoff) / 512);
338 if (!page) 341 if (!page)
339 return -ENOSPC; 342 return -ENOSPC;
340 *kaddr = page_address(page); 343 *kaddr = page_address(page);
341 *pfn = page_to_pfn_t(page); 344 *pfn = page_to_pfn_t(page);
342 345
343 return PAGE_SIZE; 346 return 1;
344} 347}
345#else 348
346#define brd_direct_access NULL 349static long brd_dax_direct_access(struct dax_device *dax_dev,
350 pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn)
351{
352 struct brd_device *brd = dax_get_private(dax_dev);
353
354 return __brd_direct_access(brd, pgoff, nr_pages, kaddr, pfn);
355}
356
357static const struct dax_operations brd_dax_ops = {
358 .direct_access = brd_dax_direct_access,
359};
347#endif 360#endif
348 361
349static const struct block_device_operations brd_fops = { 362static const struct block_device_operations brd_fops = {
350 .owner = THIS_MODULE, 363 .owner = THIS_MODULE,
351 .rw_page = brd_rw_page, 364 .rw_page = brd_rw_page,
352 .direct_access = brd_direct_access,
353}; 365};
354 366
355/* 367/*
@@ -415,9 +427,6 @@ static struct brd_device *brd_alloc(int i)
415 * is harmless) 427 * is harmless)
416 */ 428 */
417 blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE); 429 blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE);
418#ifdef CONFIG_BLK_DEV_RAM_DAX
419 queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue);
420#endif
421 disk = brd->brd_disk = alloc_disk(max_part); 430 disk = brd->brd_disk = alloc_disk(max_part);
422 if (!disk) 431 if (!disk)
423 goto out_free_queue; 432 goto out_free_queue;
@@ -430,8 +439,21 @@ static struct brd_device *brd_alloc(int i)
430 sprintf(disk->disk_name, "ram%d", i); 439 sprintf(disk->disk_name, "ram%d", i);
431 set_capacity(disk, rd_size * 2); 440 set_capacity(disk, rd_size * 2);
432 441
442#ifdef CONFIG_BLK_DEV_RAM_DAX
443 queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue);
444 brd->dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops);
445 if (!brd->dax_dev)
446 goto out_free_inode;
447#endif
448
449
433 return brd; 450 return brd;
434 451
452#ifdef CONFIG_BLK_DEV_RAM_DAX
453out_free_inode:
454 kill_dax(brd->dax_dev);
455 put_dax(brd->dax_dev);
456#endif
435out_free_queue: 457out_free_queue:
436 blk_cleanup_queue(brd->brd_queue); 458 blk_cleanup_queue(brd->brd_queue);
437out_free_dev: 459out_free_dev:
@@ -471,6 +493,10 @@ out:
471static void brd_del_one(struct brd_device *brd) 493static void brd_del_one(struct brd_device *brd)
472{ 494{
473 list_del(&brd->brd_list); 495 list_del(&brd->brd_list);
496#ifdef CONFIG_BLK_DEV_RAM_DAX
497 kill_dax(brd->dax_dev);
498 put_dax(brd->dax_dev);
499#endif
474 del_gendisk(brd->brd_disk); 500 del_gendisk(brd->brd_disk);
475 brd_free(brd); 501 brd_free(brd);
476} 502}