Skip to content

Commit f6d2b80

Browse files
committed
Merge branch 'for-5.7/libnvdimm' into libnvdimm-for-next
- Introduce 'zero_page_range' as a dax operation. This facilitates filesystem-dax operation without a block-device. - Advertise a persistence-domain for of_pmem and papr_scm. The persistence domain indicates where cpu-store cycles need to reach in the platform-memory subsystem before the platform will consider them power-fail protected. - Fixup some flexible-array declarations.
2 parents d3b8865 + 4e4ced9 commit f6d2b80

File tree

17 files changed

+251
-110
lines changed

17 files changed

+251
-110
lines changed

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
342342

343343
if (p->is_volatile)
344344
p->region = nvdimm_volatile_region_create(p->bus, &ndr_desc);
345-
else
345+
else {
346+
set_bit(ND_REGION_PERSIST_MEMCTRL, &ndr_desc.flags);
346347
p->region = nvdimm_pmem_region_create(p->bus, &ndr_desc);
348+
}
347349
if (!p->region) {
348350
dev_err(dev, "Error registering region %pR from %pOF\n",
349351
ndr_desc.res, p->dn);

drivers/acpi/nfit/nfit.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,32 @@ struct nfit_spa {
145145
unsigned long ars_state;
146146
u32 clear_err_unit;
147147
u32 max_ars;
148-
struct acpi_nfit_system_address spa[0];
148+
struct acpi_nfit_system_address spa[];
149149
};
150150

151151
struct nfit_dcr {
152152
struct list_head list;
153-
struct acpi_nfit_control_region dcr[0];
153+
struct acpi_nfit_control_region dcr[];
154154
};
155155

156156
struct nfit_bdw {
157157
struct list_head list;
158-
struct acpi_nfit_data_region bdw[0];
158+
struct acpi_nfit_data_region bdw[];
159159
};
160160

161161
struct nfit_idt {
162162
struct list_head list;
163-
struct acpi_nfit_interleave idt[0];
163+
struct acpi_nfit_interleave idt[];
164164
};
165165

166166
struct nfit_flush {
167167
struct list_head list;
168-
struct acpi_nfit_flush_address flush[0];
168+
struct acpi_nfit_flush_address flush[];
169169
};
170170

171171
struct nfit_memdev {
172172
struct list_head list;
173-
struct acpi_nfit_memory_map memdev[0];
173+
struct acpi_nfit_memory_map memdev[];
174174
};
175175

176176
enum nfit_mem_flags {

drivers/dax/bus.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,10 @@ struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
421421
* device outside of mmap of the resulting character device.
422422
*/
423423
dax_dev = alloc_dax(dev_dax, NULL, NULL, DAXDEV_F_SYNC);
424-
if (!dax_dev)
424+
if (IS_ERR(dax_dev)) {
425+
rc = PTR_ERR(dax_dev);
425426
goto err;
427+
}
426428

427429
/* a device_dax instance is dead while the driver is not attached */
428430
kill_dax(dax_dev);

drivers/dax/super.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,23 @@ size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
344344
}
345345
EXPORT_SYMBOL_GPL(dax_copy_to_iter);
346346

347+
int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
348+
size_t nr_pages)
349+
{
350+
if (!dax_alive(dax_dev))
351+
return -ENXIO;
352+
/*
353+
* There are no callers that want to zero more than one page as of now.
354+
* Once users are there, this check can be removed after the
355+
* device mapper code has been updated to split ranges across targets.
356+
*/
357+
if (nr_pages != 1)
358+
return -EIO;
359+
360+
return dax_dev->ops->zero_page_range(dax_dev, pgoff, nr_pages);
361+
}
362+
EXPORT_SYMBOL_GPL(dax_zero_page_range);
363+
347364
#ifdef CONFIG_ARCH_HAS_PMEM_API
348365
void arch_wb_cache_pmem(void *addr, size_t size);
349366
void dax_flush(struct dax_device *dax_dev, void *addr, size_t size)
@@ -551,9 +568,16 @@ struct dax_device *alloc_dax(void *private, const char *__host,
551568
dev_t devt;
552569
int minor;
553570

571+
if (ops && !ops->zero_page_range) {
572+
pr_debug("%s: error: device does not provide dax"
573+
" operation zero_page_range()\n",
574+
__host ? __host : "Unknown");
575+
return ERR_PTR(-EINVAL);
576+
}
577+
554578
host = kstrdup(__host, GFP_KERNEL);
555579
if (__host && !host)
556-
return NULL;
580+
return ERR_PTR(-ENOMEM);
557581

558582
minor = ida_simple_get(&dax_minor_ida, 0, MINORMASK+1, GFP_KERNEL);
559583
if (minor < 0)
@@ -576,7 +600,7 @@ struct dax_device *alloc_dax(void *private, const char *__host,
576600
ida_simple_remove(&dax_minor_ida, minor);
577601
err_minor:
578602
kfree(host);
579-
return NULL;
603+
return ERR_PTR(-ENOMEM);
580604
}
581605
EXPORT_SYMBOL_GPL(alloc_dax);
582606

drivers/md/dm-linear.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,27 @@ static size_t linear_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff,
201201
return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i);
202202
}
203203

