mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-18 11:54:37 +08:00
dm-log-writes: add a log_writes_dax_pgoff helper
Add a helper to perform the entire remapping for DAX accesses. This helper open codes bdev_dax_pgoff given that the alignment checks have already been done by the submitting file system and don't need to be repeated. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Mike Snitzer <snitzer@redhat.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Link: https://lore.kernel.org/r/20211129102203.2243509-11-hch@lst.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
f43e0065c2
commit
d19bd6756e
@ -947,17 +947,21 @@ static int log_dax(struct log_writes_c *lc, sector_t sector, size_t bytes,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct dax_device *log_writes_dax_pgoff(struct dm_target *ti,
|
||||||
|
pgoff_t *pgoff)
|
||||||
|
{
|
||||||
|
struct log_writes_c *lc = ti->private;
|
||||||
|
|
||||||
|
*pgoff += (get_start_sect(lc->dev->bdev) >> PAGE_SECTORS_SHIFT);
|
||||||
|
return lc->dev->dax_dev;
|
||||||
|
}
|
||||||
|
|
||||||
static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
|
static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
|
||||||
long nr_pages, void **kaddr, pfn_t *pfn)
|
long nr_pages, void **kaddr, pfn_t *pfn)
|
||||||
{
|
{
|
||||||
struct log_writes_c *lc = ti->private;
|
struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff);
|
||||||
sector_t sector = pgoff * PAGE_SECTORS;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = bdev_dax_pgoff(lc->dev->bdev, sector, nr_pages * PAGE_SIZE, &pgoff);
|
return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
return dax_direct_access(lc->dev->dax_dev, pgoff, nr_pages, kaddr, pfn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t log_writes_dax_copy_from_iter(struct dm_target *ti,
|
static size_t log_writes_dax_copy_from_iter(struct dm_target *ti,
|
||||||
@ -966,11 +970,9 @@ static size_t log_writes_dax_copy_from_iter(struct dm_target *ti,
|
|||||||
{
|
{
|
||||||
struct log_writes_c *lc = ti->private;
|
struct log_writes_c *lc = ti->private;
|
||||||
sector_t sector = pgoff * PAGE_SECTORS;
|
sector_t sector = pgoff * PAGE_SECTORS;
|
||||||
|
struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (bdev_dax_pgoff(lc->dev->bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Don't bother doing anything if logging has been disabled */
|
/* Don't bother doing anything if logging has been disabled */
|
||||||
if (!lc->logging_enabled)
|
if (!lc->logging_enabled)
|
||||||
goto dax_copy;
|
goto dax_copy;
|
||||||
@ -981,34 +983,24 @@ static size_t log_writes_dax_copy_from_iter(struct dm_target *ti,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dax_copy:
|
dax_copy:
|
||||||
return dax_copy_from_iter(lc->dev->dax_dev, pgoff, addr, bytes, i);
|
return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t log_writes_dax_copy_to_iter(struct dm_target *ti,
|
static size_t log_writes_dax_copy_to_iter(struct dm_target *ti,
|
||||||
pgoff_t pgoff, void *addr, size_t bytes,
|
pgoff_t pgoff, void *addr, size_t bytes,
|
||||||
struct iov_iter *i)
|
struct iov_iter *i)
|
||||||
{
|
{
|
||||||
struct log_writes_c *lc = ti->private;
|
struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff);
|
||||||
sector_t sector = pgoff * PAGE_SECTORS;
|
|
||||||
|
|
||||||
if (bdev_dax_pgoff(lc->dev->bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff))
|
return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i);
|
||||||
return 0;
|
|
||||||
return dax_copy_to_iter(lc->dev->dax_dev, pgoff, addr, bytes, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff,
|
static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff,
|
||||||
size_t nr_pages)
|
size_t nr_pages)
|
||||||
{
|
{
|
||||||
int ret;
|
struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff);
|
||||||
struct log_writes_c *lc = ti->private;
|
|
||||||
sector_t sector = pgoff * PAGE_SECTORS;
|
|
||||||
|
|
||||||
ret = bdev_dax_pgoff(lc->dev->bdev, sector, nr_pages << PAGE_SHIFT,
|
return dax_zero_page_range(dax_dev, pgoff, nr_pages << PAGE_SHIFT);
|
||||||
&pgoff);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
return dax_zero_page_range(lc->dev->dax_dev, pgoff,
|
|
||||||
nr_pages << PAGE_SHIFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user