Skip to content

mds,client: add new getvxattr op#42001

Merged
vshankar merged 5 commits intoceph:masterfrom
mchangir:mds-implement-new-getvxattr-rpc
Mar 7, 2022
Merged

mds,client: add new getvxattr op#42001
vshankar merged 5 commits intoceph:masterfrom
mchangir:mds-implement-new-getvxattr-rpc

Conversation

@mchangir
Copy link
Copy Markdown
Contributor

This new op fetches ceph namespace specific extended attributes
i.e. attributes that start with "ceph."

Fixes: https://tracker.ceph.com/issues/51062
Signed-off-by: Milind Changire mchangir@redhat.com

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

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 api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@mchangir mchangir requested a review from batrick June 24, 2021 04:20
@github-actions github-actions bot added the cephfs Ceph File System label Jun 24, 2021
@mchangir mchangir added the DNM label Jun 24, 2021
@mchangir mchangir requested a review from vshankar June 24, 2021 10:52
@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 1066508 to 9ffde77 Compare June 25, 2021 12:41
int r = 0;
ceph::bufferlist bl;
if (name == "ceph.dir.layout"sv) {
cur->get_inode()->layout.encode(bl, (uint64_t)-1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since these values should eventually be returned from the syscall, I think a text string makes sense. The client/kclient should not need to interpret (i.e. decode) these.

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.

as per the discussion, I'm keeping the code to fetch individual layout fields in binary form rather than the proposed text form
this avoids the string parsing hassles on the client side as well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Coming back to this: I'm not sure what the point is of binary encoding anything for getvxattr. The client (kernel or Client) does not need any of these vxattrs to function. If the client does need a vxattr, it should be encoded and sent to the client with caps (like file layouts). So I'm not seeing a use-case to binary encode these values for any kind of convenience for the client. I would suggest JSON encoding the values and let the client pass it unmodified to the application/syscall.

@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch 4 times, most recently from 0192e45 to 12f59e1 Compare July 1, 2021 14:08
int r = 0;
ceph::bufferlist bl;
if (name == "ceph.dir.layout"sv) {
cur->get_inode()->layout.encode(bl, (uint64_t)-1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Coming back to this: I'm not sure what the point is of binary encoding anything for getvxattr. The client (kernel or Client) does not need any of these vxattrs to function. If the client does need a vxattr, it should be encoded and sent to the client with caps (like file layouts). So I'm not seeing a use-case to binary encode these values for any kind of convenience for the client. I would suggest JSON encoding the values and let the client pass it unmodified to the application/syscall.

@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 12f59e1 to 922d846 Compare July 26, 2021 06:09
Copy link
Copy Markdown
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

Please change commit title to: mds,client: add new getvxattr op. It would probably be better to separate them too.

Add unit tests in src/test/libcephfs/

@mchangir mchangir changed the title mds/{client,server}: add new getvxattr op mds: add new getvxattr op Sep 20, 2021
@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 922d846 to 2aecaca Compare October 18, 2021 16:06
@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch 3 times, most recently from fff9d11 to a064f23 Compare October 18, 2021 18:00
@batrick
Copy link
Copy Markdown
Member

batrick commented Oct 19, 2021

@mchangir let me know (here) when this is ready for review

@mchangir mchangir marked this pull request as ready for review October 19, 2021 03:04
@mchangir
Copy link
Copy Markdown
Contributor Author

@mchangir let me know (here) when this is ready for review

@batrick mostly ready, please review

int r = ceph_getxattr(cmount, "test/d0", "ceph.dir.layout", (void*)value, sizeof(value));
value[r] = '\0';
ASSERT_GT(r, 0);
ASSERT_STRNE((char*)NULL, strstr(value, "\"inheritance\": \"@default\""));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Break these into separate unit tests with different names please. A unit test should be as small and specific as possible. Otherwise, it makes the mental tracking of side-effects difficult to achieve by both the test author and future code-readers.

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.

@batrick let me know if you need me to break the tests even further

@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from a064f23 to 2da8424 Compare November 9, 2021 10:38
@vshankar
Copy link
Copy Markdown
Contributor

jenkins test make check

Copy link
Copy Markdown
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.

@mchangir the added changes have weird indentation. That needs fixing too.

@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 2da8424 to 90273d1 Compare November 18, 2021 08:51
memcpy(value, buf.c_str(), len);
}
}
res = len;
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.

if size = 0, then we return 'len', is that what we want?

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.

we do need to return len if output buffer size is passed as 0
I've rearranged the code a bit; please take a look

@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 90273d1 to aeff6e6 Compare November 25, 2021 08:44
@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 86c7f4a to 16d1300 Compare January 27, 2022 16:07
Copy link
Copy Markdown
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

Well done! I think documentation is the last piece before this is ready for general QA.

@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from 16d1300 to ff704d0 Compare February 7, 2022 08:48
@mchangir mchangir requested a review from a team as a code owner February 7, 2022 11:13
@mchangir
Copy link
Copy Markdown
Contributor Author

mchangir commented Feb 8, 2022

jenkins test api

@mchangir
Copy link
Copy Markdown
Contributor Author

mchangir commented Feb 8, 2022

Teuthology run for fs:libcephfs.

vshankar added a commit to vshankar/ceph that referenced this pull request Feb 10, 2022
Server::handle_client_request() ignores unknown client operation
by returning -ENOTSUPP, however, Server::perf_gather_op_latency()
aborts on unknown client op, thereby causing -ENOTSUPP to never
reach the client. ceph_abort() seems unnecessary here.

Note, we could have invoked Server::perf_gather_op_latency()
when the return value to client is not -ENOTSUPP, however,
a valid client operation *might* just return -ENOTSUPP in
some cases.

@mchangir ran into this with his getvxattr op changes (PR ceph#42001).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 2f4060b)
vshankar added a commit to vshankar/ceph that referenced this pull request Feb 10, 2022
Server::handle_client_request() ignores unknown client operation
by returning -ENOTSUPP, however, Server::perf_gather_op_latency()
aborts on unknown client op, thereby causing -ENOTSUPP to never
reach the client. ceph_abort() seems unnecessary here.

Note, we could have invoked Server::perf_gather_op_latency()
when the return value to client is not -ENOTSUPP, however,
a valid client operation *might* just return -ENOTSUPP in
some cases.

@mchangir ran into this with his getvxattr op changes (PR ceph#42001).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 2f4060b)
This new op fetches ceph namespace specific extended attributes
i.e. attributes  "ceph.dir.layout.json", "ceph.file.layout.json"
and "ceph.dir.pin*"

For layout attributes, value of the .json xattrs provide the
following features:
1. output in json format
2. resolves layout from the most closest ancestor inode, starting
   at self
3. adds an 'inheritance' field to show the layout inheritance
   where:
       @default - implies default system-wide layout
       @inherited - implies layout has been inherited from an ancestor
       @set - implies layout has been set for that specific inode
4. adds two fields: pool_name and pool_id to differentiate between
   the two values; especially for the situations where users have
   chosen to use purely digit sequences to name pools; since pool_id
   is system generated and its output is a decimal number as well,
   users cannot distinguish the value in the field named 'pool'

Fixes: https://tracker.ceph.com/issues/51062
Signed-off-by: Milind Changire <mchangir@redhat.com>
This new op fetches ceph namespace specific extended attributes
i.e. attributes
1. ceph.dir.layout.json and ceph.file.layout.json
2. ceph.dir.layout.pool_name and ceph.file.layout.pool_name
3. ceph.dir.layout.pool_id and ceph.file.layout.pool_id
4. ceph.dir.pin, ceph.dir.pin.random and ceph.dir.pin.distributed

Fixes: https://tracker.ceph.com/issues/51062
Signed-off-by: Milind Changire <mchangir@redhat.com>
Setting the entire layout via setfattr -n ceph.dir.layout.json
requires a json value with the name of all mandatory fields as
returned by getfattr, except 'inheritance'.
Also, the json format expects a 'pool_name' or 'pool_id'.
If both are specified, the 'pool_name' is given priority over
'pool_id' for better disambiguation.

ceph.(dir|file).layout.pool_name and ceph.(dir|file).layout.pool_id
can also be set and fetched as individual fields.

Fixes: https://tracker.ceph.com/issues/51062
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Milind Changire <mchangir@redhat.com>
@mchangir mchangir force-pushed the mds-implement-new-getvxattr-rpc branch from ebccc82 to ece8909 Compare February 11, 2022 11:06
@mchangir
Copy link
Copy Markdown
Contributor Author

mchangir commented Feb 11, 2022

@vshankar PR seems ready for QA; we just need your PR to "ignore unknown op" to go in first, I guess;

@vshankar vshankar dismissed their stale review March 7, 2022 05:02

Comments addressed.

Copy link
Copy Markdown
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.

@vshankar
Copy link
Copy Markdown
Contributor

vshankar commented Mar 7, 2022

Nice work, @mchangir

@vshankar vshankar merged commit e0e2049 into ceph:master Mar 7, 2022
@gregsfortytwo
Copy link
Copy Markdown
Member

Should this PR get backported into quincy @mchangir @vshankar ? It's not tagged in the redmine ticket.

@vshankar
Copy link
Copy Markdown
Contributor

vshankar commented Mar 9, 2022

Should this PR get backported into quincy @mchangir @vshankar ? It's not tagged in the redmine ticket.

I recall @batrick mentioning that there is no real urgency for this to land in quincy. @mchangir would you concur?

NitzanMordhai pushed a commit to NitzanMordhai/ceph that referenced this pull request Nov 19, 2023
Server::handle_client_request() ignores unknown client operation
by returning -ENOTSUPP, however, Server::perf_gather_op_latency()
aborts on unknown client op, thereby causing -ENOTSUPP to never
reach the client. ceph_abort() seems unnecessary here.

Note, we could have invoked Server::perf_gather_op_latency()
when the return value to client is not -ENOTSUPP, however,
a valid client operation *might* just return -ENOTSUPP in
some cases.

@mchangir ran into this with his getvxattr op changes (PR ceph#42001).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 2f4060b)
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.

5 participants