dax: I/O path enhancements
Subsystems (10)
v3 cover dax: I/O path enhancements
The goal of this series is to enhance the DAX I/O path so that all operations that store data (I/O writes, zeroing blocks, punching holes, etc.) properly synchronize the stores to media using the PMEM API. This ensures that the data DAX is writing is durable on media before the operation completes.
Patches 1-4 are a few random cleanups.
Changes from v2:
- Introduce copy_from_iter_pmem() as part of the PMEM API. Keep the use of __arch_wmb_cache_pmem() internal to the implmentation of the PMEM API. (Dan)
Ross Zwisler (7):
brd: make rd_size static
pmem, x86: move x86 PMEM API to new pmem.h header
pmem: remove layer when calling arch_has_wmb_pmem() pmem, x86: clean up conditional pmem includes
pmem: add copy_from_iter_pmem() and clear_pmem()
dax: update I/O path to do proper PMEM flushing pmem, dax: have direct_access use __pmem annotation
Documentation/filesystems/Locking | 3 +- MAINTAINERS | 1 + arch/powerpc/sysdev/axonram.c | 7 +- arch/x86/include/asm/cacheflush.h | 71 ------------------ arch/x86/include/asm/pmem.h | 152 ++++++++++++++++++++++++++++++++++++++ drivers/block/brd.c | 6 +- drivers/nvdimm/pmem.c | 4 +- drivers/s390/block/dcssblk.c | 10 ++- fs/block_dev.c | 2 +- fs/dax.c | 68 ++++++++++------- include/linux/blkdev.h | 8 +- include/linux/pmem.h | 78 +++++++++++++++---- 12 files changed, 282 insertions(+), 128 deletions(-) create mode 100644 arch/x86/include/asm/pmem.h
Signature · 1 line
2.1.0
PATCH v3 1/7 brd: make rd_size static
Make rd_size static because it is local to drivers/block/brd.c
This was reported by sparse:
drivers/block/brd.c:445:5: warning: symbol 'rd_size' was not declared. Should it be static?
--- drivers/block/brd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/brd.c +1 -1
@@ -442,7 +442,7 @@ static int rd_nr = CONFIG_BLK_DEV_RAM_COUNT;module_param (rd_nr, int,S_IRUGO );MODULE_PARM_DESC (rd_nr,"Maximum number of brd devices" ); -int rd_size =CONFIG_BLK_DEV_RAM_SIZE ; +static int rd_size =CONFIG_BLK_DEV_RAM_SIZE ;module_param (rd_size, int,S_IRUGO );MODULE_PARM_DESC (rd_size,"Size of each RAM disk in kbytes." );
Signature · 1 line
2.1.0
Re: [PATCH v3 1/7] brd: make rd_size static
Looks good,
PATCH v3 2/7 pmem, x86: move x86 PMEM API to new pmem.h header
In reply to Ross ZwislerMove the x86 PMEM API implementation out of asm/cacheflush.h and into its own header asm/pmem.h. This will allow members of the PMEM API to be more easily identified on this and other architectures.
--- MAINTAINERS | 1 + arch/x86/include/asm/cacheflush.h | 71 ------------------------------ arch/x86/include/asm/pmem.h | 92 +++++++++++++++++++++++++++++++++++++++ include/linux/pmem.h | 2 +- 4 files changed, 94 insertions(+), 72 deletions(-) create mode 100644 arch/x86/include/asm/pmem.h
MAINTAINERS +1 -0
@@ -6165,6 +6165,7 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ S: Supported F: drivers/nvdimm/pmem.c F: include/linux/pmem.h +F: arch/*/include/asm/pmem.h LINUX FOR IBM pSERIES (RS/6000) M: Paul Mackerras <[email protected]>
arch/x86/include/asm/cacheflush.h +0 -71
75 lines not on this page · raw message
arch/x86/include/asm/pmem.h new file +92 -0
92 lines not on this page · raw message
include/linux/pmem.h +1 -1
@@ -16,7 +16,7 @@#include <linux/io.h> #ifdef CONFIG_ARCH_HAS_PMEM_API -#include <asm/cacheflush.h> +#include <asm/pmem.h> #else static inline void arch_wmb_pmem (void ) {
Signature · 1 line
2.1.0
PATCH v3 3/7 pmem: remove layer when calling arch_has_wmb_pmem()
In reply to Ross ZwislerPrior to this change arch_has_wmb_pmem() was only called by arch_has_pmem_api(). Both arch_has_wmb_pmem() and arch_has_pmem_api() checked to make sure that CONFIG_ARCH_HAS_PMEM_API was enabled.
Instead, remove the old arch_has_wmb_pmem() wrapper to be rid of one extra layer of indirection and the redundant CONFIG_ARCH_HAS_PMEM_API check. Rename __arch_has_wmb_pmem() to arch_has_wmb_pmem() since we no longer have a wrapper, and just have arch_has_pmem_api() call the architecture specific arch_has_wmb_pmem() directly.
--- arch/x86/include/asm/pmem.h | 2 +- include/linux/pmem.h | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-)
arch/x86/include/asm/pmem.h +1 -1
@@ -67,7 +67,7 @@ static inline void arch_wmb_pmem(void)pcommit_sfence (); } -static inline bool __arch_has_wmb_pmem (void ) +static inline bool arch_has_wmb_pmem (void ) {#ifdef CONFIG_X86_64 /*
include/linux/pmem.h +3 -10
@@ -23,7 +23,7 @@ static inline void arch_wmb_pmem(void)BUG (); } -static inline bool __arch_has_wmb_pmem (void ) +static inline bool arch_has_wmb_pmem (void ) {return false; }
@@ -44,7 +44,7 @@ static inline void arch_memcpy_to_pmem(void __pmem *dst, const void *src,/* * Architectures that define ARCH_HAS_PMEM_API must provide * implementations for arch_memremap_pmem(), arch_memcpy_to_pmem(), -* arch_wmb_pmem(), and __arch_has_wmb_pmem(). +* arch_wmb_pmem(), and arch_has_wmb_pmem(). */ static inline void memcpy_from_pmem(void *dst, void __pmem const *src, size_t size)
@@ -58,7 +58,7 @@ static inline void memunmap_pmem(void __pmem *addr) }/** -* arch_has_wmb_pmem - true if wmb_pmem() ensures durability +* arch_has_pmem_api - true if wmb_pmem() ensures durability * * For a given cpu implementation within an architecture it is possible * that wmb_pmem() resolves to a nop. In the case this returns
@@ -66,13 +66,6 @@ static inline void memunmap_pmem(void __pmem *addr)* fall back to a different data consistency model, or otherwise notify * the user. */ -static inline bool arch_has_wmb_pmem (void ) -{ -if (IS_ENABLED (CONFIG_ARCH_HAS_PMEM_API )) -return __arch_has_wmb_pmem (); -return false; -} -static inline bool arch_has_pmem_api (void ) {return IS_ENABLED (CONFIG_ARCH_HAS_PMEM_API ) &&arch_has_wmb_pmem ();
Signature · 1 line
2.1.0
PATCH v3 4/7 pmem, x86: clean up conditional pmem includes
In reply to Ross ZwislerPrior to this change x86_64 used the pmem defines in arch/x86/include/asm/pmem.h, and UM used the default ones at the top of include/linux/pmem.h. The inclusion or exclusion in linux/pmem.h was controlled by CONFIG_ARCH_HAS_PMEM_API, but the ones in asm/pmem.h were controlled by ARCH_HAS_NOCACHE_UACCESS.
Instead, control them both with CONFIG_ARCH_HAS_PMEM_API so that it's clear that they are related and we don't run into the possibility where they are both included or excluded. Also remove a bunch of stale function prototypes meant for UM in asm/pmem.h - these just conflicted with the inline defaults in linux/pmem.h and gave compile errors.
--- arch/x86/include/asm/pmem.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
arch/x86/include/asm/pmem.h +2 -11
@@ -18,8 +18,7 @@#include <asm/cpufeature.h> #include <asm/special_insns.h> -#ifdef ARCH_HAS_NOCACHE_UACCESS - +#ifdef CONFIG_ARCH_HAS_PMEM_API /** * arch_memcpy_to_pmem - copy data to persistent memory * @dst: destination buffer for the copy
@@ -79,14 +78,6 @@ static inline bool arch_has_wmb_pmem(void)return false;#endif } -#else /* ARCH_HAS_NOCACHE_UACCESS i.e. ARCH=um */ -extern void arch_memcpy_to_pmem(void __pmem *dst, const void *src, size_t n); -extern void arch_wmb_pmem (void ); - -static inline bool __arch_has_wmb_pmem (void ) -{ -return false; -} -#endif +#endif /* CONFIG_ARCH_HAS_PMEM_API */ #endif /* __ASM_X86_PMEM_H__ */
Signature · 1 line
2.1.0
Re: [PATCH v3 4/7] pmem, x86: clean up conditional pmem includes
Looks good,
PATCH v3 5/7 pmem: add copy_from_iter_pmem() and clear_pmem()
In reply to Ross ZwislerAdd support for two new PMEM APIs, copy_from_iter_pmem() and clear_pmem(). copy_from_iter_pmem() is used to copy data from an iterator into a PMEM buffer. clear_pmem() zeros a PMEM memory range.
Both of these new APIs must be explicitly ordered using a wmb_pmem() function call and are implemented in such a way that the wmb_pmem() will make the stores to PMEM durable. Because both APIs are unordered they can be called as needed without introducing any unwanted memory barriers.
--- arch/x86/include/asm/pmem.h | 69 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pmem.h | 65 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 131 insertions(+), 3 deletions(-)
arch/x86/include/asm/pmem.h +69 -0
@@ -14,6 +14,8 @@#define __ASM_X86_PMEM_H__#include <linux/uaccess.h> +#include <linux/uio.h> +#include <asm/cacheflush.h> #include <asm/cpufeature.h> #include <asm/special_insns.h>
@@ -66,6 +68,73 @@ static inline void arch_wmb_pmem(void)pcommit_sfence (); } +/** +* __arch_wb_cache_pmem - write back a cache range with CLWB +* @addr: virtual start address +* @size: number of bytes to write back +* +* Write back a cache range using the CLWB (cache line write back) +* instruction. This function requires explicit ordering with an +* arch_wmb_pmem() call. This API is internal to the x86 PMEM implementation. +*/ +static inline void __arch_wb_cache_pmem(void __pmem *addr, size_t size) +{ +u16 x86_clflush_size = boot_cpu_data.x86_clflush_size; +unsigned long clflush_mask = x86_clflush_size -1 ; +void *vend = (void __force *)addr + size; +void *p; + +for (p = (void *)((unsigned long )addr & ~clflush_mask); + p < vend; p += x86_clflush_size) +clwb (p); +} + +/** +* arch_copy_from_iter_pmem - copy data from an iterator to PMEM +* @addr: PMEM destination address +* @bytes: number of bytes to copy +* @i: iterator with source data +* +* Copy data from the iterator 'i' to the PMEM buffer starting at 'addr'. +* This function requires explicit ordering with an arch_wmb_pmem() call. +*/ +static inline size_t arch_copy_from_iter_pmem(void __pmem *addr, size_t bytes, +struct iov_iter *i) +{ +size_t len; + + len =copy_from_iter_nocache ((void __force *)addr, bytes, i); + +/* +* copy_from_iter_nocache() on x86 only uses non-temporal stores for +* iovec iterators, so for other types (bvec & kvec) we must do a +* cache write-back. +*/ +if (iter_is_iovec (i) == false) +__arch_wb_cache_pmem (addr, bytes); + +return len; +} + +/** +* arch_clear_pmem - zero a PMEM memory range +* @addr: virtual start address +* @size: number of bytes to zero +* +* Write zeros into the memory range starting at 'addr' for 'size' bytes. +* This function requires explicit ordering with an arch_wmb_pmem() call. +*/ +static inline void arch_clear_pmem(void __pmem *addr, size_t size) +{ +/* TODO: implement the zeroing via non-temporal writes */ +if (size ==PAGE_SIZE && ((unsigned long )addr & ~PAGE_MASK ) ==0 ) +clear_page ((void __force *)addr); +else +memset ((void __force *)addr,0 , size); + +__arch_wb_cache_pmem (addr, size); +} +static inline bool arch_has_wmb_pmem (void ) {#ifdef CONFIG_X86_64
include/linux/pmem.h +62 -3
84 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [PATCH v3 5/7] pmem: add copy_from_iter_pmem() and clear_pmem()
arch/x86/include/asm/pmem.h line 18
Quoted 3 lines
#include <
linux/uaccess.h>arch/x86/include/asm/pmem.h +2
-0+#include <linux/uio.h> +
Can we keep this in linux/pmem.h? I'm pretty sure the stubs would need it as well, and even if they don't it'll keep the includes consistent.
arch/x86/include/asm/pmem.h static inline void arch_wmb_pmem(void) · line 111
Quoted 9 lines
arch/x86/include/asm/pmem.h +9
-0+{ +size_t len; + + len =copy_from_iter_nocache ((void __force *)addr, bytes, i); + +/* +* copy_from_iter_nocache() on x86 only uses non-temporal stores for +* iovec iterators, so for other types (bvec & kvec) we must do a +* cache write-back.
Shouldn't we fi that?
arch/x86/include/asm/pmem.h static inline void arch_wmb_pmem(void) · line 114
Quoted 3 lines
arch/x86/include/asm/pmem.h +3
-0+*/ +if (iter_is_iovec (i) == false) +__arch_wb_cache_pmem (addr, bytes);
And if not and iter_needs_pmem_wb helper to encode this knowledge would be useful.
arch/x86/include/asm/pmem.h static inline void arch_wmb_pmem(void) · line 135
Quoted 9 lines
arch/x86/include/asm/pmem.h +9
-0+static inline void arch_clear_pmem(void __pmem *addr, size_t size) +{ +/* TODO: implement the zeroing via non-temporal writes */ +if (size ==PAGE_SIZE && ((unsigned long )addr & ~PAGE_MASK ) ==0 ) +clear_page ((void __force *)addr); +else +memset ((void __force *)addr,0 , size); + +__arch_wb_cache_pmem (addr, size);
Please add a local vaiable so that the __force casting is only needed once. Same for other functions with this pattern.
Re: [PATCH v3 5/7] pmem: add copy_from_iter_pmem() and clear_pmem()
Quoted 6 lines · Christoph Hellwig
arch/x86/include/asm/pmem.h line 18
Quoted 3 lines
#include <
linux/uaccess.h>arch/x86/include/asm/pmem.h +2
-0+#include <linux/uio.h> +Can we keep this in
linux/pmem.h? I'm pretty sure the stubs would need it as well, and even if they don't it'll keep the includes consistent.
Sure.
Quoted 11 lines
arch/x86/include/asm/pmem.h static inline void arch_wmb_pmem(void) · line 111
Quoted 9 lines
arch/x86/include/asm/pmem.h +9
-0+{ +size_t len; + + len =copy_from_iter_nocache ((void __force *)addr, bytes, i); + +/* +* copy_from_iter_nocache() on x86 only uses non-temporal stores for +* iovec iterators, so for other types (bvec & kvec) we must do a +* cache write-back. Shouldn't we fi that?
I'm not sure - When Al make copy_from_iter_nocache() it was just a copy of copy_from_iter(), with the iovec case changed to use __copy_from_user_nocache(). The other cases use memcpy_from_page() and memcpy(). To have everything do non-temporal stores we'd probably need to make non-temporal versions of each of those (alluded to by Al's comment in the copy_from_iter_nocache() commit: "BTW, do we want memcpy_nocache()?").
Quoted 6 lines
arch/x86/include/asm/pmem.h static inline void arch_wmb_pmem(void) · line 114
Quoted 3 lines
arch/x86/include/asm/pmem.h +3
-0+*/ +if (iter_is_iovec (i) == false) +__arch_wb_cache_pmem (addr, bytes);And if not and
iter_needs_pmem_wbhelper to encode this knowledge would be useful.
Maybe this should be the short-term solution, and I'll add a TODO to fix the copy_from_iter_nocache() implementation as described above so we can always have non-temporal stores?
Quoted 4 lines
Quoted 4 lines
arch/x86/include/asm/pmem.h +4
-0+static inline void arch_clear_pmem(void __pmem *addr, size_t size) +{ +/* TODO: implement the zeroing via non-temporal writes */ +if (size ==PAGE_SIZE && ((unsigned long )addr & ~PAGE_MASK ) ==0 )
Quoted 8 lines
arch/x86/include/asm/pmem.h static inline void arch_wmb_pmem(void) · line 135
Quoted 5 lines
arch/x86/include/asm/pmem.h +5
-0+clear_page ((void __force *)addr); + else + memset((void __force *)addr, 0, size); + +__arch_wb_cache_pmem (addr, size);Please add a local vaiable so that the
__forcecasting is only needed once. Same for other functions with this pattern.
Sure.
PATCH v3 6/7 dax: update I/O path to do proper PMEM flushing
In reply to Ross ZwislerUpdate the DAX I/O path so that all operations that store data (I/O writes, zeroing blocks, punching holes, etc.) properly synchronize the stores to media using the PMEM API. This ensures that the data DAX is writing is durable on media before the operation completes.
--- fs/dax.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-)
fs/dax.c +29 -15
@@ -17,12 +17,14 @@#include <linux/atomic.h> #include <linux/blkdev.h> #include <linux/buffer_head.h> +#include <linux/dax.h> #include <linux/fs.h> #include <linux/genhd.h> #include <linux/highmem.h> #include <linux/memcontrol.h> #include <linux/mm.h> #include <linux/mutex.h> +#include <linux/pmem.h> #include <linux/sched.h> #include <linux/uio.h> #include <linux/vmstat.h>
@@ -46,10 +48,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)unsigned pgsz =PAGE_SIZE -offset_in_page (addr);if (pgsz > count) pgsz = count; -if (pgsz <PAGE_SIZE ) -memset (addr,0 , pgsz); -else -clear_page (addr); + clear_pmem((void __pmem *)addr, pgsz); addr += pgsz; size -= pgsz; count -= pgsz;
@@ -59,6 +58,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size) } }while (size); +wmb_pmem ();return 0 ; }EXPORT_SYMBOL_GPL (dax_clear_blocks);
@@ -70,15 +70,16 @@ static long dax_get_addr(struct buffer_head *bh, void **addr, unsigned blkbits)return bdev_direct_access (bh->b_bdev, sector, addr, &pfn, bh->b_size); } +/* the clear_pmem() calls are ordered by a wmb_pmem() in the caller */ static void dax_new_buf (void *addr,unsigned size,unsigned first,loff_t pos,loff_t end) {loff_t final = end - pos + first;/* The final byte of the buffer */ if (first >0 ) -memset (addr,0 , first); + clear_pmem((void __pmem *)addr, first);if (final < size) -memset (addr + final,0 , size - final); + clear_pmem((void __pmem *)addr + final, size - final); }static bool buffer_written (struct buffer_head *bh)
@@ -108,12 +109,13 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,loff_t bh_max = start;void *addr;bool hole = false; +bool need_wmb = false;if (iov_iter_rw (iter) !=WRITE ) end =min (end,i_size_read (inode));while (pos < end) { -unsigned len; +size_t len;if (pos == max) {unsigned blkbits = inode->i_blkbits;sector_t block = pos >> blkbits;
@@ -145,18 +147,22 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, retval =dax_get_addr (bh, &addr, blkbits);if (retval <0 )break ; -if (buffer_unwritten (bh) ||buffer_new (bh)) +if (buffer_unwritten (bh) ||buffer_new (bh)) {dax_new_buf (addr, retval, first, pos, end); + need_wmb = true; + } addr += first; size = retval - first; } max =min (pos + size, end); } -if (iov_iter_rw (iter) ==WRITE ) - len =copy_from_iter_nocache (addr, max - pos, iter); -else if (!hole) +if (iov_iter_rw (iter) ==WRITE ) { + len = copy_from_iter_pmem((void __pmem *)addr, + max - pos, iter); + need_wmb = true; + }else if (!hole) len =copy_to_iter (addr, max - pos, iter);else len =iov_iter_zero (max - pos, iter);
@@ -168,6 +174,9 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, addr += len; } +if (need_wmb) +wmb_pmem (); +return (pos == start) ? retval : pos - start; }
@@ -300,8 +309,10 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, goto out; } -if (buffer_unwritten (bh) ||buffer_new (bh)) -clear_page (addr); +if (buffer_unwritten (bh) ||buffer_new (bh)) { + clear_pmem((void __pmem *)addr, PAGE_SIZE); +wmb_pmem (); + } error =vm_insert_mixed (vma, vaddr, pfn);
@@ -608,7 +619,9 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address,if (buffer_unwritten (&bh) ||buffer_new (&bh)) {int i;for (i =0 ; i <PTRS_PER_PMD ; i++) -clear_page (kaddr + i *PAGE_SIZE ); + clear_pmem((void __pmem *)kaddr + i*PAGE_SIZE, +PAGE_SIZE ); +wmb_pmem ();count_vm_event (PGMAJFAULT );mem_cgroup_count_vm_event (vma->vm_mm,PGMAJFAULT ); result |=VM_FAULT_MAJOR ;
@@ -720,7 +733,8 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length, err =dax_get_addr (&bh, &addr, inode->i_blkbits);if (err <0 )return err; -memset (addr + offset,0 , length); + clear_pmem((void __pmem *)addr + offset, length); +wmb_pmem (); }return 0 ;
Signature · 1 line
2.1.0
Re: [PATCH v3 6/7] dax: update I/O path to do proper PMEM flushing
Quoted 6 lines · Ross Zwisler
Update the DAX I/O path so that all operations that store data (I/O writes, zeroing blocks, punching holes, etc.) properly synchronize the stores to media using the PMEM API. This ensures that the data DAX is writing is durable on media before the operation completes.
Signed-off-by Ross Zwisler <[email protected]>
Looks fine (at least as long as the next patch also goes in to cut down on the crazy amount of __pmem casts..)
PATCH v3 7/7 pmem, dax: have direct_access use __pmem annotation
In reply to Ross ZwislerUpdate the annotation for the kaddr pointer returned by direct_access() so that it is a __pmem pointer. This is consistent with the PMEM driver and with how this direct_access() pointer is used in the DAX code.
--- Documentation/filesystems/Locking | 3 ++- arch/powerpc/sysdev/axonram.c | 7 ++++--- drivers/block/brd.c | 4 ++-- drivers/nvdimm/pmem.c | 4 ++-- drivers/s390/block/dcssblk.c | 10 ++++++---- fs/block_dev.c | 2 +- fs/dax.c | 42 ++++++++++++++++++++------------------- include/linux/blkdev.h | 8 ++++---- 8 files changed, 43 insertions(+), 37 deletions(-)
Documentation/filesystems/Locking +2 -1
@@ -397,7 +397,8 @@ prototypes: int (*release) (struct gendisk *, fmode_t); int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); - int (*direct_access) (struct block_device *, sector_t, void **, unsigned long *); + int (*direct_access) (struct block_device *, sector_t, void __pmem **, + unsigned long *); int (*media_changed) (struct gendisk *); void (*unlock_native_capacity) (struct gendisk *); int (*revalidate_disk) (struct gendisk *);
arch/powerpc/sysdev/axonram.c +4 -3
@@ -141,13 +141,14 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)*/ static long axon_ram_direct_access (struct block_device *device,sector_t sector, -void **kaddr,unsigned long *pfn,long size) + void __pmem **kaddr, unsigned long *pfn, long size) {struct axon_ram_bank *bank = device->bd_disk->private_data;loff_t offset = (loff_t )sector <<AXON_RAM_SECTOR_SHIFT ; +void *addr = (void *)(bank->ph_addr + offset); - *kaddr = (void *)(bank->ph_addr + offset); - *pfn =virt_to_phys (*kaddr) >>PAGE_SHIFT ; + *kaddr = (void __pmem *)addr; + *pfn =virt_to_phys (addr) >>PAGE_SHIFT ;return bank->size - offset; }
drivers/block/brd.c +2 -2
@@ -371,7 +371,7 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector,#ifdef CONFIG_BLK_DEV_RAM_DAX static long brd_direct_access (struct block_device *bdev,sector_t sector, -void **kaddr,unsigned long *pfn,long size) + void __pmem **kaddr, unsigned long *pfn, long size) {struct brd_device *brd = bdev->bd_disk->private_data;struct page *page;
@@ -381,7 +381,7 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector, page =brd_insert_page (brd, sector);if (!page)return -ENOSPC ; - *kaddr =page_address (page); + *kaddr = (void __pmem *)page_address(page); *pfn =page_to_pfn (page);/*
drivers/nvdimm/pmem.c +2 -2
@@ -92,7 +92,7 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, }static long pmem_direct_access (struct block_device *bdev,sector_t sector, -void **kaddr,unsigned long *pfn,long size) + void __pmem **kaddr, unsigned long *pfn, long size) {struct pmem_device *pmem = bdev->bd_disk->private_data;size_t offset = sector <<9 ;
@@ -101,7 +101,7 @@ static long pmem_direct_access(struct block_device *bdev, sector_t sector,return -ENODEV ;/* FIXME convert DAX to comprehend that this mapping has a lifetime */ - *kaddr = (void __force *) pmem->virt_addr + offset; + *kaddr = pmem->virt_addr + offset; *pfn = (pmem->phys_addr + offset) >>PAGE_SHIFT ;return pmem->size - offset;
drivers/s390/block/dcssblk.c +6 -4
@@ -29,7 +29,7 @@ static int dcssblk_open(struct block_device *bdev, fmode_t mode);static void dcssblk_release (struct gendisk *disk,fmode_t mode);static void dcssblk_make_request (struct request_queue *q,struct bio *bio);static long dcssblk_direct_access (struct block_device *bdev,sector_t secnum, -void **kaddr,unsigned long *pfn,long size); + void __pmem **kaddr, unsigned long *pfn, long size);static char dcssblk_segments[DCSSBLK_PARM_LEN ] ="\0" ;
@@ -879,18 +879,20 @@ fail:static long dcssblk_direct_access (struct block_device *bdev,sector_t secnum, -void **kaddr,unsigned long *pfn,long size) + void __pmem **kaddr, unsigned long *pfn, long size) {struct dcssblk_dev_info *dev_info;unsigned long offset, dev_sz; +void *addr; dev_info = bdev->bd_disk->private_data;if (!dev_info)return -ENODEV ; dev_sz = dev_info->end - dev_info->start; offset = secnum *512 ; - *kaddr = (void *) (dev_info->start + offset); - *pfn =virt_to_phys (*kaddr) >>PAGE_SHIFT ; + addr = (void *) (dev_info->start + offset); + *pfn =virt_to_phys (addr) >>PAGE_SHIFT ; + *kaddr = (void __pmem *) addr;return dev_sz - offset; }
fs/block_dev.c +1 -1
@@ -442,7 +442,7 @@ EXPORT_SYMBOL_GPL(bdev_write_page);* accessible at this address. */ long bdev_direct_access (struct block_device *bdev,sector_t sector, -void **addr,unsigned long *pfn,long size) + void __pmem **addr, unsigned long *pfn, long size) {long avail;const struct block_device_operations *ops = bdev->bd_disk->fops;
fs/dax.c +22 -20
127 lines not on this page · raw message
include/linux/blkdev.h +4 -4
@@ -1555,8 +1555,8 @@ struct block_device_operations {int (*rw_page)(struct block_device *,sector_t ,struct page *,int rw);int (*ioctl) (struct block_device *,fmode_t ,unsigned ,unsigned long );int (*compat_ioctl) (struct block_device *,fmode_t ,unsigned ,unsigned long ); -long (*direct_access)(struct block_device *,sector_t , -void **,unsigned long *pfn,long size); + long (*direct_access)(struct block_device *, sector_t, void __pmem **, +unsigned long *pfn,long size);unsigned int (*check_events) (struct gendisk *disk,unsigned int clearing);/* ->media_changed() is DEPRECATED, use ->check_events() instead */
@@ -1574,8 +1574,8 @@ extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,extern int bdev_read_page (struct block_device *,sector_t ,struct page *);extern int bdev_write_page (struct block_device *,sector_t ,struct page *,struct writeback_control *); -extern long bdev_direct_access (struct block_device *,sector_t ,void **addr, -unsigned long *pfn,long size); +extern long bdev_direct_access (struct block_device *,sector_t , + void __pmem **addr, unsigned long *pfn, long size);#else /* CONFIG_BLOCK */ struct block_device ;
Signature · 1 line
2.1.0
Re: [PATCH v3 7/7] pmem, dax: have direct_access use __pmem annotation
Looks fine,