[PVFS-developers] kernel lstat flood

Murali Vilayannur vilayann at mcs.anl.gov
Wed Jul 14 13:51:37 EDT 2004


Hi Don,
> 
> I looked in the kernel code (at least for our RH7.3 kernel) and it seems
> that d_iname is a pointer to d_name.name unless the name is longer than
> 23 characters, in which case it is ignored.  

Good catch.
d_name.name is a pointer to d_iname :)
As you figured out, d_iname is a small array of 16 bytes or so used only 
for small names. For longer file names d_name.name is kmalloc'ed.
Nonetheless, d_name.name always points to the right filename irrespective
of long/short filenames.

> I also looked in the 2.6.7 vfs code and the code is almost identical. 
> There may be some older kernels where d_iname is actually used for
> something...

I don't think this has changed from the old kernels to the new kernels.
d_name.name has always been a pointer to either d_iname or to a kmalloc'ed
region. Hence d_iname has some use for small filenames.
Snipped the relevant code snippet from d_alloc()

 if (name->len > DNAME_INLINE_LEN-1) {
      str = kmalloc(NAME_ALLOC_LEN(name->len), GFP_KERNEL);
      if (!str) {
         kmem_cache_free(dentry_cache, dentry);
         return NULL;
      }
   } else
      str = dentry->d_iname;
   memcpy(str, name->name, name->len);
   str[name->len] = 0;
   ....
   dentry->d_name.name = str;

thanks
Murali


More information about the PVFS-developers mailing list