From: Adrian Cox <adrian@humboldt.co.uk>
To: Andrew Morton <akpm@zip.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Filling holes in ext2
Date: Thu, 23 Aug 2001 20:17:10 +0100 [thread overview]
Message-ID: <3B8556B6.7040700@humboldt.co.uk> (raw)
In-Reply-To: <3B83E9FD.6020801@humboldt.co.uk> <3B83FB3F.A0BDC056@zip.com.au> <3B853BE6.3010703@humboldt.co.uk> <3B854186.F0C00E3C@zip.com.au>
Andrew Morton wrote:
> generic_file_write() will mark the page not up-to-date in this case.
> I wonder what's actually going on? Perhaps the fact that we've
> instantiated a block in ext2 outside i_size?
The problem is that the on-disk metadata now says that that disk block
is part of the file. So as the page is not up-to-date, the next read
operation will go to the disk and fetch that block of garbage into the
page cache.
> If you change the error path in -ac's generic_file_write() thusly:
>
> - goto fail_write;
> + status = -EFAULT;
> + goto sync_failure;
>
> does it fix it?
No difference, as the write is to a hole in the middle of the file, and
doesn't change i_size.
> Can you send the code you're using to demonstrate this?
The heart of it is this:
fd = open(file, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
lseek(fd, 16385, SEEK_SET);
write(fd, "x", 1);
lseek(fd, 12345, SEEK_SET);
write(fd, "y", 1);
During the final write, I intervene with gdb to force the
__copy_from_user() to fail. It should be possible to do something
similar with a multi-threaded application where another thread modifies
the VM, but I haven't actually built a real example.
Then I just take a look at the file with od.
[usermode:~] od -x /mnt/adrian/test
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0030000 0a79 0a79 0a79 0a79 0a79 0a79 0a79 0a79
*
0040000 7800
0040002
--
Adrian Cox http://www.humboldt.co.uk/
next prev parent reply other threads:[~2001-08-23 19:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-22 17:21 Filling holes in ext2 Adrian Cox
2001-08-22 18:34 ` Andrew Morton
2001-08-22 18:59 ` Adrian Cox
2001-08-23 17:22 ` Adrian Cox
2001-08-23 17:46 ` Andrew Morton
2001-08-23 19:17 ` Adrian Cox [this message]
2001-08-23 19:23 ` Alan Cox
2001-08-23 19:41 ` Andrew Morton
2001-08-23 21:21 ` Adrian Cox
2001-08-23 17:47 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B8556B6.7040700@humboldt.co.uk \
--to=adrian@humboldt.co.uk \
--cc=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.