#ifndef __LINUX_FLD_H
#define __LINUX_FLD_H
+#include <lustre/lustre_idl.h>
+#include <lustre_mdt.h>
+#include <dt_object.h>
+
+#include <libcfs/list.h>
+#include <libcfs/kp30.h>
+
struct lu_client_fld;
struct lu_server_fld;
LUSTRE_CLI_FLD_HASH_RRB
};
-typedef int (*fld_hash_func_t) (struct lu_client_fld *, __u64);
+struct lu_server_fld;
+
+struct lu_fld_target {
+ struct list_head ft_chain;
+ struct obd_export *ft_exp;
+ struct lu_server_fld *ft_srv;
+ __u64 ft_idx;
+};
+
+typedef int
+(*fld_hash_func_t) (struct lu_client_fld *, __u64);
+
+typedef struct lu_fld_target *
+(*fld_scan_func_t) (struct lu_client_fld *, __u64);
struct lu_fld_hash {
const char *fh_name;
- fld_hash_func_t fh_func;
+ fld_hash_func_t fh_hash_func;
+ fld_scan_func_t fh_scan_func;
};
struct lu_server_fld {
- /* service proc entry */
- cfs_proc_dir_entry_t *fld_proc_entry;
-
/* fld dir proc entry */
- cfs_proc_dir_entry_t *fld_proc_dir;
-
- /* pointer to started server service */
- struct ptlrpc_service *fld_service;
-
- /* device for access object index methods */
- struct dt_device *fld_dt;
+ cfs_proc_dir_entry_t *lsf_proc_dir;
/* /fld file object device */
- struct dt_object *fld_obj;
-
- /* /fld file fid */
- struct lu_fid fld_fid;
+ struct dt_object *lsf_obj;
/* fld service name in form "fld-MDTXXX" */
- char fld_name[80];
+ char lsf_name[80];
};
struct fld_cache_entry {
struct hlist_node fce_list;
+ struct list_head fce_lru;
mdsno_t fce_mds;
seqno_t fce_seq;
};
struct fld_cache_info {
- struct hlist_head *fci_hash;
+ /*
+ * cache guard, protects fci_hash mostly because others immutable after
+ * init is finished.
+ */
spinlock_t fci_lock;
- int fci_size;
+
+ /* cache shrink threshold */
+ int fci_threshold;
+
+ /* prefered number of cached entries */
+ int fci_cache_size;
+
+ /* current number of cached entries. Protected by @fci_lock */
+ int fci_cache_count;
+
+ /* hash table size (number of collision lists) */
+ int fci_hash_size;
+
+ /* hash table mask */
int fci_hash_mask;
+
+ /* hash table for all collision lists */
+ struct hlist_head *fci_hash_table;
+
+ /* lru list */
+ struct list_head fci_lru;
};
struct lu_client_fld {
/* client side proc entry */
- cfs_proc_dir_entry_t *fld_proc_dir;
+ cfs_proc_dir_entry_t *lcf_proc_dir;
/* list of exports client FLD knows about */
- struct list_head fld_targets;
+ struct list_head lcf_targets;
/* current hash to be used to chose an export */
- struct lu_fld_hash *fld_hash;
+ struct lu_fld_hash *lcf_hash;
/* exports count */
- int fld_count;
+ int lcf_count;
/* lock protecting exports list and fld_hash */
- spinlock_t fld_lock;
+ spinlock_t lcf_lock;
/* client FLD cache */
- struct fld_cache_info *fld_cache;
+ struct fld_cache_info *lcf_cache;
/* client fld proc entry name */
- char fld_name[80];
+ char lcf_name[80];
+
+ const struct lu_context *lcf_ctx;
};
-/* server methods */
+int fld_query(struct com_thread_info *info);
+
+/* Server methods */
int fld_server_init(struct lu_server_fld *fld,
- const struct lu_context *ctx,
struct dt_device *dt,
- const char *uuid);
+ const char *prefix,
+ const struct lu_context *ctx);
void fld_server_fini(struct lu_server_fld *fld,
const struct lu_context *ctx);
-int fld_server_lookup(struct lu_server_fld *fld,
- const struct lu_context *ctx,
- seqno_t seq, mdsno_t *mds);
-
int fld_server_create(struct lu_server_fld *fld,
const struct lu_context *ctx,
seqno_t seq, mdsno_t mds);
const struct lu_context *ctx,
seqno_t seq);
-/* client methods */
+int fld_server_lookup(struct lu_server_fld *fld,
+ const struct lu_context *ctx,
+ seqno_t seq, mdsno_t *mds);
+
+/* Client methods */
int fld_client_init(struct lu_client_fld *fld,
- const char *uuid,
- int hash);
+ const char *prefix, int hash);
void fld_client_fini(struct lu_client_fld *fld);
int fld_client_lookup(struct lu_client_fld *fld,
- seqno_t seq, mdsno_t *mds);
+ seqno_t seq, mdsno_t *mds,
+ const struct lu_context *ctx);
int fld_client_create(struct lu_client_fld *fld,
- seqno_t seq, mdsno_t mds);
+ seqno_t seq, mdsno_t mds,
+ const struct lu_context *ctx);
int fld_client_delete(struct lu_client_fld *fld,
- seqno_t seq);
+ seqno_t seq,
+ const struct lu_context *ctx);
int fld_client_add_target(struct lu_client_fld *fld,
- struct obd_export *exp);
+ struct lu_fld_target *tar);
int fld_client_del_target(struct lu_client_fld *fld,
- struct obd_export *exp);
+ __u64 idx);
-/* cache methods */
-struct fld_cache_info *fld_cache_init(int size);
+/* Cache methods */
+struct fld_cache_info *fld_cache_init(int hash_size,
+ int cache_size,
+ int cache_threshold);
void fld_cache_fini(struct fld_cache_info *cache);
+void fld_cache_flush(struct fld_cache_info *cache);
+
int fld_cache_insert(struct fld_cache_info *cache,
seqno_t seq, mdsno_t mds);