From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Jan Koss <kossjan@gmail.com>
Cc: arjan@infradead.org, kernelnewbies@nl.linux.org,
linux-fsdevel@vger.kernel.org
Subject: Re: truncate implementation
Date: Tue, 17 Jan 2006 09:39:06 +0000 [thread overview]
Message-ID: <1137490746.1794.7.camel@imp.csi.cam.ac.uk> (raw)
In-Reply-To: <b97d23040601170121o352bed78i9a6a84df830e6e6a@mail.gmail.com>
On Tue, 2006-01-17 at 12:21 +0300, Jan Koss wrote:
> Thanks for reply.
>
> > .. which isn't in the pagetable, and then the kernel notices it's
> > outside the file and causes a SIGBUS.
>
> But if length of file after truncate is 4 byte, for example,
> and I do p[5]=.., this didn't cause any error, so I can append some garbage
> after end of file, and this is not error?
No you can't. You only think you can. The dirty page is written using
->writepage of the file system which will "memset()" everything between
the end of file if it is in the page and the end of the page to zero
thus your write of p[5]=... will disappear every time the page is
written.
> > .. and removes the page from the pagetable.
> I'm sorry for stupid question, but where we remove from pagetable,
> I see two places in ext2_truncate:
It is not done in the file system. It is done by the core kernel before
the file system ->truncate is called. The function you want is
linux/mm/memory.c::vmtruncate(). The relevant lines are:
i_size_write(inode, offset);
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
truncate_inode_pages(mapping, offset);
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
prev parent reply other threads:[~2006-01-17 9:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-17 8:18 truncate implementation Jan Koss
2006-01-17 8:31 ` Arjan van de Ven
2006-01-17 9:21 ` Jan Koss
2006-01-17 9:38 ` Arjan van de Ven
2006-01-17 9:39 ` Anton Altaparmakov [this message]
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=1137490746.1794.7.camel@imp.csi.cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=arjan@infradead.org \
--cc=kernelnewbies@nl.linux.org \
--cc=kossjan@gmail.com \
--cc=linux-fsdevel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).