Skip to content

Commit 8bc971a

Browse files
committed
Merge PR ceph#61877 into main
* refs/pull/61877/head: libcephfs_proxy: implement client side async rw operation libcephfs_proxy: implement server side async rw operation libcephfs_proxy: implement the async rw callback libcephfs_proxy: define async rw opcode and structures libcephfs_proxy: define some helper macros for callbacks libcephfs_proxy: move pointer obfuscation functions to proxy_helpers.h libcephfs_proxy: negotiate and use the async cbk feature libcephfs_proxy: implement asynchronous callbacks libcephfs_proxy: gracefully handle connection close libcephfs_proxy: add negotiation documentation libcephfs_proxy: replace legacy handshake by negotation in server side libcephfs_proxy: replace legacy handshake by negotation in client side libcephfs_proxy: implement server side negotiation libcephfs_proxy: implement client side negotiation libcephfs_proxy: implement receiving of negotiate structure libcephfs_proxy: add negotiation structures libcephfs_proxy: add support for control messages libcephfs_proxy: reuse proxy_link_{read|write} Reviewed-by: Sachin Prabhu <[email protected]> Reviewed-by: Venky Shankar <[email protected]>
2 parents 4cbf549 + 6b2c742 commit 8bc971a

File tree

11 files changed

+1211
-188
lines changed

11 files changed

+1211
-188
lines changed

doc/dev/libcephfs_proxy.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ overhead for encoding and decoding, and would provide an easy way to support
7070
backward compatibility if the network protocol needs to be modified in the
7171
future.
7272

73+
**Feature negotiation**
74+
75+
During the initial connection through the UNIX socket, the client will
76+
initiate a negotiation of the features that it want to enable. Currently it
77+
supports a bitmap of features supported/required/desired, but it allows the
78+
structure containing the negotiated data to be extended by adding more fields
79+
without breaking backward compatibility.
80+
81+
The structure itself contains the version and size of the structure, as well as
82+
the minimum required version supported, allowing the other peer to read the
83+
transmitted data even if it doesn't fully understand its contents, and adjust
84+
to the highest possible version known by both peers.
85+
86+
The client will send the bitmap of supported features, the bitmap of features
87+
that must be available (otherwise the connection cannot proceed), and the
88+
bitmap of features the client would like to enable. When the server receives
89+
it, it will create a bitmap of the supported features on both sides, and verify
90+
that all required features by the server are supported by the client. It will
91+
also add its desired features to the features desired by the client. This data
92+
will be sent back to the client, who will do a final check and decide the
93+
final set of enabled features. Once this feature set is sent to the server,
94+
both peers can start using the enabled features.
95+
96+
7397
Design of the *libcephfs_proxy.so* library
7498
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7599

src/libcephfs_proxy/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(proxy_common_srcs proxy_link.c proxy_log.c)
1+
set(proxy_common_srcs proxy_link.c proxy_async.c proxy_log.c)
22
set(libcephfsd_srcs libcephfsd.c proxy_manager.c proxy_mount.c proxy_helpers.c ${proxy_common_srcs})
33
set(libcephfs_proxy_srcs libcephfs_proxy.c ${proxy_common_srcs})
44

src/libcephfs_proxy/libcephfs_proxy.c

Lines changed: 82 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,42 @@
66
#include "proxy_log.h"
77
#include "proxy_helpers.h"
88
#include "proxy_requests.h"
9+
#include "proxy_async.h"
910

1011
/* We override the definition of the ceph_mount_info structure to contain
1112
* internal proxy information. This is already a black box for libcephfs users,
1213
* so this won't be noticed. */
1314
struct ceph_mount_info {
1415
proxy_link_t link;
16+
proxy_link_negotiate_t neg;
17+
proxy_async_t async;
1518
uint64_t cmount;
1619
};
1720

1821
/* The global_cmount is used to stablish an initial connection to serve requests
1922
* not related to a real cmount, like ceph_version or ceph_userperm_new. */
20-
static struct ceph_mount_info global_cmount = { PROXY_LINK_DISCONNECTED, 0 };
23+
static struct ceph_mount_info global_cmount = {
24+
.link = PROXY_LINK_DISCONNECTED,
25+
.neg = {},
26+
.cmount = 0
27+
};
2128

2229
static bool client_stop(proxy_link_t *link)
2330
{
2431
return false;
2532
}
2633

34+
static int32_t proxy_negotiation_check(proxy_link_negotiate_t *neg)
35+
{
36+
proxy_log(LOG_INFO, 0, "Features enabled: %08x", neg->v1.enabled);
37+
38+
return 0;
39+
}
40+
2741
static int32_t proxy_connect(proxy_link_t *link)
2842
{
29-
CEPH_REQ(hello, req, 0, ans, 0);
3043
char *path, *env;
31-
int32_t sd, err;
44+
int32_t sd;
3245

3346
path = PROXY_SOCKET;
3447
env = getenv(PROXY_SOCKET_ENV);
@@ -41,31 +54,7 @@ static int32_t proxy_connect(proxy_link_t *link)
4154
return sd;
4255
}
4356

