Skip to content

cephfs: Introduce xattr to get and set alternate_name - #71881

Merged
vshankar merged 21 commits into
ceph:mainfrom
chrisphoffman:wip-79375
Nov 6, 2026
Merged

vshankar merged 21 commits into
ceph:mainfrom
chrisphoffman:wip-79375

Conversation

@chrisphoffman

@chrisphoffman chrisphoffman commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Add extended attribute "ceph.alternate_name" to get and set dentry alternate_name field.

What's left:

  • Document usage
  • Integration test to validate backup capability

Special 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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

Copy link
Copy Markdown

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.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@chrisphoffman

Copy link
Copy Markdown
Contributor Author

@chrisphoffman
chrisphoffman force-pushed the wip-79375 branch 2 times, most recently from 54303e0 to f871556 Compare October 6, 2026 19:07
@vshankar

vshankar commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

jenkins retest this please

Comment thread src/mds/Server.cc Resolved
Comment thread src/mds/Server.cc Resolved
Comment thread src/mds/Server.cc Resolved
@chrisphoffman

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@@ -646,3 +646,13 @@ options:
- mds_client
flags:
- runtime
- name: client_alternate_name_visible

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be a runtime flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/mds/Server.cc Outdated
if (!mds->locker->acquire_locks(mdr, lov))
return;

if (req->get_alternate_name().size() > alternate_name_max) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you are right, thanks! Done

Comment thread src/mds/Server.cc
}

if (!dn)
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request needs to be completed here, else the request remains hung.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/client/Client.h Outdated
/* Flags for VXattr */
static const unsigned VXATTR_RSTAT = 0x1;
static const unsigned VXATTR_DIRSTAT = 0x2;
static const unsigned VXATTR_ALTNAME = 0x3;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread src/client/Client.cc Outdated

bool Client::_vxattrcb_alternate_name_exists(Inode *in)
{
auto alternate_name = in->get_first_parent()->alternate_name.c_str();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, done.

Comment thread src/mds/Server.cc
if (!mdr->dn[0].empty()) {
dn = mdr->dn[0].back();
} else {
dn = cur->get_projected_parent_dn();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/client/Client.cc

if (fscrypt_options.fscrypt_auth.size())
req->fscrypt_auth = fscrypt_options.fscrypt_auth;
if (!alternate_name_visible) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

ceph_shutdown(cmount);
}

TEST(LibCephFS, AlternateName) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides restarting mds, this is done. I ran out of time today and haven't worked it out yet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the test to respawn as requested. I borrowed mds command from how @dparmar18 did it in reclaim tests.

Comment thread qa/tasks/cephfs/mount.py Outdated
continue
os.setxattr(cur_dst_path, xattr, value)
except OSError:
pass

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This swallows the exception -- does a failed alternate_name set silently would make the test pass?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chrisphoffman
chrisphoffman force-pushed the wip-79375 branch 2 times, most recently from c4709d4 to 877a3dc Compare October 26, 2026 20:45
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]>
@chrisphoffman

Copy link
Copy Markdown
Contributor Author

/config check ok

@chrisphoffman

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@chrisphoffman

Copy link
Copy Markdown
Contributor Author

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]>
@vshankar

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by vshankar started 2026-10-31-06:57.

@vshankar
vshankar requested a review from kotreshhr November 3, 2026 05:38
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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cephfs.pyx does support fcopyfile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, We should fix this up as a follow up to call fcopyfile() python binding.

@vshankar

vshankar commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

jenkins retest this please

@chrisphoffman

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vshankar
vshankar merged commit bfdca23 into ceph:main Nov 6, 2026
17 checks passed
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I found one or more Fixes: tags in the commit messages in

git log bfdca235443e37988d65d27618c170b408cd4966^..bfdca235443e37988d65d27618c170b408cd4966

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.

Update Log: https://github.com/ceph/ceph/actions/runs/42166446535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants