[PATCH v3 4/5] Documentation/device-mapper: add optional parameter reinit
From: Huaisheng Ye Add intro and usage guide for reinit. Signed-off-by: Huaisheng Ye --- Documentation/device-mapper/writecache.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/device-mapper/writecache.txt b/Documentation/device-mapper/writecache.txt index 01532b3..255c68c 100644 --- a/Documentation/device-mapper/writecache.txt +++ b/Documentation/device-mapper/writecache.txt @@ -45,6 +45,10 @@ Constructor parameters: afterwards - some underlying devices perform better with fua, some with nofua. The user should test it + reinit (by default off) + applicable only to persistent memory - use the REINIT flag + when the surper block has messy data, that would cause fn ctr + failed to work with invalid magic or version in the superblock Status: 1. error indicator - 0 if there was no error, otherwise error number -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 5/5] dm-writecache: output seq_count within status
From: Huaisheng Ye seq_count is important for flush operations, output it within status for debugging and analyzing code behavior. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2c1e825..3396710 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -2231,9 +2231,9 @@ static void writecache_status(struct dm_target *ti, status_type_t type, switch (type) { case STATUSTYPE_INFO: - DMEMIT("%ld %llu %llu %llu", writecache_has_error(wc), + DMEMIT("%ld %llu %llu %llu %llu", writecache_has_error(wc), (unsigned long long)wc->n_blocks, (unsigned long long)wc->freelist_size, - (unsigned long long)wc->writeback_size); + (unsigned long long)wc->writeback_size, wc->seq_count); break; case STATUSTYPE_TABLE: DMEMIT("%c %s %s %u ", WC_MODE_PMEM(wc) ? 'p' : 's', -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 0/5] Optimize writecache when using pmem as cache
From: Huaisheng Ye This patch set could be used for dm-writecache when use persistent memory as cache data device. Patch 1 and 2 go towards removing unused parameter and codes which actually doesn't really work. Patch 3 and 4 are targeted at solving problem fn ctr failed to work due to invalid magic or version, which is caused by the super block of pmem has messy data stored. Patch 5 is used for getting the status of seq_count. Changes Since v2: - seq_count is important for flush operations, output it within status for debugging and analyzing code behavior. [1]: https://lkml.org/lkml/2019/1/3/43 [2]: https://lkml.org/lkml/2019/1/9/6 Huaisheng Ye (5): dm-writecache: remove unused size to writecache_flush_region dm-writecache: get rid of memory_data flush to writecache_flush_entry dm-writecache: expand pmem_reinit for struct dm_writecache Documentation/device-mapper: add optional parameter reinit dm-writecache: output seq_count within status Documentation/device-mapper/writecache.txt | 4 drivers/md/dm-writecache.c | 23 +-- 2 files changed, 17 insertions(+), 10 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 3/5] dm-writecache: expand pmem_reinit for struct dm_writecache
From: Huaisheng Ye When use persistent memory as cache data device, sometimes the super block of pmem has messy data stored in it. That would have risk to lead fn ctr failed to work due to invalid magic or version. Here we expand pmem_reinit to optional parameters in order to solve this issue. When user gets pmem device, which has unrelated data, as cache device, he should use paramenter 'reinit' to avoid s.magic and s.version don't equal to NULL or correct MEMORY_SUPERBLOCK_MAGIC/VERSION. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index c69317c..2c1e825 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -149,6 +149,7 @@ struct dm_writecache { bool pmem_mode:1; bool writeback_fua:1; + bool pmem_reinit:1; bool overwrote_committed:1; bool memory_vmapped:1; @@ -2026,6 +2027,10 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) wc->writeback_fua = false; wc->writeback_fua_set = true; } else goto invalid_optional; + } else if (!strcasecmp(string, "reinit")) { + if (WC_MODE_PMEM(wc)) + wc->pmem_reinit = true; + else goto invalid_optional; } else { invalid_optional: r = -EINVAL; @@ -2127,7 +2132,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) ti->error = "Hardware memory error when reading superblock"; goto bad; } - if (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version)) { + if (wc->pmem_reinit || (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version))) { r = init_memory(wc); if (r) { ti->error = "Unable to initialize device"; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 1/5] dm-writecache: remove unused size to writecache_flush_region
From: Huaisheng Ye writecache_flush_region doesn't use size to calculate flush region. That uses _set_bits to mark the region in dirty_bitmap directly. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2d50eec..2d8e0c0 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -418,7 +418,7 @@ static void writecache_flush_all_metadata(struct dm_writecache *wc) memset(wc->dirty_bitmap, -1, wc->dirty_bitmap_size); } -static void writecache_flush_region(struct dm_writecache *wc, void *ptr, size_t size) +static void writecache_flush_region(struct dm_writecache *wc, void *ptr) { if (!WC_MODE_PMEM(wc)) __set_bit(((char *)ptr - (char *)wc->memory_map) / BITMAP_GRANULARITY, @@ -657,7 +657,7 @@ static void writecache_free_entry(struct dm_writecache *wc, struct wc_entry *e) writecache_unlink(wc, e); writecache_add_to_freelist(wc, e); clear_seq_count(wc, e); - writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry)); + writecache_flush_region(wc, memory_entry(wc, e)); if (unlikely(waitqueue_active(&wc->freelist_wait))) wake_up(&wc->freelist_wait); } @@ -687,9 +687,9 @@ static void writecache_poison_lists(struct dm_writecache *wc) static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e) { - writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry)); + writecache_flush_region(wc, memory_entry(wc, e)); if (WC_MODE_PMEM(wc)) - writecache_flush_region(wc, memory_data(wc, e), wc->block_size); + writecache_flush_region(wc, memory_data(wc, e)); } static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e) @@ -733,7 +733,7 @@ static void writecache_flush(struct dm_writecache *wc) wc->seq_count++; pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count)); - writecache_flush_region(wc, &sb(wc)->seq_count, sizeof sb(wc)->seq_count); + writecache_flush_region(wc, &sb(wc)->seq_count); writecache_commit_flushed(wc); wc->overwrote_committed = false; @@ -1757,7 +1757,7 @@ static int init_memory(struct dm_writecache *wc) writecache_flush_all_metadata(wc); writecache_commit_flushed(wc); pmem_assign(sb(wc)->magic, cpu_to_le32(MEMORY_SUPERBLOCK_MAGIC)); - writecache_flush_region(wc, &sb(wc)->magic, sizeof sb(wc)->magic); + writecache_flush_region(wc, &sb(wc)->magic); writecache_commit_flushed(wc); return 0; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 2/5] dm-writecache: get rid of memory_data flush to writecache_flush_entry
From: Huaisheng Ye writecache_flush_region only works when SSD mode. If wc->pmem_mode sets, writecache_flush_region doesn't need to be called in writecache_flush_entry. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2d8e0c0..c69317c 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -688,8 +688,6 @@ static void writecache_poison_lists(struct dm_writecache *wc) static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e) { writecache_flush_region(wc, memory_entry(wc, e)); - if (WC_MODE_PMEM(wc)) - writecache_flush_region(wc, memory_data(wc, e)); } static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 4/4] Documentation/device-mapper: add optional parameter reinit
From: Huaisheng Ye Add intro and usage guide for reinit. Signed-off-by: Huaisheng Ye --- Documentation/device-mapper/writecache.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/device-mapper/writecache.txt b/Documentation/device-mapper/writecache.txt index 01532b3..255c68c 100644 --- a/Documentation/device-mapper/writecache.txt +++ b/Documentation/device-mapper/writecache.txt @@ -45,6 +45,10 @@ Constructor parameters: afterwards - some underlying devices perform better with fua, some with nofua. The user should test it + reinit (by default off) + applicable only to persistent memory - use the REINIT flag + when the surper block has messy data, that would cause fn ctr + failed to work with invalid magic or version in the superblock Status: 1. error indicator - 0 if there was no error, otherwise error number -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 2/4] dm-writecache: get rid of memory_data flush to writecache_flush_entry
From: Huaisheng Ye writecache_flush_region only works when SSD mode. If wc->pmem_mode sets, writecache_flush_region doesn't need to be called in writecache_flush_entry. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2d8e0c0..c69317c 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -688,8 +688,6 @@ static void writecache_poison_lists(struct dm_writecache *wc) static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e) { writecache_flush_region(wc, memory_entry(wc, e)); - if (WC_MODE_PMEM(wc)) - writecache_flush_region(wc, memory_data(wc, e)); } static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 3/4] dm-writecache: expand pmem_reinit for struct dm_writecache
From: Huaisheng Ye When use persistent memory as cache data device, sometimes the super block of pmem has messy data stored in it. That would have risk to lead fn ctr failed to work due to invalid magic or version. Here we expand pmem_reinit to optional parameters in order to solve this issue. When user gets pmem device, which has unrelated data in it, as cache device, he should use paramenter 'reinit' to avoid s.magic and s.version don't equal to NULL or correct MEMORY_SUPERBLOCK_MAGIC/VERSION. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index c69317c..2c1e825 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -149,6 +149,7 @@ struct dm_writecache { bool pmem_mode:1; bool writeback_fua:1; + bool pmem_reinit:1; bool overwrote_committed:1; bool memory_vmapped:1; @@ -2026,6 +2027,10 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) wc->writeback_fua = false; wc->writeback_fua_set = true; } else goto invalid_optional; + } else if (!strcasecmp(string, "reinit")) { + if (WC_MODE_PMEM(wc)) + wc->pmem_reinit = true; + else goto invalid_optional; } else { invalid_optional: r = -EINVAL; @@ -2127,7 +2132,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) ti->error = "Hardware memory error when reading superblock"; goto bad; } - if (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version)) { + if (wc->pmem_reinit || (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version))) { r = init_memory(wc); if (r) { ti->error = "Unable to initialize device"; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 1/4] dm-writecache: remove unused size to writecache_flush_region
From: Huaisheng Ye writecache_flush_region doesn't use size to calculate flush region. That uses _set_bits to mark the region in dirty_bitmap directly. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 2d50eec..2d8e0c0 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -418,7 +418,7 @@ static void writecache_flush_all_metadata(struct dm_writecache *wc) memset(wc->dirty_bitmap, -1, wc->dirty_bitmap_size); } -static void writecache_flush_region(struct dm_writecache *wc, void *ptr, size_t size) +static void writecache_flush_region(struct dm_writecache *wc, void *ptr) { if (!WC_MODE_PMEM(wc)) __set_bit(((char *)ptr - (char *)wc->memory_map) / BITMAP_GRANULARITY, @@ -657,7 +657,7 @@ static void writecache_free_entry(struct dm_writecache *wc, struct wc_entry *e) writecache_unlink(wc, e); writecache_add_to_freelist(wc, e); clear_seq_count(wc, e); - writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry)); + writecache_flush_region(wc, memory_entry(wc, e)); if (unlikely(waitqueue_active(&wc->freelist_wait))) wake_up(&wc->freelist_wait); } @@ -687,9 +687,9 @@ static void writecache_poison_lists(struct dm_writecache *wc) static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e) { - writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry)); + writecache_flush_region(wc, memory_entry(wc, e)); if (WC_MODE_PMEM(wc)) - writecache_flush_region(wc, memory_data(wc, e), wc->block_size); + writecache_flush_region(wc, memory_data(wc, e)); } static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e) @@ -733,7 +733,7 @@ static void writecache_flush(struct dm_writecache *wc) wc->seq_count++; pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count)); - writecache_flush_region(wc, &sb(wc)->seq_count, sizeof sb(wc)->seq_count); + writecache_flush_region(wc, &sb(wc)->seq_count); writecache_commit_flushed(wc); wc->overwrote_committed = false; @@ -1757,7 +1757,7 @@ static int init_memory(struct dm_writecache *wc) writecache_flush_all_metadata(wc); writecache_commit_flushed(wc); pmem_assign(sb(wc)->magic, cpu_to_le32(MEMORY_SUPERBLOCK_MAGIC)); - writecache_flush_region(wc, &sb(wc)->magic, sizeof sb(wc)->magic); + writecache_flush_region(wc, &sb(wc)->magic); writecache_commit_flushed(wc); return 0; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 0/4] add parameter for pmem cache device init
From: Huaisheng Ye This patch set could be used for dm-writecache when use persistent memory as cache data device. Patch 1 and 2 go towards removing unused parameter and codes which actually doesn't really work. Patch 3 and 4 are targeted at solving problem fn ctr failed to work due to invalid magic or version, which is caused by the super block of pmem has messy data stored. Changes Since v1: - add optional parameter reinit to avoid invalid magic or version. [1]: https://lkml.org/lkml/2019/1/3/43 Huaisheng Ye (4): dm-writecache: remove unused size to writecache_flush_region dm-writecache: get rid of memory_data flush to writecache_flush_entry dm-writecache: expand pmem_reinit for struct dm_writecache Documentation/device-mapper: add optional parameter reinit Documentation/device-mapper/writecache.txt | 4 drivers/md/dm-writecache.c | 19 +++ 2 files changed, 15 insertions(+), 8 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: Snapshot target and DAX-capable devices
On Fri, 31 Aug 2018 17:42:55 +0800 Jan Kara wrote > On Fri 31-08-18 09:38:09, Dave Chinner wrote: > > On Thu, Aug 30, 2018 at 03:47:32PM -0400, Mikulas Patocka wrote: > > > > > > > > > On Thu, 30 Aug 2018, Jeff Moyer wrote: > > > > > > > Mike Snitzer writes: > > > > > > > > > Until we properly add DAX support to dm-snapshot I'm afraid we > > > > > really do > > > > > need to tolerate this "regression". Since reality is the original > > > > > support for snapshot of a DAX DM device never worked in a robust > > > > > way. > > > > > > > > Agreed. > > > > > > > > -Jeff > > > > > > You can't support dax on snapshot - if someone maps a block and the > > > block > > > needs to be moved, then what? > > > > This is only a problem for access via mmap and page faults. > > > > At the filesystem level, it's no different to the existing direct IO > > algorithm for read/write IO - we simply allocate new space, copy the > > data we need to copy into the new space (may be no copy needed), and > > then write the new data into the new space. I'm pretty sure that for > > bio-based IO to dm-snapshot devices the algorithm will be exactly > > the same. > > > > However, for direct access via mmap, we have to modify how the > > userspace virtual address is mapped to the physical location. IOWs, > > during the COW operation, we have to invalidate all existing user > > mappings we have for that physical address. This means we have to do > > an invalidation after the allocate/copy part of the COW operation. > > > > If we are doing this during a page fault, it means we'll probably > > have to restart the page fault so it can look up the new physical > > address associated with the faulting user address. After we've done > > the invalidation, any new (or restarted) page fault finds the > > location of new copy we just made, maps it into the user address > > space, updates the ptes and we're all good. > > > > Well, that's the theory. We haven't implemented this for XFS yet, so > > it might end up a little different, and we might yet hit unexpected > > problems (it's DAX, that's what happens :/). > > Yes, that's outline of a plan :) > > > It's a whole different ballgame for a dm-snapshot device - block > > devices are completely unaware of page faults to DAX file mappings. > > Actually, block devices are not completely unaware of DAX page faults - > they will get ->direct_access callback for the fault range. It does not > currently convey enough information - we also need to inform the block > device whether it is read or write. But that's about all that's needed to > add AFAICT. And by comparing returned PFN with the one we have stored in > the radix tree (which we have if that file offset is mapped by anybody), > the filesystem / DAX code can tell whether remapping happened and do the > unmapping. Hi Jan, I am trying to investigate how to make dm-snapshot to support DAX, and I dropped a patchset to upstream for comments. Any suggestion is welcome. # https://lkml.org/lkml/2018/11/21/281 In the beginning, I haven't considered the situation of mmap write faults. >From Dan's reply and this email thread, now I have a more clear understanding. The question is that, even the virtual dm block device has been informed that the mmap may have write operations through PROT_WRITE, if userspace directly operate the virtual address of origin device like memcpy, dm-snapshot doesn't have chance to detect this behavior. Although dm-snapshot can have chance to prepare a COW area to back up origin's blocks within ->direct_access callback for the fault range, how can it to have opportunity to read the data from origin device and save it to COW? --- Cheers, Huaisheng Ye ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 3/3] dm: expand valid types for dm-ioctl
From: Huaisheng Ye If use DAX way to mount the origin device of dm_snapshot, when merging back snapshot to origin, system call table_load during the construction of snapshot-merge will try to detect new dm_table's type equals to the existed md's type or not. The existed type equals to DM_TYPE_DAX_BIO_BASED, but the new created type belongs to DM_TYPE_BIO_BASED. So, we need to expand valid_type in function is_valid_type. Signed-off-by: Huaisheng Ye --- drivers/md/dm-ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index a27016e..158d657 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1295,7 +1295,8 @@ static int populate_table(struct dm_table *table, static bool is_valid_type(enum dm_queue_mode cur, enum dm_queue_mode new) { if (cur == new || - (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED)) + (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED) || + (cur == DM_TYPE_DAX_BIO_BASED && new == DM_TYPE_BIO_BASED)) return true; return false; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 2/3] dm: expand hc_map in mapped_device for lack of map
From: Huaisheng Ye Sometimes dm_swap_table couldn't be used in time. For example, during the origin construction of dm-snapshot, the sys_ioctl table_load will try to detect the lower device origin-real whether support direct access or not. But origin-real md's struct dm-table pointer has not yet been assigned real address in time by dev_suspend. So I expand hc_map for get the address from struct hash_cell directly in this case. Here is the call trace, dm_dax_direct_access will call dm_dax_get_live_target for get the struct dm_table pointer. [ 213.975827] Call Trace: [ 213.975832] dump_stack+0x5a/0x73 [ 213.975840] dm_dax_direct_access+0x12b/0x1b0 [dm_mod] [ 213.975845] dax_direct_access+0x2d/0x60 [ 213.975848] __bdev_dax_supported+0x162/0x2a0 [ 213.975851] ? dump_stack+0x5a/0x73 [ 213.975859] device_supports_dax+0x15/0x20 [dm_mod] [ 213.975867] dm_table_supports_dax.isra.13+0x7d/0xa0 [dm_mod] [ 213.975875] dm_table_complete+0x3fb/0x750 [dm_mod] [ 213.975883] table_load+0x19a/0x390 [dm_mod] [ 213.975891] ? retrieve_status+0x1c0/0x1c0 [dm_mod] [ 213.975898] ctl_ioctl+0x1d8/0x450 [dm_mod] [ 213.975909] dm_ctl_ioctl+0xa/0x10 [dm_mod] [ 213.975913] do_vfs_ioctl+0xa9/0x620 [ 213.975918] ? syscall_trace_enter+0x1c9/0x2b0 [ 213.975923] ksys_ioctl+0x60/0x90 [ 213.975927] __x64_sys_ioctl+0x16/0x20 [ 213.975931] do_syscall_64+0x5b/0x180 [ 213.975936] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Huaisheng Ye --- drivers/md/dm-core.h | 1 + drivers/md/dm-ioctl.c | 1 + drivers/md/dm.c | 15 +++ 3 files changed, 17 insertions(+) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 224d445..5577d90 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -40,6 +40,7 @@ struct mapped_device { * dereference. */ void __rcu *map; + struct dm_table *hc_map; unsigned long flags; diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index f666778..a27016e 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1365,6 +1365,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si if (hc->new_map) old_map = hc->new_map; hc->new_map = t; + hc->md->hc_map = hc->new_map; up_write(&_hash_lock); param->flags |= DM_INACTIVE_PRESENT_FLAG; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c510179..19b48bb 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1080,6 +1080,21 @@ static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, struct dm_target *ti; map = dm_get_live_table(md, srcu_idx); + if (!map) { + /* Sometimes dm_swap_table couldn't be used in time. +* +* For example, during the origin construction of +* dm-snapshot, the sys_ioctl table_load will try to +* detect the lower device origin-real whether support +* direct access or not. But origin-real device md's struct +* dm-table pointer has not yet been assigned real address. +* So hc_map has been used for get the address from +* struct hash_cell directly. +*/ + DMINFO("failed to get map, use hc_map insteadly"); + map = md->hc_map; + } + if (!map) return NULL; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 0/3] realize dax_operations for dm-snapshot
From: Huaisheng Ye Changes v1->v2: Add NULL funtions for origin_dax_direct_access and origin_dax_copy_from/to_iter in order to avoid building error when CONFIG_DAX_DRIVER has NOT been enabled. [v1]: https://lkml.org/lkml/2018/11/20/759 This series patches are used to realize the dax_operations for dm-snapshot with persistent memory device. Here are the steps about how to verify the function. 1. Configure the persistent memory to fs-dax mode and create namespace with ndctl; 2. find them in /dev; # ndctl list { "dev":"namespace0.0", "mode":"fsdax", "map":"dev", "size":132118478848, "sector_size":512, "blockdev":"pmem0", "name":"yhs_pmem0", "numa_node":0 }, 3. create lv_pmem (here is 4G size) for testing; # pvcreate /dev/pmem0 # vgcreate vg_pmem /dev/pmem0 # lvcreate -L 4G -n lv_pmem vg_pmem 4. create filesystem (ext2 or ext4) to /dev/pmem0 # mkfs.ext2 -b 4096 /dev/vg_pmem/lv_pmem 5. mount pmem with DAX way; # mkdir /mnt/lv_pmem # mount -o dax /dev/vg_pmem/lv_pmem /mnt/lv_pmem/ 6. cp some files to /mnt/lv_pmem; # cp linear_table03.log /mnt/lv_pmem/ # cp test0.log /mnt/lv_pmem/ 7. create snapshot for test (here I limit it to 1G size); # lvcreate -L 1G -n snap_pmem -s /dev/vg_pmem/lv_pmem 8. modify the files copied with vim or copy more other new files; # vim /mnt/lv_pmem/test0.log 9. umount the pmem device; # umount /mnt/lv_pmem/ 10.merge the snapshot back to origin; # lvconvert --merge /dev/vg_pmem/snap_pmem 11.mount pmem device again for checking the content of files; # mount -o dax /dev/vg_pmem/lv_pmem /mnt/lv_pmem/ Huaisheng Ye (3): dm: enable dax_operations for dm-snapshot dm: expand hc_map in mapped_device for lack of map dm: expand valid types for dm-ioctl drivers/md/dm-core.h | 1 + drivers/md/dm-ioctl.c | 4 +++- drivers/md/dm-snap.c | 51 +-- drivers/md/dm.c | 15 +++ 4 files changed, 68 insertions(+), 3 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 1/3] dm: enable dax_operations for dm-snapshot
From: Huaisheng Ye Reconstruct origin_dax_direct_access and expand functions origin_dax_copy_to/from_iter for DAX operations of dm-snapshot. Here is the call trace of origin_dax_copy_to_iter, origin_dax_copy_to_iter will callin dm-linear (-real) for further dax_operation. [518597.924019] Call Trace: [518597.927320] dump_stack+0x65/0x7e [518597.931592] origin_dax_copy_to_iter+0x51/0x78 [dm_snapshot] [518597.938494] dm_dax_copy_to_iter+0x86/0xc5 [dm_mod] [518597.944519] dax_copy_to_iter+0x27/0x29 [518597.949371] dax_iomap_actor+0x264/0x326 [518597.954308] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.962159] iomap_apply+0xc7/0x128 [518597.966609] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.974447] dax_iomap_rw+0x66/0xa8 [518597.978893] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.986741] ext2_file_read_iter+0x4f/0x83 [ext2] [518597.992552] __vfs_read+0x130/0x168 [518597.997001] vfs_read+0x92/0x146 [518598.001155] ksys_read+0x4f/0xa5 [518598.005308] __x64_sys_read+0x16/0x18 [518598.009942] do_syscall_64+0x88/0x15f [518598.014575] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Huaisheng Ye --- drivers/md/dm-snap.c | 51 +-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index ae4b33d..714e26f 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "dm.h" @@ -2316,13 +2317,57 @@ static int origin_map(struct dm_target *ti, struct bio *bio) return do_origin(o->dev, bio); } +#if IS_ENABLED(CONFIG_DAX_DRIVER) static long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { - DMWARN("device does not support dax."); - return -EIO; + long ret = 0; + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + ret = bdev_dax_pgoff(bdev, sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +static size_t origin_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + if (bdev_dax_pgoff(bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); } +static size_t origin_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + if (bdev_dax_pgoff(bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + + return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); +} + +#else +#define origin_dax_direct_access NULL +#define origin_dax_copy_from_iter NULL +#define origin_dax_copy_to_iter NULL +#endif + /* * Set the target "max_io_len" field to the minimum of all the snapshots' * chunk sizes. @@ -2383,6 +2428,8 @@ static int origin_iterate_devices(struct dm_target *ti, .status = origin_status, .iterate_devices = origin_iterate_devices, .direct_access = origin_dax_direct_access, + .dax_copy_to_iter = origin_dax_copy_to_iter, + .dax_copy_from_iter = origin_dax_copy_from_iter, }; static struct target_type snapshot_target = { -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH 1/3] dm: enable dax_operations for dm-snapshot
From: Huaisheng Ye Reconstruct origin_dax_direct_access and expand functions origin_dax_copy_to/from_iter for DAX operations of dm-snapshot. Here is the call trace of origin_dax_copy_to_iter, origin_dax_copy_to_iter will callin dm-linear (-real) for further dax_operation. [518597.924019] Call Trace: [518597.927320] dump_stack+0x65/0x7e [518597.931592] origin_dax_copy_to_iter+0x51/0x78 [dm_snapshot] [518597.938494] dm_dax_copy_to_iter+0x86/0xc5 [dm_mod] [518597.944519] dax_copy_to_iter+0x27/0x29 [518597.949371] dax_iomap_actor+0x264/0x326 [518597.954308] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.962159] iomap_apply+0xc7/0x128 [518597.966609] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.974447] dax_iomap_rw+0x66/0xa8 [518597.978893] ? trace_event_raw_event_dax_pmd_load_hole_class+0xd0/0xd0 [518597.986741] ext2_file_read_iter+0x4f/0x83 [ext2] [518597.992552] __vfs_read+0x130/0x168 [518597.997001] vfs_read+0x92/0x146 [518598.001155] ksys_read+0x4f/0xa5 [518598.005308] __x64_sys_read+0x16/0x18 [518598.009942] do_syscall_64+0x88/0x15f [518598.014575] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Huaisheng Ye --- drivers/md/dm-snap.c | 44 ++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index ae4b33d..75738b3 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "dm.h" @@ -2319,8 +2320,45 @@ static int origin_map(struct dm_target *ti, struct bio *bio) static long origin_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { - DMWARN("device does not support dax."); - return -EIO; + long ret = 0; + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + ret = bdev_dax_pgoff(bdev, sector, nr_pages * PAGE_SIZE, &pgoff); + if (ret) + return ret; + + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); +} + +static size_t origin_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + if (bdev_dax_pgoff(bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); +} + +static size_t origin_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dm_origin *o = ti->private; + struct block_device *bdev = o->dev->bdev; + struct dax_device *dax_dev = o->dev->dax_dev; + sector_t sector = pgoff * PAGE_SECTORS; + + if (bdev_dax_pgoff(bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + return 0; + + return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); } /* @@ -2383,6 +2421,8 @@ static int origin_iterate_devices(struct dm_target *ti, .status = origin_status, .iterate_devices = origin_iterate_devices, .direct_access = origin_dax_direct_access, + .dax_copy_to_iter = origin_dax_copy_to_iter, + .dax_copy_from_iter = origin_dax_copy_from_iter, }; static struct target_type snapshot_target = { -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH 2/3] dm: expand hc_map in mapped_device for lack of map
From: Huaisheng Ye Sometimes dm_swap_table couldn't be used in time. For example, during the origin construction of dm-snapshot, the sys_ioctl table_load will try to detect the lower device origin-real whether support direct access or not. But origin-real md's struct dm-table pointer has not yet been assigned real address in time by dev_suspend. So I expand hc_map for get the address from struct hash_cell directly in this case. Here is the call trace, dm_dax_direct_access will call dm_dax_get_live_target for get the struct dm_table pointer. [ 213.975827] Call Trace: [ 213.975832] dump_stack+0x5a/0x73 [ 213.975840] dm_dax_direct_access+0x12b/0x1b0 [dm_mod] [ 213.975845] dax_direct_access+0x2d/0x60 [ 213.975848] __bdev_dax_supported+0x162/0x2a0 [ 213.975851] ? dump_stack+0x5a/0x73 [ 213.975859] device_supports_dax+0x15/0x20 [dm_mod] [ 213.975867] dm_table_supports_dax.isra.13+0x7d/0xa0 [dm_mod] [ 213.975875] dm_table_complete+0x3fb/0x750 [dm_mod] [ 213.975883] table_load+0x19a/0x390 [dm_mod] [ 213.975891] ? retrieve_status+0x1c0/0x1c0 [dm_mod] [ 213.975898] ctl_ioctl+0x1d8/0x450 [dm_mod] [ 213.975909] dm_ctl_ioctl+0xa/0x10 [dm_mod] [ 213.975913] do_vfs_ioctl+0xa9/0x620 [ 213.975918] ? syscall_trace_enter+0x1c9/0x2b0 [ 213.975923] ksys_ioctl+0x60/0x90 [ 213.975927] __x64_sys_ioctl+0x16/0x20 [ 213.975931] do_syscall_64+0x5b/0x180 [ 213.975936] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Huaisheng Ye --- drivers/md/dm-core.h | 1 + drivers/md/dm-ioctl.c | 1 + drivers/md/dm.c | 15 +++ 3 files changed, 17 insertions(+) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index 224d445..5577d90 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -40,6 +40,7 @@ struct mapped_device { * dereference. */ void __rcu *map; + struct dm_table *hc_map; unsigned long flags; diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index f666778..a27016e 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1365,6 +1365,7 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si if (hc->new_map) old_map = hc->new_map; hc->new_map = t; + hc->md->hc_map = hc->new_map; up_write(&_hash_lock); param->flags |= DM_INACTIVE_PRESENT_FLAG; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c510179..19b48bb 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1080,6 +1080,21 @@ static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, struct dm_target *ti; map = dm_get_live_table(md, srcu_idx); + if (!map) { + /* Sometimes dm_swap_table couldn't be used in time. +* +* For example, during the origin construction of +* dm-snapshot, the sys_ioctl table_load will try to +* detect the lower device origin-real whether support +* direct access or not. But origin-real device md's struct +* dm-table pointer has not yet been assigned real address. +* So hc_map has been used for get the address from +* struct hash_cell directly. +*/ + DMINFO("failed to get map, use hc_map insteadly"); + map = md->hc_map; + } + if (!map) return NULL; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH 3/3] dm: expand valid types for dm-ioctl
From: Huaisheng Ye If use DAX way to mount the origin device of dm_snapshot, when merging back snapshot to origin, system call table_load during the construction of snapshot-merge will try to detect new dm_table's type equals to the existed md's type or not. The existed type equals to DM_TYPE_DAX_BIO_BASED, but the new created type belongs to DM_TYPE_BIO_BASED. So, we need to expand valid_type in function is_valid_type. Signed-off-by: Huaisheng Ye --- drivers/md/dm-ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index a27016e..158d657 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1295,7 +1295,8 @@ static int populate_table(struct dm_table *table, static bool is_valid_type(enum dm_queue_mode cur, enum dm_queue_mode new) { if (cur == new || - (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED)) + (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED) || + (cur == DM_TYPE_DAX_BIO_BASED && new == DM_TYPE_BIO_BASED)) return true; return false; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH 0/3] realize dax_operations for dm-snapshot
From: Huaisheng Ye This series patches are used to realize the dax_operations for dm-snapshot with persistent memory device. Here are the steps about how to verify the function. 1. Configure the persistent memory to fs-dax mode and create namespace with ndctl; 2. find them in /dev; # ndctl list { "dev":"namespace0.0", "mode":"fsdax", "map":"dev", "size":132118478848, "sector_size":512, "blockdev":"pmem0", "name":"yhs_pmem0", "numa_node":0 }, 3. create lv_pmem (here is 4G size) for testing; # pvcreate /dev/pmem0 # vgcreate vg_pmem /dev/pmem0 # lvcreate -L 4G -n lv_pmem vg_pmem 4. create filesystem (ext2 or ext4) to /dev/pmem0 # mkfs.ext2 -b 4096 /dev/vg_pmem/lv_pmem 5. mount pmem with DAX way; # mkdir /mnt/lv_pmem # mount -o dax /dev/vg_pmem/lv_pmem /mnt/lv_pmem/ 6. cp some files to /mnt/lv_pmem; # cp linear_table03.log /mnt/lv_pmem/ # cp test0.log /mnt/lv_pmem/ 7. create snapshot for test (here I limit it to 1G size); # lvcreate -L 1G -n snap_pmem -s /dev/vg_pmem/lv_pmem 8. modify the files copied with vim or copy more other new files; # vim /mnt/lv_pmem/test0.log 9. umount the pmem device; # umount /mnt/lv_pmem/ 10.merge the snapshot back to origin; # lvconvert --merge /dev/vg_pmem/snap_pmem 11.mount pmem device again for checking the content of files; # mount -o dax /dev/vg_pmem/lv_pmem /mnt/lv_pmem/ Huaisheng Ye (3): dm: enable dax_operations for dm-snapshot dm: expand hc_map in mapped_device for lack of map dm: expand valid types for dm-ioctl drivers/md/dm-core.h | 1 + drivers/md/dm-ioctl.c | 4 +++- drivers/md/dm-snap.c | 44 ++-- drivers/md/dm.c | 15 +++ 4 files changed, 61 insertions(+), 3 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 6/6] filesystem-dax: Do not request kaddr and pfn when not required
From: Huaisheng Ye Some functions within fs/dax don't need to get local pointer kaddr or variable pfn from direct_access. Using NULL instead of having to pass in useless pointer or variable that caller then just throw away. Signed-off-by: Huaisheng Ye Reviewed-by: Ross Zwisler --- fs/dax.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 6411928..959a533 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -647,7 +647,6 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, { void *vto, *kaddr; pgoff_t pgoff; - pfn_t pfn; long rc; int id; @@ -656,7 +655,7 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, &pfn); + rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -967,7 +966,6 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, { const sector_t sector = dax_iomap_sector(iomap, pos); pgoff_t pgoff; - void *kaddr; int id, rc; long length; @@ -976,7 +974,7 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, return rc; id = dax_read_lock(); length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), - &kaddr, pfnp); + NULL, pfnp); if (length < 0) { rc = length; goto out; @@ -1052,15 +1050,13 @@ int __dax_zero_page_range(struct block_device *bdev, pgoff_t pgoff; long rc, id; void *kaddr; - pfn_t pfn; rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); if (rc) return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, - &pfn); + rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -1116,7 +1112,6 @@ int __dax_zero_page_range(struct block_device *bdev, ssize_t map_len; pgoff_t pgoff; void *kaddr; - pfn_t pfn; if (fatal_signal_pending(current)) { ret = -EINTR; @@ -1128,7 +1123,7 @@ int __dax_zero_page_range(struct block_device *bdev, break; map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), - &kaddr, &pfn); + &kaddr, NULL); if (map_len < 0) { ret = map_len; break; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 5/6] md/dm-writecache: Don't request pointer dummy_addr when not required
From: Huaisheng Ye Function persistent_memory_claim doesn't need to get local pointer dummy_addr from direct_access. Using NULL instead of having to pass in a useless local pointer that caller then just throw away. Suggested-by: Ross Zwisler Signed-off-by: Huaisheng Ye Reviewed-by: Ross Zwisler Acked-by: Mike Snitzer --- drivers/md/dm-writecache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 87107c9..9d79084 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -268,9 +268,8 @@ static int persistent_memory_claim(struct dm_writecache *wc) i = 0; do { long daa; - void *dummy_addr; daa = dax_direct_access(wc->ssd_dev->dax_dev, i, p - i, - &dummy_addr, &pfn); + NULL, &pfn); if (daa <= 0) { r = daa ? daa : -EINVAL; goto err3; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 2/6] s390, dcssblk: kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye dcssblk_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If either of them is equal to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a pointer or local variable that they then just throw away. Signed-off-by: Huaisheng Ye Reviewed-by: Ross Zwisler Acked-by: Martin Schwidefsky --- drivers/s390/block/dcssblk.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index ed60728..23e526c 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -922,9 +922,11 @@ static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show, unsigned long dev_sz; dev_sz = dev_info->end - dev_info->start + 1; - *kaddr = (void *) dev_info->start + offset; - *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), - PFN_DEV|PFN_SPECIAL); + if (kaddr) + *kaddr = (void *) dev_info->start + offset; + if (pfn) + *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), + PFN_DEV|PFN_SPECIAL); return (dev_sz - offset) / PAGE_SIZE; } -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 3/6] tools/testing/nvdimm: kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye The mock / test version of pmem_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If pointer equals to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a local pointer or variable that they then just throw away. Suggested-by: Dan Williams Signed-off-by: Huaisheng Ye Reviewed-by: Ross Zwisler --- tools/testing/nvdimm/pmem-dax.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596a..2e7fd82 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -31,17 +31,21 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (get_nfit_res(pmem->phys_addr + offset)) { struct page *page; - *kaddr = pmem->virt_addr + offset; + if (kaddr) + *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); - *pfn = page_to_pfn_t(page); + if (pfn) + *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", __func__, pmem, pgoff, page_to_pfn(page)); return 1; } - *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (kaddr) + *kaddr = pmem->virt_addr + offset; + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 4/6] dax/super: Do not request a pointer kaddr when not required
From: Huaisheng Ye Function __bdev_dax_supported doesn't need to get local pointer kaddr from direct_access. Using NULL instead of having to pass in a useless local pointer that caller then just throw away. Signed-off-by: Huaisheng Ye Reviewed-by: Ross Zwisler --- drivers/dax/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 45276ab..6e928f3 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -89,7 +89,6 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) struct request_queue *q; pgoff_t pgoff; int err, id; - void *kaddr; pfn_t pfn; long len; char buf[BDEVNAME_SIZE]; @@ -122,7 +121,7 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) } id = dax_read_lock(); - len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); + len = dax_direct_access(dax_dev, pgoff, 1, NULL, &pfn); dax_read_unlock(id); put_dax(dax_dev); -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 0/6] kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye Changes since v2 [2]: * Collect Martin and Mike's acks for dcssblk and dm-writecache; * Rebase the series of patch to v4.18-rc7. Changes since v1 [1]: * Involve the previous patches for pfn can be NULL. * Reword the patch descriptions according to Christian's comment. * According to Ross's suggestion, replace local pointer dummy_addr with NULL within md/dm-writecache for direct_access. [1]: https://lkml.org/lkml/2018/7/24/199 [2]: https://lkml.org/lkml/2018/7/25/581 Some functions within fs/dax, dax/super and md/dm-writecache don't need to get local pointer kaddr or variable pfn from direct_access. Assigning NULL to kaddr or pfn with ->direct_access() is more straightforward and simple than offering a useless local pointer or variable. So all ->direct_access() need to check the validity of pointer kaddr and pfn for NULL assignment. If either of them is equal to NULL, that is to say callers may have no need for kaddr or pfn, so this series of patch are prepared for allowing them to pass in NULL instead of having to pass in a local pointer or variable that they then just throw away. Huaisheng Ye (6): libnvdimm, pmem: kaddr and pfn can be NULL to ->direct_access() s390, dcssblk: kaddr and pfn can be NULL to ->direct_access() tools/testing/nvdimm: kaddr and pfn can be NULL to ->direct_access() dax/super: Do not request a pointer kaddr when not required md/dm-writecache: Don't request pointer dummy_addr when not required filesystem-dax: Do not request kaddr and pfn when not required drivers/dax/super.c | 3 +-- drivers/md/dm-writecache.c | 3 +-- drivers/nvdimm/pmem.c | 7 +-- drivers/s390/block/dcssblk.c| 8 +--- fs/dax.c| 13 - tools/testing/nvdimm/pmem-dax.c | 12 6 files changed, 24 insertions(+), 22 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 1/6] libnvdimm, pmem: kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye pmem_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If pointer equals to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a pointer or local variable that they then just throw away. Signed-off-by: Huaisheng Ye Reviewed-by: Ross Zwisler --- drivers/nvdimm/pmem.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 8b1fd7f..ecf9024 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -227,8 +227,11 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, PFN_PHYS(nr_pages return -EIO; - *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + + if (kaddr) + *kaddr = pmem->virt_addr + offset; + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 6/6] filesystem-dax: Do not request kaddr and pfn when not required
From: Huaisheng Ye Some functions within fs/dax don't need to get local pointer kaddr or variable pfn from direct_access. Using NULL instead of having to pass in useless pointer or variable that caller then just throw away. Signed-off-by: Huaisheng Ye --- fs/dax.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 6411928..959a533 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -647,7 +647,6 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, { void *vto, *kaddr; pgoff_t pgoff; - pfn_t pfn; long rc; int id; @@ -656,7 +655,7 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, &pfn); + rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -967,7 +966,6 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, { const sector_t sector = dax_iomap_sector(iomap, pos); pgoff_t pgoff; - void *kaddr; int id, rc; long length; @@ -976,7 +974,7 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, return rc; id = dax_read_lock(); length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), - &kaddr, pfnp); + NULL, pfnp); if (length < 0) { rc = length; goto out; @@ -1052,15 +1050,13 @@ int __dax_zero_page_range(struct block_device *bdev, pgoff_t pgoff; long rc, id; void *kaddr; - pfn_t pfn; rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); if (rc) return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, - &pfn); + rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -1116,7 +1112,6 @@ int __dax_zero_page_range(struct block_device *bdev, ssize_t map_len; pgoff_t pgoff; void *kaddr; - pfn_t pfn; if (fatal_signal_pending(current)) { ret = -EINTR; @@ -1128,7 +1123,7 @@ int __dax_zero_page_range(struct block_device *bdev, break; map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), - &kaddr, &pfn); + &kaddr, NULL); if (map_len < 0) { ret = map_len; break; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 5/6] md/dm-writecache: Don't request pointer dummy_addr when not required
From: Huaisheng Ye Function persistent_memory_claim doesn't need to get local pointer dummy_addr from direct_access. Using NULL instead of having to pass in a useless local pointer that caller then just throw away. Suggested-by: Ross Zwisler Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 87107c9..9d79084 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -268,9 +268,8 @@ static int persistent_memory_claim(struct dm_writecache *wc) i = 0; do { long daa; - void *dummy_addr; daa = dax_direct_access(wc->ssd_dev->dax_dev, i, p - i, - &dummy_addr, &pfn); + NULL, &pfn); if (daa <= 0) { r = daa ? daa : -EINVAL; goto err3; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 4/6] dax/super: Do not request a pointer kaddr when not required
From: Huaisheng Ye Function __bdev_dax_supported doesn't need to get local pointer kaddr from direct_access. Using NULL instead of having to pass in a useless local pointer that caller then just throw away. Signed-off-by: Huaisheng Ye --- drivers/dax/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 45276ab..6e928f3 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -89,7 +89,6 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) struct request_queue *q; pgoff_t pgoff; int err, id; - void *kaddr; pfn_t pfn; long len; char buf[BDEVNAME_SIZE]; @@ -122,7 +121,7 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) } id = dax_read_lock(); - len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); + len = dax_direct_access(dax_dev, pgoff, 1, NULL, &pfn); dax_read_unlock(id); put_dax(dax_dev); -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 3/6] tools/testing/nvdimm: kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye The mock / test version of pmem_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If pointer equals to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a local pointer or variable that they then just throw away. Suggested-by: Dan Williams Signed-off-by: Huaisheng Ye --- tools/testing/nvdimm/pmem-dax.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596a..2e7fd82 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -31,17 +31,21 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (get_nfit_res(pmem->phys_addr + offset)) { struct page *page; - *kaddr = pmem->virt_addr + offset; + if (kaddr) + *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); - *pfn = page_to_pfn_t(page); + if (pfn) + *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", __func__, pmem, pgoff, page_to_pfn(page)); return 1; } - *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (kaddr) + *kaddr = pmem->virt_addr + offset; + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 2/6] s390, dcssblk: kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye dcssblk_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If either of them is equal to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a pointer or local variable that they then just throw away. Signed-off-by: Huaisheng Ye --- drivers/s390/block/dcssblk.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index ed60728..23e526c 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -922,9 +922,11 @@ static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show, unsigned long dev_sz; dev_sz = dev_info->end - dev_info->start + 1; - *kaddr = (void *) dev_info->start + offset; - *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), - PFN_DEV|PFN_SPECIAL); + if (kaddr) + *kaddr = (void *) dev_info->start + offset; + if (pfn) + *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), + PFN_DEV|PFN_SPECIAL); return (dev_sz - offset) / PAGE_SIZE; } -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 1/6] libnvdimm, pmem: kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye pmem_direct_access() needs to check the validity of pointers kaddr and pfn for NULL assignment. If anyone equals to NULL, it doesn't need to calculate the value. If pointer equals to NULL, that is to say callers may have no need for kaddr or pfn, so this patch is prepared for allowing them to pass in NULL instead of having to pass in a pointer or local variable that they then just throw away. Signed-off-by: Huaisheng Ye --- drivers/nvdimm/pmem.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 8b1fd7f..ecf9024 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -227,8 +227,11 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, PFN_PHYS(nr_pages return -EIO; - *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + + if (kaddr) + *kaddr = pmem->virt_addr + offset; + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 0/6] kaddr and pfn can be NULL to ->direct_access()
From: Huaisheng Ye Changes since v1 [1]: * Involve the previous patches for pfn can be NULL. * Reword the patch descriptions according to Christian's comment. * According to Ross's suggestion, replace local pointer dummy_addr with NULL within md/dm-writecache for direct_access. [1]: https://lkml.org/lkml/2018/7/24/199 Some functions within fs/dax, dax/super and md/dm-writecache don't need to get local pointer kaddr or variable pfn from direct_access. Assigning NULL to kaddr or pfn to ->direct_access() is more straightforward and simple than offering a useless local pointer or variable. So all ->direct_access() need to check the validity of pointer kaddr and pfn for NULL assignment. If either of them is equal to NULL, that is to say callers may have no need for kaddr or pfn, so this series of patch are prepared for allowing them to pass in NULL instead of having to pass in a local pointer or variable that they then just throw away. Huaisheng Ye (6): libnvdimm, pmem: kaddr and pfn can be NULL to ->direct_access() s390, dcssblk: kaddr and pfn can be NULL to ->direct_access() tools/testing/nvdimm: kaddr and pfn can be NULL to ->direct_access() dax/super: Do not request a pointer kaddr when not required md/dm-writecache: Don't request pointer dummy_addr when not required filesystem-dax: Do not request kaddr and pfn when not required drivers/dax/super.c | 3 +-- drivers/md/dm-writecache.c | 3 +-- drivers/nvdimm/pmem.c | 7 +-- drivers/s390/block/dcssblk.c| 8 +--- fs/dax.c| 13 - tools/testing/nvdimm/pmem-dax.c | 12 6 files changed, 24 insertions(+), 22 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 5/5] dax/super: Do not request a pointer kaddr when not required
From: Huaisheng Ye Some functions within driver/dax don't need to get pointer kaddr from direct_access. In support of allowing memmap initialization to run in the background elide requests for pointer kaddr when not required. Signed-off-by: Huaisheng Ye --- drivers/dax/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 2b2332b..fad68d2 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -88,7 +88,6 @@ int __bdev_dax_supported(struct super_block *sb, int blocksize) struct dax_device *dax_dev; pgoff_t pgoff; int err, id; - void *kaddr; pfn_t pfn; long len; @@ -113,7 +112,7 @@ int __bdev_dax_supported(struct super_block *sb, int blocksize) } id = dax_read_lock(); - len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); + len = dax_direct_access(dax_dev, pgoff, 1, NULL, &pfn); dax_read_unlock(id); put_dax(dax_dev); -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 4/5] filesystem-dax: Do not request a pointer kaddr when not required
From: Huaisheng Ye Some functions within fs/dax don't need to get pointer kaddr from direct_access. In support of allowing memmap initialization to run in the background elide requests for pointer kaddr when not required. Signed-off-by: Huaisheng Ye --- fs/dax.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index aaec72de..abdb9e2 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -870,7 +870,6 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, { const sector_t sector = dax_iomap_sector(iomap, pos); pgoff_t pgoff; - void *kaddr; int id, rc; long length; @@ -879,7 +878,7 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, return rc; id = dax_read_lock(); length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), - &kaddr, pfnp); + NULL, pfnp); if (length < 0) { rc = length; goto out; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 0/5] Do not request a pointer kaddr when not required
From: Huaisheng Ye Some functions within fs/dax and dax/super don't need to get kaddr from direct_access. Assigning NULL to kaddr to ->direct_access() is more straightforward and simple than offering a useless local pointer. So all direct_access() need to check the validity of second rank pointer kaddr for NULL assignment. If kaddr equals to NULL, it doesn't need to calculate its value. * This series are supplement to [PATCH v2 00/14]mm: Asynchronous + multithreaded memmap init for ZONE_DEVICE. [1] [1]: https://lkml.org/lkml/2018/7/16/828 Huaisheng Ye (5): libnvdimm, pmem: Allow a NULL-kaddr to ->direct_access() tools/testing/nvdimm: Allow a NULL-kaddr to ->direct_access() s390, dcssblk: Allow a NULL-kaddr to ->direct_access() filesystem-dax: Do not request a pointer kaddr when not required dax/super: Do not request a pointer kaddr when not required drivers/dax/super.c | 3 +-- drivers/nvdimm/pmem.c | 4 +++- drivers/s390/block/dcssblk.c| 3 ++- fs/dax.c| 3 +-- tools/testing/nvdimm/pmem-dax.c | 6 -- 5 files changed, 11 insertions(+), 8 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 3/5] s390, dcssblk: Allow a NULL-kaddr to ->direct_access()
From: Huaisheng Ye dcssblk_direct_access() needs to check the validity of second rank pointer kaddr for NULL assignment. If kaddr equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye --- drivers/s390/block/dcssblk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 0a312e4..9c13dc5 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -915,7 +915,8 @@ static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show, unsigned long dev_sz; dev_sz = dev_info->end - dev_info->start + 1; - *kaddr = (void *) dev_info->start + offset; + if (kaddr) + *kaddr = (void *) dev_info->start + offset; *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), PFN_DEV|PFN_SPECIAL); -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 2/5] tools/testing/nvdimm: Allow a NULL-kaddr to ->direct_access()
From: Huaisheng Ye The mock / test version of pmem_direct_access() needs to check the validity of second rank pointer kaddr for NULL assignment. If kaddr equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye --- tools/testing/nvdimm/pmem-dax.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596a..c3ba159 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -31,7 +31,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (get_nfit_res(pmem->phys_addr + offset)) { struct page *page; - *kaddr = pmem->virt_addr + offset; + if (kaddr) + *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", @@ -40,7 +41,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, return 1; } - *kaddr = pmem->virt_addr + offset; + if (kaddr) + *kaddr = pmem->virt_addr + offset; *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 1/5] libnvdimm, pmem: Allow a NULL-kaddr to ->direct_access()
From: Huaisheng Ye pmem_direct_access() needs to check the validity of second rank pointer kaddr for NULL assignment. If kaddr equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye --- drivers/nvdimm/pmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9d71492..b1d121a 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -232,7 +232,9 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, PFN_PHYS(nr_pages return -EIO; - *kaddr = pmem->virt_addr + offset; + + if (kaddr) + *kaddr = pmem->virt_addr + offset; *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v2 0/4] Assigning NULL to gfn of dax_direct_access if useless
On Thu, 05 Jul 2018 00:48:40 +0800 Dan Williams wrote > On Wed, Jul 4, 2018 at 9:38 AM, Huaisheng Ye wrote: > > From: Huaisheng Ye > > > > Changes since v1 [1]: > > * Collect Jan's reviewed-by. > > * According to Dan's suggestion, update the unit test infrastructure > > tools/testing/nvdimm/pmem-dax.c for checking the validity of gfn. > > > > [1]: https://lkml.org/lkml/2018/7/4/81 > > > > --- > > > > Some functions within fs/dax don't need to get gfn from direct_access. > > Any reason you are calling it 'gfn'? I'm assuming that is a typo and > it should be 'pfn'. Oh, sorry. I made a mistake, it is a typo. I will correct it right now. --- Cheers, Huaisheng Ye ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 4/4] fs/dax: Assign NULL to gfn of dax_direct_access if useless
From: Huaisheng Ye Some functions within fs/dax don't need to get gfn from direct_access. Assigning NULL to gfn of dax_direct_access is more intuitive and simple than offering a useless local variable. Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara --- fs/dax.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index aaec72de..aa75dfd 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -550,7 +550,6 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, { void *vto, *kaddr; pgoff_t pgoff; - pfn_t pfn; long rc; int id; @@ -559,7 +558,7 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, &pfn); + rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -961,7 +960,6 @@ int __dax_zero_page_range(struct block_device *bdev, pgoff_t pgoff; long rc, id; void *kaddr; - pfn_t pfn; rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); if (rc) @@ -969,7 +967,7 @@ int __dax_zero_page_range(struct block_device *bdev, id = dax_read_lock(); rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, - &pfn); + NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -1024,7 +1022,6 @@ int __dax_zero_page_range(struct block_device *bdev, ssize_t map_len; pgoff_t pgoff; void *kaddr; - pfn_t pfn; if (fatal_signal_pending(current)) { ret = -EINTR; @@ -1036,7 +1033,7 @@ int __dax_zero_page_range(struct block_device *bdev, break; map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), - &kaddr, &pfn); + &kaddr, NULL); if (map_len < 0) { ret = map_len; break; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 3/4] s390/block/dcssblk: check the validity of the pointer pfn
From: Huaisheng Ye direct_access needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara --- drivers/s390/block/dcssblk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 0a312e4..5cdfa02 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -916,7 +916,8 @@ static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show, dev_sz = dev_info->end - dev_info->start + 1; *kaddr = (void *) dev_info->start + offset; - *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), + if (pfn) + *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), PFN_DEV|PFN_SPECIAL); return (dev_sz - offset) / PAGE_SIZE; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 2/4] nvdimm/pmem-dax: check the validity of the pointer pfn
From: Huaisheng Ye direct_access needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. Suggested-by: Dan Williams Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara --- tools/testing/nvdimm/pmem-dax.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596a..d4cb528 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -33,7 +33,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); - *pfn = page_to_pfn_t(page); + if (pfn) + *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", __func__, pmem, pgoff, page_to_pfn(page)); @@ -41,7 +42,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, } *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 0/4] Assigning NULL to gfn of dax_direct_access if useless
From: Huaisheng Ye Changes since v1 [1]: * Collect Jan's reviewed-by. * According to Dan's suggestion, update the unit test infrastructure tools/testing/nvdimm/pmem-dax.c for checking the validity of gfn. [1]: https://lkml.org/lkml/2018/7/4/81 --- Some functions within fs/dax don't need to get gfn from direct_access. Assigning NULL to gfn of dax_direct_access is more intuitive and simple than offering a useless local variable. So all direct_access need to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate its value. --- Huaisheng Ye (4): nvdimm/pmem: check the validity of the pointer pfn nvdimm/pmem-dax: check the validity of the pointer pfn s390/block/dcssblk: check the validity of the pointer pfn fs/dax: Assign NULL to gfn of dax_direct_access if useless drivers/nvdimm/pmem.c | 3 ++- drivers/s390/block/dcssblk.c| 3 ++- fs/dax.c| 9 +++-- tools/testing/nvdimm/pmem-dax.c | 6 -- 4 files changed, 11 insertions(+), 10 deletions(-) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 1/4] nvdimm/pmem: check the validity of the pointer pfn
From: Huaisheng Ye direct_access needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara --- drivers/nvdimm/pmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9d71492..018f990 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -233,7 +233,8 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, PFN_PHYS(nr_pages return -EIO; *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 3/3] fs/dax: Assigning NULL to gfn of dax_direct_access if useless
On Wed, 04 Jul 2018 19:30:12 +0800 Jan Kara wrote > On Wed 04-07-18 14:40:58, Huaisheng Ye wrote: > > From: Huaisheng Ye > > > > Some functions within fs/dax don't need to get gfn from direct_access. > > Assigning NULL to gfn of dax_direct_access is more intuitive and simple > > than offering a useless local variable. > > > > Signed-off-by: Huaisheng Ye > > I like this. You can add: > > Reviewed-by: Jan Kara > > for the series. > > Honza > I am so happy you like them, thank you very much. --- Cheers, Huaisheng ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 3/3] fs/dax: Assigning NULL to gfn of dax_direct_access if useless
From: Huaisheng Ye Some functions within fs/dax don't need to get gfn from direct_access. Assigning NULL to gfn of dax_direct_access is more intuitive and simple than offering a useless local variable. Signed-off-by: Huaisheng Ye --- fs/dax.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index aaec72de..aa75dfd 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -550,7 +550,6 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, { void *vto, *kaddr; pgoff_t pgoff; - pfn_t pfn; long rc; int id; @@ -559,7 +558,7 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, &pfn); + rc = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -961,7 +960,6 @@ int __dax_zero_page_range(struct block_device *bdev, pgoff_t pgoff; long rc, id; void *kaddr; - pfn_t pfn; rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); if (rc) @@ -969,7 +967,7 @@ int __dax_zero_page_range(struct block_device *bdev, id = dax_read_lock(); rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, - &pfn); + NULL); if (rc < 0) { dax_read_unlock(id); return rc; @@ -1024,7 +1022,6 @@ int __dax_zero_page_range(struct block_device *bdev, ssize_t map_len; pgoff_t pgoff; void *kaddr; - pfn_t pfn; if (fatal_signal_pending(current)) { ret = -EINTR; @@ -1036,7 +1033,7 @@ int __dax_zero_page_range(struct block_device *bdev, break; map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), - &kaddr, &pfn); + &kaddr, NULL); if (map_len < 0) { ret = map_len; break; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 1/3] nvdimm/pmem: check the validity of the pointer pfn
From: Huaisheng Ye Some functions within fs/dax don't need to get gfn from direct_access. Assigning NULL to gfn of dax_direct_access is more intuitive and simple than offering a useless local variable. So direct_access needs to check validity of the pointer pfn For NULL assignment. Signed-off-by: Huaisheng Ye --- drivers/nvdimm/pmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9d71492..018f990 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -233,7 +233,8 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, PFN_PHYS(nr_pages return -EIO; *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 2/3] drivers/s390/block/dcssblk: check the validity of the pointer pfn
From: Huaisheng Ye Some functions within fs/dax don't need to get gfn from direct_access. Assigning NULL to gfn of dax_direct_access is more intuitive and simple than offering a useless local variable. So direct_access needs to check validity of the pointer pfn For NULL assignment. If pfn equals to NULL, it doesn't need to calculate its value. Signed-off-by: Huaisheng Ye --- drivers/s390/block/dcssblk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 0a312e4..5cdfa02 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -916,7 +916,8 @@ static DEVICE_ATTR(save, S_IWUSR | S_IRUSR, dcssblk_save_show, dev_sz = dev_info->end - dev_info->start + 1; *kaddr = (void *) dev_info->start + offset; - *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), + if (pfn) + *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), PFN_DEV|PFN_SPECIAL); return (dev_sz - offset) / PAGE_SIZE; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax
On Mon, 02 Jul 2018 03:26:00 +0800 Al Viro wrote > On Sun, Jul 01, 2018 at 02:18:47PM +0800, Huaisheng Ye wrote: > > From: Huaisheng Ye > > > > The type of offset within struct iomap is loff_t, which represents > > file offset of mapping. > > > > In ext2_iomap_begin, iomap->offset shall be given a type cast as > > loff_t instead of u64. > > Why is it an error? loff_t is uniformly typedefed to long long. > In which case the second variant is different from the first one > *and* does not step into nasal demon territory? Sorry for my inaccuracy. The type of iomap->offset is loff_t, is it better to cast first_block to loff_t, then do the left shift operation? > > > -iomap->offset = (u64)first_block << blkbits; > > +iomap->offset = (loff_t)first_block << blkbits; > --- Cheers, Huaisheng ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax
From: Huaisheng Ye The type of offset within struct iomap is loff_t, which represents file offset of mapping. In ext2_iomap_begin, iomap->offset shall be given a type cast as loff_t instead of u64. Signed-off-by: Huaisheng Ye --- fs/ext2/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 7163590..ca211bd 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -816,7 +816,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->flags = 0; iomap->bdev = inode->i_sb->s_bdev; - iomap->offset = (u64)first_block << blkbits; + iomap->offset = (loff_t)first_block << blkbits; iomap->dax_dev = sbi->s_daxdev; if (ret == 0) { -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin
From: Huaisheng Ye If ext2_get_blocks returns negative result, ext2_iomap_begin will return for error case. Adjust the judging condition of ret value will be useful for code simplification. Signed-off-by: Huaisheng Ye --- fs/ext2/inode.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index ca211bd..9b1004d 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->offset = (loff_t)first_block << blkbits; iomap->dax_dev = sbi->s_daxdev; - if (ret == 0) { - iomap->type = IOMAP_HOLE; - iomap->addr = IOMAP_NULL_ADDR; - iomap->length = 1 << blkbits; - } else { + if (ret) { iomap->type = IOMAP_MAPPED; iomap->addr = (u64)bno << blkbits; iomap->length = (u64)ret << blkbits; iomap->flags |= IOMAP_F_MERGED; + } else { + iomap->type = IOMAP_HOLE; + iomap->addr = IOMAP_NULL_ADDR; + iomap->length = 1 << blkbits; } if (new) -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH 1/3] drivers/dax/super: Add annotation for ops in struct dax_device
From: Huaisheng Ye There is no annotation for member ops within struct dax_device. Add it. Signed-off-by: Huaisheng Ye --- drivers/dax/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 2b2332b..aa6382a 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -161,6 +161,7 @@ enum dax_device_flags { * @host: optional name for lookups where the device path is not available * @private: dax driver private data * @flags: state and boolean properties + * @ops: function pointers for direct_access and fs-dax */ struct dax_device { struct hlist_node list; -- 1.8.3.1 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm