diff mbox

[1/2] ext4: fix DAX write locking

Message ID 1484063288-18255-2-git-send-email-hch@lst.de (mailing list archive)
State New, archived
Headers show

Commit Message

Christoph Hellwig Jan. 10, 2017, 3:48 p.m. UTC
Unlike O_DIRECT DAX is not an optional opt-in feature selected by the
application, so we'll have to provide the traditional synchronіzation
of overlapping writes as we do for buffered writes.

This was broken historically for DAX, but got fixed for ext2 and XFS
as part of the iomap conversion.  Fix up ext4 as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/ext4/file.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

Comments

Jan Kara Jan. 11, 2017, 9:01 a.m. UTC | #1
On Tue 10-01-17 16:48:07, Christoph Hellwig wrote:
> Unlike O_DIRECT DAX is not an optional opt-in feature selected by the
> application, so we'll have to provide the traditional synchronіzation
> of overlapping writes as we do for buffered writes.
> 
> This was broken historically for DAX, but got fixed for ext2 and XFS
> as part of the iomap conversion.  Fix up ext4 as well.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Makes sense. You can add:

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

Ted, can you please pick it up? Thanks!

								Honza

> ---
>  fs/ext4/file.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index d663d3d..a1e88aa 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -175,7 +175,6 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  {
>  	struct inode *inode = file_inode(iocb->ki_filp);
>  	ssize_t ret;
> -	bool overwrite = false;
>  
>  	inode_lock(inode);
>  	ret = ext4_write_checks(iocb, from);
> @@ -188,16 +187,9 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  	if (ret)
>  		goto out;
>  
> -	if (ext4_overwrite_io(inode, iocb->ki_pos, iov_iter_count(from))) {
> -		overwrite = true;
> -		downgrade_write(&inode->i_rwsem);
> -	}
>  	ret = dax_iomap_rw(iocb, from, &ext4_iomap_ops);
>  out:
> -	if (!overwrite)
> -		inode_unlock(inode);
> -	else
> -		inode_unlock_shared(inode);
> +	inode_unlock(inode);
>  	if (ret > 0)
>  		ret = generic_write_sync(iocb, ret);
>  	return ret;
> -- 
> 2.1.4
>
Christoph Hellwig Feb. 8, 2017, 5:14 p.m. UTC | #2
On Wed, Jan 11, 2017 at 10:01:36AM +0100, Jan Kara wrote:
> On Tue 10-01-17 16:48:07, Christoph Hellwig wrote:
> > Unlike O_DIRECT DAX is not an optional opt-in feature selected by the
> > application, so we'll have to provide the traditional synchronіzation
> > of overlapping writes as we do for buffered writes.
> > 
> > This was broken historically for DAX, but got fixed for ext2 and XFS
> > as part of the iomap conversion.  Fix up ext4 as well.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Makes sense. You can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> Ted, can you please pick it up? Thanks!

Did this get picked up?
Theodore Ts'o Feb. 8, 2017, 7:38 p.m. UTC | #3
On Wed, Feb 08, 2017 at 09:14:10AM -0800, Christoph Hellwig wrote:
> On Wed, Jan 11, 2017 at 10:01:36AM +0100, Jan Kara wrote:
> > On Tue 10-01-17 16:48:07, Christoph Hellwig wrote:
> > > Unlike O_DIRECT DAX is not an optional opt-in feature selected by the
> > > application, so we'll have to provide the traditional synchronіzation
> > > of overlapping writes as we do for buffered writes.
> > > 
> > > This was broken historically for DAX, but got fixed for ext2 and XFS
> > > as part of the iomap conversion.  Fix up ext4 as well.
> > > 
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > 
> > Makes sense. You can add:
> > 
> > Reviewed-by: Jan Kara <jack@suse.cz>
> > 
> > Ted, can you please pick it up? Thanks!
> 
> Did this get picked up?

Sorry, I missed Jan's request to pick it up.  I had assumed it would
be going in via the dax tree.  I'll take a look at it now for the ext4
tree.

					- Ted
Theodore Ts'o Feb. 8, 2017, 7:41 p.m. UTC | #4
On Wed, Jan 11, 2017 at 10:01:36AM +0100, Jan Kara wrote:
> On Tue 10-01-17 16:48:07, Christoph Hellwig wrote:
> > Unlike O_DIRECT DAX is not an optional opt-in feature selected by the
> > application, so we'll have to provide the traditional synchronіzation
> > of overlapping writes as we do for buffered writes.
> > 
> > This was broken historically for DAX, but got fixed for ext2 and XFS
> > as part of the iomap conversion.  Fix up ext4 as well.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Makes sense. You can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> Ted, can you please pick it up? Thanks!

Thanks, applied to the ext4 tree.

					- Ted
diff mbox

Patch

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index d663d3d..a1e88aa 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -175,7 +175,6 @@  ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct inode *inode = file_inode(iocb->ki_filp);
 	ssize_t ret;
-	bool overwrite = false;
 
 	inode_lock(inode);
 	ret = ext4_write_checks(iocb, from);
@@ -188,16 +187,9 @@  ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	if (ret)
 		goto out;
 
-	if (ext4_overwrite_io(inode, iocb->ki_pos, iov_iter_count(from))) {
-		overwrite = true;
-		downgrade_write(&inode->i_rwsem);
-	}
 	ret = dax_iomap_rw(iocb, from, &ext4_iomap_ops);
 out:
-	if (!overwrite)
-		inode_unlock(inode);
-	else
-		inode_unlock_shared(inode);
+	inode_unlock(inode);
 	if (ret > 0)
 		ret = generic_write_sync(iocb, ret);
 	return ret;