44-
req.id = LIBCEPHFS_LIB_CLIENT;
45-
err = proxy_link_send(sd, req_iov, 1);
46-
if (err < 0) {
47-
goto failed;
48-
}
49-
err = proxy_link_recv(sd, ans_iov, 1);
50-
if (err < 0) {
51-
goto failed;
52-
}
53-
54-
proxy_log(LOG_INFO, 0, "Connected to libcephfsd version %d.%d",
55-
ans.major, ans.minor);
56-
57-
if ((ans.major != LIBCEPHFSD_MAJOR) ||
58-
(ans.minor != LIBCEPHFSD_MINOR)) {
59-
err = proxy_log(LOG_ERR, ENOTSUP, "Version not supported");
60-
goto failed;
61-
}
62-
6357
return sd;
64-
65-
failed:
66-
proxy_link_close(link);
67-
68-
return err;
6958
}
7059

7160
static void proxy_disconnect(proxy_link_t *link)
@@ -81,6 +70,19 @@ static int32_t proxy_global_connect(void)
8170

8271
if (!proxy_link_is_connected(&global_cmount.link)) {
8372
err = proxy_connect(&global_cmount.link);
73+
if (err < 0) {
74+
return err;
75+
}
76+
77+
proxy_link_negotiate_init(&global_cmount.neg, 0, PROXY_FEAT_ALL,
78+
0, 0);
79+
80+
err = proxy_link_handshake_client(&global_cmount.link, err,
81+
&global_cmount.neg,
82+
proxy_negotiation_check);
83+
if (err < 0) {
84+
proxy_disconnect(&global_cmount.link);
85+
}
8486
}
8587

8688
return err;
@@ -178,6 +180,24 @@ __public int ceph_create(struct ceph_mount_info **cmount, const char *const id)
178180
}
179181
sd = err;
180182

183+
proxy_link_negotiate_init(&ceph_mount->neg, 0, PROXY_FEAT_ALL, 0,
184+
PROXY_FEAT_ASYNC_IO);
185+
186+
err = proxy_link_handshake_client(&ceph_mount->link, sd,
187+
&ceph_mount->neg,
188+
proxy_negotiation_check);
189+
if (err < 0) {
190+
goto failed_link;
191+
}
192+
193+
if ((ceph_mount->neg.v1.enabled & PROXY_FEAT_ASYNC_CBK) != 0) {
194+
err = proxy_async_client(&ceph_mount->async, &ceph_mount->link,
195+
sd);
196+
if (err < 0) {
197+
goto failed_link;
198+
}
199+
}
200+
181201
CEPH_STR_ADD(req, id, id);
182202

183203
err = CEPH_CALL(sd, LIBCEPHFSD_OP_CREATE, req, ans);
@@ -891,3 +911,38 @@ __public UserPerm *ceph_mount_perms(struct ceph_mount_info *cmount)
891911

892912
return value_ptr(ans.userperm);
893913
}
914+
915+
__public int64_t ceph_ll_nonblocking_readv_writev(
916+
struct ceph_mount_info *cmount, struct ceph_ll_io_info *io_info)
917+
{
918+
CEPH_REQ(ceph_ll_nonblocking_readv_writev, req,
919+
io_info->write ? io_info->iovcnt : 0, ans, 0);
920+
int32_t i, err;
921+
922+
if ((cmount->neg.v1.enabled & PROXY_FEAT_ASYNC_IO) == 0) {
923+
return -EOPNOTSUPP;
924+
}
925+
926+
req.info = ptr_checksum(&cmount->async.random, io_info);
927+
req.fh = (uintptr_t)io_info->fh;
928+
req.off = io_info->off;
929+
req.size = 0;
930+
req.write = io_info->write;
931+
req.fsync = io_info->fsync;
932+
req.syncdataonly = io_info->syncdataonly;
933+
934+
for (i = 0; i < io_info->iovcnt; i++) {
935+
if (io_info->write) {
936+
CEPH_BUFF_ADD(req, io_info->iov[i].iov_base,
937+
io_info->iov[i].iov_len);
938+
}
939+
req.size += io_info->iov[i].iov_len;
940+
}
941+
942+
err = CEPH_PROCESS(cmount, LIBCEPHFSD_OP_LL_NONBLOCKING_RW, req, ans);
943+
if (err < 0) {
944+
return err;
945+
}
946+
947+
return ans.res;
948+
}

0 commit comments

Comments
 (0)