204+
static int linear_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff,
205+
size_t nr_pages)
206+
{
207+
int ret;
208+
struct linear_c *lc = ti->private;
209+
struct block_device *bdev = lc->dev->bdev;
210+
struct dax_device *dax_dev = lc->dev->dax_dev;
211+
sector_t dev_sector, sector = pgoff * PAGE_SECTORS;
212+
213+
dev_sector = linear_map_sector(ti, sector);
214+
ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages << PAGE_SHIFT, &pgoff);
215+
if (ret)
216+
return ret;
217+
return dax_zero_page_range(dax_dev, pgoff, nr_pages);
218+
}
219+
204220
#else
205221
#define linear_dax_direct_access NULL
206222
#define linear_dax_copy_from_iter NULL
207223
#define linear_dax_copy_to_iter NULL
224+
#define linear_dax_zero_page_range NULL
208225
#endif
209226

210227
static struct target_type linear_target = {
@@ -226,6 +243,7 @@ static struct target_type linear_target = {
226243
.direct_access = linear_dax_direct_access,
227244
.dax_copy_from_iter = linear_dax_copy_from_iter,
228245
.dax_copy_to_iter = linear_dax_copy_to_iter,
246+
.dax_zero_page_range = linear_dax_zero_page_range,
229247
};
230248

231249
int __init dm_linear_init(void)

drivers/md/dm-log-writes.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,26 @@ static size_t log_writes_dax_copy_to_iter(struct dm_target *ti,
994994
return dax_copy_to_iter(lc->dev->dax_dev, pgoff, addr, bytes, i);
995995
}
996996

997+
static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff,
998+
size_t nr_pages)
999+
{
1000+
int ret;
1001+
struct log_writes_c *lc = ti->private;
1002+
sector_t sector = pgoff * PAGE_SECTORS;
1003+
1004+
ret = bdev_dax_pgoff(lc->dev->bdev, sector, nr_pages << PAGE_SHIFT,
1005+
&pgoff);
1006+
if (ret)
1007+
return ret;
1008+
return dax_zero_page_range(lc->dev->dax_dev, pgoff,
1009+
nr_pages << PAGE_SHIFT);
1010+
}
1011+
9971012
#else
9981013
#define log_writes_dax_direct_access NULL
9991014
#define log_writes_dax_copy_from_iter NULL
10001015
#define log_writes_dax_copy_to_iter NULL
1016+
#define log_writes_dax_zero_page_range NULL
10011017
#endif
10021018

10031019
static struct target_type log_writes_target = {
@@ -1016,6 +1032,7 @@ static struct target_type log_writes_target = {
10161032
.direct_access = log_writes_dax_direct_access,
10171033
.dax_copy_from_iter = log_writes_dax_copy_from_iter,
10181034
.dax_copy_to_iter = log_writes_dax_copy_to_iter,
1035+
.dax_zero_page_range = log_writes_dax_zero_page_range,
10191036
};
10201037

10211038
static int __init dm_log_writes_init(void)

drivers/md/dm-stripe.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,32 @@ static size_t stripe_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff,
360360
return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i);
361361
}
362362

