mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1 linux-next] fs/affs/file.c: fix direct IO writes beyond EOF
@ 2015-01-09 21:19 Fabian Frederick
  2015-01-12 10:14 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2015-01-09 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Fabian Frederick, Jan Kara, Andrew Morton

Use the same fallback to normal IO in case of write
operations beyond EOF as fat direct IO. This patch fixes

fsx file -d -Z -r 4096 -w 4096

Report:
129(129 mod 256): TRUNCATE DOWN from 0x3ff01 to 0xb3f6
130(130 mod 256): WRITE    0x22000 thru 0x2dfff (0xc000 bytes) HOLE

Thanks to Jan for helping me on this problem.

Cc: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
Ideal solution suggested by Jan Kara would be to use cont_write_begin but
 affs direct_IO shouldn't be used a lot anyway...

 fs/affs/file.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index 7e83ba2..d2468bf 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -398,6 +398,13 @@ affs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
 	size_t count = iov_iter_count(iter);
 	ssize_t ret;
 
+	if (rw == WRITE) {
+		loff_t size = offset + count;
+
+		if (AFFS_I(inode)->mmu_private < size)
+			return 0;
+	}
+
 	ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, affs_get_block);
 	if (ret < 0 && (rw & WRITE))
 		affs_write_failed(mapping, offset + count);
-- 
2.1.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-12 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 21:19 [PATCH 1/1 linux-next] fs/affs/file.c: fix direct IO writes beyond EOF Fabian Frederick
2015-01-12 10:14 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome