]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs_proxy: negotiate and use the async cbk feature
authorXavi Hernandez <xhernandez@gmail.com>
Mon, 17 Feb 2025 09:55:03 +0000 (10:55 +0100)
committerXavi Hernandez <xhernandez@gmail.com>
Tue, 18 Feb 2025 14:20:22 +0000 (15:20 +0100)
Implement client and server side code to use the feature.

Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
src/libcephfs_proxy/libcephfs_proxy.c
src/libcephfs_proxy/libcephfsd.c
src/libcephfs_proxy/proxy.h

index 719c87895ff6c8c47aa6d4768c930d30d78fcfc1..b71ba92a2885c8a8b3ad22321503241a2d5e7e1b 100644 (file)
@@ -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);
 
index 6d04838465cdd8c48be9d335b7c81725244a0acd..2cb5664034c4ad36b8a5903ea0ca6b310e30d30e 100644 (file)
@@ -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);
 }
 
index 162eec81b183d7d975399678dec1c8dfbbd46ea5..699e35ab872359ac5d8b47b141fecd132696d196 100644 (file)
        ((_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;