Andreas, thanks for the thoughtful reply, and sorry for being so slow to acknowledge and respond to it.&nbsp;&nbsp; Responses are below.&nbsp; <br><br><div class="gmail_quote">On Fri, Nov 14, 2008 at 6:00 PM, Andreas Dilger <span dir="ltr">&lt;<a href="mailto:adilger@sun.com">adilger@sun.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Nov 11, 2008 &nbsp;13:23 -0600, John Groves wrote:<br>
&gt; This work is primarily motivated by the need to improve the performance<br>
&gt; of lustre clients as SMB servers to windows nodes. &nbsp;As I understand it,<br>
&gt; this need is primarily for file readers.<br>
&gt;<br>
&gt; Requirements<br>
&gt;<br>
&gt; 1. Enabling fscache should be a mount option, and there should be ioctl<br>
&gt; &nbsp; &nbsp;support for enabling, disabling and querying a file&#39;s fscache usage.<br>
<br>
</div>For Lustre there should also be the ability to do this via /proc/fs/lustre<br>
tunables/stats.</blockquote><div><br>Makes sense, thanks.<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<div class="Ih2E3d"><br>
&gt; 2. Data read into the page cache will be asynchronously copied to the<br>
&gt; &nbsp; &nbsp;disk-based fscache upon arrival.<br>
&gt; 3. If requested data is not present in the page cache, it will be retrieved<br>
&gt; &nbsp; &nbsp;preferentially from the fscache. &nbsp;If not present in the fscache, data<br>
&gt; &nbsp; &nbsp;will be read via RPC.<br>
&gt; 4. When pages are reclaimed due to memory pressure, they should remain in<br>
&gt; &nbsp; &nbsp;the fscache.<br>
&gt; 5. When a user writes a page (if we support fscache for non-read-only<br>
&gt; opens),<br>
&gt; &nbsp; &nbsp;the corresponding fscache page must either be invalidated or<br>
&gt; &nbsp; &nbsp;(more likely) rewritten.<br>
&gt; 6. When a DLM lock is revoked, the entire extent of the lock must be<br>
&gt; &nbsp; &nbsp;dropped from the fscache (in addition to dropping any page cache<br>
&gt; &nbsp; &nbsp;resident pages) - regardless of whether any pages are currently resident<br>
&gt; &nbsp; &nbsp;in the page cache.<br>
&gt; 7. As sort-of a corollary to #6, DLM locks must not be canceled by the owner<br>
&gt; &nbsp; &nbsp;as long as pages are resident in the fscache, even if memory pressure<br>
&gt; &nbsp; &nbsp;reclamation has emptied the page cache for a given file.<br>
&gt; 8. Utilities and test programs will be needed, of course.<br>
&gt; 9. The fscache must be cleared upon mount or dismount.<br>
<br>
&gt; High Level Design Points<br>
&gt;<br>
&gt; The following is written based primarily on review of the 1.6.5.1 code.<br>
&gt; I&#39;m aware that this is not the place for new development, but it was<br>
&gt; deemed a stable place for initial experimentation.<br>
<br>
</div>Note that the client IO code was substantially re-written for the 2.0<br>
release. &nbsp;The client IO code from 1.6.5 is still present through the<br>
1.8.x releases.</blockquote><div><br>Understood.<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
&gt; Req. &nbsp; &nbsp;Notes<br>
&gt;<br>
&gt; &nbsp;1. &nbsp; &nbsp;In current Redhat distributions, fscache is included and<br>
&gt; &nbsp; &nbsp; NFS includes fscache support, enabled by a mount option.<br>
&gt; &nbsp; &nbsp; We don&#39;t see any problems with doing something similar.<br>
&gt; &nbsp; &nbsp; A per-file ioctl to enable/disable fscache usage is also seen<br>
&gt; &nbsp; &nbsp; as straightforward.<br>
&gt;<br>
&gt; &nbsp;2. &nbsp; &nbsp; When an RPC read (into the page cache) completes, in the<br>
&gt; &nbsp; &nbsp; ll_ap_completion() function, an asynchronous read to the<br>
&gt; &nbsp; &nbsp; same offset in the file&#39;s fscache object will be initiated.<br>
&gt; &nbsp; &nbsp; This should not materially impact access time (think dirty page<br>
&gt; &nbsp; &nbsp; to fscache filesystem).<br>
<br>
</div><br>Do you mean an &quot;asynchronous write to the ... fscache object&quot;?</blockquote><div><br>Yes - write it is.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
&gt; &nbsp;3. &nbsp; &nbsp; When the readpage method is invoked because a page is not<br>
&gt; &nbsp; &nbsp; already resident in the page cache, the page will be read<br>
&gt; &nbsp; &nbsp; first from the fscache. &nbsp;This is non-blocking and (presumably)<br>
&gt; &nbsp; &nbsp; fast for the non-resident case. &nbsp;If available, the fscache<br>
&gt; &nbsp; &nbsp; read will proceed asynchronously, after which the page will be<br>
&gt; &nbsp; &nbsp; valid in the page cache. &nbsp;If not available in the fscache,<br>
&gt; &nbsp; &nbsp; the RPC read will proceed normally.<br>
&gt;<br>
&gt; &nbsp;4. &nbsp; &nbsp; Page removal due to memory pressure is triggered by a call to<br>
&gt; &nbsp; &nbsp; the llap_shrink_cache function. &nbsp;This function should not require<br>
&gt; &nbsp; &nbsp; any material change, since pages can be removed from the page<br>
&gt; &nbsp; &nbsp; cache without removal from the fscache in this case. &nbsp;In fact,<br>
&gt; &nbsp; &nbsp; if this doesn&#39;t happen, the fscache will never be read.<br>
&gt; &nbsp; &nbsp; (note: test coverage will be important here)<br>
&gt;<br>
&gt; &nbsp;5. &nbsp; &nbsp;It may be reasonable in early code to enable fscache only<br>
&gt; &nbsp; &nbsp; for read-only opens. &nbsp;However, we don&#39;t see any inherent problems<br>
&gt; &nbsp; &nbsp; with running an asynchronous write to the fscache concurrently<br>
&gt; &nbsp; &nbsp; with a Lustre RPC write. &nbsp;Note that this approach would *never*<br>
&gt; &nbsp; &nbsp; have dirty pages exist only in the fscache; if it&#39;s dirty it<br>
&gt; &nbsp; &nbsp; stays in the page cache until it&#39;s written via RPC (or RPC<br>
&gt; &nbsp; &nbsp; AND fscache if we&#39;re writing to both places)..<br>
<br>
</div><br>This is dangerous from the point of view that the write to the fscache<br>
may succeed, but the RPC may fail for a number of reasons (e.g. client<br>
eviction) so it would seem that the write to the fscache cannot start<br>
until the RPC completes successfully.</blockquote><div><br>Good catch, thanks.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">

