Skip to content

Commit 4a123db

Browse files
committed
Merge tag 'libnvdimm-fixes-5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm fixes from Dan Williams: "A handful of fixes to address a string of mistakes in the mechanism for device-mapper to determine if its component devices are dax capable. - Fix an original bug in device-mapper table reference counting when interrogating dax capability in the component device. This bug was hidden by the following bug. - Fix device-mapper to use the proper helper (dax_supported() instead of the leaf helper generic_fsdax_supported()) to determine dax operation of a stacked block device configuration. The original implementation is only valid for one level of dax-capable block device stacking. This bug was discovered while fixing the below regression. - Fix an infinite recursion regression introduced by broken attempts to quiet the generic_fsdax_supported() path and make it bail out before logging "dax capability not found" errors" * tag 'libnvdimm-fixes-5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: dax: Fix stack overflow when mounting fsdax pmem device dm: Call proper helper to determine dax support dm/dax: Fix table reference counts
2 parents bdcf11d + d4c5da5 commit 4a123db

4 files changed

Lines changed: 40 additions & 13 deletions

File tree

drivers/dax/super.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
8585
return false;
8686
}
8787

88+
if (!dax_dev) {
89+
pr_debug("%s: error: dax unsupported by block device\n",
90+
bdevname(bdev, buf));
91+
return false;
92+
}
93+
8894
err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff);
8995
if (err) {
9096
pr_info("%s: error: unaligned partition for dax\n",
@@ -100,12 +106,6 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
100106
return false;
101107
}
102108

103-
if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
104-
pr_debug("%s: error: dax unsupported by block device\n",
105-
bdevname(bdev, buf));
106-
return false;
107-
}
108-
109109
id = dax_read_lock();
110110
len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn);
111111
len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn);
@@ -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 */

drivers/md/dm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,15 +1136,16 @@ static bool dm_dax_supported(struct dax_device *dax_dev, struct block_device *bd
11361136
{
11371137
struct mapped_device *md = dax_get_private(dax_dev);
11381138
struct dm_table *map;
1139+
bool ret = false;
11391140
int srcu_idx;
1140-
bool ret;
11411141

11421142
map = dm_get_live_table(md, &srcu_idx);
11431143
if (!map)
1144-
return false;
1144+
goto out;
11451145

11461146
ret = dm_table_supports_dax(map, device_supports_dax, &blocksize);
11471147

1148+
out:
11481149
dm_put_live_table(md, srcu_idx);
11491150

11501151
return ret;

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)