<p><br>
On Jan 28, 2014 7:57 AM, &quot;Zameer Manji&quot; &lt;<a href="mailto:zmanji@gmail.com">zmanji@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hey,<br>
&gt;<br>
&gt; My colleague Will and I are working on improving eCryptfs, an encrypted file system that ships with linux. We are trying to add a new cipher mode and we have run into a problem [1]. When the user calls `ftruncate` on a file and increases the file size, eCryptfs attempts fetch new pages for the file by calling `read_mapping_page` and which calls `read_cache_page`. This calls eCryptfs&#39; `readpage` implementation. We believe `read_cache_page` calls</p>

<p>If readpage is called then it&#39;s because</p>
<p>a) page not in page cache</p>
<p>b) page isn&#39;t uptodate.<br></p>
<p> `readpage` with a page that we have not written to before (since the user is increasing the file size via `ftruncate`).</p>
<p>I&#39;m  not so sure but is it calling truncate on inode mapping?<br>
Since that would invalidate your page cache pages.</p>
<p>&gt;<br>
&gt; What function can we use to identify when we are given a page to our `readpage` implementation that is a page we have never written to before? </p>
<p>PageUptodate(page) is your best bet.</p>
<p>We need to do this so we know if should check the integrity of the data in the page (if we wrote to it before) or just ignore the contents (because it is a fresh pagewith garbage data).</p>
<p>Fresh page would not have uptodate flag set which <a href="http://would.be">would.be</a> set in readpage implementation.</p>
<p> For more information our ecryptfs_readpage implementation is available on github [2].<br>
&gt;<br>
&gt; Please note that I am not subscribed to kernelnewbies so please include me directly in any replies.<br>
&gt;<br>
&gt; [1]: <a href="http://marc.info/?l=ecryptfs-users&amp;m=139007357027191&amp;w=2">http://marc.info/?l=ecryptfs-users&amp;m=139007357027191&amp;w=2</a><br>
&gt; [2]: <a href="https://github.com/zmanji/ecryptfs/blob/next-patch/fs/ecryptfs/mmap.c#L193">https://github.com/zmanji/ecryptfs/blob/next-patch/fs/ecryptfs/mmap.c#L193</a><br>
&gt;<br>
&gt; -- <br>
&gt; Zameer Manji<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Kernelnewbies mailing list<br>
&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt;<br>
     ---P.K.S</p>