Message ID | 1478034381-19037-3-git-send-email-jack@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Nov 01, 2016 at 10:06:12PM +0100, Jan Kara wrote: > Currently we don't allow unaligned writes without inode_lock. This is > because zeroing of partial blocks could cause data corruption for racing > unaligned writes to the same block. However DAX handles zeroing during > block allocation and thus zeroing of partial blocks cannot race. Allow > DAX unaligned IO to run without inode_lock. DAX writes should always take the inode lock. Without that you break the expectations of existing applications that did not specify O_DIRECT. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed 02-11-16 07:27:46, Christoph Hellwig wrote: > On Tue, Nov 01, 2016 at 10:06:12PM +0100, Jan Kara wrote: > > Currently we don't allow unaligned writes without inode_lock. This is > > because zeroing of partial blocks could cause data corruption for racing > > unaligned writes to the same block. However DAX handles zeroing during > > block allocation and thus zeroing of partial blocks cannot race. Allow > > DAX unaligned IO to run without inode_lock. > > DAX writes should always take the inode lock. Without that you break > the expectations of existing applications that did not specify O_DIRECT. Yeah, actually this patch has no practical effect since later iomap conversion just effectively reverts this patch and I didn't realize it. I'll just drop it. Thanks. Honza
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index a6a7becb9465..55f8b922b76d 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -161,7 +161,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) iocb->private = &overwrite; /* Check whether we do a DIO overwrite or not */ - if (o_direct && ext4_should_dioread_nolock(inode) && !unaligned_aio && + if (((o_direct && !unaligned_aio) || IS_DAX(inode)) && + ext4_should_dioread_nolock(inode) && ext4_overwrite_io(inode, iocb->ki_pos, iov_iter_count(from))) overwrite = 1;
Currently we don't allow unaligned writes without inode_lock. This is because zeroing of partial blocks could cause data corruption for racing unaligned writes to the same block. However DAX handles zeroing during block allocation and thus zeroing of partial blocks cannot race. Allow DAX unaligned IO to run without inode_lock. Signed-off-by: Jan Kara <jack@suse.cz> --- fs/ext4/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)