Skip to content

Commit f8c3500

Browse files
committed
Merge tag 'libnvdimm-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Dan Williams: "Primarily just the virtio_pmem driver: - virtio_pmem The new virtio_pmem facility introduces a paravirtualized persistent memory device that allows a guest VM to use DAX mechanisms to access a host-file with host-page-cache. It arranges for MAP_SYNC to be disabled and instead triggers a host fsync() when a 'write-cache flush' command is sent to the virtual disk device. - Miscellaneous small fixups" * tag 'libnvdimm-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: virtio_pmem: fix sparse warning xfs: disable map_sync for async flush ext4: disable map_sync for async flush dax: check synchronous mapping is supported dm: enable synchronous dax libnvdimm: add dax_dev sync flag virtio-pmem: Add virtio pmem driver libnvdimm: nd_region flush callback support libnvdimm, namespace: Drop uuid_t implementation detail
2 parents d77e9e4 + 8c2e408 commit f8c3500

File tree

23 files changed

+508
-38
lines changed

23 files changed

+508
-38
lines changed

drivers/acpi/nfit/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ static void write_blk_ctl(struct nfit_blk *nfit_blk, unsigned int bw,
24262426
offset = to_interleave_offset(offset, mmio);
24272427

24282428
writeq(cmd, mmio->addr.base + offset);
2429-
nvdimm_flush(nfit_blk->nd_region);
2429+
nvdimm_flush(nfit_blk->nd_region, NULL);
24302430

24312431
if (nfit_blk->dimm_flags & NFIT_BLK_DCR_LATCH)
24322432
readq(mmio->addr.base + offset);
@@ -2475,7 +2475,7 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk,
24752475
}
24762476

24772477
if (rw)
2478-
nvdimm_flush(nfit_blk->nd_region);
2478+
nvdimm_flush(nfit_blk->nd_region, NULL);
24792479

24802480
rc = read_blk_stat(nfit_blk, lane) ? -EIO : 0;
24812481
return rc;

drivers/dax/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
388388
* No 'host' or dax_operations since there is no access to this
389389
* device outside of mmap of the resulting character device.
390390
*/
391-
dax_dev = alloc_dax(dev_dax, NULL, NULL);
391+
dax_dev = alloc_dax(dev_dax, NULL, NULL, DAXDEV_F_SYNC);
392392
if (!dax_dev)
393393
goto err;
394394

drivers/dax/super.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ enum dax_device_flags {
195195
DAXDEV_ALIVE,
196196
/* gate whether dax_flush() calls the low level flush routine */
197197
DAXDEV_WRITE_CACHE,
198+
/* flag to check if device supports synchronous flush */
199+
DAXDEV_SYNC,
198200
};
199201

200202
/**
@@ -372,6 +374,18 @@ bool dax_write_cache_enabled(struct dax_device *dax_dev)
372374
}
373375
EXPORT_SYMBOL_GPL(dax_write_cache_enabled);
374376

377+
bool __dax_synchronous(struct dax_device *dax_dev)
378+
{
379+
return test_bit(DAXDEV_SYNC, &dax_dev->flags);
380+
}
381+
EXPORT_SYMBOL_GPL(__dax_synchronous);
382+
383+
void __set_dax_synchronous(struct dax_device *dax_dev)
384+
{
385+
set_bit(DAXDEV_SYNC, &dax_dev->flags);
386+
}
387+
EXPORT_SYMBOL_GPL(__set_dax_synchronous);
388+
375389
bool dax_alive(struct dax_device *dax_dev)
376390
{
377391
lockdep_assert_held(&dax_srcu);
@@ -526,7 +540,7 @@ static void dax_add_host(struct dax_device *dax_dev, const char *host)
526540
}
527541

528542
struct dax_device *alloc_dax(void *private, const char *__host,
529-
const struct dax_operations *ops)
543+
const struct dax_operations *ops, unsigned long flags)
530544
{
531545
struct dax_device *dax_dev;
532546
const char *host;
@@ -549,6 +563,9 @@ struct dax_device *alloc_dax(void *private, const char *__host,
549563
dax_add_host(dax_dev, host);
550564
dax_dev->ops = ops;
551565
dax_dev->private = private;
566+
if (flags & DAXDEV_F_SYNC)
567+
set_dax_synchronous(dax_dev);
568+
552569
return dax_dev;
553570

554571
err_dev:

drivers/md/dm-table.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type)
881881
EXPORT_SYMBOL_GPL(dm_table_set_type);
882882

883883
/* validate the dax capability of the target device span */
884-
static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
884+
int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
885885
sector_t start, sector_t len, void *data)
886886
{
887887
int blocksize = *(int *) data;
@@ -890,7 +890,15 @@ static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
890890
start, len);
891891
}
892892

