From: Andrew Morton <akpm@digeo.com>
To: Dave McCracken <dmccr@us.ibm.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix vmtruncate race and distributed filesystem race
Date: Thu, 12 Jun 2003 13:49:46 -0700 [thread overview]
Message-ID: <20030612134946.450e0f77.akpm@digeo.com> (raw)
In-Reply-To: <133430000.1055448961@baldur.austin.ibm.com>
Dave McCracken <dmccr@us.ibm.com> wrote:
>
>
> Paul McKenney and I sat down today and hashed out just what the races are
> for both vmtruncate and the distributed filesystems. We took Andrea's
> idea of using seqlocks and came up with a simple solution that definitely
> fixes the race in vmtruncate, as well as most likely the invalidate race in
> distributed filesystems. Paul is going to discuss it with the DFS folks to
> verify that it's a complete fix for them, but neither of us can see a hole.
>
> + seqlock_init(&(mtd_rawdevice->as.truncate_lock));
Why cannot this just be an atomic_t?
> + /* Protect against page fault */
> + write_seqlock(&mapping->truncate_lock);
> + write_sequnlock(&mapping->truncate_lock);
See, this just does foo++.
> + /*
> + * If someone invalidated the page, serialize against the inode,
> + * then go try again.
> + */
This comment is inaccurate. "If this vma is file-backed and someone has
truncated that file, this page may have been invalidated".
> + if (unlikely(read_seqretry(&mapping->truncate_lock, sequence))) {
> + spin_unlock(&mm->page_table_lock);
> + down(&inode->i_sem);
> + up(&inode->i_sem);
> + goto retry;
> + }
> +
mm/memory.c shouldn't know about inodes (ok, vmtruncate() should be in
filemap.c).
How about you do this:
do_no_page()
{
int sequence = 0;
...
retry:
new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, &sequence);
....
if (vma->vm_ops->revalidate && vma->vm_opa->revalidate(vma, sequence))
goto retry;
}
filemap_nopage(..., int *sequence)
{
...
*sequence = atomic_read(&mapping->truncate_sequence);
...
}
int filemap_revalidate(vma, sequence)
{
struct address_space *mapping;
mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
return sequence - atomic_read(&mapping->truncate_sequence);
}
--
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:"aart@kvack.org"> aart@kvack.org </a>
next prev parent reply other threads:[~2003-06-12 20:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-12 20:16 Dave McCracken
2003-06-12 20:49 ` Andrew Morton [this message]
2003-06-12 21:00 ` Andrew Morton
2003-06-12 21:08 ` Dave McCracken
2003-06-12 21:44 ` Andrew Morton
2003-06-12 22:56 ` Dave McCracken
2003-06-12 23:07 ` Andrew Morton
2003-06-20 0:17 ` Andrea Arcangeli
2003-06-23 3:28 ` Paul E. McKenney
2003-06-23 6:29 ` Andrea Arcangeli
2003-06-23 6:32 ` Andrew Morton
2003-06-23 7:43 ` Andrea Arcangeli
2003-06-23 7:56 ` Andrew Morton
2003-06-23 8:10 ` Andrea Arcangeli
2003-06-24 1:37 ` Paul E. McKenney
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=20030612134946.450e0f77.akpm@digeo.com \
--to=akpm@digeo.com \
--cc=dmccr@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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