]> www.infradead.org Git - users/hch/misc.git/commitdiff
dax: skip read lock assertion for read-only filesystems
authorYuezhang Mo <Yuezhang.Mo@sony.com>
Tue, 30 Sep 2025 05:42:57 +0000 (13:42 +0800)
committerChristian Brauner <brauner@kernel.org>
Tue, 7 Oct 2025 10:48:33 +0000 (12:48 +0200)
The commit 168316db3583("dax: assert that i_rwsem is held
exclusive for writes") added lock assertions to ensure proper
locking in DAX operations. However, these assertions trigger
false-positive lockdep warnings since read lock is unnecessary
on read-only filesystems(e.g., erofs).

This patch skips the read lock assertion for read-only filesystems,
eliminating the spurious warnings while maintaining the integrity
checks for writable filesystems.

Fixes: 168316db3583 ("dax: assert that i_rwsem is held exclusive for writes")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Friendy Su <friendy.su@sony.com>
Reviewed-by: Daniel Palmer <daniel.palmer@sony.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/dax.c

index 89f071ba7b1020aad51e6402ab60787c0963e205..516f995a988c8f660d85227ddc72b9de843d98b6 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1725,7 +1725,7 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
        if (iov_iter_rw(iter) == WRITE) {
                lockdep_assert_held_write(&iomi.inode->i_rwsem);
                iomi.flags |= IOMAP_WRITE;
-       } else {
+       } else if (!sb_rdonly(iomi.inode->i_sb)) {
                lockdep_assert_held(&iomi.inode->i_rwsem);
        }