Li Dongyang
2010-Apr-15 13:01 UTC
[Ocfs2-devel] [PATCH] ocfs2: avoid direct write if we fall back to buffered v2
when we fall back to buffered write from direct write, we call
__generic_file_aio_write but that will end up doing direct write
even we are only prepared to do buffered write because the file
has O_DIRECT flag set. This is a fix for
https://bugzilla.novell.com/show_bug.cgi?id=591039
revised with Joel's comments.
---
fs/ocfs2/file.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index de059f4..0240de7 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1973,18 +1973,18 @@ relock:
/* communicate with ocfs2_dio_end_io */
ocfs2_iocb_set_rw_locked(iocb, rw_level);
- if (direct_io) {
- ret = generic_segment_checks(iov, &nr_segs, &ocount,
- VERIFY_READ);
- if (ret)
- goto out_dio;
+ ret = generic_segment_checks(iov, &nr_segs, &ocount,
+ VERIFY_READ);
+ if (ret)
+ goto out_dio;
- count = ocount;
- ret = generic_write_checks(file, ppos, &count,
- S_ISBLK(inode->i_mode));
- if (ret)
- goto out_dio;
+ count = ocount;
+ ret = generic_write_checks(file, ppos, &count,
+ S_ISBLK(inode->i_mode));
+ if (ret)
+ goto out_dio;
+ if (direct_io) {
written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
ppos, count, ocount);
if (written < 0) {
@@ -1999,7 +1999,8 @@ relock:
goto out_dio;
}
} else {
- written = __generic_file_aio_write(iocb, iov, nr_segs, ppos);
+ written = generic_file_buffered_write(iocb, iov, nr_segs, *ppos,
+ ppos, count, 0);
}
out_dio:
--
1.6.4.2
Joel Becker
2010-Apr-16 10:07 UTC
[Ocfs2-devel] [PATCH] ocfs2: avoid direct write if we fall back to buffered v2
On Thu, Apr 15, 2010 at 09:01:56PM +0800, Li Dongyang wrote:> - if (direct_io) { > - ret = generic_segment_checks(iov, &nr_segs, &ocount, > - VERIFY_READ); > - if (ret) > - goto out_dio; > + ret = generic_segment_checks(iov, &nr_segs, &ocount, > + VERIFY_READ); > + if (ret) > + goto out_dio; > > - count = ocount; > - ret = generic_write_checks(file, ppos, &count, > - S_ISBLK(inode->i_mode)); > - if (ret) > - goto out_dio; > + count = ocount; > + ret = generic_write_checks(file, ppos, &count, > + S_ISBLK(inode->i_mode)); > + if (ret) > + goto out_dio;Make sure you add the management of current->backing_dev_info just like __generic_file_aio_write() does. We want to ensure that page writeback works OK. Joel -- "If the human brain were so simple we could understand it, we would be so simple that we could not." - W. A. Clouston Joel Becker Principal Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127
Maybe Matching Threads
- [PATCH V8 21/33] ocfs2: add support for read_iter and write_iter
- [PATCH V5 19/30] ocfs2: add support for read_iter, write_iter, and direct_IO_bvec
- Initialize count in aio_write before generic_write_checks
- [PATCH 1/5] fs: allow short direct-io reads to be completed via buffered IO V2
- Bug#603727: xen-hypervisor-4.0-amd64: i386 Dom0 crashes after doing some I/O on local storage (software Raid1 on SAS-drives with mpt2sas driver)