Skip to content

Commit

Permalink
dax: move the partition alignment check into fs_dax_get_by_bdev
Browse files Browse the repository at this point in the history
fs_dax_get_by_bdev is the primary interface to find a dax device for a
block device, so move the partition alignment check there instead of
wiring it up through ->dax_supported.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Dan Williams <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
Christoph Hellwig authored and djbw committed Dec 4, 2021
1 parent 586f616 commit 0c44587
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions drivers/dax/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
if (!blk_queue_dax(bdev->bd_disk->queue))
return NULL;

if ((get_start_sect(bdev) * SECTOR_SIZE) % PAGE_SIZE ||
(bdev_nr_sectors(bdev) * SECTOR_SIZE) % PAGE_SIZE) {
pr_info("%pg: error: unaligned partition for dax\n", bdev);
return NULL;
}

id = dax_read_lock();
dax_dev = xa_load(&dax_hosts, (unsigned long)bdev->bd_disk);
if (!dax_dev || !dax_alive(dax_dev) || !igrab(&dax_dev->inode))
Expand All @@ -106,10 +112,6 @@ bool generic_fsdax_supported(struct dax_device *dax_dev,
struct block_device *bdev, int blocksize, sector_t start,
sector_t sectors)
{
pgoff_t pgoff, pgoff_end;
sector_t last_page;
int err;

if (blocksize != PAGE_SIZE) {
pr_info("%pg: error: unsupported blocksize for dax\n", bdev);
return false;
Expand All @@ -120,19 +122,6 @@ bool generic_fsdax_supported(struct dax_device *dax_dev,
return false;
}

err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff);
if (err) {
pr_info("%pg: error: unaligned partition for dax\n", bdev);
return false;
}

last_page = PFN_DOWN((start + sectors - 1) * 512) * PAGE_SIZE / 512;
err = bdev_dax_pgoff(bdev, last_page, PAGE_SIZE, &pgoff_end);
if (err) {
pr_info("%pg: error: unaligned partition for dax\n", bdev);
return false;
}

return true;
}
EXPORT_SYMBOL_GPL(generic_fsdax_supported);
Expand Down

0 comments on commit 0c44587

Please sign in to comment.