<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Jan 13, 2017 at 8:03 PM, Xavier Hernandez <span dir="ltr">&lt;<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Hi,<span><br>
<br>
On 13/01/17 10:58, jayakrishnan mm wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
Hi Xavier,<span><br>
I went through the source  code. Some questions remain.<br>
<br>
1. If two clients try to write to same file, it should succeed, even if<br>
they overlap. (Locks should ensure it happens in sequence, in the bricks).<br>
from the source code<br>
         lock-&gt;flock.l_type = F_WRLCK;<br>
         lock-&gt;flock.l_whence = SEEK_SET;<br>
<br>
            fop-&gt;flock.l_len += ec_adjust_offset(fop-&gt;xl-&gt;priv<wbr>ate,<br>
                                                 &amp;fop-&gt;flock.l_start, 1);<br>
            fop-&gt;flock.l_len = ec_adjust_size(fop-&gt;xl-&gt;privat<wbr>e,<br>
                                              fop-&gt;flock.l_len, 1);<br>
if flock.l_len is 0, the entire file  is locked for writing<br>
<br>
In my test case  with 2 clients, I always  get  flock.l_len as 0. But<br>
still  I am able to write to the same file  from both clients at the<br>
 same time.<br>
</span></blockquote>
<br>
How are you sure you are really writing at the same time ? do you get partial writes from some of the client ?</blockquote><div><br></div></span><div>I am not sure, if they are happening simultaneously. I am using  fio to do that.</div><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><span><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<br>
If it is  acquiring lock chunk by chunk, why I am getting l_len =0<br>
always ?<br>
</blockquote>
<br></span>
EC doesn&#39;t acquire partial locks. The entire file is locked when a modification is needed. This makes possible to reuse locks for future operations (eager locking).<span><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
Why I am not getting the actual write size  and offset f(for<br>
flock.l_len &amp; flock.l_start respectively) for each  write FOP ?<br>
(In afr , it is set to transaction.len transaction.start respectively,<br>
which in turn is  write length &amp; offset  for the normal write case)<br>
</blockquote>
<br></span>
Because an erasure code splits the data is smaller fragments for each brick, so offsets and lengths need to be adjusted.<span><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<br>
2. As per source code ,a full file lock is taken by the shd also.<br>
<br>
ec_heal_inodelk(heal, F_WRLCK, 1, 0, 0);<br>
 which means  offset=0 &amp; size=0  in  ec_heal_lock() function in ec-heal.c<br>
flock.l_start = offset;<br>
flock.l_len = size;<br>
Does it mean , in a single file write cannot happen simultaneously with<br>
healing?<br>
</blockquote>
<br></span>
Correct. Heal procedure is like an additional client. If a client and the heal process try to write at the same time, they must be serialized, like any other regular write. However heal only takes the full lock for some critical operations. Regular self heal of file contents is done locking chunk by chunk.<br></blockquote><div><br></div></span><div>Have got a question about index heal/full heal.</div><div>As per the code, index healer thread (ec_shd_index_healer)is <wbr>created  when there is a child_up event OR  when there is a TRANSLATOR_OP/GF_SHD_OP_HEAL_<wbr>INDEX.  When does the second case arise ?  </div><div><br></div><div>Full heal  thread(ec_shd_full_healer) is created  only when TRANSLATOR_OP/GF_SHD_OP_HEAL_<wbr>FULL arise. Does this happen during replace brick condition only ?</div><div><br></div><div>Thanks &amp; regards</div><div>JK</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<br>
Xavi<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><span>
<br>
Correct me , if I am wrong.<br>
<br>
Best Regards<br>
JK<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Wed, Dec 14, 2016 at 12:07 PM, jayakrishnan mm<br></span><span>
&lt;<a href="mailto:jayakrishnan.mm@gmail.com" target="_blank">jayakrishnan.mm@gmail.com</a> &lt;mailto:<a href="mailto:jayakrishnan.mm@gmail.com" target="_blank">jayakrishnan.mm@gmail.<wbr>com</a>&gt;&gt; wrote:<br>
<br>
    Thanks Xavier, for making it clear.<br>
    Regards<br>
    JK<br>
<br>
<br>
    On Dec 13, 2016 3:52 PM, &quot;Xavier Hernandez&quot; &lt;<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a><br></span><div><div class="m_-5762069545650022052gmail-h5">
    &lt;mailto:<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a>&gt;<wbr>&gt; wrote:<br>
<br>
        Hi JK,<br>
<br>
<br>
        On 12/13/2016 08:34 AM, jayakrishnan mm wrote:<br>
<br>
            Dear Xavi,<br>
<br>
            How do I test  the locks, for example locks  for write fop.<br>
            I have two<br>
            clients(independent), both  are  trying to write to same file.<br>
<br>
<br>
            1. According to my understanding, both  can successfully<br>
            write  if the<br>
            offsets don&#39;t overlap . I mean, the WRITE FOP  takes a chunk<br>
            lock on the<br>
            file . As<br>
            long as the clients don&#39;t try  to write to the same chunk,<br>
            it should be<br>
            OK. If no locks  present, it can lead to inconsistency.<br>
<br>
<br>
        With locks all writes will be fine as defined by posix (i.e. the<br>
        final result will be equivalent to the sequential execution of<br>
        both operations, though in an undefined order), even if they<br>
        overlap. Without locks, there are chances that some bricks<br>
        execute the operations in one order and the remaining bricks<br>
        execute the same operations in the reverse order, causing data<br>
        corruption.<br>
