From 22ad8e16e8cc5f2d4b70e1804e13dbc0b22b8db4 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Mon, 17 Feb 2025 10:55:03 +0100 Subject: [PATCH] libcephfs_proxy: negotiate and use the async cbk feature Implement client and server side code to use the feature. Signed-off-by: Xavi Hernandez --- src/libcephfs_proxy/libcephfs_proxy.c | 12 +++++++++++- src/libcephfs_proxy/libcephfsd.c | 16 ++++++++++++++-- src/libcephfs_proxy/proxy.h | 5 ++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/libcephfs_proxy/libcephfs_proxy.c b/src/libcephfs_proxy/libcephfs_proxy.c index 719c87895ff6c..b71ba92a2885c 100644 --- a/src/libcephfs_proxy/libcephfs_proxy.c +++ b/src/libcephfs_proxy/libcephfs_proxy.c @@ -6,6 +6,7 @@ #include "proxy_log.h" #include "proxy_helpers.h" #include "proxy_requests.h" +#include "proxy_async.h" /* We override the definition of the ceph_mount_info structure to contain * internal proxy information. This is already a black box for libcephfs users, @@ -13,6 +14,7 @@ struct ceph_mount_info { proxy_link_t link; proxy_link_negotiate_t neg; + proxy_async_t async; uint64_t cmount; }; @@ -178,7 +180,8 @@ __public int ceph_create(struct ceph_mount_info **cmount, const char *const id) } sd = err; - proxy_link_negotiate_init(&ceph_mount->neg, 0, PROXY_FEAT_ALL, 0, 0); + proxy_link_negotiate_init(&ceph_mount->neg, 0, PROXY_FEAT_ALL, 0, + PROXY_FEAT_ASYNC_CBK); err = proxy_link_handshake_client(&ceph_mount->link, sd, &ceph_mount->neg, @@ -187,6 +190,13 @@ __public int ceph_create(struct ceph_mount_info **cmount, const char *const id) goto failed_link; } + if ((ceph_mount->neg.v1.enabled & PROXY_FEAT_ASYNC_CBK) != 0) { + err = proxy_async_client(&ceph_mount->async, &ceph_mount->link, + sd); + if (err < 0) { + goto failed_link; + } + } CEPH_STR_ADD(req, id, id); diff --git a/src/libcephfs_proxy/libcephfsd.c b/src/libcephfs_proxy/libcephfsd.c index 6d04838465cdd..2cb5664034c4a 100644 --- a/src/libcephfs_proxy/libcephfsd.c +++ b/src/libcephfs_proxy/libcephfsd.c @@ -13,6 +13,7 @@ #include "proxy_log.h" #include "proxy_requests.h" #include "proxy_mount.h" +#include "proxy_async.h" typedef struct _proxy_server { proxy_link_t link; @@ -22,6 +23,7 @@ typedef struct _proxy_server { typedef struct _proxy_client { proxy_worker_t worker; proxy_link_negotiate_t neg; + proxy_async_t async; proxy_link_t *link; proxy_random_t random; void *buffer; @@ -1675,10 +1677,20 @@ static void serve_connection(proxy_worker_t *worker) err = proxy_link_handshake_server(client->link, client->sd, &client->neg, server_negotiation_check); - if (err >= 0) { - serve_binary(client); + if (err < 0) { + goto done; } + if ((client->neg.v1.enabled & PROXY_FEAT_ASYNC_CBK) != 0) { + err = proxy_async_server(&client->async, client->sd); + if (err < 0) { + goto done; + } + } + + serve_binary(client); + +done: close(client->sd); } diff --git a/src/libcephfs_proxy/proxy.h b/src/libcephfs_proxy/proxy.h index 162eec81b183d..699e35ab87235 100644 --- a/src/libcephfs_proxy/proxy.h +++ b/src/libcephfs_proxy/proxy.h @@ -26,8 +26,11 @@ ((_type *)((uintptr_t)(_ptr) - offset_of(_type, _field))) enum { + /* Mask of all features requiring the asynchronous callback handling. */ + PROXY_FEAT_ASYNC_CBK = 0x00000001, + /* Mask of all supported/known features. */ - PROXY_FEAT_ALL = 0x00000000 + PROXY_FEAT_ALL = 0x00000001 }; struct _list; -- 2.39.5