ocfs2: Use buffer IO if we are appending a file.
PATCH 1/1 ocfs2: Use buffer IO if we are appending a file.
In ocfs2_file_aio_write, we will prevent direct io if we find that we are appending(changing i_size) and call generic_file_aio_write_nolock. But actually O_DIRECT flag is there and this function will call generic_file_direct_write eventually which will update i_size and leave di->i_size alone. The bug is that
http://oss.oracle.com/bugzilla/show_bug.cgi?id=1173.
So this patch let ocfs2_direct_IO returns 0 directly if we are appending so that buffered write will be called and di->i_size get updated successfully. And this is also what we want in ocfs2_file_aio_write.
--- fs/ocfs2/aops.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
fs/ocfs2/aops.c +4 -0
@@ -690,6 +690,10 @@ static ssize_t ocfs2_direct_IO(int rw,if (OCFS2_I (inode)->ip_dyn_features &OCFS2_INLINE_DATA_FL )return 0 ; +/* Fallback to buffered I/O if we are appending. */ +if (i_size_read (inode) <= offset) +return 0 ; + ret = blockdev_direct_IO_no_locking(rw, iocb, inode, inode->i_sb->s_bdev, iov, offset, nr_segs,
Signature · 1 line
1.5.5
PATCH 1/1 ocfs2: Use buffer IO if we are appending a file.
Quoted 34 lines · Tao Ma
In
ocfs2_file_aio_write, we will prevent direct io if we find that we areappending(changing i_size)and callgeneric_file_aio_write_nolock. But actuallyO_DIRECTflag is there and this function will callgeneric_file_direct_writeeventually which will updatei_sizeand leavedi->i_sizealone. The bug is that
http://oss.oracle.com/bugzilla/show_bug.cgi?id=1173.So this patch let
ocfs2_direct_IOreturns 0 directly if we are appending so that buffered write will be called anddi->i_sizeget updated successfully. And this is also what we want inocfs2_file_aio_write.Signed-off-by Tao Ma <[email protected]>--- fs/ocfs2/aops.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)fs/ocfs2/aops.c +4
-0@@ -690,6 +690,10 @@ static ssize_t ocfs2_direct_IO(int rw,if (OCFS2_I (inode)->ip_dyn_features &OCFS2_INLINE_DATA_FL )return 0 ; +/* Fallback to buffered I/O if we are appending. */ +if (i_size_read (inode) <= offset) +return 0 ; + ret = blockdev_direct_IO_no_locking(rw, iocb, inode, inode->i_sb->s_bdev, iov, offset, nr_segs,