&gt; &nbsp;6 &amp; 7 &nbsp; &nbsp;This is where it gets a little more tedious. &nbsp;Let me revert to<br>
&gt; &nbsp; &nbsp; paragraph form to address these cases below.<br>
&gt;<br>
&gt; &nbsp;8 &nbsp; &nbsp;Testing will require the following:<br>
&gt; &nbsp; &nbsp; * ability to query and punch holes in the page cache (already done).<br>
&gt; &nbsp; &nbsp; * ability to query and punch holes in the fscache (nearly done).<br>
&gt;<br>
&gt; &nbsp;9 &nbsp;I presume that all locks are canceled when a client dismounts<br>
&gt; &nbsp; &nbsp; a filesystem, in which case it would never be safe to use data<br>
&gt; &nbsp; &nbsp; in the fscache from a prior mount.<br>
<br>
</div><br>A potential future improvement in the second generation of this feature<br>
might be the ability to revalidate the files in the local disk cache by<br>
the MDT and OST object versions, if those are also stored in fscache.</blockquote><div><br>Cool idea.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
&gt; Lock Revocation<br>
&gt;<br>
&gt; Please apply that &quot;it looks to me like this is how things work&quot; filter here;<br>
&gt; I am still pretty new to Lustre (thanks). &nbsp;My questions are summarized<br>
&gt; after the the text of this section.<br>
&gt;<br>
&gt; As of 1.6.5.1, DLM locks keep a list of page-cached pages<br>
&gt; (lock-&gt;l_extents_list contains osc_async_page structs for all currently<br>
&gt; cached pages - and I think the word extent is used both for each page cached<br>
&gt; under a lock, and to describe a locked region...is this right?). &nbsp;If a lock<br>
&gt; is revoked, that list is torn down and the pages are freed. &nbsp;Pages are also<br>
&gt; removed from that list when they are freed due to memory pressure, making<br>
&gt; that list sparse with regard to the actual region of the lock.<br>
&gt;<br>
&gt; Adding fscache, there will be zero or more page-cache pages in the extent<br>
&gt; list, as well as zero or more pages in the file object in the fscache.<br>
&gt; The primary question, then, is whether a lock will remain valid (i.e. not be<br>
&gt; voluntarily released) if all of the page-cache pages are freed for<br>
&gt; non-lock-related reasons (see question 3 below).<br>
<br>
</div><br>Yes, the lock can remain valid on the client even when no pages are<br>
protected by the lock. &nbsp;However, locks with few pages are more likely<br>
to be cancelled by the DLM LRU because the cost of re-fetching those<br>
locks is much smaller compared to locks covering lots of data. &nbsp;The<br>
lock &quot;weight&quot; function would need to be enhanced to include pages that<br>
are in fscache instead of just those in memory.</blockquote><div><br>Got it, thanks.&nbsp; That would have eluded me...<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
&gt; The way I foresee cleaning up the fscache is by looking at the overall<br>
&gt; extent of the lock (at release or revocation time), and punching a<br>
&gt; lock-extent-sized hole in the fscache object prior to looping through<br>
&gt; the page list (possibly in cache_remove_lock() prior to calling<br>
&gt; cache_remove_extents_from_lock()).</div></blockquote><div><br>FYI it turns out that fscache doesn&#39;t have the ability to punch a hole.&nbsp; The whole file has to be dropped at present.&nbsp; <br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
&gt;<br>
&gt; However, that would require finding the inode, which (AFAICS) is not<br>
&gt; available in that context (ironically, unless the l_extents_list is non-<br>
&gt; empty, in which case the inode can be found via any of the page structs in<br>
&gt; the list). &nbsp;I have put in a hack to solve this, but see question 6 below.<br>
<br>
</div><br>Actually, each lock has a back-pointer to the inode that is referencing<br>
it, in l_ast_data, so that lock_cancel-&gt;mapping-&gt;page_removal can work.<br>
Use ll_inode_from_lock() for this.</blockquote><div><br>That&#39;s much nicer than my hack...thanks.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
&gt; Summarized questions:<br>
&gt; Q1: Where can I read up on the unit testing infrastructure for Lustre?<br>
<br>
</div><br>There is an internal wiki page with some information on this, it should<br>
probably be moved to the public wiki.</blockquote><div><br>If there&#39;s a way to let me know when that happens, I&#39;d appreciate it.&nbsp; I&#39;m not a full time lustre-devel reader (at least currently).<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
&gt; Q2: Is stale cache already covered by existing unit tests?<br>
<br>
</div><br>I&#39;m not sure what you mean. &nbsp;There is no such thing as stale cache in<br>
Lustre.</blockquote><div><br>What I was driving at is a test to verify that any page cache data was discarded when a lock was revoked.&nbsp; The same test would catch failure to discard fscache data, that being a potentially stale place to reload the page cache from.&nbsp; Perhaps that&#39;s implicitly covered somehow.<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
&gt; Q3: Will a DLM lock remain valid (i.e. not be canceled) even if its page<br>
&gt; &nbsp; &nbsp; list is empty (i.e. all pages have been freed due to memory pressure)?<br>
<br>
</div><br>Yes, though the reverse is impossible.<br>
<div class="Ih2E3d"><br>
&gt; Q4: Will there *always* be a call to cache_remove_lock() when a lock is<br>
&gt; &nbsp; &nbsp; canceled or revoked? &nbsp;(i.e. is this the place to punch a hole in the<br>
&gt; &nbsp; &nbsp; fscache object?)<br>
&gt; Q5: for the purpose of punching a hole in a cache object upon lock<br>
&gt; &nbsp; &nbsp; revocation, can I rely on the lock-&gt;l_req_extent structure as the<br>
&gt; &nbsp; &nbsp; actual extent of the lock?<br>
<br>
</div>No, there are two different extent ranges on each lock. &nbsp;The requested<br>
extent, and the granted extent. &nbsp;The requested extent is the minimum<br>
extent size that the server could possibly grant to the client to finish<br>
the operation (e.g. large enough to handle a single read or write syscall).<br>
The server may decide to grant a larger lock if the resource (object) is<br>
not contended.<br>
<br>
In the current implementation, the DLM will always grant a full-file lock<br>
to the first client that requests it, because the most common application<br>
case is that only a single client is accessing the file. &nbsp;This avoids any<br>
future lock requests for this file in the majority of cases.</blockquote><div><br>Thanks.&nbsp; Given that fscache invalidation turns out to be full-file anyway, this becomes moot for the time being.<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
&gt; Q6: a) is there a way to find the inode that I&#39;ve missed?, and<br>
&gt; &nbsp; &nbsp; b) if not what is the preferred way of giving that function a way to<br>
&gt; &nbsp; &nbsp; find the inode?<br>
<br>
</div><br>See above.<br>
<div class="Ih2E3d"><br>
&gt; FYI we have done some experimenting and we have the read path in a<br>
&gt; demonstrable state, including crude code to effect lock revocation on the<br>
&gt; fscache contents. &nbsp;The NFS code modularized the fscache hooks pretty nicely,<br>
&gt; and we have followed that example.<br>
<br>
</div>Cheers, Andreas<br>
<font color="#888888">--<br>
Andreas Dilger<br>
Sr. Staff Engineer, Lustre Group<br>
Sun Microsystems of Canada, Inc.<br>
<br>
<br>
</font></blockquote></div><br><br>Thanks again!<br>John <br><br><br><br><br>