1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _FS_CEPH_STRING_TABLE_H
3 #define _FS_CEPH_STRING_TABLE_H
5 #include <linux/types.h>
6 #include <linux/kref.h>
7 #include <linux/rbtree.h>
8 #include <linux/rcupdate.h>
20 extern void ceph_release_string(struct kref *ref);
21 extern struct ceph_string *ceph_find_or_create_string(const char *str,
23 extern bool ceph_strings_empty(void);
25 static inline struct ceph_string *ceph_get_string(struct ceph_string *str)
31 static inline void ceph_put_string(struct ceph_string *str)
35 kref_put(&str->kref, ceph_release_string);
38 static inline int ceph_compare_string(struct ceph_string *cs,
39 const char* str, size_t len)
41 size_t cs_len = cs ? cs->len : 0;
46 return strncmp(cs->str, str, len);
49 #define ceph_try_get_string(x) \
51 struct ceph_string *___str; \
54 ___str = rcu_dereference(x); \
56 kref_get_unless_zero(&___str->kref)) \