[LU-11107] getxattr() returns 0 length values for nonexistent xattrs (with xattr_cache=0) Created: 29/Jun/18  Updated: 03/Aug/18  Resolved: 24/Jul/18

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.12.0, Lustre 2.10.5

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: John Hammond
Resolution: Fixed Votes: 0
Labels: xattr

Issue Links:
Related
is related to LU-11074 Invalid argument reading file caps Resolved
Severity: 3
Rank (Obsolete): 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);


 Comments   
Comment by Gerrit Updater [ 02/Jul/18 ]

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

Comment by Gerrit Updater [ 24/Jul/18 ]

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

Comment by Peter Jones [ 24/Jul/18 ]

Landed for 2.12

Comment by Gerrit Updater [ 01/Aug/18 ]

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

Comment by Gerrit Updater [ 03/Aug/18 ]

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

Generated at Sat Feb 10 02:41:00 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.