* Which is the proper way to bring in the backing store behind an inode as an struct page?
@ 2004-07-02 6:34 Perez-Gonzalez, Inaky
2004-07-02 18:07 ` Chen, Kenneth W
2004-07-02 18:46 ` Dave Hansen
0 siblings, 2 replies; 5+ messages in thread
From: Perez-Gonzalez, Inaky @ 2004-07-02 6:34 UTC (permalink / raw)
To: linux-mm
Hi all
Dummy question that has been evading me for the last hours. Can you
help? Please bear with me here, I am a little lost in how to deal
with inodes and the cache.
I have a problem where I have to modify a value in user space from
inside a function called from do_exit() [this is for robust mutexes].
The reason for this is when a task exits holding a mutex, it needs to
update the user space word that represents the mutex to indicate that
it is dead. This is needed to allow for fast-lock operations when
there is no mutex contention.
I need to be able to kmap the location where the page is so I can
modify it. The problem is that in one of the cases, when the thing
is in a shared mapping (linear or non-linear), I just have the inode,
the page offset and the offset into the page.
Thus, what I need is a way that given the pair (inode,pgoff)
returns to me the 'struct page *' if the thing is cached in memory or
pulls it up from swap/file into memory and gets me a 'struct page *'.
Is there a way to do this?
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Which is the proper way to bring in the backing store behind an inode as an struct page?
2004-07-02 6:34 Which is the proper way to bring in the backing store behind an inode as an struct page? Perez-Gonzalez, Inaky
@ 2004-07-02 18:07 ` Chen, Kenneth W
2004-07-02 18:46 ` Dave Hansen
1 sibling, 0 replies; 5+ messages in thread
From: Chen, Kenneth W @ 2004-07-02 18:07 UTC (permalink / raw)
To: Perez-Gonzalez, Inaky, linux-mm
Perez-Gonzalez, Inaky wrote on Thursday, July 01, 2004 11:35 PM
> Dummy question that has been evading me for the last hours. Can you
> help? Please bear with me here, I am a little lost in how to deal
> with inodes and the cache.
>
> ....
>
> Thus, what I need is a way that given the pair (inode,pgoff)
> returns to me the 'struct page *' if the thing is cached in memory or
> pulls it up from swap/file into memory and gets me a 'struct page *'.
>
> Is there a way to do this?
find_get_page() might be the one you are looking for.
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Which is the proper way to bring in the backing store behind an inode as an struct page?
2004-07-02 6:34 Which is the proper way to bring in the backing store behind an inode as an struct page? Perez-Gonzalez, Inaky
2004-07-02 18:07 ` Chen, Kenneth W
@ 2004-07-02 18:46 ` Dave Hansen
1 sibling, 0 replies; 5+ messages in thread
From: Dave Hansen @ 2004-07-02 18:46 UTC (permalink / raw)
To: Perez-Gonzalez, Inaky; +Cc: linux-mm
On Thu, 2004-07-01 at 23:34, Perez-Gonzalez, Inaky wrote:
> Thus, what I need is a way that given the pair (inode,pgoff)
> returns to me the 'struct page *' if the thing is cached in memory or
> pulls it up from swap/file into memory and gets me a 'struct page *'.
>
> Is there a way to do this?
Do you have the VMA? Why not just use the user mapping, and something
like copy_to_user()? It already handles all of the mess getting the
page into memory and pulling it out of swap if necessary.
If you go into the page cache yourself, you'll have to deal with all of
the usual !PageUptodate() and so forth.
-- Dave
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Which is the proper way to bring in the backing store behind an inode as an struct page?
2004-07-03 0:37 Perez-Gonzalez, Inaky
@ 2004-07-03 5:52 ` Ram Pai
0 siblings, 0 replies; 5+ messages in thread
From: Ram Pai @ 2004-07-03 5:52 UTC (permalink / raw)
To: Perez-Gonzalez, Inaky; +Cc: Chen, Kenneth W, linux-mm
On Fri, 2004-07-02 at 17:37, Perez-Gonzalez, Inaky wrote:
> Hi Ken
>
> > From: Chen, Kenneth W [mailto:kenneth.w.chen@intel.com]
> >
> > Perez-Gonzalez, Inaky wrote on Thursday, July 01, 2004 11:35 PM
> > > Dummy question that has been evading me for the last hours. Can you
> > > help? Please bear with me here, I am a little lost in how to deal
> > > with inodes and the cache.
> > >
> > > ....
> > >
> > > Thus, what I need is a way that given the pair (inode,pgoff)
> > > returns to me the 'struct page *' if the thing is cached in memory or
> > > pulls it up from swap/file into memory and gets me a 'struct page *'.
> > >
> > > Is there a way to do this?
> >
> > find_get_page() might be the one you are looking for.
>
> Something like this? [I am trying blindly]
> page = find_get_page (inode->i_mapping, pgoff)
I would like at the logic of do_generic_mapping_read(). The code below
is perhaps roughly what you want.
page = find_get_page(inode->i_mapping, pgoff);
if(unlikely(page==NULL)) {
page = page_cache_alloc_cold(mapping);
if (!page) {
/* NO LUCK SORRY :-( */
}
if(add_to_page_cache_lru(page, mapping, pgoff, GFP_KERNEL)) {
/* NO LUCK SORRY :-( */
}
}
if (!PageUptodate(page)) {
lock_page(page);
mapping->a_ops->readpage(filp /*i guess this can be null */,
page);
}
>
> Under which circumstances will this fail? [I am guessing the only ones
> are if the page offset is out of the limits of the map]. What about
> i_mapping? When is it not defined? [ie: NULL].
>
> Thanks
>
> IA+-aky PA(C)rez-GonzA!lez -- 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>
>
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Which is the proper way to bring in the backing store behind an inode as an struct page?
@ 2004-07-03 0:37 Perez-Gonzalez, Inaky
2004-07-03 5:52 ` Ram Pai
0 siblings, 1 reply; 5+ messages in thread
From: Perez-Gonzalez, Inaky @ 2004-07-03 0:37 UTC (permalink / raw)
To: Chen, Kenneth W, linux-mm
Hi Ken
> From: Chen, Kenneth W [mailto:kenneth.w.chen@intel.com]
>
> Perez-Gonzalez, Inaky wrote on Thursday, July 01, 2004 11:35 PM
> > Dummy question that has been evading me for the last hours. Can you
> > help? Please bear with me here, I am a little lost in how to deal
> > with inodes and the cache.
> >
> > ....
> >
> > Thus, what I need is a way that given the pair (inode,pgoff)
> > returns to me the 'struct page *' if the thing is cached in memory or
> > pulls it up from swap/file into memory and gets me a 'struct page *'.
> >
> > Is there a way to do this?
>
> find_get_page() might be the one you are looking for.
Something like this? [I am trying blindly]
page = find_get_page (inode->i_mapping, pgoff)
Under which circumstances will this fail? [I am guessing the only ones
are if the page offset is out of the limits of the map]. What about
i_mapping? When is it not defined? [ie: NULL].
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-07-03 5:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-02 6:34 Which is the proper way to bring in the backing store behind an inode as an struct page? Perez-Gonzalez, Inaky
2004-07-02 18:07 ` Chen, Kenneth W
2004-07-02 18:46 ` Dave Hansen
2004-07-03 0:37 Perez-Gonzalez, Inaky
2004-07-03 5:52 ` Ram Pai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox