Jane Chu
047218ec90
dax: add .recovery_write dax_operation
...
Introduce dax_recovery_write() operation. The function is used to
recover a dax range that contains poison. Typical use case is when
a user process receives a SIGBUS with si_code BUS_MCEERR_AR
indicating poison(s) in a dax range, in response, the user process
issues a pwrite() to the page-aligned dax range, thus clears the
poison and puts valid data in the range.
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Jane Chu <jane.chu@oracle.com >
Link: https://lore.kernel.org/r/20220422224508.440670-6-jane.chu@oracle.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2022-05-16 13:37:59 -07:00
Jane Chu
e511c4a3d2
dax: introduce DAX_RECOVERY_WRITE dax access mode
...
Up till now, dax_direct_access() is used implicitly for normal
access, but for the purpose of recovery write, dax range with
poison is requested. To make the interface clear, introduce
enum dax_access_mode {
DAX_ACCESS,
DAX_RECOVERY_WRITE,
}
where DAX_ACCESS is used for normal dax access, and
DAX_RECOVERY_WRITE is used for dax recovery write.
Suggested-by: Dan Williams <dan.j.williams@intel.com >
Signed-off-by: Jane Chu <jane.chu@oracle.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Cc: Mike Snitzer <snitzer@redhat.com >
Reviewed-by: Vivek Goyal <vgoyal@redhat.com >
Link: https://lore.kernel.org/r/165247982851.52965.11024212198889762949.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2022-05-16 13:35:56 -07:00
Linus Torvalds
f0614eefbf
Merge tag 'dax-for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
...
Pull DAX updates from Dan Williams:
"Andrew has been shepherding major dax features that touch the core -mm
through his tree, but I still collect the dax updates that are core-mm
independent.
- Fix a crash due to a missing rcu_barrier() in dax_fs_exit()
- Fix two miscellaneous doc issues"
* tag 'dax-for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
dax: Fix missing kdoc for dax_device
dax: make sure inodes are flushed before destroy cache
fsdax: fix function description
2022-03-24 18:12:09 -07:00
Muchun Song
fd60b28842
fs: allocate inode by using alloc_inode_sb()
...
The inode allocation is supposed to use alloc_inode_sb(), so convert
kmem_cache_alloc() of all filesystems to alloc_inode_sb().
Link: https://lkml.kernel.org/r/20220228122126.37293-5-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com >
Acked-by: Theodore Ts'o <tytso@mit.edu > [ext4]
Acked-by: Roman Gushchin <roman.gushchin@linux.dev >
Cc: Alex Shi <alexs@kernel.org >
Cc: Anna Schumaker <Anna.Schumaker@Netapp.com >
Cc: Chao Yu <chao@kernel.org >
Cc: Dave Chinner <david@fromorbit.com >
Cc: Fam Zheng <fam.zheng@bytedance.com >
Cc: Jaegeuk Kim <jaegeuk@kernel.org >
Cc: Johannes Weiner <hannes@cmpxchg.org >
Cc: Kari Argillander <kari.argillander@gmail.com >
Cc: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Michal Hocko <mhocko@kernel.org >
Cc: Qi Zheng <zhengqi.arch@bytedance.com >
Cc: Shakeel Butt <shakeelb@google.com >
Cc: Trond Myklebust <trond.myklebust@hammerspace.com >
Cc: Vladimir Davydov <vdavydov.dev@gmail.com >
Cc: Vlastimil Babka <vbabka@suse.cz >
Cc: Wei Yang <richard.weiyang@gmail.com >
Cc: Xiongchun Duan <duanxiongchun@bytedance.com >
Cc: Yang Shi <shy828301@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2022-03-22 15:57:03 -07:00
Ira Weiny
db8cd5efee
dax: Fix missing kdoc for dax_device
...
struct dax_device has a member named ops which was undocumented.
Add the kdoc.
Signed-off-by: Ira Weiny <ira.weiny@intel.com >
Link: https://lore.kernel.org/r/20220304204655.3489216-1-ira.weiny@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2022-03-12 13:46:25 -08:00
Tong Zhang
a7e8de822e
dax: make sure inodes are flushed before destroy cache
...
A bug can be triggered by following command
$ modprobe nd_pmem && modprobe -r nd_pmem
[ 10.060014] BUG dax_cache (Not tainted): Objects remaining in dax_cache on __kmem_cache_shutdown()
[ 10.060938] Slab 0x0000000085b729ac objects=9 used=1 fp=0x000000004f5ae469 flags=0x200000000010200(slab|head|node)
[ 10.062433] Call Trace:
[ 10.062673] dump_stack_lvl+0x34/0x44
[ 10.062865] slab_err+0x90/0xd0
[ 10.063619] __kmem_cache_shutdown+0x13b/0x2f0
[ 10.063848] kmem_cache_destroy+0x4a/0x110
[ 10.064058] __x64_sys_delete_module+0x265/0x300
This is caused by dax_fs_exit() not flushing inodes before destroy cache.
To fix this issue, call rcu_barrier() before destroy cache.
Signed-off-by: Tong Zhang <ztong0001@gmail.com >
Reviewed-by: Ira Weiny <ira.weiny@intel.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20220212071111.148575-1-ztong0001@gmail.com
Fixes: 7b6be8444e ("dax: refactor dax-fs into a generic provider of 'struct dax_device' instances")
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2022-02-17 16:57:27 -08:00
Christoph Hellwig
7ac5360cd4
dax: remove the copy_from_iter and copy_to_iter methods
...
These methods indirect the actual DAX read/write path. In the end pmem
uses magic flush and mc safe variants and fuse and dcssblk use plain ones
while device mapper picks redirects to the underlying device.
Add set_dax_nocache() and set_dax_nomc() APIs to control which copy
routines are used to remove indirect call from the read/write fast path
as well as a lot of boilerplate code.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Vivek Goyal <vgoyal@redhat.com > [virtiofs]
Link: https://lore.kernel.org/r/20211215084508.435401-5-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-18 08:04:53 -08:00
Christoph Hellwig
30c6828a17
dax: remove the DAXDEV_F_SYNC flag
...
Remove the DAXDEV_F_SYNC flag and thus the flags argument to alloc_dax and
just let the drivers call set_dax_synchronous directly.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20211215084508.435401-4-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-18 08:04:52 -08:00
Christoph Hellwig
fd1d00ec92
dax: simplify dax_synchronous and set_dax_synchronous
...
Remove the pointless wrappers.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20211215084508.435401-3-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-18 08:04:52 -08:00
Christoph Hellwig
cd913c76f4
dax: return the partition offset from fs_dax_get_by_bdev
...
Prepare for the removal of the block_device from the DAX I/O path by
returning the partition offset from fs_dax_get_by_bdev so that the file
systems have it at hand for use during I/O.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Reviewed-by: Darrick J. Wong <djwong@kernel.org >
Link: https://lore.kernel.org/r/20211129102203.2243509-26-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:54 -08:00
Christoph Hellwig
60696eb26a
fsdax: simplify the pgoff calculation
...
Replace the two steps of dax_iomap_sector and bdev_dax_pgoff with a
single dax_iomap_pgoff helper that avoids lots of cumbersome sector
conversions.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Reviewed-by: Darrick J. Wong <djwong@kernel.org >
Link: https://lore.kernel.org/r/20211129102203.2243509-15-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:52 -08:00
Christoph Hellwig
7b0800d00d
dax: remove dax_capable
...
Just open code the block size and dax_dev == NULL checks in the callers.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Mike Snitzer <snitzer@redhat.com >
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com > [erofs]
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Reviewed-by: Darrick J. Wong <djwong@kernel.org >
Link: https://lore.kernel.org/r/20211129102203.2243509-9-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:51 -08:00
Christoph Hellwig
0c44587138
dax: move the partition alignment check into fs_dax_get_by_bdev
...
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 <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Reviewed-by: Darrick J. Wong <djwong@kernel.org >
Link: https://lore.kernel.org/r/20211129102203.2243509-7-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:51 -08:00
Christoph Hellwig
586f616828
dax: remove the pgmap sanity checks in generic_fsdax_supported
...
Drivers that register a dax_dev should make sure it works, no need
to double check from the file system.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Reviewed-by: Darrick J. Wong <djwong@kernel.org >
Link: https://lore.kernel.org/r/20211129102203.2243509-6-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:51 -08:00
Christoph Hellwig
fb08a1908c
dax: simplify the dax_device <-> gendisk association
...
Replace the dax_host_hash with an xarray indexed by the pointer value
of the gendisk, and require explicitly calls from the block drivers that
want to associate their gendisk with a dax_device.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Mike Snitzer <snitzer@redhat.com >
Reviewed-by: Darrick J. Wong <djwong@kernel.org >
Link: https://lore.kernel.org/r/20211129102203.2243509-5-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:51 -08:00
Christoph Hellwig
5d2a228b9e
dm: make the DAX support depend on CONFIG_FS_DAX
...
The device mapper DAX support is all hanging off a block device and thus
can't be used with device dax. Make it depend on CONFIG_FS_DAX instead
of CONFIG_DAX_DRIVER. This also means that bdev_dax_pgoff only needs to
be built under CONFIG_FS_DAX now.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Mike Snitzer <snitzer@redhat.com >
Link: https://lore.kernel.org/r/20211129102203.2243509-3-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-12-04 08:58:50 -08:00
Christoph Hellwig
e765f13ed1
nvdimm/pmem: move dax_attribute_group from dax to pmem
...
dax_attribute_group is only used by the pmem driver, and can avoid the
completely pointless lookup by the disk name if moved there. This
leaves just a single caller of dax_get_by_host, so move dax_get_by_host
into the same ifdef block as that caller.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210922173431.2454024-3-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-09-27 11:32:51 -07:00
Christoph Hellwig
bdd3c50d83
dax: remove bdev_dax_supported
...
All callers already have a dax_device obtained from fs_dax_get_by_bdev
at hand, so just pass that to dax_supported() insted of doing another
lookup.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210826135510.6293-10-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-08-26 16:52:03 -07:00
Christoph Hellwig
60b8340f0d
dax: stub out dax_supported for !CONFIG_FS_DAX
...
dax_supported calls into ->dax_supported which checks for fsdax support.
Don't bother building it for !CONFIG_FS_DAX as it will always return
false.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210826135510.6293-8-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-08-26 16:52:03 -07:00
Christoph Hellwig
cd93a2a4d1
dax: remove __generic_fsdax_supported
...
Just implement generic_fsdax_supported directly out of line instead of
adding a wrapper. Given that generic_fsdax_supported is only supplied
for CONFIG_FS_DAX builds this also allows to not provide it at all for
!CONFIG_FS_DAX builds.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210826135510.6293-7-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-08-26 16:52:03 -07:00
Christoph Hellwig
673a0658f6
dax: move the dax_read_lock() locking into dax_supported
...
Move the dax_read_lock/dax_read_unlock pair from the callers into
dax_supported to make it a little easier to use.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210826135510.6293-6-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-08-26 16:52:03 -07:00
Christoph Hellwig
1b7646014e
dax: mark dax_get_by_host static
...
And move the code around a bit to avoid a forward declaration.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210826135510.6293-5-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-08-26 16:52:03 -07:00
Christoph Hellwig
39b6389a7f
dax: stop using bdevname
...
Just use the %pg format specifier instead.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Link: https://lore.kernel.org/r/20210826135510.6293-3-hch@lst.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-08-26 16:52:02 -07:00
Ira Weiny
b05d4c576b
dax: Ensure errno is returned from dax_direct_access
...
If the caller specifies a negative nr_pages that is an invalid
parameter.
Return -EINVAL to ensure callers get an errno if they want to check it.
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Signed-off-by: Ira Weiny <ira.weiny@intel.com >
Link: https://lore.kernel.org/r/20210525172428.3634316-4-ira.weiny@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com >
2021-07-07 22:10:04 -07:00
Al Viro
6f24784f00
whack-a-mole: don't open-code iminor/imajor
...
several instances creeped back into the tree...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
2021-02-23 10:25:29 -05:00