893-
bool dm_table_supports_dax(struct dm_table *t, int blocksize)
893+
/* Check devices support synchronous DAX */
894+
static int device_synchronous(struct dm_target *ti, struct dm_dev *dev,
895+
sector_t start, sector_t len, void *data)
896+
{
897+
return dax_synchronous(dev->dax_dev);
898+
}
899+
900+
bool dm_table_supports_dax(struct dm_table *t,
901+
iterate_devices_callout_fn iterate_fn, int *blocksize)
894902
{
895903
struct dm_target *ti;
896904
unsigned i;
@@ -903,8 +911,7 @@ bool dm_table_supports_dax(struct dm_table *t, int blocksize)
903911
return false;
904912

905913
if (!ti->type->iterate_devices ||
906-
!ti->type->iterate_devices(ti, device_supports_dax,
907-
&blocksize))
914+
!ti->type->iterate_devices(ti, iterate_fn, blocksize))
908915
return false;
909916
}
910917

@@ -940,6 +947,7 @@ static int dm_table_determine_type(struct dm_table *t)
940947
struct dm_target *tgt;
941948
struct list_head *devices = dm_table_get_devices(t);
942949
enum dm_queue_mode live_md_type = dm_get_md_type(t->md);
950+
int page_size = PAGE_SIZE;
943951

