Skip to content

Commit e2ec512

Browse files
jankaradjbw
authored andcommitted
dm: Call proper helper to determine dax support
DM was calling generic_fsdax_supported() to determine whether a device referenced in the DM table supports DAX. However this is a helper for "leaf" device drivers so that they don't have to duplicate common generic checks. High level code should call dax_supported() helper which that calls into appropriate helper for the particular device. This problem manifested itself as kernel messages: dm-3: error: dax access failed (-95) when lvm2-testsuite run in cases where a DM device was stacked on top of another DM device. Fixes: 7bf7eac ("dax: Arrange for dax_supported check to span multiple devices") Cc: <stable@vger.kernel.org> Tested-by: Adrian Huang <ahuang12@lenovo.com> Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Mike Snitzer <snitzer@redhat.com> Reported-by: kernel test robot <lkp@intel.com> Link: https://lore.kernel.org/r/160061715195.13131.5503173247632041975.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 02186d8 commit e2ec512

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

drivers/dax/super.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,15 @@ EXPORT_SYMBOL_GPL(dax_direct_access);
325325
bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
326326
int blocksize, sector_t start, sector_t len)
327327
{
328+
if (!dax_dev)
329+
return false;
330+
328331
if (!dax_alive(dax_dev))
329332
return false;
330333

331334
return dax_dev->ops->dax_supported(dax_dev, bdev, blocksize, start, len);
332335
}
336+
EXPORT_SYMBOL_GPL(dax_supported);
333337

334338
size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
335339
size_t bytes, struct iov_iter *i)

drivers/md/dm-table.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,14 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
860860
int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
861861
sector_t start, sector_t len, void *data)
862862
{
863-
int blocksize = *(int *) data;
863+
int blocksize = *(int *) data, id;
864+
bool rc;
864865

865-
return generic_fsdax_supported(dev->dax_dev, dev->bdev, blocksize,
866-
start, len);
866+
id = dax_read_lock();
867+
rc = dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len);
868+
dax_read_unlock(id);
869+
870+
return rc;
867871
}
868872

869873
/* Check devices support synchronous DAX */

include/linux/dax.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ static inline bool generic_fsdax_supported(struct dax_device *dax_dev,
130130
return __generic_fsdax_supported(dax_dev, bdev, blocksize, start,
131131
sectors);
132132
}
133+
bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
134+
int blocksize, sector_t start, sector_t len);
133135

134136
static inline void fs_put_dax(struct dax_device *dax_dev)
135137
{
@@ -157,6 +159,13 @@ static inline bool generic_fsdax_supported(struct dax_device *dax_dev,
157159
return false;
158160
}
159161

162+
static inline bool dax_supported(struct dax_device *dax_dev,
163+
struct block_device *bdev, int blocksize, sector_t start,
164+
sector_t len)
165+
{
166+
return false;
167+
}
168+
160169
static inline void fs_put_dax(struct dax_device *dax_dev)
161170
{
162171
}
@@ -189,14 +198,23 @@ static inline void dax_unlock_page(struct page *page, dax_entry_t cookie)
189198
}
190199
#endif
191200

201+
#if IS_ENABLED(CONFIG_DAX)
192202
int dax_read_lock(void);
193203
void dax_read_unlock(int id);
204+
#else
205+
static inline int dax_read_lock(void)
206+
{
207+
return 0;
208+
}
209+
210+
static inline void dax_read_unlock(int id)
211+
{
212+
}
213+
#endif /* CONFIG_DAX */
194214
bool dax_alive(struct dax_device *dax_dev);
195215
void *dax_get_private(struct dax_device *dax_dev);
196216
long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
197217
void **kaddr, pfn_t *pfn);
198-
bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
199-
int blocksize, sector_t start, sector_t len);
200218
size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
201219
size_t bytes, struct iov_iter *i);
202220
size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,

0 commit comments

Comments
 (0)