From: Andrew Morton <akpm@osdl.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: cpw@sgi.com, linux-kernel@vger.kernel.org, clameter@sgi.com,
lhms-devel@lists.sourceforge.net, taka@valinux.co.jp,
kamezawa.hiroyu@jp.fujitsu.com
Subject: Re: [PATCH 5/5] Direct Migration V9: Avoid writeback / page_migrate() method
Date: Tue, 10 Jan 2006 22:25:27 -0800 [thread overview]
Message-ID: <20060110222527.1cfdf70b.akpm@osdl.org> (raw)
In-Reply-To: <20060110224140.19138.84122.sendpatchset@schroedinger.engr.sgi.com>
Christoph Lameter <clameter@sgi.com> wrote:
>
> +int buffer_migrate_page(struct page *newpage, struct page *page)
> +{
> + struct address_space *mapping = page->mapping;
> + struct buffer_head *bh, *head;
> +
> + if (!mapping)
> + return -EAGAIN;
> +
> + if (!page_has_buffers(page))
> + return migrate_page(newpage, page);
> +
> + head = page_buffers(page);
> +
> + if (migrate_page_remove_references(newpage, page, 3))
> + return -EAGAIN;
> +
> + spin_lock(&mapping->private_lock);
Why are you taking ->private_lock here?
address_space.private_lock protects the list of buffers at
address_space.private_list. For a regular file (or directory or long
symlink..) that list contains buffers against the blockdev mapping (a
different address_space) which need to be synced for a successful fsync of
this file. ie: dirty metadata for this file.
So we have two situations:
a) page->mapping->host refers to a regular file/dir/etc
Here, mapping->private_list holds potentially-dirty buffers against
the blockdev mapping (a different address_space).
Nothing needs to be done.
b) page->mapping->host refers to a blockdev (/dev/hda1's pages)
Here, mapping->private_list is actually always empty.
Nothing needs to be done.
BUT, page_buffers(page) refers to buffers which might be on some
other address_space's ->private_list. Because a blockdev may have dirty
buffers which some other address_space needs to write out for its sync.
blockdevmapping->private_lock is the correct lock for these buffers.
Each regular file has a copy of blockdevmapping in its ->assoc_mapping,
so all files end up taking the same lock when manipulating their
->private_list.
As long as you've taken a ref on the blockdev mapping's buffers and
locked them then nobody will be starting I/O against them or fiddling
with ->b_page while you do the swizzle (I think).
AFAIK nobody ever used address_space.private_list for anything apart from
the associated buffers, but that's just a btw.
Anyway, ->private_lock is purely for protecting the thing at
->private_list, so I suspect this locking is simply unneeded.
Please explain the reasoning behind taking this lock. In fact, that should
have been commented, in the spirit of buffer.c's glorious overcommenting,
which I'm sure you enjoyed ;)
next prev parent reply other threads:[~2006-01-11 6:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-10 22:41 [PATCH 0/5] Direct Migration V9: Overview Christoph Lameter
2006-01-10 22:41 ` [PATCH 1/5] Direct Migration V9: PageSwapCache checks Christoph Lameter
2006-01-10 22:41 ` [PATCH 2/5] Direct Migration V9: migrate_pages() extension Christoph Lameter
2006-01-11 5:46 ` Andrew Morton
2006-01-12 3:25 ` Christoph Lameter
2006-01-10 22:41 ` [PATCH 3/5] Direct Migration V9: remove_from_swap() to remove swap ptes Christoph Lameter
2006-01-10 22:41 ` [PATCH 4/5] Direct Migration V9: upgrade MPOL_MF_MOVE and sys_migrate_pages() Christoph Lameter
2006-01-10 22:41 ` [PATCH 5/5] Direct Migration V9: Avoid writeback / page_migrate() method Christoph Lameter
2006-01-11 6:03 ` Andrew Morton
2006-01-11 6:38 ` Christoph Lameter
2006-01-11 6:49 ` Andrew Morton
2006-01-11 6:52 ` Christoph Lameter
2006-01-11 6:25 ` Andrew Morton [this message]
2006-01-11 3:26 ` [PATCH 0/5] Direct Migration V9: Overview KAMEZAWA Hiroyuki
2006-01-11 6:10 ` Christoph Lameter
2006-01-11 6:18 ` Christoph Lameter
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=20060110222527.1cfdf70b.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=clameter@sgi.com \
--cc=cpw@sgi.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=lhms-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=taka@valinux.co.jp \
/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
Powered by JetHome