From: Jeff Layton Date: Thu, 16 Apr 2020 16:09:54 +0000 (-0400) Subject: client: move callback typedefs and arg struct into ceph_ll_client.h X-Git-Tag: v15.2.4~28^2~1^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c02bca7d02a156a9f0d61f5d47ba891d9f8edae4;p=ceph.git client: move callback typedefs and arg struct into ceph_ll_client.h Put them in a common interface header file. This also allows us to eliminate the duplicate definition of ceph_deleg_cb_t in Delegation.h. Signed-off-by: Jeff Layton (cherry picked from commit 8370f70cacfb0bccc96d121cab687376155e8b8d) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index b92abcfa244e..b4e4a1abbaa2 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10420,7 +10420,7 @@ int Client::ll_statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms) return statfs(0, stbuf, perms); } -void Client::ll_register_callbacks(struct client_callback_args *args) +void Client::ll_register_callbacks(struct ceph_client_callback_args *args) { if (!args) return; diff --git a/src/client/Client.h b/src/client/Client.h index c488cf7c3863..98745db8a730 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -121,29 +121,6 @@ struct CapSnap; struct MetaRequest; class ceph_lock_state_t; - -typedef void (*client_ino_callback_t)(void *handle, vinodeno_t ino, int64_t off, int64_t len); - -typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino, - vinodeno_t ino, const char *name, - size_t len); -typedef int (*client_remount_callback_t)(void *handle); - -typedef void(*client_switch_interrupt_callback_t)(void *handle, void *data); -typedef mode_t (*client_umask_callback_t)(void *handle); - -/* Callback for delegation recalls */ -typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv); - -struct client_callback_args { - void *handle; - client_ino_callback_t ino_cb; - client_dentry_callback_t dentry_cb; - client_switch_interrupt_callback_t switch_intr_cb; - client_remount_callback_t remount_cb; - client_umask_callback_t umask_cb; -}; - // ======================================================== // client interface @@ -602,7 +579,7 @@ public: int ll_osdaddr(int osd, uint32_t *addr); int ll_osdaddr(int osd, char* buf, size_t size); - void ll_register_callbacks(struct client_callback_args *args); + void ll_register_callbacks(struct ceph_client_callback_args *args); int test_dentry_handling(bool can_invalidate); const char** get_tracked_conf_keys() const override; diff --git a/src/client/Delegation.h b/src/client/Delegation.h index e260f6c9980a..d24a02487e13 100644 --- a/src/client/Delegation.h +++ b/src/client/Delegation.h @@ -5,8 +5,7 @@ #include "common/Clock.h" #include "common/Timer.h" - -class Fh; +#include "include/cephfs/ceph_ll_client.h" /* Commands for manipulating delegation state */ #ifndef CEPH_DELEGATION_NONE @@ -15,9 +14,6 @@ class Fh; # define CEPH_DELEGATION_WR 2 #endif -/* Callback for delegation recalls */ -typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv); - /* Converts CEPH_DELEGATION_* to cap mask */ int ceph_deleg_caps_for_type(unsigned type); diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index b35606309ce3..88afd05de51e 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -1233,7 +1233,7 @@ int CephFuse::Handle::start() #endif - struct client_callback_args args = { + struct ceph_client_callback_args args = { handle: this, ino_cb: client->cct->_conf.get_val("fuse_use_invalidate_cb") ? ino_invalidate_cb : NULL, diff --git a/src/include/cephfs/ceph_ll_client.h b/src/include/cephfs/ceph_ll_client.h index f2645c0e0ff6..c1af46dc010f 100644 --- a/src/include/cephfs/ceph_ll_client.h +++ b/src/include/cephfs/ceph_ll_client.h @@ -17,7 +17,31 @@ #ifdef __cplusplus extern "C" { -#endif + +class Fh; + +struct inodeno_t; +struct vinodeno_t; +typedef struct vinodeno_t vinodeno; + +#else /* __cplusplus */ + +typedef struct Fh Fh; + +typedef struct inodeno_t { + uint64_t val; +} inodeno_t; + +typedef struct _snapid_t { + uint64_t val; +} snapid_t; + +typedef struct vinodeno_t { + inodeno_t ino; + snapid_t snapid; +} vinodeno_t; + +#endif /* __cplusplus */ /* * Heavily borrowed from David Howells' draft statx patchset. @@ -74,6 +98,40 @@ struct ceph_statx { */ #define CEPH_REQ_FLAG_MASK (AT_SYMLINK_NOFOLLOW|AT_NO_ATTR_SYNC) +/* delegation recalls */ +typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv); + +/* inode data/metadata invalidation */ +typedef void (*client_ino_callback_t)(void *handle, vinodeno_t ino, + int64_t off, int64_t len); + +/* dentry invalidation */ +typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino, + vinodeno_t ino, const char *name, + size_t len); + +/* remount entire fs */ +typedef int (*client_remount_callback_t)(void *handle); + +/* lock request interrupted */ +typedef void (*client_switch_interrupt_callback_t)(void *handle, void *data); + +/* fetch umask of actor */ +typedef mode_t (*client_umask_callback_t)(void *handle); + +/* + * The handle is an opaque value that gets passed to some callbacks. Any fields + * set to NULL will be left alone. There is no way to unregister callbacks. + */ +struct ceph_client_callback_args { + void *handle; + client_ino_callback_t ino_cb; + client_dentry_callback_t dentry_cb; + client_switch_interrupt_callback_t switch_intr_cb; + client_remount_callback_t remount_cb; + client_umask_callback_t umask_cb; +}; + #ifdef __cplusplus } #endif diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 2876a317c303..ae771f07fe8d 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -78,27 +78,7 @@ struct ceph_file_layout { uint32_t fl_pg_pool; /* namespace, crush ruleset, rep level */ } __attribute__ ((packed)); - -typedef struct inodeno_t { - uint64_t val; -} inodeno_t; - -typedef struct _snapid_t { - uint64_t val; -} snapid_t; - -typedef struct vinodeno_t { - inodeno_t ino; - snapid_t snapid; -} vinodeno_t; - -typedef struct Fh Fh; struct CephContext; -#else /* _cplusplus */ - -struct inodeno_t; -struct vinodeno_t; -typedef struct vinodeno_t vinodeno; #endif /* ! __cplusplus */ struct UserPerm; @@ -1794,7 +1774,6 @@ int ceph_ll_lazyio(struct ceph_mount_info *cmount, Fh *fh, int enable); * needs, but it should take care to choose a value that allows it to avoid * forcible eviction from the cluster in the event of an application bug. */ -typedef void (*ceph_deleg_cb_t)(struct Fh *fh, void *priv); /* Commands for manipulating delegation state */ #ifndef CEPH_DELEGATION_NONE diff --git a/src/libcephfs.cc b/src/libcephfs.cc index ebc8e932825b..0e5d9e6e3657 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -116,7 +116,7 @@ public: goto fail; { - client_callback_args args = {}; + ceph_client_callback_args args = {}; args.handle = this; args.umask_cb = umask_cb; client->ll_register_callbacks(&args);