2010-08-05 01:25:28

by Trond Myklebust

[permalink] [raw]
Subject: Re: Write delegation

On Wed, 2010-08-04 at 18:22 -0700, Yudong Gao wrote:

> But for the integration with NFS, it is confusing. The
> fscache_write_page() is called only in one place:
> nfs_readpage_release(). So a NFS page is only written to fscache after
> it is read from the server in nfs_readpage. So my question is, if a
> page is locally modified, when its data is propagated to fscache? I
> check the nfs_write_begin() and nfs_write_end() but cannot find any
> relative implementation.

See my previous answer. fscache only supports read-only files in NFS.

Trond



2010-08-05 18:10:51

by Yudong Gao

[permalink] [raw]
Subject: Re: Write delegation

I see. I was kind of confused before. Sorry about that.

I am trying to figure out how this read-only is supported in the
source code. When a page is read from the network through
nfs_readpage(), it will be cached to fscache, as implemented in
nfs_readpage_release(). The code in nfs_readpage_release() only checks
whether fscache is available, and if so, the page will be cached to
fscache.

If a page is modified locally in memory (the page cache), then it
becomes dirty. But since the fscache is read-only, the copy of the
page in fscache becomes stale. When the file is close, the dirty page
will be written back to the server. Later when it is not used for a
while, it will be removed from the page cache. Here I suppose the copy
in fscache will not be deleted, or fscache becomes useless: it can
only mirror the pages in the page cache and does not provide extra
cache. And actually in the source code, I can not find the code to
uncache the page in fscache().

So far so good. But if later this page is read again, the behavior
becomes strange. The nfs_readpage() checks first try to read the page
from fscache. In this case, it will read the stale page and oops!

I think the problem here is that when a page become dirty in page
cache, it should be removed from fscache. So my question is where is
this implemented?

Thanks a lot!

best,

Yudong

On Wed, Aug 4, 2010 at 6:25 PM, Trond Myklebust
<[email protected]> wrote:
> On Wed, 2010-08-04 at 18:22 -0700, Yudong Gao wrote:
>
>> But for the integration with NFS, it is confusing. The
>> fscache_write_page() is called only in one place:
>> nfs_readpage_release(). So a NFS page is only written to fscache after
>> it is read from the server in nfs_readpage. So my question is, if a
>> page is locally modified, when its data is propagated to fscache? I
>> check the nfs_write_begin() and nfs_write_end() but cannot find any
>> relative implementation.
>
> See my previous answer. fscache only supports read-only files in NFS.
>
> Trond
>
>

2010-08-05 20:38:39

by Gilliam, PaulX J

[permalink] [raw]
Subject: RE: fscache.

Yudong,

There is a email list just for fscache, cachefiles and cachefs:
[email protected]
It gets a lot less traffic than [email protected] and I don't know if one can find the same level of expertise monitoring it, I have seen David Howells there. He is the author of fcache, cachefiles and cachefs.

-=# Paul Gilliam #=-


