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

GFS2: Fix direct IO write rounding error

The fsx test in xfstests was failing because it was using direct IO
writes which were using a bad calculation. It was using
loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); when it should be
loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1);
Thus, the write at offset 0x67e00 was calculating lstart to be
0xe00, the address of our corruption. Instead, it should have been
0x67000. This patch fixes the calculation.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Acked-by: Steven Whitehouse <swhiteho@redhat.com>

+1 -1
+1 -1
fs/gfs2/aops.c
··· 1082 1082 * the first place, mapping->nr_pages will always be zero. 1083 1083 */ 1084 1084 if (mapping->nrpages) { 1085 - loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); 1085 + loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1); 1086 1086 loff_t len = iov_iter_count(iter); 1087 1087 loff_t end = PAGE_ALIGN(offset + len) - 1; 1088 1088