Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <joseph.qi@huawei.com> back in January;
unfortunately, I'd missed his mail back then ;-/

Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 64b4e252 9ce5a232

+10 -4
+10 -4
fs/ocfs2/file.c
··· 2439 2439 /* buffered aio wouldn't have proper lock coverage today */ 2440 2440 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); 2441 2441 2442 + if (unlikely(written <= 0)) 2443 + goto no_sync; 2444 + 2442 2445 if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) || 2443 2446 ((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); 2446 2450 if (ret < 0) 2447 2451 written = ret; 2448 2452 ··· 2457 2453 } 2458 2454 2459 2455 if (!ret) 2460 - ret = filemap_fdatawait_range(file->f_mapping, *ppos, 2461 - *ppos + count - 1); 2456 + ret = filemap_fdatawait_range(file->f_mapping, 2457 + iocb->ki_pos - written, 2458 + iocb->ki_pos - 1); 2462 2459 } 2463 2460 2461 + no_sync: 2464 2462 /* 2465 2463 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io 2466 2464 * function pointer which is called when o_direct io completes so that