>-----Original Message-----
>From: [email protected] [mailto:linux-nfs-
>[email protected]] On Behalf Of Yudong Gao
>Sent: Thursday, August 05, 2010 1:14 PM
>To: Trond Myklebust
>Cc: Andy Adamson; [email protected]
>Subject: Re: Write delegation
>
>Hi Trond,
>
>I just find the function nfs_fscache_set_inode_cookie() that checks
>the access flag and allows only read-only files to use the cache.
>
>Thanks!
>
>best,
>
>Yudong
>
>On Thu, Aug 5, 2010 at 11:10 AM, Yudong Gao <[email protected]> wrote:
>> I see. I was kind of confused before. Sorry about that.
>>
>> I am trying to figure out how this read-only is supported in the
>> source code. When a page is read from the network through
>> nfs_readpage(), it will be cached to fscache, as implemented in
>> nfs_readpage_release(). The code in nfs_readpage_release() only checks
>> whether fscache is available, and if so, the page will be cached to
>> fscache.
>>
>> If a page is modified locally in memory (the page cache), then it
>> becomes dirty. But since the fscache is read-only, the copy of the
>> page in fscache becomes stale. When the file is close, the dirty page
>> will be written back to the server. Later when it is not used for a
>> while, it will be removed from the page cache. Here I suppose the copy
>> in fscache will not be deleted, or fscache becomes useless: it can
>> only mirror the pages in the page cache and does not provide extra
>> cache. And actually in the source code, I can not find the code to
>> uncache the page in fscache().
>>
>> So far so good. But if later this page is read again, the behavior
>> becomes strange. The nfs_readpage() checks first try to read the page
>> from fscache. In this case, it will read the stale page and oops!
>>
>> I think the problem here is that when a page become dirty in page
>> cache, it should be removed from fscache. So my question is where is
>> this implemented?
>>
>> Thanks a lot!
>>
>> best,
>>
>> Yudong
>>
>> On Wed, Aug 4, 2010 at 6:25 PM, Trond Myklebust
>> <[email protected]> wrote:
>>> On Wed, 2010-08-04 at 18:22 -0700, Yudong Gao wrote:
>>>
>>>> But for the integration with NFS, it is confusing. The
>>>> fscache_write_page() is called only in one place:
>>>> nfs_readpage_release(). So a NFS page is only written to fscache after
>>>> it is read from the server in nfs_readpage. So my question is, if a
>>>> page is locally modified, when its data is propagated to fscache? I
>>>> check the nfs_write_begin() and nfs_write_end() but cannot find any
>>>> relative implementation.
>>>
>>> See my previous answer. fscache only supports read-only files in NFS.
>>>
>>> Trond
>>>
>>>
>>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
>the body of a message to [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html

2010-08-05 20:13:54

by Yudong Gao

[permalink] [raw]
Subject: Re: Write delegation

Hi Trond,

I just find the function nfs_fscache_set_inode_cookie() that checks
the access flag and allows only read-only files to use the cache.

Thanks!

best,

Yudong

On Thu, Aug 5, 2010 at 11:10 AM, Yudong Gao <[email protected]> wrote:
> I see. I was kind of confused before. Sorry about that.
>
> I am trying to figure out how this read-only is supported in the
> source code. When a page is read from the network through
> nfs_readpage(), it will be cached to fscache, as implemented in
> nfs_readpage_release(). The code in nfs_readpage_release() only checks
> whether fscache is available, and if so, the page will be cached to
> fscache.
>
> If a page is modified locally in memory (the page cache), then it
> becomes dirty. But since the fscache is read-only, the copy of the
> page in fscache becomes stale. When the file is close, the dirty page
> will be written back to the server. Later when it is not used for a
> while, it will be removed from the page cache. Here I suppose the copy
> in fscache will not be deleted, or fscache becomes useless: it can
> only mirror the pages in the page cache and does not provide extra
> cache. And actually in the source code, I can not find the code to
> uncache the page in fscache().
>
> So far so good. But if later this page is read again, the behavior
> becomes strange. The nfs_readpage() checks first try to read the page
> from fscache. In this case, it will read the stale page and oops!
>
> I think the problem here is that when a page become dirty in page
> cache, it should be removed from fscache. So my question is where is
> this implemented?
>
> Thanks a lot!
>
> best,
>
> Yudong
>
> On Wed, Aug 4, 2010 at 6:25 PM, Trond Myklebust
> <[email protected]> wrote:
>> On Wed, 2010-08-04 at 18:22 -0700, Yudong Gao wrote:
>>
>>> But for the integration with NFS, it is confusing. The
>>> fscache_write_page() is called only in one place:
>>> nfs_readpage_release(). So a NFS page is only written to fscache after
>>> it is read from the server in nfs_readpage. So my question is, if a
>>> page is locally modified, when its data is propagated to fscache? I
>>> check the nfs_write_begin() and nfs_write_end() but cannot find any
>>> relative implementation.
>>
>> See my previous answer. fscache only supports read-only files in NFS.
>>
>> Trond
>>
>>
>