944952
if (t->type != DM_TYPE_NONE) {
945953
/* target already set the table's type */
@@ -984,7 +992,7 @@ static int dm_table_determine_type(struct dm_table *t)
984992
verify_bio_based:
985993
/* We must use this table as bio-based */
986994
t->type = DM_TYPE_BIO_BASED;
987-
if (dm_table_supports_dax(t, PAGE_SIZE) ||
995+
if (dm_table_supports_dax(t, device_supports_dax, &page_size) ||
988996
(list_empty(devices) && live_md_type == DM_TYPE_DAX_BIO_BASED)) {
989997
t->type = DM_TYPE_DAX_BIO_BASED;
990998
} else {
@@ -1883,6 +1891,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18831891
struct queue_limits *limits)
18841892
{
18851893
bool wc = false, fua = false;
1894+
int page_size = PAGE_SIZE;
18861895

18871896
/*
18881897
* Copy table's limits to the DM device's request_queue
@@ -1910,8 +1919,11 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
19101919
}
19111920
blk_queue_write_cache(q, wc, fua);
19121921

1913-
if (dm_table_supports_dax(t, PAGE_SIZE))
1922+
if (dm_table_supports_dax(t, device_supports_dax, &page_size)) {
19141923
blk_queue_flag_set(QUEUE_FLAG_DAX, q);
1924+
if (dm_table_supports_dax(t, device_synchronous, NULL))
1925+
set_dax_synchronous(t->md->dax_dev);
1926+
}
19151927
else
19161928
blk_queue_flag_clear(QUEUE_FLAG_DAX, q);
19171929

drivers/md/dm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ static bool dm_dax_supported(struct dax_device *dax_dev, struct block_device *bd
11171117
if (!map)
11181118
return false;
11191119

1120-
ret = dm_table_supports_dax(map, blocksize);
1120+
ret = dm_table_supports_dax(map, device_supports_dax, &blocksize);
11211121

11221122
dm_put_live_table(md, srcu_idx);
11231123

@@ -1989,7 +1989,8 @@ static struct mapped_device *alloc_dev(int minor)
19891989
sprintf(md->disk->disk_name, "dm-%d", minor);
19901990

19911991
if (IS_ENABLED(CONFIG_DAX_DRIVER)) {
1992-
md->dax_dev = alloc_dax(md, md->disk->disk_name, &dm_dax_ops);
1992+
md->dax_dev = alloc_dax(md, md->disk->disk_name,
1993+
&dm_dax_ops, 0);
19931994
if (!md->dax_dev)
19941995
goto bad;
19951996
}

drivers/md/dm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ bool dm_table_bio_based(struct dm_table *t);
7272
bool dm_table_request_based(struct dm_table *t);
7373
void dm_table_free_md_mempools(struct dm_table *t);
7474
struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t);
75-
bool dm_table_supports_dax(struct dm_table *t, int blocksize);
75+
bool dm_table_supports_dax(struct dm_table *t, iterate_devices_callout_fn fn,
76+
int *blocksize);
77+
int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
78+
sector_t start, sector_t len, void *data);
7679

7780
void dm_lock_md_type(struct mapped_device *md);
7881
void dm_unlock_md_type(struct mapped_device *md);

drivers/nvdimm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ obj-$(CONFIG_ND_BTT) += nd_btt.o
55
obj-$(CONFIG_ND_BLK) += nd_blk.o
66
obj-$(CONFIG_X86_PMEM_LEGACY) += nd_e820.o
77
obj-$(CONFIG_OF_PMEM) += of_pmem.o
8+
obj-$(CONFIG_VIRTIO_PMEM) += virtio_pmem.o nd_virtio.o
89

910
nd_pmem-y := pmem.o
1011

drivers/nvdimm/claim.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
255255
struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
256256
unsigned int sz_align = ALIGN(size + (offset & (512 - 1)), 512);
257257
sector_t sector = offset >> 9;
258-
int rc = 0;
258+
int rc = 0, ret = 0;
259259

260260
if (unlikely(!size))
261261
return 0;
@@ -293,7 +293,9 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
293293
}
294294

295295
memcpy_flushcache(nsio->addr + offset, buf, size);
296-
nvdimm_flush(to_nd_region(ndns->dev.parent));
296+
ret = nvdimm_flush(to_nd_region(ndns->dev.parent), NULL);
297+
if (ret)
298+
rc = ret;
297299

298300
return rc;
299301
}

drivers/nvdimm/namespace_devs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,8 @@ static bool has_uuid_at_pos(struct nd_region *nd_region, u8 *uuid,
18221822
&& !guid_equal(&nd_set->type_guid,
18231823
&nd_label->type_guid)) {
18241824
dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
1825-
nd_set->type_guid.b,
1826-
nd_label->type_guid.b);
1825+
&nd_set->type_guid,
1826+
&nd_label->type_guid);
18271827
continue;
18281828
}
18291829

@@ -2227,8 +2227,8 @@ static struct device *create_namespace_blk(struct nd_region *nd_region,
22272227
if (namespace_label_has(ndd, type_guid)) {
22282228
if (!guid_equal(&nd_set->type_guid, &nd_label->type_guid)) {
22292229
dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
2230-
nd_set->type_guid.b,
2231-
nd_label->type_guid.b);
2230+
&nd_set->type_guid,
2231+
&nd_label->type_guid);
22322232
return ERR_PTR(-EAGAIN);
22332233
}
22342234

drivers/nvdimm/nd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct nd_region {
155155
struct badblocks bb;
156156
struct nd_interleave_set *nd_set;
157157
struct nd_percpu_lane __percpu *lane;
158+
int (*flush)(struct nd_region *nd_region, struct bio *bio);
158159
struct nd_mapping mapping[0];
159160
};
160161

0 commit comments

Comments
 (0)