diff mbox

[2/2] dax: assert that i_rwsem is held exclusive for writes

Message ID 1484063288-18255-3-git-send-email-hch@lst.de
State Accepted, archived
Headers show

Commit Message

Christoph Hellwig Jan. 10, 2017, 3:48 p.m. UTC
Make sure all callers follow the same locking protocol, given that DAX
transparantly replaced the normal buffered I/O path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/dax.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jan Kara Jan. 11, 2017, 9:02 a.m. UTC | #1
On Tue 10-01-17 16:48:08, Christoph Hellwig wrote:
> Make sure all callers follow the same locking protocol, given that DAX
> transparantly replaced the normal buffered I/O path.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

Probably also for Ted since it depends on the ext4 fix...

								Honza
> ---
>  fs/dax.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index 5c74f60..04734da 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -1061,8 +1061,12 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
>  	loff_t pos = iocb->ki_pos, ret = 0, done = 0;
>  	unsigned flags = 0;
>  
> -	if (iov_iter_rw(iter) == WRITE)
> +	if (iov_iter_rw(iter) == WRITE) {
> +		lockdep_assert_held_exclusive(&inode->i_rwsem);
>  		flags |= IOMAP_WRITE;
> +	} else {
> +		lockdep_assert_held(&inode->i_rwsem);
> +	}
>  
>  	while (iov_iter_count(iter)) {
>  		ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
> -- 
> 2.1.4
>
Theodore Ts'o Feb. 8, 2017, 7:43 p.m. UTC | #2
On Wed, Jan 11, 2017 at 10:02:50AM +0100, Jan Kara wrote:
> On Tue 10-01-17 16:48:08, Christoph Hellwig wrote:
> > Make sure all callers follow the same locking protocol, given that DAX
> > transparantly replaced the normal buffered I/O path.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Looks good. You can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> Probably also for Ted since it depends on the ext4 fix...

Thanks, applied to the ext4 tree.

					- Ted
diff mbox

Patch

diff --git a/fs/dax.c b/fs/dax.c
index 5c74f60..04734da 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1061,8 +1061,12 @@  dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
 	loff_t pos = iocb->ki_pos, ret = 0, done = 0;
 	unsigned flags = 0;
 
-	if (iov_iter_rw(iter) == WRITE)
+	if (iov_iter_rw(iter) == WRITE) {
+		lockdep_assert_held_exclusive(&inode->i_rwsem);
 		flags |= IOMAP_WRITE;
+	} else {
+		lockdep_assert_held(&inode->i_rwsem);
+	}
 
 	while (iov_iter_count(iter)) {
 		ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,