Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-12371

Odd behavior on lustre client listxattr for directories


    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: Lustre 2.7.0, Lustre 2.10.8
    • Fix Version/s: None
    • Labels:
    • Environment:
      CentOS 6 & 7, Vmware workstation virtual machine test environement
    • Epic/Theme:
    • Epic:
    • Rank (Obsolete):


      > Our backup software found an unusual result when listing xattrs for directories.

      > On the client side, when requesting the buffer size for the list:
      > listxattr("foo", NULL, 0)               = 36 (bytes)

      > But when the list is actually read, it comes up short:
      > listxattr("foo", "trusted.link\0trusted.lma\0", 256) = 25 (bytes)

      > On the server side, on an ldiskfs mount, the results are more consistent.
      > listxattr("foo", NULL, 0)               = 25
      > listxattr("foo", "trusted.lma\0trusted.link\0", 256) = 25

      It seems like a bug in the following piece of code:

      ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)

               * If we're being called to get the size of the xattr list
               * (size == 0) then just assume that a lustre.lov xattr
               * exists.
              if (!size)
                      RETURN(rc + sizeof(XATTR_LUSTRE_LOV));

      This is true for regular files, but not directories (or at least not all
      of them).  As a starting point, something like the following should fix
      the immediate problem you see:

              if (!size)

      {                 rc += S_ISREG(inode->i_mode) ? sizeof(XATTR_LUSTRE_LOV) : 0;                 RETURN(rc);         }

      though it is still not wholly correct.  We should go through xattr_type_filter()
      in all cases, so that e.g. it filters out trusted.* xattrs for regular users.
      I guess it depends on whether one considers the returned buffer size "large
      enough to hold all xattrs", or "exactly the size of the returned xattrs".  The
      latter is definitely more forgiving and could be fixed immediately in your code,
      rather than depending on a fix to propagate into all of the installed Lustre
      systems you are running on.




            • Assignee:
              adilger Andreas Dilger
              kwebb Kristin Webb
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: