Re: 2.6.19-rc2-mm2 : empty files on vfat file system

OGAWA Hirofumi
2006-10-21T13:25:10Z

Damien Wyart <damien.wyart@free.fr> writes:

> I have noticed something strange (and bad :) since using 2.6.19-rc2-mm2
> (the problem is NOT present on 2.6.19-rc2-mm1 ; do not know for
> mainline, I have not been able to test yet, but I think there have not
> been recent changes in this area) : writing a file to a vfat
> fs (fat 32) writes it, but with size 0 and no content. All this is
> silent : no error message, nothing in the logs. After several attempts,
> I checked the fs with fsck.vfat and it reported errors about some of the
> files and told it was truncating them to size 0 (but their displayed
> size was already 0, btw).

diff -puN fs/fat/inode.c~fs-prepare_write-fixes fs/fat/inode.c
--- a/fs/fat/inode.c~fs-prepare_write-fixes
+++ a/fs/fat/inode.c
@@ -150,7 +150,11 @@ static int fat_commit_write(struct file
unsigned from, unsigned to)
{
struct inode *inode = page->mapping->host;
- int err = generic_commit_write(file, page, from, to);
+ int err;
+ if (to - from > 0)
+ return 0;
+
+ err = generic_commit_write(file, page, from, to);
if (!err && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) {
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
MSDOS_I(inode)->i_attrs |= ATTR_ARCH;

This change does't update ->i_size. Could you just delete, and test it?
Anyway, this seems wrong even if it's "if ((to - from) == 0)". The zero
range is valid for cont_prepare_write()...
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>