<div><br></div><div>Hi all,</div><div><br></div><div>We are testing BD xlator to verify the KVM running with gluster. After some </div><div>simple tests, we encountered a coredump of glusterfs lead by liblvm2app.so. </div><div>Hope some one here might give some advises about this issue. </div><div><br></div><div>We have debug for some time, and found out this coredump is triggered by a </div><div>thread-safe issue. From the core file, the top function is _update_mda()</div><div>with a invailid pointer which is from lvmcache_foreach_mda(). As we know, the glusterfsd</div><div>has some io threads to simulate the async io. That will make more than 1 thread run into</div><div>bd_statfs_cbk(). And in liblvm2app.so, _text_read() will look up an info in a hash </div><div>table named _pvid_hash. If no info item exist, it will allocate a new one. However, </div><div>there isn&#39;t any lock to protect this operations! liblvm2app.so will get crashed with </div><div>multi-thread like this precedures:</div><div><br></div><div>Thread A and thread B go into bd_statfs_cbk() at the same time:</div><div>1. A allocate an new info node, and put it into _pvid_hash, call lvmcache_foreach_mda().</div><div>2. B looks up and get the info generaed by A in _pvid_hash, pass it to lvmcache_del_mdas(), this will free the info node.</div><div>3. A keep using the info node which has been freed by B.</div><div>4. Memory crash...</div><div><br></div><div>Reproduce steps:</div><div>1. Create a BD volume with BD xlator follow a standard method. Mount it on a glusterfs client.</div><div><br></div><div>2. Write a simple test script crash_bd.sh:</div><div>#!/bin/bash</div><div>while :;do</div><div>    i=0 </div><div>    while [ $i -lt 10 ]; do</div><div>        df &gt; /dev/null</div><div>        i=`expr $i + 1`</div><div>    done</div><div>    sleep 10;</div><div>done</div><div><br></div><div>3. Start some crash_bd.sh at the same time</div><div># ./crash_bd.sh &amp;</div><div># ./crash_bd.sh &amp;</div><div># ./crash_bd.sh &amp;</div><div># ./crash_bd.sh &amp;</div><div><br></div><div>4. Just wait some minutes, it will get an error like this:</div><div>df: `/mnt/bd_vol&#39;: Transport endpoint is not connected</div><div>the glusterfs has crashed.</div><div><br></div><div>Note: If we set the io-thread number to single, the BD xlator looks running very well!</div><div><br></div><div>Hope some one here might give some advises about this issue. Any infomations is appriciated!</div><div><br></div><div>Core detail:</div><div>Core was generated by `/usr/sbin/glusterfsd -s host-005056b50a23 --volfile-id bd.host-0050&#39;.</div><div>Program terminated with signal 11, Segmentation fault.</div><div>#0  _update_mda (mda=0x11fb000, baton=0x7f83b1d0a6d0) at format_text/text_label.c:328</div><div>353    format_text/text_label.c: No such file or directory.</div><div>(gdb) bt</div><div>#0  _update_mda (mda=0x11fb000, baton=0x7f83b1d0a6d0) at format_text/text_label.c:328</div><div>#1  0x00007f83b59a0e09 in lvmcache_foreach_mda (info=info@entry=0x11faf00, fun=fun@entry=0x7f83b59c1a60 &lt;_update_mda&gt;, </div><div>    baton=baton@entry=0x7f83b1d0a6d0) at cache/lvmcache.c:1880</div><div>#2  0x00007f83b59c0e5f in _text_read (l=&lt;optimized out&gt;, dev=0x11ee8d8, buf=&lt;optimized out&gt;, label=0x7f83b1d0a958)</div><div>    at format_text/text_label.c:459</div><div>#3  0x00007f83b59c27e7 in label_read (dev=0x11ee8d8, result=result@entry=0x7f83b1d0a958, scan_sector=scan_sector@entry=0)</div><div>    at label/label.c:284</div><div>#4  0x00007f83b599dd2b in lvmcache_fmt_from_vgname (cmd=cmd@entry=0x11d3c40, vgname=vgname@entry=0x11d2c50 &quot;bd-vg&quot;, </div><div>    vgid=vgid@entry=0x0, revalidate_labels=revalidate_labels@entry=1) at cache/lvmcache.c:506</div><div>#5  0x00007f83b59e1ad8 in _vg_read (cmd=cmd@entry=0x11d3c40, vgname=vgname@entry=0x11d2c50 &quot;bd-vg&quot;, vgid=vgid@entry=0x0, </div><div>    warnings=warnings@entry=1, consistent=consistent@entry=0x7f83b1d0ab48, precommitted=precommitted@entry=0)</div><div>    at metadata/metadata.c:3143</div><div>#6  0x00007f83b59e2ecc in vg_read_internal (cmd=cmd@entry=0x11d3c40, vgname=vgname@entry=0x11d2c50 &quot;bd-vg&quot;, </div><div>    vgid=vgid@entry=0x0, warnings=warnings@entry=1, consistent=consistent@entry=0x7f83b1d0ab48) at metadata/metadata.c:3549</div><div>#7  0x00007f83b59e30cc in _vg_lock_and_read (misc_flags=0, status_flags=0, lock_flags=33, vgid=0x0, </div><div>    vg_name=0x11d2c50 &quot;bd-vg&quot;, cmd=0x11d3c40) at metadata/metadata.c:4235</div><div>#8  vg_read (cmd=cmd@entry=0x11d3c40, vg_name=vg_name@entry=0x11d2c50 &quot;bd-vg&quot;, vgid=vgid@entry=0x0, flags=0)</div><div>    at metadata/metadata.c:4343</div><div>#9  0x00007f83b599753f in _lvm_vg_open (mode=0x7f83b5c8971e &quot;r&quot;, vgname=0x11d2c50 &quot;bd-vg&quot;, libh=0x11d3c40, </div><div>    flags=&lt;optimized out&gt;) at lvm_vg.c:221</div><div>#10 lvm_vg_open (libh=0x11d3c40, vgname=0x11d2c50 &quot;bd-vg&quot;, mode=mode@entry=0x7f83b5c8971e &quot;r&quot;, flags=flags@entry=0)</div><div>    at lvm_vg.c:238</div><div>#11 0x00007f83b5c7ee36 in bd_statfs_cbk (frame=0x7f83b95416e4, cookie=&lt;optimized out&gt;, this=0x119eb90, op_ret=0, op_errno=0, </div><div>    buff=0x7f83b1d0ac70, xdata=0x0) at bd.c:353</div><div>......</div><div><br></div><div>(gdb) f 1</div><div>#1  0x00007f83b59a0e09 in lvmcache_foreach_mda (info=info@entry=0x11faf00, fun=fun@entry=0x7f83b59c1a60 &lt;_update_mda&gt;, </div><div>    baton=baton@entry=0x7f83b1d0a6d0) at cache/lvmcache.c:1899</div><div>1899    cache/lvmcache.c: No such file or directory.</div><div>(gdb) p *info</div><div>$1 = {list = {n = 0x11fa650, p = 0x11fa650}, mdas = {n =0x11fafd0, p = 0x11fafd0}, das = {n = 0x11fb000, p = 0x11fb000}, </div><div>  bas = {n = 0x11faf30, p = 0x11faf30}, vginfo = 0x11fa640, label = 0x11faed0, fmt = 0x11f8480, dev = 0x11ee8d8, </div><div>  device_size = 531870253056, status = 1}</div><div>(gdb) info threads </div><div>  Id   Target Id         Frame </div><div>  11   Thread 0x7f83b3786700 (LWP 24272) 0x00007f7bc917cdec in _dev_close (dev=0x16421d0, immediate=immediate@entry=0) at device/dev-io.c:624</div><div>  10   Thread 0x7f83bb968700 (LWP 23306) 0x00007f83ba5e40d3 in epoll_wait () from /lib/x86_64-linux-gnu/libc.so.6</div><div>  9    Thread 0x7f83b250c700 (LWP 24276) 0x00007f83bac822d4 in pthread_cond_wait@@GLIBC_2.3.2 ()</div><div>   from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>  8    Thread 0x7f83b2d0d700 (LWP 24275) 0x00007f83bac8264b in pthread_cond_timedwait@@GLIBC_2.3.2 ()</div><div>   from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>  7    Thread 0x7f83b350e700 (LWP 24274) 0x00007f83ba5b4bdd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6</div><div>  6    Thread 0x7f83b3887700 (LWP 24271) 0x00007f83bac822d4 in pthread_cond_wait@@GLIBC_2.3.2 ()</div><div>   from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>  5    Thread 0x7f83b6ed7700 (LWP 23310) 0x00007f83bac858ad in nanosleep () from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>  4    Thread 0x7f83b7d57700 (LWP 23309) 0x00007f83bac8264b in pthread_cond_timedwait@@GLIBC_2.3.2 ()</div><div>   from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>  3    Thread 0x7f83b8558700 (LWP 23308) 0x00007f83bac8264b in pthread_cond_timedwait@@GLIBC_2.3.2 ()</div><div>   from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>  2    Thread 0x7f83b8d59700 (LWP 23307) 0x00007f83bac85d77 in do_sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>* 1    Thread 0x7f83b1d0b700 (LWP 26000) _update_mda (mda=0x11fb000, baton=0x7f83b1d0a6d0) at format_text/text_label.c:353</div><div>(gdb)thread 11</div><div>[Switching to thread 11 (Thread 0x7f83b3786700 (LWP 24272))]</div><div>#0  0x00007f83bac8578d in fsync () from /lib/x86_64-linux-gnu/libpthread.so.0</div><div>(gdb) bt</div><div>#0  0x00007f7bc917cdec in _dev_close (dev=0x16421d0, immediate=immediate@entry=0) at device/dev-io.c:624</div><div>#1  0x00007f7bc917d257 in dev_close (dev=&lt;optimized out&gt;) at device/dev-io.c:631</div><div>#2  0x00007f83b59c1a88 in _update_mda (mda=0x11fafd0, baton=0x7f83b37856d0) at at format_text/text_label.c:361</div><div>#3  0x00007f83b59a0e09 in lvmcache_foreach_mda (info=info@entry=0x11faf00, fun=fun@entry=0x7f83b59c1a60 &lt;_update_mda&gt;, </div><div>    baton=baton@entry=0x7f83b37856d0) at cache/lvmcache.c:1899</div><div>#4  0x00007f83b59c0e5f in _text_read (l=&lt;optimized out&gt;, dev=0x11ee8d8, buf=&lt;optimized out&gt;, label=0x7f83b3785958)</div><div>    at format_text/text_label.c:459</div><div>#5  0x00007f83b59c27e7 in label_read (dev=0x11ee8d8, result=result@entry=0x7f83b3785958, scan_sector=scan_sector@entry=0)</div><div>    at label/label.c:284</div><div>#6  0x00007f83b599dd2b in lvmcache_fmt_from_vgname (cmd=cmd@entry=0x11d3c40, vgname=vgname@entry=0x11d2c50 &quot;bd-vg&quot;, </div><div>    vgid=vgid@entry=0x0, revalidate_labels=revalidate_labels@entry=1) at cache/lvmcache.c:506</div><div>#7  0x00007f83b59e1ad8 in _vg_read (cmd=cmd@entry=0x11d3c40, vgname=vgname@entry=0x11d2c50 &quot;bd-vg&quot;, vgid=vgid@entry=0x0, </div><div>    warnings=warnings@entry=1, consistent=consistent@entry=0x7f83b3785b48, precommitted=precommitted@entry=0)</div><div>    at metadata/metadata.c:3143</div><div>#8  0x00007f83b59e2ecc in vg_read_internal (cmd=cmd@entry=0x11d3c40, vgname=vgname@entry=0x11d2c50 &quot;bd-vg&quot;, </div><div>    vgid=vgid@entry=0x0, warnings=warnings@entry=1, consistent=consistent@entry=0x7f83b3785b48) at metadata/metadata.c:3549</div><div>#9  0x00007f83b59e30cc in _vg_lock_and_read (misc_flags=0, status_flags=0, lock_flags=33, vgid=0x0, </div><div>    vg_name=0x11d2c50 &quot;bd-vg&quot;, cmd=0x11d3c40) at metadata/metadata.c:4235</div><div>#10 vg_read (cmd=cmd@entry=0x11d3c40, vg_name=vg_name@entry=0x11d2c50 &quot;bd-vg&quot;, vgid=vgid@entry=0x0, flags=0)</div><div>    at metadata/metadata.c:4343</div><div>#11 0x00007f83b599753f in _lvm_vg_open (mode=0x7f83b5c8971e &quot;r&quot;, vgname=0x11d2c50 &quot;bd-vg&quot;, libh=0x11d3c40, </div><div>    flags=&lt;optimized out&gt;) at lvm_vg.c:221</div><div>#12 lvm_vg_open (libh=0x11d3c40, vgname=0x11d2c50 &quot;bd-vg&quot;, mode=mode@entry=0x7f83b5c8971e &quot;r&quot;, flags=flags@entry=0)</div><div>    at lvm_vg.c:238</div><div>#13 0x00007f83b5c7ee36 in bd_statfs_cbk (frame=0x7f83b95412dc, cookie=&lt;optimized out&gt;, this=0x119eb90, op_ret=0, op_errno=0, </div><div>    buff=0x7f83b3785c70, xdata=0x0) at bd.c:353</div><div>......</div><div>(gdb) f 3</div><div>#3  0x00007f83b59a0e09 in lvmcache_foreach_mda (info=info@entry=0x11faf00, fun=fun@entry=0x7f83b59c1a60 &lt;_update_mda&gt;, </div><div>    baton=baton@entry=0x7f83b37856d0) at cache/lvmcache.c:1899</div><div>1899    in cache/lvmcache.c</div><div>(gdb) p *info</div><div>$2 = {list = {n = 0x11fa650, p = 0x11fa650}, mdas = {n = 0x11fafd0, p = 0x11fafd0}, das = {n = 0x11fb000, p = 0x11fb000}, </div><div>  bas = {n = 0x11faf30, p = 0x11faf30}, vginfo = 0x11fa640, label = 0x11faed0, fmt = 0x11f8480, dev = 0x11ee8d8, </div><div>  device_size = 531870253056, status = 1}</div><div><br></div><div><br></div>