From: Hugh Dickins <hugh@veritas.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: akpm@linux-foundation.org, mszeredi@suse.cz, pbadari@us.ibm.com,
linux-mm@kvack.org
Subject: Re: [PATCH 1/4] holepunch: fix shmem_truncate_range punching too far
Date: Thu, 29 Mar 2007 14:39:29 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0703291412240.24494@blonde.wat.veritas.com> (raw)
In-Reply-To: <E1HWtTi-00013Z-00@dorka.pomaz.szeredi.hu>
On Thu, 29 Mar 2007, Miklos Szeredi wrote:
>
> I think we should at least have a
>
> BUG_ON((end + 1) % PAGE_CACHE_SIZE);
>
> or something, to remind us about this wart.
truncate_inode_pages_range does indeed have
BUG_ON((lend & (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1));
but you're right that falls short of covering all the places we might
make such a mistake.
And in future I'd expect them to be extended to allow non-page-sized
holes, zeroing the partial areas at each end of the hole: whereupon
no such BUG_ON will be possible.
I'd much prefer to change the interface to vmtruncate_range,
truncate_inode_pages_range, shmem_truncate_range,
i_op->truncate_range, to take the expected end offset.
There are other interface changes needed to eradicate
(rather than paper over) the races we've mentioned in private mail.
shmem_truncate_range, and I believe any other implementation of an
i_op->truncate_range, needs to know when the holepunch is beginning
(if the prior unmap_mapping_range and truncate_inode_pages_range
aren't just to be a waste of time that has to be repeated).
Easiest is just to move those calls into each i_op->truncate_range.
But are we free to make such interface changes now?
Might third parties have observed MADV_REMOVE and ->truncate_range,
and be implementing them in their own filesystems?
And another change I'd like to suggest: at present holepunching
is using unmap_mapping_range(,,,1) which discards privately COWed
pages from vmas. It's certainly easier to implement unracily if
we change it only to unmap the shared file pages: and I argue that
it's more correct that way, that the madvise(,,MADV_REMOVE) caller
should not be discarding private data from others' address spaces.
That behaviour is mandated by standards for truncation, and probably
necessary for consistent SIGBUS-beyond-EOF behaviour: but I question
(a year late!) whether we should be extending it to holepunching.
Hugh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-03-29 13:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-28 14:50 Hugh Dickins
2007-03-28 14:51 ` [PATCH 2/4] holepunch: fix shmem_truncate_range punch locking Hugh Dickins
2007-03-29 11:32 ` Miklos Szeredi
2007-03-28 14:52 ` [PATCH 3/4] holepunch: fix disconnected pages after second truncate Hugh Dickins
2007-03-28 14:54 ` [PATCH 4/4] holepunch: fix mmap_sem i_mutex deadlock Hugh Dickins
2007-03-29 10:57 ` [PATCH 1/4] holepunch: fix shmem_truncate_range punching too far Miklos Szeredi
2007-03-29 11:56 ` Hugh Dickins
2007-03-29 12:11 ` Miklos Szeredi
2007-03-29 13:39 ` Hugh Dickins [this message]
2007-03-29 14:35 ` Miklos Szeredi
2007-03-29 22:48 ` Peter Chubb
2007-03-30 4:01 ` Hugh Dickins
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=Pine.LNX.4.64.0703291412240.24494@blonde.wat.veritas.com \
--to=hugh@veritas.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@suse.cz \
--cc=pbadari@us.ibm.com \
/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