mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
NVDIMM and DAX for v7.4
DAX fixes: dax: fix wrong error code returned from dax_dedupe_file_range_compare() dax: fix dax_range_compare_iter() to use correct size and address offset dax: Return errors from dax_core_init() dax/bus: Return errors for invalid mapping targets NVDIMM fixes: libnvdimm: Handle negative return from nvdimm_clear_poison() in nsio_rw_bytes() nvdimm/pmem: Release gendisk on probe failure -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQR/ATNjDEocsE1wudD5tRoRP7nxxwUCat69PwAKCRD5tRoRP7nx x8mlAQD1awwUyAbI4sGUkqjVA+EcVJcvopVJ1I8V6alq0eb5gAEA+p5ML/X2msQK 5nWXQEkAQU1OCaNZOuQiWbkmiLGe/AA= =peSp -----END PGP SIGNATURE----- Merge tag 'libnvdimm-for-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm Pull NVDIMM and DAX updates from Alison Schofield: "A small set of fixes: error handling corrections in the DAX core and bus code, a fix to the DAX file range comparison helpers, and two libnvdimm/pmem fixes for error and probe failure paths" * tag 'libnvdimm-for-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: dax: fix wrong error code returned from dax_dedupe_file_range_compare() dax/bus: Return errors for invalid mapping targets dax: fix dax_range_compare_iter() to use correct size and address offset dax: Return errors from dax_core_init() libnvdimm: Handle negative return from nvdimm_clear_poison() in nsio_rw_bytes() nvdimm/pmem: Release gendisk on probe failure
This commit is contained in:
commit
c60ebc3208
|
|
@ -1192,7 +1192,7 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr,
|
|||
return rc;
|
||||
if (!dax_region->dev->driver) {
|
||||
up_write(&dax_region_rwsem);
|
||||
return rc;
|
||||
return -ENXIO;
|
||||
}
|
||||
rc = down_write_killable(&dax_dev_rwsem);
|
||||
if (rc) {
|
||||
|
|
@ -1201,8 +1201,12 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
to_alloc = range_len(&r);
|
||||
if (alloc_is_aligned(dev_dax, to_alloc))
|
||||
if (!alloc_is_aligned(dev_dax, to_alloc)) {
|
||||
dev_dbg(dev, "%s: size: %zu misaligned\n", __func__, to_alloc);
|
||||
rc = -EINVAL;
|
||||
} else {
|
||||
rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc);
|
||||
}
|
||||
up_write(&dax_dev_rwsem);
|
||||
up_write(&dax_region_rwsem);
|
||||
|
||||
|
|
|
|||
|
|
@ -738,7 +738,7 @@ static int __init dax_core_init(void)
|
|||
unregister_chrdev_region(dax_devt, MINORMASK+1);
|
||||
err_chrdev:
|
||||
dax_fs_exit();
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void __exit dax_core_exit(void)
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
|
|||
might_sleep();
|
||||
cleared = nvdimm_clear_poison(&ndns->dev,
|
||||
nsio->res.start + offset, size);
|
||||
if (cleared < size)
|
||||
if (cleared < 0 || cleared < size)
|
||||
rc = -EIO;
|
||||
if (cleared > 0 && cleared / 512) {
|
||||
cleared /= 512;
|
||||
|
|
|
|||
|
|
@ -563,8 +563,10 @@ static int pmem_attach_disk(struct device *dev,
|
|||
nvdimm_namespace_disk_name(ndns, disk->disk_name);
|
||||
set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
|
||||
/ 512);
|
||||
if (devm_init_badblocks(dev, &pmem->bb))
|
||||
return -ENOMEM;
|
||||
if (devm_init_badblocks(dev, &pmem->bb)) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
nvdimm_badblocks_populate(nd_region, &pmem->bb, &bb_range);
|
||||
disk->bb = &pmem->bb;
|
||||
|
||||
|
|
|
|||
14
fs/dax.c
14
fs/dax.c
|
|
@ -2190,6 +2190,7 @@ static int dax_range_compare_iter(struct iomap_iter *it_src,
|
|||
const struct iomap *dmap = &it_dest->iomap;
|
||||
loff_t pos1 = it_src->pos, pos2 = it_dest->pos;
|
||||
void *saddr, *daddr;
|
||||
size_t size1, size2;
|
||||
int id, ret;
|
||||
|
||||
len = min(len, min(smap->length, dmap->length));
|
||||
|
|
@ -2205,17 +2206,18 @@ static int dax_range_compare_iter(struct iomap_iter *it_src,
|
|||
}
|
||||
|
||||
id = dax_read_lock();
|
||||
ret = dax_iomap_direct_access(smap, pos1, ALIGN(pos1 + len, PAGE_SIZE),
|
||||
&saddr, NULL);
|
||||
size1 = ALIGN(len + offset_in_page(pos1), PAGE_SIZE);
|
||||
ret = dax_iomap_direct_access(smap, pos1, size1, &saddr, NULL);
|
||||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
|
||||
ret = dax_iomap_direct_access(dmap, pos2, ALIGN(pos2 + len, PAGE_SIZE),
|
||||
&daddr, NULL);
|
||||
size2 = ALIGN(len + offset_in_page(pos2), PAGE_SIZE);
|
||||
ret = dax_iomap_direct_access(dmap, pos2, size2, &daddr, NULL);
|
||||
if (ret < 0)
|
||||
goto out_unlock;
|
||||
|
||||
*same = !memcmp(saddr, daddr, len);
|
||||
*same = !memcmp(saddr + offset_in_page(pos1),
|
||||
daddr + offset_in_page(pos2), len);
|
||||
if (!*same)
|
||||
len = 0;
|
||||
dax_read_unlock(id);
|
||||
|
|
@ -2254,7 +2256,7 @@ int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
|
|||
status = dax_range_compare_iter(&src_iter, &dst_iter,
|
||||
min(src_iter.len, dst_iter.len), same);
|
||||
if (status < 0)
|
||||
return ret;
|
||||
return status;
|
||||
src_iter.status = dst_iter.status = status;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user