Skip to content

mds: Implement remove for ceph vxattrs #53755

Merged
vshankar merged 5 commits intoceph:mainfrom
chrisphoffman:wip-62793
Jun 27, 2024
Merged

mds: Implement remove for ceph vxattrs #53755
vshankar merged 5 commits intoceph:mainfrom
chrisphoffman:wip-62793

Conversation

@chrisphoffman
Copy link
Contributor

@chrisphoffman chrisphoffman commented Oct 2, 2023

For a variety of ceph xattrs, the setfattr remove
isn't handled and "No such attribute" is returned.

Add support to remove xattrs to match where docs
say to clear value, one can remove or set to X value.
When removing, add "default" value back to xattr depending
on xattr name.

Fixes: https://tracker.ceph.com/issues/62793
Signed-off-by: Christopher Hoffman choffman@redhat.com

Contribution Guidelines

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@github-actions github-actions bot added cephfs Ceph File System tests labels Oct 2, 2023
@chrisphoffman chrisphoffman requested a review from a team October 2, 2023 18:48
@chrisphoffman
Copy link
Contributor Author

In some kernels on test machines, vxattrs getxattr isn't supported. I've added a TODO, to uncomment getfattrs for failing xattrs when they are supported.

Here's the failure:
http://qa-proxy.ceph.com/teuthology/choffman-2023-09-29_15:56:41-fs:workload-wip-choffman-62793-distro-default-smithi/7406444/teuthology.log

Here's a working run with latest version (failure unrelated to test):
http://qa-proxy.ceph.com/teuthology/choffman-2023-10-02_17:48:08-fs:workload-wip-choffman-62793-distro-default-smithi/7408606/teuthology.log

@dparmar18
Copy link
Contributor

@chrisphoffman just a quick question, what about not providing any values with setfattr -n, will it set it to 0 in that case?

@chrisphoffman
Copy link
Contributor Author

chrisphoffman commented Oct 3, 2023

@chrisphoffman just a quick question, what about not providing any values with setfattr -n, will it set it to 0 in that case?

Yes in that case, it will set to default value. I provided a value because I wanted to test the value changing from something back to default. Are you suggesting something different?

@dparmar18
Copy link
Contributor

@chrisphoffman just a quick question, what about not providing any values with setfattr -n, will it set it to 0 in that case?

Yes in that case, it will set to default value. I provided a value because I wanted to test the value changing from something back to default. Are you suggesting something different?

So something like setfattr -n ceph.dir.pin foo would work and set it's value to -1, i'm not sure about the correctness but from user's perspective it looks like a bug where without providing any value it sets a value. General sense is that whatever sets something must accept something right and this although might not be that problematic if we mention this somewhere in our docs as a note but this will surely create some doubt in user's mind in first glance.

What i'm thinking is to only accept no values as valid arg only in case for removal of vxattr. So check if the client req is to set or remove the vxattr by looking at request's head op. Something like this

      if (value.length() == 0 && req->get_op() == CEPH_MDS_OP_RMXATTR) {
        value = "<reset_value>";
      }

So now we have the expected behaviour:

$ setfattr -n ceph.dir.pin -v 2 mnt/foo/
$ getfattr -n ceph.dir.pin mnt/foo/
# file: mnt/foo/
ceph.dir.pin="2"

$ setfattr -n ceph.dir.pin mnt/foo/
setfattr: mnt/foo/: Invalid argument
$ getfattr -n ceph.dir.pin mnt/foo/
# file: mnt/foo/
ceph.dir.pin="2"

$ setfattr -x ceph.dir.pin mnt/foo/
$ getfattr -n ceph.dir.pin mnt/foo/
# file: mnt/foo/
ceph.dir.pin="-1"

