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

getxattr() returns 0 length values for nonexistent xattrs (with xattr_cache=0)

    XMLWordPrintable

Details

    • 3
    • 9223372036854775807

    Description

      When the xattr cache is disabled (or when we bypass it as in LU-11074), getxattr() will return a zero length value for any nonexistent attribute:

      o:~# lctl set_param llite.*.xattr_cache=0
      llite.lustre-ffff8c4ac8a60000.xattr_cache=0
      o:~# cd /mnt/lustre
      o:lustre# touch f0
      o:lustre# getfattr -d -m- f0
      # file: f0
      lustre.lov=0s0AvRCwEAAAABAAAAAAAAAAEEAAACAAAAAAAQAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
      trusted.link=0s3/HqEQEAAAAsAAAAAAAAAAAAAAAAAAAAABQAAAACAAAABwAAAAEAAAAAZjA=
      trusted.lma=0sAAAAAAAAAAABBAAAAgAAAAEAAAAAAAAA
      trusted.lov=0s0AvRCwEAAAABAAAAAAAAAAEEAAACAAAAAAAQAAEAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
      trusted.version=0sAQAAAAEAAAA=
      
      o:lustre# getfattr -d -n user.blah f0
      # file: f0
      user.blah
      
      o:lustre# strace getfattr -d -n user.blah f0
      ...
      lstat("f0", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
      getxattr("f0", "user.blah", NULL, 0)    = 0
      getxattr("f0", "user.blah", NULL, 0)    = 0
      ...
      

      After reenabling the xattr cache getxattr() works as expected:

      o:lustre# lctl set_param llite.*.xattr_cache=1
      llite.lustre-ffff8c4ac8a60000.xattr_cache=1
      o:lustre# getfattr -d -n user.blah f0
      f0: user.blah: No such attribute
      

      This is because in mdt_getxattr_pack_reply() if the xattr doesn't exist then we return 0. And in mdt_getxattr() we have the following:

              easize = mdt_getxattr_pack_reply(info);
              if (easize < 0)
                      GOTO(out, rc = err_serious(easize));
      
              repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
              LASSERT(repbody != NULL);
      
              /* No need further getxattr. */
              if (easize == 0 || reqbody->mbo_eadatasize == 0)
                      GOTO(out, rc = easize);
      

      Attachments

        Issue Links

          Activity

            People

              jhammond John Hammond
              jhammond John Hammond
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: