[guardian-dev] debugging libsqlfs

Hans-Christoph Steiner hans at guardianproject.info
Wed Jan 9 19:54:19 EST 2013

On 01/08/2013 09:44 AM, Hans of Guardian wrote:
> On Jan 8, 2013, at 4:05 AM, Abel Luck wrote:
>> Hans-Christoph Steiner:
>>> It seems that sqlfs_t gets re-issued a lot, I added this to get_sqlfs() and
>>> got it many many times:
>>>    if (p)
>>>        return p;
>>>    else
>>>        show_msg(stderr, "sqlfs was 0");
>>> This lead me to examine the threading stuff, since it seems that when sqlfs ==
>>> 0, its getting a new sqlfs issued from:
>>>    sqlfs = (sqlfs_t *) (pthread_getspecific(sql_key));
>>> Since the libsqlfs code only has pthread code relating to the pthread_key_t
>>> creation and use, my guess is that FUSE itself is handling the rest of the
>>> threading.  So the good news is that libsqlfs was made with threading in mind,
>>> the bad news is that a lot of it is normally handled in libfuse, so we'll have
>>> to figure that part out and implement it in IOCipher in order to support threads.
>> Yes! This was a conclusion I had several months ago when looking at
>> Aaron's threading bug. There are definitely discrepancies between the
>> way IOCipher runs and the we test things with libsqlfs and fuse.
> Hey Abel,
> I think that first thing's first: let's getting fully passing long fsx tests, then we can check whether we need to handle threads different in IOCipher.

Ok, today was a good day, much better than before.

* we isolated the super mysterious crash/corruption issues in libsqlfs itself.
 It only happens with mmap'ed writes in multi-threaded mode.  So we can easily
avoid doing that in IOCipher.

* we now have a pretty solid grasp of the multi-threading issues in IOCipher's
JNI C code. We have some working test cases, so by the end of tomorrow we hope
to have something for you to test in your app.  We need to restructure things
a little bit to make sure that we're using the pthread_key_t to keep track of
the instances of sqlfs_t state struct.

I pushed my libsqlfs changes to implement the sqlfs threaded mode with a key,
i.e. using the key in get_sqlfs():

Abel, feel free to merge this to the official repo if you think they're good.


More information about the Guardian-dev mailing list