Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curvefs: fix list xattr miss someone #2940

Open
wants to merge 1 commit into
base: release2.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions curvefs/src/client/fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,13 @@ CURVEFS_ERROR FuseClient::FuseOpListXattr(fuse_req_t req, fuse_ino_t ino,
// +1 because, the format is key\0key\0
*realSize += it.first.length() + 1;
}
// add summary xattr key
if (inodeAttr.type() == FsFileType::TYPE_DIRECTORY) {
*realSize += strlen(XATTR_DIR_RFILES) + 1;
*realSize += strlen(XATTR_DIR_RSUBDIRS) + 1;
*realSize += strlen(XATTR_DIR_RENTRIES) + 1;
*realSize += strlen(XATTR_DIR_RFBYTES) + 1;
}

if (size == 0) {
return CURVEFS_ERROR::OK;
Expand All @@ -1188,6 +1195,16 @@ CURVEFS_ERROR FuseClient::FuseOpListXattr(fuse_req_t req, fuse_ino_t ino,
memcpy(value, it.first.c_str(), tsize);
value += tsize;
}
if (inodeAttr.type() == FsFileType::TYPE_DIRECTORY) {
memcpy(value, XATTR_DIR_RFILES, strlen(XATTR_DIR_RFILES) + 1);
value += strlen(XATTR_DIR_RFILES) + 1;
memcpy(value, XATTR_DIR_RSUBDIRS, strlen(XATTR_DIR_RSUBDIRS) + 1);
value += strlen(XATTR_DIR_RSUBDIRS) + 1;
memcpy(value, XATTR_DIR_RENTRIES, strlen(XATTR_DIR_RENTRIES) + 1);
value += strlen(XATTR_DIR_RENTRIES) + 1;
memcpy(value, XATTR_DIR_RFBYTES, strlen(XATTR_DIR_RFBYTES) + 1);
value += strlen(XATTR_DIR_RFBYTES) + 1;
}
return CURVEFS_ERROR::OK;
}
return CURVEFS_ERROR::OUT_OF_RANGE;
Expand Down
5 changes: 4 additions & 1 deletion curvefs/test/client/test_fuse_s3_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4069,7 +4069,10 @@ TEST_F(TestFuseS3Client, FuseOpListXattr) {
.WillOnce(DoAll(SetArgPointee<1>(inode), Return(CURVEFS_ERROR::OK)));
ret = client_->FuseOpListXattr(req, ino, buf, size, &realSize);
ASSERT_EQ(CURVEFS_ERROR::OK, ret);
auto expected = key.length() + 1;
auto expected = key.length() + 1 + strlen(XATTR_DIR_RFILES) + 1 +
strlen(XATTR_DIR_RSUBDIRS) + 1 +
strlen(XATTR_DIR_RENTRIES) + 1 +
strlen(XATTR_DIR_RFBYTES) + 1;
ASSERT_EQ(realSize, expected);

realSize = 0;
Expand Down