<br>
<br>
<br>
<br>
            2.  Different FOPs can always run simultaneously. (Example<br>
            WRITE  and<br>
            READ FOPs, or  two READ FOPs).<br>
<br>
<br>
        All fops can be executed concurrently. If there&#39;s any chance<br>
        that two operations could interfere, locks are taken in the<br>
        appropriate places. For example, reads cannot be merged with<br>
        overlapping writes. Otherwise they could return inconsistent data.<br>
<br>
<br>
<br>
            3. WRITE &amp; some metadata FOP (like setattr)  together .<br>
            Cannot happen<br>
            together with locks , even though chances  are very low.<br>
<br>
<br>
        As in 2, if there&#39;s any possible interference, the appropriate<br>
        locks will be taken.<br>
<br>
        You can look at the code to see which locks are taken for each<br>
        fop. See the corresponding ec_manager_&lt;fop&gt;() function, in the<br>
        EC_STATE_LOCK switch case. There you will see calls to<br>
        ec_lock_prepare_xxx() for each taken lock.<br>
<br>
        Xavi<br>
<br>
<br>
            Pls. clarify.<br>
<br>
            Best regards<br>
            JK<br>
<br>
<br>
<br>
            On Wed, Nov 30, 2016 at 5:49 PM, jayakrishnan mm<br>
            &lt;<a href="mailto:jayakrishnan.mm@gmail.com" target="_blank">jayakrishnan.mm@gmail.com</a><br>
            &lt;mailto:<a href="mailto:jayakrishnan.mm@gmail.com" target="_blank">jayakrishnan.mm@gmail.<wbr>com</a>&gt;<br></div></div>
            &lt;mailto:<a href="mailto:jayakrishnan.mm@gmail.com" target="_blank">jayakrishnan.mm@gmail.<wbr>com</a><span><br>
            &lt;mailto:<a href="mailto:jayakrishnan.mm@gmail.com" target="_blank">jayakrishnan.mm@gmail.<wbr>com</a>&gt;&gt;&gt; wrote:<br>
<br>
                Hi Xavier,<br>
<br>
                Thank you very much for your explanation. This helped  me to<br>
                understand  more  about  locking in EC.<br>
<br>
                Best Regards<br>
                JK<br>
<br>
<br>
                On Mon, Nov 28, 2016 at 4:17 PM, Xavier Hernandez<br>
                &lt;<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a> &lt;mailto:<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a>&gt;<br></span>
            &lt;mailto:<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a><div><div class="m_-5762069545650022052gmail-h5"><br>
            &lt;mailto:<a href="mailto:xhernandez@datalab.es" target="_blank">xhernandez@datalab.es</a>&gt;<wbr>&gt;&gt; wrote:<br>
<br>
                    Hi,<br>
<br>
                    On 11/28/2016 02:59 AM, jayakrishnan mm wrote:<br>
<br>
                        Hi Xavier,<br>
<br>
                        Notice  that EC xlator uses blocking locks. Any<br>
            specific<br>
                        reason for this?<br>
<br>
<br>
                    In a distributed filesystem like gluster a<br>
            synchronization<br>
                    mechanism is a must to avoid data corruption.<br>
<br>
<br>
                        Do you think this will  affect the  performance ?<br>
<br>
<br>
                    Of course the need for locks has a performance<br>
            impact, and we<br>
                    cannot avoid them to guarantee data integrity.<br>
            However some<br>
                    optimizations have been applied, specially the eager<br>
            locking<br>
                    which allows a lock to be reused without<br>
            unlocking/locking again.<br>
<br>
<br>
                        (In comparison AFR  first tries  non blocking<br>
            locks  and if not<br>
                        successful, tries blocking locks then)<br>
<br>
<br>
                    EC also tries a non-blocking lock first.<br>
<br>
<br>
                        Also, why two locks  are  needed  per FOP ? One<br>
            for normal<br>
                        I/O and<br>
                        another for self healing?<br>
<br>
<br>
                    The only fop that currently needs two locks is<br>
            &#39;rename&#39;, and<br>
                    only when source and destination directories are<br>
            different. All<br>
                    other fops only take one lock at most.<br>
<br>
                    Best regards,<br>
<br>
                    Xavi<br>
<br>
<br>
                        Best regards<br>
                        JK<br>
<br>
<br>
                        ______________________________<wbr>_________________<br>
                        Gluster-devel mailing list<br>
                        <a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
            &lt;mailto:<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.<wbr>org</a>&gt;<br></div></div>
            &lt;mailto:<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.<wbr>org</a><span><br>
            &lt;mailto:<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.<wbr>org</a>&gt;&gt;<br>
<br>
            <a href="http://www.gluster.org/mailman/listinfo/gluster-devel" target="_blank" rel="noreferrer">http://www.gluster.org/mailman<wbr>/listinfo/gluster-devel</a><br>
            &lt;<a href="http://www.gluster.org/mailman/listinfo/gluster-devel" target="_blank" rel="noreferrer">http://www.gluster.org/mailma<wbr>n/listinfo/gluster-devel</a>&gt;<br>
<br></span>
            &lt;<a href="http://www.gluster.org/mailman/listinfo/gluster-devel" target="_blank" rel="noreferrer">http://www.gluster.org/mailma<wbr>n/listinfo/gluster-devel</a><br>
            &lt;<a href="http://www.gluster.org/mailman/listinfo/gluster-devel" target="_blank" rel="noreferrer">http://www.gluster.org/mailma<wbr>n/listinfo/gluster-devel</a>&gt;&gt;<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div></div></div><br></div></div>
</div><br></div>