<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 28, 2014 at 6:48 PM, RAGHAVENDRA TALUR <span dir="ltr">&lt;<a href="mailto:raghavendra.talur@gmail.com" target="_blank">raghavendra.talur@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Nov 27, 2014 at 2:59 PM, Raghavendra Bhat &lt;<a href="mailto:rabhat@redhat.com">rabhat@redhat.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; With USS to access snapshots, we depend on last snapshot of the volume (or<br>
&gt; the latest snapshot) to resolve some issues.<br>
&gt; Ex:<br>
&gt; Say there is a directory called &quot;dir&quot; within the root of the volume and USS<br>
&gt; is enabled. Now when .snaps is accessed from &quot;dir&quot; (i.e. /dir/.snaps), first<br>
&gt; a lookup is sent on /dir which snapview-client xlator passes onto the normal<br>
&gt; graph till posix xlator of the brick. Next the lookup comes on /dir/.snaps.<br>
&gt; snapview-client xlator now redirects this call to the snap daemon (since<br>
&gt; .snaps is a virtual directory to access the snapshots). The lookup comes to<br>
&gt; snap daemon with parent gfid set to the gfid of &quot;/dir&quot; and the basename<br>
&gt; being set to &quot;.snaps&quot;. Snap daemon will first try to resolve the parent gfid<br>
&gt; by trying to find the inode for that gfid. But since that gfid was not<br>
&gt; looked up before in the snap daemon, it will not be able to find the inode.<br>
&gt; So now to resolve it, snap daemon depends upon the latest snapshot. i.e. it<br>
&gt; tries to look up the gfid of /dir in the latest snapshot and if it can get<br>
&gt; the gfid, then lookup on /dir/.snaps is also successful.<br>
<br>
</span>From the user point of view, I would like to be able to enter into the<br>
.snaps anywhere.<br>
To be able to do that, we can turn the dependency upside down, instead<br>
of listing all<br>
snaps in the .snaps dir, lets just show whatever snapshots had that dir.<br></blockquote><div><br></div><div style>Currently readdir in snap-view server is listing _all_ the snapshots. However if you try to do &quot;ls&quot; on a snapshot which doesn&#39;t contain this directory (say dir/.snaps/snap3), I think it returns ESTALE/ENOENT. So, to get what you&#39;ve explained above, readdir(p) should filter out those snapshots which doesn&#39;t contain this directory (to do that, it has to lookup dir on each of the snapshots).</div><div style><br></div><div style>Raghavendra Bhat explained the problem and also a possible solution to me in person. There are some pieces missing in the problem description as explained in the mail (but not in the discussion we had). The problem explained here occurs  when you restore a snapshot (say snap3) where the directory got created, but deleted before next snapshot. So, directory doesn&#39;t exist in snap2 and snap4, but exists only in snap3. Now, when you restore snap3, &quot;ls&quot; on dir/.snaps should show nothing. Now, what should be result of lookup (gfid-of-dir, &quot;.snaps&quot;) should be?</div><div style><br></div><div style>1. we can blindly return a virtual inode, assuming there is atleast one snapshot contains dir. If fops come on specific snapshots (eg., dir/.snaps/snap4), they&#39;ll anyways fail with ENOENT (since dir is not present on any snaps).</div><div style>2. we can choose to return ENOENT if we figure out that dir is not present on any snaps.</div><div style><br></div><div style>The problem we are trying to solve here is how to achieve 2. One simple solution is to lookup for &lt;gfid-of-dir&gt; on all the snapshots and if every lookup fails with ENOENT, we can return ENOENT. The other solution is to just lookup in snapshots before and after (if both are present, otherwise just in latest snapshot). If both fail, then we can be sure that no snapshots contain that directory.</div><div style><br></div><div style>Rabhat, Correct me if I&#39;ve missed out anything :).</div><div style><br></div><div style><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
May be it is good enough if we resolve the parent on the main volume<br>
and rely on that<br>
in snapview client and server.<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;<br>
&gt; But, there can be some confusion in the case of snapshot restore. Say there<br>
&gt; are 5 snapshots (snap1, snap2, snap3, snap4, snap5) for a volume vol. Now<br>
&gt; say the volume is restored to snap3. If there was a directory called<br>
&gt; &quot;/a&quot; at the time of taking snap3 and was later removed, then after snapshot<br>
&gt; restore accessing .snaps from that directory (in fact all the directories<br>
&gt; which were present while taking snap3) might cause problems. Because now the<br>
&gt; original volume is nothing but the snap3 and snap daemon when gets the<br>
&gt; lookup on &quot;/a/.snaps&quot;, it tries to find the gfid of &quot;/a&quot; in the latest<br>
&gt; snapshot (which is snap5) and if a was removed after taking snap3, then the<br>
&gt; lookup of &quot;/a&quot; in snap5 fails and thus the lookup of &quot;/a/.snaps&quot; will also<br>
&gt; fail.<br>
<br>
<br>
&gt;<br>
&gt; Possible Solution:<br>
&gt; One of the possible solution that can be helpful in this case is, whenever<br>
&gt; glusterd sends the list of snapshots to snap daemon after snapshot restore,<br>
&gt; send the list in such a way that the snapshot which is previous to the<br>
&gt; restored snapshot is sent as the latest snapshot (in the example above,<br>
&gt; since snap3 is restored, glusterd should send snap2 as the latest snapshot<br>
&gt; to snap daemon).<br>
&gt;<br>
&gt; But in the above solution also, there is a problem. If there are only 2<br>
&gt; snapshots (snap1, snap2) and the volume is restored to the first snapshot<br>
&gt; (snap1), there is no previous snapshot to look at. And glusterd will send<br>
&gt; only one name in the list which is snap2 but it is in a future state than<br>
&gt; the volume.<br>
&gt;<br>
&gt; A patch has been submitted for the review to handle this<br>
&gt; (<a href="http://review.gluster.org/#/c/9094/" target="_blank">http://review.gluster.org/#/c/9094/</a>).<br>
&gt; And in the patch because of the above confusions snapd tries to consult the<br>
&gt; adjacent snapshots  of the restored snapshot to resolve the gfids. As per<br>
&gt; the 5 snapshots example, it tries to look at snap2 and snap4 (i.e. look into<br>
&gt; snap2 first, if it fails then look into snap4). If there is no previous<br>
&gt; snapshot, then look at the next snapshot (2 snapshots example). If there is<br>
&gt; no next snapshot, then look at the previous snapshot.<br>
&gt;<br>
&gt; Please provide feed back about how this issue can be handled.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Raghavendra Bhat<br>
&gt; _______________________________________________<br>
&gt; Gluster-devel mailing list<br>
&gt; <a href="mailto:Gluster-devel@gluster.org">Gluster-devel@gluster.org</a><br>
&gt; <a href="http://supercolony.gluster.org/mailman/listinfo/gluster-devel" target="_blank">http://supercolony.gluster.org/mailman/listinfo/gluster-devel</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Raghavendra Talur<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org">Gluster-devel@gluster.org</a><br>
<a href="http://supercolony.gluster.org/mailman/listinfo/gluster-devel" target="_blank">http://supercolony.gluster.org/mailman/listinfo/gluster-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Raghavendra G<br></div>
</div></div>