mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
libshare: use AVL tree with static data, pass all data in arguments
This makes it so we don't leak a consistent 64 bytes anymore, makes the searches simpler and faster, removes /all allocations/ from the driver (quite trivially, since they were absolutely needless), and makes libshare thread-safe (except, maybe, linux/smb, but that only does pointer-width loads/stores so it's also mostly fine, except for leaking smb_shares) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13165
This commit is contained in:
@@ -27,39 +27,26 @@
|
||||
#ifndef _LIBSPL_LIBSHARE_IMPL_H
|
||||
#define _LIBSPL_LIBSHARE_IMPL_H
|
||||
|
||||
typedef struct sa_share_fsinfo {
|
||||
char *shareopts;
|
||||
} sa_share_fsinfo_t;
|
||||
#include <sys/avl.h>
|
||||
|
||||
typedef struct sa_share_impl {
|
||||
char *sa_mountpoint;
|
||||
char *sa_zfsname;
|
||||
|
||||
sa_share_fsinfo_t *sa_fsinfo; /* per-fstype information */
|
||||
typedef const struct sa_share_impl {
|
||||
const char *sa_zfsname;
|
||||
const char *sa_mountpoint;
|
||||
const char *sa_shareopts;
|
||||
} *sa_share_impl_t;
|
||||
|
||||
#define FSINFO(impl_share, fstype) \
|
||||
(&(impl_share->sa_fsinfo[fstype->fsinfo_index]))
|
||||
typedef struct {
|
||||
const char *protocol;
|
||||
|
||||
typedef struct sa_share_ops {
|
||||
int (*enable_share)(sa_share_impl_t share);
|
||||
int (*disable_share)(sa_share_impl_t share);
|
||||
boolean_t (*is_shared)(sa_share_impl_t share);
|
||||
int (*validate_shareopts)(const char *shareopts);
|
||||
int (*update_shareopts)(sa_share_impl_t impl_share,
|
||||
const char *shareopts);
|
||||
void (*clear_shareopts)(sa_share_impl_t impl_share);
|
||||
int (*commit_shares)(void);
|
||||
} sa_share_ops_t;
|
||||
int (*const enable_share)(sa_share_impl_t share);
|
||||
int (*const disable_share)(sa_share_impl_t share);
|
||||
boolean_t (*const is_shared)(sa_share_impl_t share);
|
||||
int (*const validate_shareopts)(const char *shareopts);
|
||||
int (*const commit_shares)(void);
|
||||
|
||||
typedef struct sa_fstype {
|
||||
struct sa_fstype *next;
|
||||
|
||||
const char *name;
|
||||
const sa_share_ops_t *ops;
|
||||
int fsinfo_index;
|
||||
avl_node_t node;
|
||||
} sa_fstype_t;
|
||||
|
||||
sa_fstype_t *register_fstype(const char *name, const sa_share_ops_t *ops);
|
||||
extern sa_fstype_t libshare_nfs_type, libshare_smb_type;
|
||||
|
||||
#endif /* _LIBSPL_LIBSHARE_IMPL_H */
|
||||
|
||||
Reference in New Issue
Block a user