From: "Perez-Gonzalez, Inaky" <inaky.perez-gonzalez@intel.com>
To: linux-mm@kvack.org
Subject: Protection of 'struct address_space'?
Date: Tue, 27 Jul 2004 19:30:57 -0700 [thread overview]
Message-ID: <F989B1573A3A644BAB3920FBECA4D25A6EBFE6@orsmsx407> (raw)
Hi All
Some days ago I came around with a question on how to get
a 'struct page *' backed up by a 'struct inode *' and an offset.
Came up with:
01 int __vl_key_page_get_shared (struct page **ppage,
02 struct inode *inode, unsigned pgoff)
03 {
04 int result;
05 struct page *page;
06 struct address_space *mapping = inode->i_mapping;
07
08 #warning: FIXME: block/lock the mapping...I am not that sure of this
09 down (&mapping->i_shared_sem);
10 page = read_cache_page (mapping, pgoff,
11 (filler_t *) mapping->a_ops->readpage, NULL);
12 result = PTR_ERR (page);
13 if (IS_ERR (page))
14 goto out_up;
15
16 wait_on_page_locked (page);
17 if (!PageUptodate (page)) {
18 page_cache_release (page);
19 page = ERR_PTR (-EIO);
20 }
21 *ppage = page;
22 return 0;
23
24 out_up:
25 up (&mapping->i_shared_sem);
26 return result;
27 }
[this followed a put() kind of function that would release
the page and the i_shared_sem semaphore].
Now in 2.6.7, i_shared_sem is gone and replaced by a i_mmap_lock,
what makes it impossible to use for this case as read_cache_page()
will sleep and so might wait_on_page_locked().
Then I realized I probably don't need to lock the struct
address_space, but it strikes me as odd--it's a shared struct.
I need to maintain the address space in tight control while I am
accessing it. So the question is: what is the proper way? can't
find any good examples in the kernel code that show it.
Thanks,
Inaky Perez-Gonzalez -- Not speaking for Intel -- all opinions are my own (and my fault)
--
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>
reply other threads:[~2004-07-28 2:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=F989B1573A3A644BAB3920FBECA4D25A6EBFE6@orsmsx407 \
--to=inaky.perez-gonzalez@intel.com \
--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