diff options
-rw-r--r-- | fs/ocfs2/file.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index a39067f4dd55..ba1790e52ff2 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2439,10 +2439,14 @@ out_dio: | |||
2439 | /* buffered aio wouldn't have proper lock coverage today */ | 2439 | /* buffered aio wouldn't have proper lock coverage today */ |
2440 | BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); | 2440 | BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); |
2441 | 2441 | ||
2442 | if (unlikely(written <= 0)) | ||
2443 | goto no_sync; | ||
2444 | |||
2442 | if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) || | 2445 | if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) || |
2443 | ((file->f_flags & O_DIRECT) && !direct_io)) { | 2446 | ((file->f_flags & O_DIRECT) && !direct_io)) { |
2444 | ret = filemap_fdatawrite_range(file->f_mapping, *ppos, | 2447 | ret = filemap_fdatawrite_range(file->f_mapping, |
2445 | *ppos + count - 1); | 2448 | iocb->ki_pos - written, |
2449 | iocb->ki_pos - 1); | ||
2446 | if (ret < 0) | 2450 | if (ret < 0) |
2447 | written = ret; | 2451 | written = ret; |
2448 | 2452 | ||
@@ -2453,10 +2457,12 @@ out_dio: | |||
2453 | } | 2457 | } |
2454 | 2458 | ||
2455 | if (!ret) | 2459 | if (!ret) |
2456 | ret = filemap_fdatawait_range(file->f_mapping, *ppos, | 2460 | ret = filemap_fdatawait_range(file->f_mapping, |
2457 | *ppos + count - 1); | 2461 | iocb->ki_pos - written, |
2462 | iocb->ki_pos - 1); | ||
2458 | } | 2463 | } |
2459 | 2464 | ||
2465 | no_sync: | ||
2460 | /* | 2466 | /* |
2461 | * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io | 2467 | * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io |
2462 | * function pointer which is called when o_direct io completes so that | 2468 | * function pointer which is called when o_direct io completes so that |