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

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

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

            [LU-11107] getxattr() returns 0 length values for nonexistent xattrs (with xattr_cache=0)

            John L. Hammond (jhammond@whamcloud.com) merged in patch https://review.whamcloud.com/32910/
            Subject: LU-11107 mdt: handle nonexistent xattrs correctly
            Project: fs/lustre-release
            Branch: b2_10
            Current Patch Set:
            Commit: 0ae570b4dccc621c0c5fca9407dd053fc957cc1c

            gerrit Gerrit Updater added a comment - John L. Hammond (jhammond@whamcloud.com) merged in patch https://review.whamcloud.com/32910/ Subject: LU-11107 mdt: handle nonexistent xattrs correctly Project: fs/lustre-release Branch: b2_10 Current Patch Set: Commit: 0ae570b4dccc621c0c5fca9407dd053fc957cc1c

            Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/32910
            Subject: LU-11107 mdt: handle nonexistent xattrs correctly
            Project: fs/lustre-release
            Branch: b2_10
            Current Patch Set: 1
            Commit: 52ef02bc1f821e0edf7d50e1d51aea1c232d7e21

            gerrit Gerrit Updater added a comment - Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/32910 Subject: LU-11107 mdt: handle nonexistent xattrs correctly Project: fs/lustre-release Branch: b2_10 Current Patch Set: 1 Commit: 52ef02bc1f821e0edf7d50e1d51aea1c232d7e21
            pjones Peter Jones added a comment -

            Landed for 2.12

            pjones Peter Jones added a comment - Landed for 2.12

            Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/32753/
            Subject: LU-11107 mdt: handle nonexistent xattrs correctly
            Project: fs/lustre-release
            Branch: master
            Current Patch Set:
            Commit: 39c7ac4c0dce3c62795814cd12a78bec1877520b

            gerrit Gerrit Updater added a comment - Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/32753/ Subject: LU-11107 mdt: handle nonexistent xattrs correctly Project: fs/lustre-release Branch: master Current Patch Set: Commit: 39c7ac4c0dce3c62795814cd12a78bec1877520b

            John L. Hammond (jhammond@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/32753
            Subject: LU-11107 mdt: handle nonexistent xattrs correctly
            Project: fs/lustre-release
            Branch: master
            Current Patch Set: 1
            Commit: b927ed32003a2571e992ea681f4b8615c2b447a5

            gerrit Gerrit Updater added a comment - John L. Hammond (jhammond@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/32753 Subject: LU-11107 mdt: handle nonexistent xattrs correctly Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: b927ed32003a2571e992ea681f4b8615c2b447a5

            People

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

              Dates

                Created:
                Updated:
                Resolved: