mds,client: add new getvxattr op#42001
Conversation
1066508 to
9ffde77
Compare
src/mds/Server.cc
Outdated
| int r = 0; | ||
| ceph::bufferlist bl; | ||
| if (name == "ceph.dir.layout"sv) { | ||
| cur->get_inode()->layout.encode(bl, (uint64_t)-1); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
0192e45 to
12f59e1
Compare
src/mds/Server.cc
Outdated
| int r = 0; | ||
| ceph::bufferlist bl; | ||
| if (name == "ceph.dir.layout"sv) { | ||
| cur->get_inode()->layout.encode(bl, (uint64_t)-1); |
There was a problem hiding this comment.
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.
12f59e1 to
922d846
Compare
batrick
left a comment
There was a problem hiding this comment.
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/
922d846 to
2aecaca
Compare
fff9d11 to
a064f23
Compare
|
@mchangir let me know (here) when this is ready for review |
src/test/libcephfs/vxattr.cc
Outdated
| 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\"")); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@batrick let me know if you need me to break the tests even further
a064f23 to
2da8424
Compare
|
jenkins test make check |
2da8424 to
90273d1
Compare
src/client/Client.cc
Outdated
| memcpy(value, buf.c_str(), len); | ||
| } | ||
| } | ||
| res = len; |
There was a problem hiding this comment.
if size = 0, then we return 'len', is that what we want?
There was a problem hiding this comment.
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
90273d1 to
aeff6e6
Compare
86c7f4a to
16d1300
Compare
batrick
left a comment
There was a problem hiding this comment.
Well done! I think documentation is the last piece before this is ready for general QA.
16d1300 to
ff704d0
Compare
|
jenkins test api |
|
Teuthology run for fs:libcephfs. |
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)
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>
ebccc82 to
ece8909
Compare
|
@vshankar PR seems ready for QA; we just need your PR to "ignore unknown op" to go in first, I guess; |
|
Nice work, @mchangir |
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 that start with "ceph."
Fixes: https://tracker.ceph.com/issues/51062
Signed-off-by: Milind Changire mchangir@redhat.com
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox