Up till now, dax_direct_access() is used implicitly for normal access, but for the purpose of recovery write, dax range with poison is requested. To make the interface clear, introduce enum dax_access_mode { DAX_ACCESS, DAX_RECOVERY_WRITE, } where DAX_ACCESS is used for normal dax access, and DAX_RECOVERY_WRITE is used for dax recovery write.
Unified · Split
| @@ -117,6 +117,7 @@ enum dax_device_flags { · 116 unmodified lines | |||
| 117 | * @dax_dev: a dax_device instance representing the logical memory range | 117 | * @dax_dev: a dax_device instance representing the logical memory range |
| 118 | * @pgoff: offset in pages from the start of the device to translate | 118 | * @pgoff: offset in pages from the start of the device to translate |
| 119 | * @nr_pages: number of consecutive pages caller can handle relative to @pfn | 119 | * @nr_pages: number of consecutive pages caller can handle relative to @pfn |
| 120 | * @mode: indicator on normal access or recovery write | ||
| 120 | * @kaddr: output parameter that returns a virtual address mapping of pfn | 121 | * @kaddr: output parameter that returns a virtual address mapping of pfn |
| 121 | * @pfn: output parameter that returns an absolute pfn translation of @pgoff | 122 | * @pfn: output parameter that returns an absolute pfn translation of @pgoff |
| 122 | * | 123 | * |
| @@ -124,7 +125,7 @@ enum dax_device_flags { · 1 unmodified line | |||
| 124 | * pages accessible at the device relative @pgoff. | 125 | * pages accessible at the device relative @pgoff. |
| 125 | */ | 126 | */ |
| 126 | long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, | 127 | long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, |
| 127 | void **kaddr, pfn_t *pfn) | 128 | enum dax_access_mode mode, void **kaddr, pfn_t *pfn) |
| 128 | { | 129 | { |
| 129 | long avail; | 130 | long avail; |
| 130 | 131 | ||
| @@ -138,7 +139,7 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, · 7 unmodified lines | |||
| 138 | return -EINVAL; | 139 | return -EINVAL; |
| 139 | 140 | ||
| 140 | avail = dax_dev->ops->direct_access(dax_dev, pgoff, nr_pages, | 141 | avail = dax_dev->ops->direct_access(dax_dev, pgoff, nr_pages, |
| 141 | kaddr, pfn); | 142 | mode, kaddr, pfn); |
| 142 | if (!avail) | 143 | if (!avail) |
| 143 | return -ERANGE; | 144 | return -ERANGE; |
| 144 | return min(avail, nr_pages); | 145 | return min(avail, nr_pages); |
| @@ -172,11 +172,12 @@ static struct dax_device *linear_dax_pgoff(struct dm_target *ti, pgoff_t *pgoff) · 171 unmodified lines | |||
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, | 174 | static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, |
| 175 | long nr_pages, void **kaddr, pfn_t *pfn) | 175 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 176 | pfn_t *pfn) | ||
| 176 | { | 177 | { |
| 177 | struct dax_device *dax_dev = linear_dax_pgoff(ti, &pgoff); | 178 | struct dax_device *dax_dev = linear_dax_pgoff(ti, &pgoff); |
| 178 | 179 | ||
| 179 | return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); | 180 | return dax_direct_access(dax_dev, pgoff, nr_pages, mode, kaddr, pfn); |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | static int linear_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, | 183 | static int linear_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, |
| @@ -889,11 +889,12 @@ static struct dax_device *log_writes_dax_pgoff(struct dm_target *ti, · 888 unmodified lines | |||
| 889 | } | 889 | } |
| 890 | 890 | ||
| 891 | static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, | 891 | static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, |
| 892 | long nr_pages, void **kaddr, pfn_t *pfn) | 892 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 893 | pfn_t *pfn) | ||
| 893 | { | 894 | { |
| 894 | struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff); | 895 | struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff); |
| 895 | 896 | ||
| 896 | return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); | 897 | return dax_direct_access(dax_dev, pgoff, nr_pages, mode, kaddr, pfn); |
| 897 | } | 898 | } |
| 898 | 899 | ||
| 899 | static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, | 900 | static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, |
| @@ -315,11 +315,12 @@ static struct dax_device *stripe_dax_pgoff(struct dm_target *ti, pgoff_t *pgoff) · 314 unmodified lines | |||
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, | 317 | static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, |
| 318 | long nr_pages, void **kaddr, pfn_t *pfn) | 318 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 319 | pfn_t *pfn) | ||
| 319 | { | 320 | { |
| 320 | struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); | 321 | struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); |
| 321 | 322 | ||
| 322 | return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); | 323 | return dax_direct_access(dax_dev, pgoff, nr_pages, mode, kaddr, pfn); |
| 323 | } | 324 | } |
| 324 | 325 | ||
| 325 | static int stripe_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, | 326 | static int stripe_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | |||
| 10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
| 11 | #include <linux/kmod.h> | 11 | #include <linux/kmod.h> |
| 12 | #include <linux/bio.h> | 12 | #include <linux/bio.h> |
| 13 | #include <linux/dax.h> | ||
| 13 | 14 | ||
| 14 | #define DM_MSG_PREFIX "target" | 15 | #define DM_MSG_PREFIX "target" |
| 15 | 16 | ||
| @@ -142,7 +143,8 @@ static void io_err_release_clone_rq(struct request *clone, · 126 unmodified lines | |||
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, | 145 | static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, |
| 145 | long nr_pages, void **kaddr, pfn_t *pfn) | 146 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 147 | pfn_t *pfn) | ||
| 146 | { | 148 | { |
| 147 | return -EIO; | 149 | return -EIO; |
| 148 | } | 150 | } |
| @@ -286,7 +286,8 @@ static int persistent_memory_claim(struct dm_writecache *wc) · 285 unmodified lines | |||
| 286 | 286 | ||
| 287 | id = dax_read_lock(); | 287 | id = dax_read_lock(); |
| 288 | 288 | ||
| 289 | da = dax_direct_access(wc->ssd_dev->dax_dev, offset, p, &wc->memory_map, &pfn); | 289 | da = dax_direct_access(wc->ssd_dev->dax_dev, offset, p, DAX_ACCESS, |
| 290 | &wc->memory_map, &pfn); | ||
| 290 | if (da < 0) { | 291 | if (da < 0) { |
| 291 | wc->memory_map = NULL; | 292 | wc->memory_map = NULL; |
| 292 | r = da; | 293 | r = da; |
| @@ -308,8 +309,8 @@ static int persistent_memory_claim(struct dm_writecache *wc) · 15 unmodified lines | |||
| 308 | i = 0; | 309 | i = 0; |
| 309 | do { | 310 | do { |
| 310 | long daa; | 311 | long daa; |
| 311 | daa = dax_direct_access(wc->ssd_dev->dax_dev, offset + i, p - i, | 312 | daa = dax_direct_access(wc->ssd_dev->dax_dev, offset + i, |
| 312 | NULL, &pfn); | 313 | p - i, DAX_ACCESS, NULL, &pfn); |
| 313 | if (daa <= 0) { | 314 | if (daa <= 0) { |
| 314 | r = daa ? daa : -EINVAL; | 315 | r = daa ? daa : -EINVAL; |
| 315 | goto err3; | 316 | goto err3; |
| @@ -1093,7 +1093,8 @@ static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, · 1092 unmodified lines | |||
| 1093 | } | 1093 | } |
| 1094 | 1094 | ||
| 1095 | static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, | 1095 | static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, |
| 1096 | long nr_pages, void **kaddr, pfn_t *pfn) | 1096 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 1097 | pfn_t *pfn) | ||
| 1097 | { | 1098 | { |
| 1098 | struct mapped_device *md = dax_get_private(dax_dev); | 1099 | struct mapped_device *md = dax_get_private(dax_dev); |
| 1099 | sector_t sector = pgoff * PAGE_SECTORS; | 1100 | sector_t sector = pgoff * PAGE_SECTORS; |
| @@ -1111,7 +1112,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, · 11 unmodified lines | |||
| 1111 | if (len < 1) | 1112 | if (len < 1) |
| 1112 | goto out; | 1113 | goto out; |
| 1113 | nr_pages = min(len, nr_pages); | 1114 | nr_pages = min(len, nr_pages); |
| 1114 | ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); | 1115 | ret = ti->type->direct_access(ti, pgoff, nr_pages, mode, kaddr, pfn); |
| 1115 | 1116 | ||
| 1116 | out: | 1117 | out: |
| 1117 | dm_put_live_table(md, srcu_idx); | 1118 | dm_put_live_table(md, srcu_idx); |
| @@ -239,7 +239,8 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, · 238 unmodified lines | |||
| 239 | 239 | ||
| 240 | /* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */ | 240 | /* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */ |
| 241 | __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, | 241 | __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, |
| 242 | long nr_pages, void **kaddr, pfn_t *pfn) | 242 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 243 | pfn_t *pfn) | ||
| 243 | { | 244 | { |
| 244 | resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; | 245 | resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; |
| 245 | 246 | ||
| @@ -278,11 +279,12 @@ static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, · 32 unmodified lines | |||
| 278 | } | 279 | } |
| 279 | 280 | ||
| 280 | static long pmem_dax_direct_access(struct dax_device *dax_dev, | 281 | static long pmem_dax_direct_access(struct dax_device *dax_dev, |
| 281 | pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) | 282 | pgoff_t pgoff, long nr_pages, enum dax_access_mode mode, |
| 283 | void **kaddr, pfn_t *pfn) | ||
| 282 | { | 284 | { |
| 283 | struct pmem_device *pmem = dax_get_private(dax_dev); | 285 | struct pmem_device *pmem = dax_get_private(dax_dev); |
| 284 | 286 | ||
| 285 | return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn); | 287 | return __pmem_direct_access(pmem, pgoff, nr_pages, mode, kaddr, pfn); |
| 286 | } | 288 | } |
| 287 | 289 | ||
| 288 | static const struct dax_operations pmem_dax_ops = { | 290 | static const struct dax_operations pmem_dax_ops = { |
| @@ -8,6 +8,8 @@ · 7 unmodified lines | |||
| 8 | #include <linux/pfn_t.h> | 8 | #include <linux/pfn_t.h> |
| 9 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
| 10 | 10 | ||
| 11 | enum dax_access_mode; | ||
| 12 | |||
| 11 | /* this definition is in it's own header for tools/testing/nvdimm to consume */ | 13 | /* this definition is in it's own header for tools/testing/nvdimm to consume */ |
| 12 | struct pmem_device { | 14 | struct pmem_device { |
| 13 | /* One contiguous memory region per device */ | 15 | /* One contiguous memory region per device */ |
| @@ -28,7 +30,8 @@ struct pmem_device { · 14 unmodified lines | |||
| 28 | }; | 30 | }; |
| 29 | 31 | ||
| 30 | long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, | 32 | long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, |
| 31 | long nr_pages, void **kaddr, pfn_t *pfn); | 33 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 34 | pfn_t *pfn); | ||
| 32 | 35 | ||
| 33 | #ifdef CONFIG_MEMORY_FAILURE | 36 | #ifdef CONFIG_MEMORY_FAILURE |
| 34 | static inline bool test_and_clear_pmem_poison(struct page *page) | 37 | static inline bool test_and_clear_pmem_poison(struct page *page) |
| @@ -32,7 +32,8 @@ static int dcssblk_open(struct block_device *bdev, fmode_t mode); · 31 unmodified lines | |||
| 32 | static void dcssblk_release(struct gendisk *disk, fmode_t mode); | 32 | static void dcssblk_release(struct gendisk *disk, fmode_t mode); |
| 33 | static void dcssblk_submit_bio(struct bio *bio); | 33 | static void dcssblk_submit_bio(struct bio *bio); |
| 34 | static long dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, | 34 | static long dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, |
| 35 | long nr_pages, void **kaddr, pfn_t *pfn); | 35 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 36 | pfn_t *pfn); | ||
| 36 | 37 | ||
| 37 | static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0"; | 38 | static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0"; |
| 38 | 39 | ||
| @@ -50,7 +51,8 @@ static int dcssblk_dax_zero_page_range(struct dax_device *dax_dev, · 11 unmodified lines | |||
| 50 | long rc; | 51 | long rc; |
| 51 | void *kaddr; | 52 | void *kaddr; |
| 52 | 53 | ||
| 53 | rc = dax_direct_access(dax_dev, pgoff, nr_pages, &kaddr, NULL); | 54 | rc = dax_direct_access(dax_dev, pgoff, nr_pages, DAX_ACCESS, |
| 55 | &kaddr, NULL); | ||
| 54 | if (rc < 0) | 56 | if (rc < 0) |
| 55 | return rc; | 57 | return rc; |
| 56 | memset(kaddr, 0, nr_pages << PAGE_SHIFT); | 58 | memset(kaddr, 0, nr_pages << PAGE_SHIFT); |
| @@ -927,7 +929,8 @@ __dcssblk_direct_access(struct dcssblk_dev_info *dev_info, pgoff_t pgoff, · 870 unmodified lines | |||
| 927 | 929 | ||
| 928 | static long | 930 | static long |
| 929 | dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, | 931 | dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, |
| 930 | long nr_pages, void **kaddr, pfn_t *pfn) | 932 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 933 | pfn_t *pfn) | ||
| 931 | { | 934 | { |
| 932 | struct dcssblk_dev_info *dev_info = dax_get_private(dax_dev); | 935 | struct dcssblk_dev_info *dev_info = dax_get_private(dax_dev); |
| 933 | 936 | ||
| @@ -721,7 +721,8 @@ static int copy_cow_page_dax(struct vm_fault *vmf, const struct iomap_iter *iter · 720 unmodified lines | |||
| 721 | int id; | 721 | int id; |
| 722 | 722 | ||
| 723 | id = dax_read_lock(); | 723 | id = dax_read_lock(); |
| 724 | rc = dax_direct_access(iter->iomap.dax_dev, pgoff, 1, &kaddr, NULL); | 724 | rc = dax_direct_access(iter->iomap.dax_dev, pgoff, 1, DAX_ACCESS, |
| 725 | &kaddr, NULL); | ||
| 725 | if (rc < 0) { | 726 | if (rc < 0) { |
| 726 | dax_read_unlock(id); | 727 | dax_read_unlock(id); |
| 727 | return rc; | 728 | return rc; |
| @@ -1013,7 +1014,7 @@ static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, · 285 unmodified lines | |||
| 1013 | 1014 | ||
| 1014 | id = dax_read_lock(); | 1015 | id = dax_read_lock(); |
| 1015 | length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), | 1016 | length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), |
| 1016 | NULL, pfnp); | 1017 | DAX_ACCESS, NULL, pfnp); |
| 1017 | if (length < 0) { | 1018 | if (length < 0) { |
| 1018 | rc = length; | 1019 | rc = length; |
| 1019 | goto out; | 1020 | goto out; |
| @@ -1122,7 +1123,7 @@ static int dax_memzero(struct dax_device *dax_dev, pgoff_t pgoff, · 102 unmodified lines | |||
| 1122 | void *kaddr; | 1123 | void *kaddr; |
| 1123 | long ret; | 1124 | long ret; |
| 1124 | 1125 | ||
| 1125 | ret = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL); | 1126 | ret = dax_direct_access(dax_dev, pgoff, 1, DAX_ACCESS, &kaddr, NULL); |
| 1126 | if (ret > 0) { | 1127 | if (ret > 0) { |
| 1127 | memset(kaddr + offset, 0, size); | 1128 | memset(kaddr + offset, 0, size); |
| 1128 | dax_flush(dax_dev, kaddr + offset, size); | 1129 | dax_flush(dax_dev, kaddr + offset, size); |
| @@ -1247,7 +1248,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, · 118 unmodified lines | |||
| 1247 | } | 1248 | } |
| 1248 | 1249 | ||
| 1249 | map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), | 1250 | map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), |
| 1250 | &kaddr, NULL); | 1251 | DAX_ACCESS, &kaddr, NULL); |
| 1251 | if (map_len < 0) { | 1252 | if (map_len < 0) { |
| 1252 | ret = map_len; | 1253 | ret = map_len; |
| 1253 | break; | 1254 | break; |
| @@ -1241,8 +1241,8 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd) · 1240 unmodified lines | |||
| 1241 | INIT_DELAYED_WORK(&fcd->free_work, fuse_dax_free_mem_worker); | 1241 | INIT_DELAYED_WORK(&fcd->free_work, fuse_dax_free_mem_worker); |
| 1242 | 1242 | ||
| 1243 | id = dax_read_lock(); | 1243 | id = dax_read_lock(); |
| 1244 | nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), NULL, | 1244 | nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), |
| 1245 | NULL); | 1245 | DAX_ACCESS, NULL, NULL); |
| 1246 | dax_read_unlock(id); | 1246 | dax_read_unlock(id); |
| 1247 | if (nr_pages < 0) { | 1247 | if (nr_pages < 0) { |
| 1248 | pr_debug("dax_direct_access() returned %ld\n", nr_pages); | 1248 | pr_debug("dax_direct_access() returned %ld\n", nr_pages); |
| @@ -752,7 +752,8 @@ static void virtio_fs_cleanup_vqs(struct virtio_device *vdev, · 751 unmodified lines | |||
| 752 | * offset. | 752 | * offset. |
| 753 | */ | 753 | */ |
| 754 | static long virtio_fs_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, | 754 | static long virtio_fs_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, |
| 755 | long nr_pages, void **kaddr, pfn_t *pfn) | 755 | long nr_pages, enum dax_access_mode mode, |
| 756 | void **kaddr, pfn_t *pfn) | ||
| 756 | { | 757 | { |
| 757 | struct virtio_fs *fs = dax_get_private(dax_dev); | 758 | struct virtio_fs *fs = dax_get_private(dax_dev); |
| 758 | phys_addr_t offset = PFN_PHYS(pgoff); | 759 | phys_addr_t offset = PFN_PHYS(pgoff); |
| @@ -772,7 +773,8 @@ static int virtio_fs_zero_page_range(struct dax_device *dax_dev, · 13 unmodified lines | |||
| 772 | long rc; | 773 | long rc; |
| 773 | void *kaddr; | 774 | void *kaddr; |
| 774 | 775 | ||
| 775 | rc = dax_direct_access(dax_dev, pgoff, nr_pages, &kaddr, NULL); | 776 | rc = dax_direct_access(dax_dev, pgoff, nr_pages, DAX_ACCESS, &kaddr, |
| 777 | NULL); | ||
| 776 | if (rc < 0) | 778 | if (rc < 0) |
| 777 | return rc; | 779 | return rc; |
| 778 | memset(kaddr, 0, nr_pages << PAGE_SHIFT); | 780 | memset(kaddr, 0, nr_pages << PAGE_SHIFT); |
| @@ -14,6 +14,11 @@ struct iomap_ops; · 13 unmodified lines | |||
| 14 | struct iomap_iter; | 14 | struct iomap_iter; |
| 15 | struct iomap; | 15 | struct iomap; |
| 16 | 16 | ||
| 17 | enum dax_access_mode { | ||
| 18 | DAX_ACCESS, | ||
| 19 | DAX_RECOVERY_WRITE, | ||
| 20 | }; | ||
| 21 | |||
| 17 | struct dax_operations { | 22 | struct dax_operations { |
| 18 | /* | 23 | /* |
| 19 | * direct_access: translate a device-relative | 24 | * direct_access: translate a device-relative |
| @@ -21,7 +26,7 @@ struct dax_operations { · 1 unmodified line | |||
| 21 | * number of pages available for DAX at that pfn. | 26 | * number of pages available for DAX at that pfn. |
| 22 | */ | 27 | */ |
| 23 | long (*direct_access)(struct dax_device *, pgoff_t, long, | 28 | long (*direct_access)(struct dax_device *, pgoff_t, long, |
| 24 | void **, pfn_t *); | 29 | enum dax_access_mode, void **, pfn_t *); |
| 25 | /* | 30 | /* |
| 26 | * Validate whether this device is usable as an fsdax backing | 31 | * Validate whether this device is usable as an fsdax backing |
| 27 | * device. | 32 | * device. |
| @@ -178,7 +183,7 @@ static inline void dax_read_unlock(int id) · 150 unmodified lines | |||
| 178 | bool dax_alive(struct dax_device *dax_dev); | 183 | bool dax_alive(struct dax_device *dax_dev); |
| 179 | void *dax_get_private(struct dax_device *dax_dev); | 184 | void *dax_get_private(struct dax_device *dax_dev); |
| 180 | long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, | 185 | long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, |
| 181 | void **kaddr, pfn_t *pfn); | 186 | enum dax_access_mode mode, void **kaddr, pfn_t *pfn); |
| 182 | size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, | 187 | size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, |
| 183 | size_t bytes, struct iov_iter *i); | 188 | size_t bytes, struct iov_iter *i); |
| 184 | size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, | 189 | size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, |
| @@ -20,6 +20,7 @@ struct dm_table; · 19 unmodified lines | |||
| 20 | struct dm_report_zones_args; | 20 | struct dm_report_zones_args; |
| 21 | struct mapped_device; | 21 | struct mapped_device; |
| 22 | struct bio_vec; | 22 | struct bio_vec; |
| 23 | enum dax_access_mode; | ||
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * Type of table, mapped_device's mempool and request_queue | 26 | * Type of table, mapped_device's mempool and request_queue |
| @@ -146,7 +147,8 @@ typedef int (*dm_busy_fn) (struct dm_target *ti); · 120 unmodified lines | |||
| 146 | * >= 0 : the number of bytes accessible at the address | 147 | * >= 0 : the number of bytes accessible at the address |
| 147 | */ | 148 | */ |
| 148 | typedef long (*dm_dax_direct_access_fn) (struct dm_target *ti, pgoff_t pgoff, | 149 | typedef long (*dm_dax_direct_access_fn) (struct dm_target *ti, pgoff_t pgoff, |
| 149 | long nr_pages, void **kaddr, pfn_t *pfn); | 150 | long nr_pages, enum dax_access_mode node, void **kaddr, |
| 151 | pfn_t *pfn); | ||
| 150 | typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, | 152 | typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, |
| 151 | size_t nr_pages); | 153 | size_t nr_pages); |
| 152 | 154 | ||
| @@ -4,11 +4,13 @@ · 3 unmodified lines | |||
| 4 | */ | 4 | */ |
| 5 | #include "test/nfit_test.h" | 5 | #include "test/nfit_test.h" |
| 6 | #include <linux/blkdev.h> | 6 | #include <linux/blkdev.h> |
| 7 | #include <linux/dax.h> | ||
| 7 | #include <pmem.h> | 8 | #include <pmem.h> |
| 8 | #include <nd.h> | 9 | #include <nd.h> |
| 9 | 10 | ||
| 10 | long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, | 11 | long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, |
| 11 | long nr_pages, void **kaddr, pfn_t *pfn) | 12 | long nr_pages, enum dax_access_mode mode, void **kaddr, |
| 13 | pfn_t *pfn) | ||
| 12 | { | 14 | { |
| 13 | resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; | 15 | resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; |
| 14 | 16 | ||