|| name == "ceph.dir.pin.distributed"
|| name == "ceph.dir.pin.random"
|| name == "ceph.dir.subvolume") {
handle_set_vxattr(mdr, cur);
Copy link
Member

Choose a reason for hiding this comment

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

It seems the comment above this if block is no longer correct. How about we change the code to:

if (name.find("ceph.") == 0) {
  if (req->get_data().length()) {
     respond_to_request(mdr, -CEPHFS_EINVAL);
     return;
  }
  handle_set_vxattr(mdr, cur);
}

Copy link
Member

Choose a reason for hiding this comment

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

Fix all vxattrs that should not allow removal to reject the RPC (EINVAL).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That works for me. Thanks for the suggestion!

Copy link
Member

Choose a reason for hiding this comment

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

@chrisphoffman don't forget:

Fix all vxattrs that should not allow removal to reject the RPC (EINVAL).

Include in your test that setfattr -x ceph.X <path>. fails for vxattrs where removal makes no sense. I think ceph.quota is another example of a vxattr which should support rmxattr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took a while to unpack all of this. I did an audit of all xattrs handled. All ceph.* xattrs should either reset to def value, or reject for xattrs that shouldn't be removed (my judgement). If neither case, it is unknown xattr and will reject again with EINVAL.


bool val;
try {
if (value.length() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

For readability, put at the start of this method:

bool is_rmxattr = (value.length() == 0);

Then use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up using bool is_rmxattr = (req->get_op() == CEPH_MDS_OP_RMXATTR); instead. That way seemed more straight forward.

|| name == "ceph.dir.pin.distributed"
|| name == "ceph.dir.pin.random"
|| name == "ceph.dir.subvolume") {
handle_set_vxattr(mdr, cur);
Copy link
Member

Choose a reason for hiding this comment

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

@chrisphoffman don't forget:

Fix all vxattrs that should not allow removal to reject the RPC (EINVAL).

Include in your test that setfattr -x ceph.X <path>. fails for vxattrs where removal makes no sense. I think ceph.quota is another example of a vxattr which should support rmxattr.

@github-actions
Copy link

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

@chrisphoffman
Copy link
Contributor Author

chrisphoffman commented Oct 10, 2023

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

Somehow extra commits got into the push and triggered this message. I removed the label and repushed as I don't believe there are any conflicts.

running ``getfattr /some/dir -n ceph.<some-xattr>``.

To remove a quota, set the value of extended attribute to ``0``::
To remove a quota, remove the respective extended attribute or set the value to ``0``::
Copy link
Contributor

Choose a reason for hiding this comment

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

i know it's quite trivial but how about adding example illustrating removal using setfattr -x, maybe helpful for naive users i guess and also the reason that we illustrate setting val to 0; this might be a good addition

#ceph.quota, def value 0, reset val 0
setfattr -n ceph.quota.max_bytes -v 100000000 dir
setfattr -n ceph.quota.max_files -v 10000 dir
setfattr -x ceph.quota.max_bytes dir
setfattr -x ceph.quota.max_files dir
Copy link
Contributor

@dparmar18 dparmar18 Oct 10, 2023

Choose a reason for hiding this comment

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

we should check for the change using getfattr here, or maybe add a comment for now since you've mentioned the test machines don't support it yet?

vshankar added a commit to vshankar/ceph that referenced this pull request May 9, 2024
* refs/pull/53755/head:
	PendingReleaseNotes: add note about CephFS set_vxattrs
	doc/cephfs: Update docs to match remove functionality and respective vxattrs
	qa: Add test coverage for vxattr behavior
	qa: Add removexattr to support setfattr removal.
	mds: Implement remove for ceph vxattrs

Reviewed-by: Dhairya Parmar <dparmar@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

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

PTAL at the failure @chrisphoffman

For a variety of ceph xattrs, the setfattr remove
isn't handled and "No such attribute" is returned.

Add support to remove xattrs to match where docs
say to clear value, one can remove or set to X value.
When removing, add "default" value back to xattr depending
on xattr name.

Simplify current code to make clearer and minimize code reuse.

Fixes: https://tracker.ceph.com/issues/62793
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
Add tests to validate default and remove xattr behaviors.

Signed-off-by: Christopher Hoffman <choffman@redhat.com>
…vxattrs

Signed-off-by: Christopher Hoffman <choffman@redhat.com>
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
@vshankar
Copy link
Contributor

vshankar commented Jun 3, 2024

jenkins retest this please

@vshankar
Copy link
Contributor

vshankar commented Jun 3, 2024

This PR is under test in https://tracker.ceph.com/issues/66327.

@chrisphoffman
Copy link
Contributor Author

jenkins test windows

@chrisphoffman
Copy link
Contributor Author

jenkins render docs

@chrisphoffman
Copy link
Contributor Author

jenkins test api

@chrisphoffman
Copy link
Contributor Author

jenkins test make check

1 similar comment
@chrisphoffman
Copy link
Contributor Author

jenkins test make check

@chrisphoffman
Copy link
Contributor Author

jenkins test docs

@vshankar
Copy link
Contributor

This PR is under test in https://tracker.ceph.com/issues/66522.

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

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

@chrisphoffman
Copy link
Contributor Author

jenkins retest this please

@vshankar
Copy link
Contributor

jenkins test api

1 similar comment
@chrisphoffman
Copy link
Contributor Author

jenkins test api

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.

6 participants