[LU-12371] Odd behavior on lustre client listxattr for directories Created: 31/May/19 Updated: 07/Jan/22 Resolved: 12/Jun/19 |
|
| Status: | Resolved |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | Lustre 2.7.0, Lustre 2.10.8 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Kristin Webb | Assignee: | Andreas Dilger |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | easy | ||
| Environment: |
CentOS 6 & 7, Vmware workstation virtual machine test environement |
||
| Issue Links: |
|
||||
| Epic/Theme: | client | ||||
| Epic: | client | ||||
| Rank (Obsolete): | 9223372036854775807 | ||||
| Description |
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
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() |
| Comments |
| Comment by Andreas Dilger [ 11/Jun/19 ] |
|
Kristin, Also, while the likelihood is rare, it is possible for there to be a race condition between calling listxattr(list=NULL) to fetch the buffer size, and listxattr() with the allocated buffer to fetch the actual xattr names. This means that the list size may be larger or smaller than listxattr() originally reported, so it is safer to assume that the returned buffer size is a reasonable estimate, but have retry logic in the caller if an error is returned like ERANGE indicating the buffer is too small, and be accepting if the buffer is too large. |
| Comment by Kristin Webb [ 11/Jun/19 ] |
|
I agree. I also see the race condition between calls and that is something that software that manages/uses xattr's needs to be aware of. Thank you for taking a look into this. Do I need to do anything to close out the ticket? Kris |
| Comment by Gerrit Updater [ 01/Sep/20 ] |
|
Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/39791 |