[Gluster-devel] readdir() harmful in threaded code

Kaleb S. KEITHLEY kkeithle at redhat.com
Mon Jul 25 11:28:00 UTC 2016


On 07/25/2016 07:26 AM, Kaleb S. KEITHLEY wrote:
> On 07/23/2016 10:32 AM, Emmanuel Dreyfus wrote:
>> Pranith Kumar Karampuri <pkarampu at redhat.com> wrote:
>>
>>> So should we do readdir() with external locks for everything instead?
>>
>> readdir() with a per-directory lock is safe. However, it may come with a
>> performance hit in some scenarios, since two threads cannot read the
>> same directory at once. But I am not sure it can happen in GlusterFS.
>>
>> I am a bit disturbed by readdir_r() being planned for deprecation. The
>> Open Group does not say that, or I missed it:
>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html
> 
> You should take that concern up, perhaps, with the glibc people.
> 
> As for GlusterFS, the recent change I made only affects Linux/glibc.
> 
> Non-linux platforms are unchanged; they use the same old hodgepodge of
> readdir(3)/readdir_r(3) they always have.

I take that back. Non-linux platforms now use readdir_r(3) exclusively.
Which seems to me to be better than the old hodgepodge of readdir(3) and
readdir_r(3).

> 
> As such I don't understand what it is that you're concerned about.
> 

-- 

Kaleb


More information about the Gluster-devel mailing list