Repository navigation
cephfs: Introduce xattr to get and set alternate_name - #71881
Conversation
Config Diff Tool Output+ added: client_alternate_name_visible (mds-client.yaml.in)
The above configuration changes are found in the PR. Please update the relevant release documentation if necessary. |
f4d08a5 to
9eb0fbf
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
I ran a prelim test run to shake out any obvious issues: https://pulpito.ceph.com/choffman-2026-10-02_13:28:39-fs-wip-choffman-79375-distro-default-trial/ . The run looks OK to me |
54303e0 to
f871556
Compare
|
jenkins retest this please |
f871556 to
fc140b0
Compare
fc140b0 to
4cb95d9
Compare
|
jenkins test make check |
4cb95d9 to
1a0b12e
Compare
| @@ -646,3 +646,13 @@ options: | |||
| - mds_client | |||
| flags: | |||
| - runtime | |||
| - name: client_alternate_name_visible | |||
There was a problem hiding this comment.
nit: should be a runtime flag.
| if (!mds->locker->acquire_locks(mdr, lov)) | ||
| return; | ||
|
|
||
| if (req->get_alternate_name().size() > alternate_name_max) { |
There was a problem hiding this comment.
nit: shouldn't this be value.size() > alternate_name_max ?
create, mkdir, and rename fill that and then store it, but this is a vxattr request.
There was a problem hiding this comment.
Yeah you are right, thanks! Done
| } | ||
|
|
||
| if (!dn) | ||
| return; |
There was a problem hiding this comment.
The request needs to be completed here, else the request remains hung.
| /* Flags for VXattr */ | ||
| static const unsigned VXATTR_RSTAT = 0x1; | ||
| static const unsigned VXATTR_DIRSTAT = 0x2; | ||
| static const unsigned VXATTR_ALTNAME = 0x3; |
There was a problem hiding this comment.
VXATTR_ALTNAME is 0x3, which is XATTR_CREATE | XATTR_REPLACE. _do_setxattr uses this same flags word for both, so any setxattr with XATTR_CREATE (0x1) or XATTR_REPLACE (0x2) takes the alternate-name path and pins get_first_parent() instead of the inode. Passing VXATTR_ALTNAME itself also sets both CEPH_XATTR_CREATE and CEPH_XATTR_REPLACE.
VXATTR_RSTAT is 0x1 and VXATTR_DIRSTAT is 0x2. Make this 0x4.
There was a problem hiding this comment.
Done. It still feels a bit weird how it is defined (next to flags that we only use in get, but this one is used in set)
|
|
||
| bool Client::_vxattrcb_alternate_name_exists(Inode *in) | ||
| { | ||
| auto alternate_name = in->get_first_parent()->alternate_name.c_str(); |
There was a problem hiding this comment.
exists_cb uses alternate_name.c_str() as a presence check. c_str() never returns null, so an empty name is still true. With client_alternate_name_visible on and client_fscrypt_as off, getxattr("ceph.alternate_name") returns 0 instead of -ENODATA for a short fscrypt name.
Check the string, as ceph.fscrypt.auth does: !in->get_first_parent()->alternate_name.empty().
There was a problem hiding this comment.
Nice catch, done.
| if (!mdr->dn[0].empty()) { | ||
| dn = mdr->dn[0].back(); | ||
| } else { | ||
| dn = cur->get_projected_parent_dn(); |
There was a problem hiding this comment.
I think the vxattr set call here arrives with an empty mds->dn[0], so this is going to choose the first (primary?) link, on which the xattr set would happen.
I think setxattr() for this vxattr, the client has to send the parent directory and the dentry name. Same for getxattr() I suppose.
There was a problem hiding this comment.
And since we reach here after try_get_auth_inode(), this will run on the inode auth and not the dentry auth (e.g., hardlink case). Then journal_cow_dentry() could assert as per:
void MDCache::journal_cow_dentry(MutationImpl *mut, EMetaBlob *metablob,
CDentry *dn, snapid_t follows,
CInode **pcow_inode, CDentry::linkage_t *dnl)
{
if (!dn) {
dout(10) << "journal_cow_dentry got null CDentry, returning" << dendl;
return;
}
dout(10) << "journal_cow_dentry follows " << follows << " on " << *dn << dendl;
ceph_assert(dn->is_auth()); <<< HERE
This should be easy to reproduce and validate (once fixed) with the hardlink on different rank than the primary.
There was a problem hiding this comment.
Hmm, I'm having issues reproducing this, here's what I did
I set max_mds to 2
./bin/ceph fs set a max_mds 2
then on ceph-fuse mount
mkdir -p a/b
setfattr -n ceph.dir.pin -v 0 a/b
setfattr -n ceph.dir.pin -v 1 a/
touch a/file
ln a/file a/b/filea
setfattr -n ceph.alternate_name -v `openssl rand -hex 12800 | head -c 256; echo` a/b/filea
Then I checked mds logs and no assert was hit.
./bin/ceph fs status
a - 1 clients
=
RANK STATE MDS ACTIVITY DNS INOS DIRS CAPS
0 active a Reqs: 0 /s 22 23 18 7
1 active c Reqs: 0 /s 17 19 17 3
POOL TYPE USED AVAIL
cephfs.a.meta metadata 1597k 164G
cephfs.a.data data 0 164G
I'm probably misunderstanding what to do here, can you help me out?
There was a problem hiding this comment.
No, you did not misunderstand. My comment was a bit vague. Short story -- the MDS does not hit the assert -- I incorrectly thought it would when the vxattr request is sent to the auth MDS for the inode. The MDS picks up the primary dentry linkage (not the linkage of the path for which the alternate_name update is being performed). This auth for this dentry is the (same) MDS that is handling the vxattr request, so the dn->is_auth() assert journal_cow_dentry() would be valid.
The bug however is that the MDS would end up updating the alternate_name for the incorrect dentry.
There was a problem hiding this comment.
I think obtaining dn from mdr was misleading in this case.
Consider this flow:
A client request comes in handle_client_request with payload in MClientRequest.
Then a mdr is constructed via mdcache::request_start. Inside this, it does not populate mdr->dn.
I see other places where mdr->dn is used with rdlock_path_xlock_dentry, where that does populate the dn. AFAICT, it's not proper to use this in this case.
I've updated with the comment for dn and dname, but from what I can tell it should be ok. Can you take a look and see if my reasoning is fine? If so I'll go ahead and remove the existing lookup in Server.cc
|
|
||
| if (fscrypt_options.fscrypt_auth.size()) | ||
| req->fscrypt_auth = fscrypt_options.fscrypt_auth; | ||
| if (!alternate_name_visible) { |
There was a problem hiding this comment.
This block has missing req->set_alternate_name() which in L16508 get unconditionally set:
req->set_alternate_name(alternate_name.empty() ? wdr.alternate_name : alternate_name);
| ceph_shutdown(cmount); | ||
| } | ||
|
|
||
| TEST(LibCephFS, AlternateName) { |
There was a problem hiding this comment.
This test should cover the following:
- memcmp the buffer against "foo".
- Setting "foo" again returns 0.
- Setting a different value returns -EPERM.
- ceph_fremovexattr returns -EINVAL, and the following get still returns "foo".
- Before the first set, getxattr returns -ENODATA.
Additionally, restart the MDS before the second get so replay of the empty-to-non-empty alternate_name is actually exercised.
There was a problem hiding this comment.
Besides restarting mds, this is done. I ran out of time today and haven't worked it out yet
There was a problem hiding this comment.
I've updated the test to respawn as requested. I borrowed mds command from how @dparmar18 did it in reclaim tests.
| continue | ||
| os.setxattr(cur_dst_path, xattr, value) | ||
| except OSError: | ||
| pass |
There was a problem hiding this comment.
This swallows the exception -- does a failed alternate_name set silently would make the test pass?
There was a problem hiding this comment.
Yeah, I figured the compare tree would catch anything missing. I reworked this section to make it fail earlier to be clearer. Take a look
| self.mount_a.remount() | ||
| self.mount_a.run_shell_payload(f"sudo fscrypt unlock --verbose --key=/tmp/key_volume {src_path}") | ||
| for i in range(num_of_files): | ||
| self.mount_a.compare_trees(f"{src_path}/{i}", f"{dst_path}/{i}") |
There was a problem hiding this comment.
There was a problem hiding this comment.
Yikes, existing tests at the time on my dev box passed and compared but somewhere switching it to a remote call it got messed up and silently missed.
Signed-off-by: Christopher Hoffman <[email protected]>
c4709d4 to
877a3dc
Compare
Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Christopher Hoffman <[email protected]>
Add guardrails to client and mds to ensure get and set of alternate_name is done correctly to minimize users clobbering things. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Christopher Hoffman <[email protected]>
As inode-only calls to getxattr ceph.alternate_name that reference hardlinks do not provide path, we cannot with certainty return alternate name if there are multiple dentries when calling. This action will be not supported. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Christopher Hoffman <[email protected]>
6bc8dff to
dc8cf2b
Compare
|
/config check ok |
|
jenkins test make check |
|
jenkins test api |
In order to get or set ceph.alternate_name a dentry is needed. Since callbacks do not have this parameter use separate methods instead. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Christopher Hoffman <[email protected]>
984857a to
d3051cf
Compare
|
This PR has been added to main integration testing by vshankar started 2026-10-31-06:57. |
The kernel client returns EOPNOTSUPP for setxattr of ceph.fscrypt.auth, so the backup copy cannot run there. Schedule that test on ceph-fuse only. The copied tree has no hardlinks because fuse getxattr is inode-based. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Venky Shankar <[email protected]>
TestFSCryptBackup runs alone, so nothing has created /etc/fscrypt.conf yet. fscrypt setup of the mount reads that file. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Venky Shankar <[email protected]>
Subvolume clone reads and writes the stored ciphertext. Creating the destination minted a new nonce, so a keyed client decrypted those bytes into garbage. Copy ceph.fscrypt.auth, ceph.fscrypt.file, and ceph.alternate_name from the source. A locked tree compare cannot open file contents, so it checks names, sizes, and symlink targets only. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Venky Shankar <[email protected]>
The exclusive-cap path dirtied FILE_EXCL but still sent SETATTR. A subvolume clone hit that after writing ciphertext and before fsync, so the MDS had to xlock filelock while the request could not release the dirty buffer cap. Record the value and publish it with the cap flush. Fixes: https://tracker.ceph.com/issues/79375 Signed-off-by: Venky Shankar <[email protected]>
Drop the distro stock kernel facet so kclient jobs run on the ceph-client testing branch. Rocky kclient jobs are still rejected there; fuse coverage is unchanged. Signed-off-by: Venky Shankar <[email protected]>
| data = fs.read(src_file_fd, -1, 1 * 1024 * 1024) | ||
| if not len(data): | ||
| break | ||
| while True: |
There was a problem hiding this comment.
cephfs.pyx does support fcopyfile
There was a problem hiding this comment.
yes, We should fix this up as a follow up to call fcopyfile() python binding.
|
jenkins retest this please |
|
jenkins test make check arm64 |
|
This is an automated message by src/script/redmine-upkeep.py. I found one or more
The referenced tickets are:
Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them. |
Add extended attribute "ceph.alternate_name" to get and set dentry alternate_name field.
What's left:
Document usageIntegration test to validate backup capabilitySpecial note to reviewers: Please take a close look at the mds side, I had a bit of trouble with asserts/versioning. Things appear to work fine, but there may be more work to do.
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionje nkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.