Skip to content

Commit 64b4e25

Browse files
author
Al Viro
committed
ocfs2: _really_ sync the right range
"ocfs2 syncs the wrong range" had been broken; prior to it the code was doing the wrong thing in case of O_APPEND, all right, but _after_ it we were syncing the wrong range in 100% cases. *ppos, aka iocb->ki_pos is incremented prior to that point, so we are always doing sync on the area _after_ the one we'd written to. Spotted by Joseph Qi <[email protected]> back in January; unfortunately, I'd missed his mail back then ;-/ Cc: [email protected] Signed-off-by: Al Viro <[email protected]>
1 parent 9ce5a23 commit 64b4e25

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fs/ocfs2/file.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,10 +2439,14 @@ static ssize_t ocfs2_file_write_iter(struct kiocb *iocb,
24392439
/* buffered aio wouldn't have proper lock coverage today */
24402440
BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));
24412441

2442+
if (unlikely(written <= 0))
2443+
goto no_sync;
2444+
24422445
if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) ||
24432446
((file->f_flags & O_DIRECT) && !direct_io)) {
2444-
ret = filemap_fdatawrite_range(file->f_mapping, *ppos,
2445-
*ppos + count - 1);
2447+
ret = filemap_fdatawrite_range(file->f_mapping,
2448+
iocb->ki_pos - written,
2449+
iocb->ki_pos - 1);
24462450
if (ret < 0)
24472451
written = ret;
24482452

@@ -2453,10 +2457,12 @@ static ssize_t ocfs2_file_write_iter(struct kiocb *iocb,
24532457
}
24542458

24552459
if (!ret)
2456-
ret = filemap_fdatawait_range(file->f_mapping, *ppos,
2457-
*ppos + count - 1);
2460+
ret = filemap_fdatawait_range(file->f_mapping,
2461+
iocb->ki_pos - written,
2462+
iocb->ki_pos - 1);
24582463
}
24592464

2465+
no_sync:
24602466
/*
24612467
* deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
24622468
* function pointer which is called when o_direct io completes so that

0 commit comments

Comments
 (0)