add tytso's DCO
[ext4-patch-queue.git] / dax-assert-that-i_rw_sem-is-held-exclusive-for-writes
blobc02fe4853f9b01f95bd0ffaff54e494d892c7aec
1 dax: assert that i_rwsem is held exclusive for writes
3 From: Christoph Hellwig <hch@lst.de>
5 Make sure all callers follow the same locking protocol, given that DAX
6 transparantly replaced the normal buffered I/O path.
8 Signed-off-by: Christoph Hellwig <hch@lst.de>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 Reviewed-by: Jan Kara <jack@suse.cz>
11 ---
12  fs/dax.c | 6 +++++-
13  1 file changed, 5 insertions(+), 1 deletion(-)
15 diff --git a/fs/dax.c b/fs/dax.c
16 index 5c74f60d0a50..04734daed1bd 100644
17 --- a/fs/dax.c
18 +++ b/fs/dax.c
19 @@ -1061,8 +1061,12 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
20         loff_t pos = iocb->ki_pos, ret = 0, done = 0;
21         unsigned flags = 0;
23 -       if (iov_iter_rw(iter) == WRITE)
24 +       if (iov_iter_rw(iter) == WRITE) {
25 +               lockdep_assert_held_exclusive(&inode->i_rwsem);
26                 flags |= IOMAP_WRITE;
27 +       } else {
28 +               lockdep_assert_held(&inode->i_rwsem);
29 +       }
31         while (iov_iter_count(iter)) {
32                 ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,