363+
static int stripe_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff,
364+
size_t nr_pages)
365+
{
366+
int ret;
367+
sector_t dev_sector, sector = pgoff * PAGE_SECTORS;
368+
struct stripe_c *sc = ti->private;
369+
struct dax_device *dax_dev;
370+
struct block_device *bdev;
371+
uint32_t stripe;
372+
373+
stripe_map_sector(sc, sector, &stripe, &dev_sector);
374+
dev_sector += sc->stripe[stripe].physical_start;
375+
dax_dev = sc->stripe[stripe].dev->dax_dev;
376+
bdev = sc->stripe[stripe].dev->bdev;
377+
378+
ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages << PAGE_SHIFT, &pgoff);
379+
if (ret)
380+
return ret;
381+
return dax_zero_page_range(dax_dev, pgoff, nr_pages);
382+
}
383+
363384
#else
364385
#define stripe_dax_direct_access NULL
365386
#define stripe_dax_copy_from_iter NULL
366387
#define stripe_dax_copy_to_iter NULL
388+
#define stripe_dax_zero_page_range NULL
367389
#endif
368390

369391
/*
@@ -486,6 +508,7 @@ static struct target_type stripe_target = {
486508
.direct_access = stripe_dax_direct_access,
487509
.dax_copy_from_iter = stripe_dax_copy_from_iter,
488510
.dax_copy_to_iter = stripe_dax_copy_to_iter,
511+
.dax_zero_page_range = stripe_dax_zero_page_range,
489512
};
490513

491514
int __init dm_stripe_init(void)

drivers/md/dm.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,35 @@ static size_t dm_dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff,
11981198
return ret;
11991199
}
12001200

1201+
static int dm_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
1202+
size_t nr_pages)
1203+
{
1204+
struct mapped_device *md = dax_get_private(dax_dev);
1205+
sector_t sector = pgoff * PAGE_SECTORS;
1206+
struct dm_target *ti;
1207+
int ret = -EIO;
1208+
int srcu_idx;
1209+
1210+
ti = dm_dax_get_live_target(md, sector, &srcu_idx);
1211+
1212+
if (!ti)
1213+
goto out;
1214+
if (WARN_ON(!ti->type->dax_zero_page_range)) {
1215+
/*
1216+
* ->zero_page_range() is mandatory dax operation. If we are
1217+
* here, something is wrong.
1218+
*/
1219+
dm_put_live_table(md, srcu_idx);
1220+
goto out;
1221+
}
1222+
ret = ti->type->dax_zero_page_range(ti, pgoff, nr_pages);
1223+
1224+
out:
1225+
dm_put_live_table(md, srcu_idx);
1226+
1227+
return ret;
1228+
}
1229+
12011230
/*
12021231
* A target may call dm_accept_partial_bio only from the map routine. It is
12031232
* allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_RESET,
@@ -1976,7 +2005,7 @@ static struct mapped_device *alloc_dev(int minor)
19762005
if (IS_ENABLED(CONFIG_DAX_DRIVER)) {
19772006
md->dax_dev = alloc_dax(md, md->disk->disk_name,
19782007
&dm_dax_ops, 0);
1979-
if (!md->dax_dev)
2008+
if (IS_ERR(md->dax_dev))
19802009
goto bad;
19812010
}
19822011

@@ -3199,6 +3228,7 @@ static const struct dax_operations dm_dax_ops = {
31993228
.dax_supported = dm_dax_supported,
32003229
.copy_from_iter = dm_dax_copy_from_iter,
32013230
.copy_to_iter = dm_dax_copy_to_iter,
3231+
.zero_page_range = dm_dax_zero_page_range,
32023232
};
32033233

32043234
/*

drivers/nvdimm/label.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct nd_namespace_index {
6262
__le16 major;
6363
__le16 minor;
6464
__le64 checksum;
65-
u8 free[0];
65+
u8 free[];
6666
};
6767

6868
/**

drivers/nvdimm/nd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct nd_region_data {
3939
int ns_count;
4040
int ns_active;
4141
unsigned int hints_shift;
42-
void __iomem *flush_wpq[0];
42+
void __iomem *flush_wpq[];
4343
};
4444

4545
static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd,
@@ -157,7 +157,7 @@ struct nd_region {
157157
struct nd_interleave_set *nd_set;
158158
struct nd_percpu_lane __percpu *lane;
159159
int (*flush)(struct nd_region *nd_region, struct bio *bio);
160-
struct nd_mapping mapping[0];
160+
struct nd_mapping mapping[];
161161
};
162162

163163
struct nd_blk_region {

0 commit comments

Comments
 (0)