return fld_rrb_hash(fld, seq);
}
-static struct lu_fld_hash fld_hash[3] = {
+struct lu_fld_hash fld_hash[3] = {
{
.fh_name = "DHT",
.fh_func = fld_dht_hash
ENTRY;
LASSERT(fld->fld_hash != NULL);
+
+ spin_lock(&fld->fld_lock);
hash = fld->fld_hash->fh_func(fld, seq);
+ spin_unlock(&fld->fld_lock);
spin_lock(&fld->fld_lock);
list_for_each_entry(fld_exp,
LASSERT(exp != NULL);
- CDEBUG(D_INFO|D_WARNING, "adding export %s\n",
+ CDEBUG(D_INFO|D_WARNING, "FLD(cli): adding export %s\n",
exp->exp_client_uuid.uuid);
spin_lock(&fld->fld_lock);
spin_lock(&fld->fld_lock);
list_for_each_entry(fld_exp,
- &fld->fld_exports, exp_fld_chain) {
+ &fld->fld_exports, exp_fld_chain)
+ {
+ struct client_obd *cli = &fld_exp->exp_obd->u.cli;
+
rc = snprintf(page, count, "%s\n",
- fld_exp->exp_client_uuid.uuid);
+ cli->cl_target_uuid.uuid);
page += rc;
count -= rc;
total += rc;
RETURN(total);
}
+static int
+fld_proc_read_hash(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct lu_client_fld *fld = (struct lu_client_fld *)data;
+ int rc;
+ ENTRY;
+
+ LASSERT(fld != NULL);
+
+ spin_lock(&fld->fld_lock);
+ rc = snprintf(page, count, "%s\n",
+ fld->fld_hash->fh_name);
+ spin_unlock(&fld->fld_lock);
+
+ RETURN(rc);
+}
+
+static int
+fld_proc_write_hash(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct lu_client_fld *fld = (struct lu_client_fld *)data;
+ struct lu_fld_hash *hash = NULL;
+ int i;
+ ENTRY;
+
+ LASSERT(fld != NULL);
+
+ for (i = 0; i < sizeof(fld_hash) / sizeof(*hash); i++) {
+ if (fld_hash[i].fh_name == NULL ||
+ count != strlen(fld_hash[i].fh_name))
+ continue;
+
+ if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
+ hash = &fld_hash[i];
+ break;
+ }
+ }
+
+ if (hash != NULL) {
+ spin_lock(&fld->fld_lock);
+ fld->fld_hash = hash;
+ spin_unlock(&fld->fld_lock);
+
+ CDEBUG(D_WARNING, "FLD(cli): changed hash to \"%s\"\n",
+ hash->fh_name);
+ }
+
+ RETURN(count);
+}
+
struct lprocfs_vars fld_server_proc_list[] = {
{ NULL }};
struct lprocfs_vars fld_client_proc_list[] = {
{ "targets", fld_proc_read_targets, NULL, NULL },
+ { "hash", fld_proc_read_hash, fld_proc_write_hash, NULL },
{ NULL }};
#endif
};
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;
+
+ /* /fld file object device */
struct dt_object *fld_obj;
+
+ /* /fld file fid */
struct lu_fid fld_fid;
+
+ /* fld service name in form "fld-MDTXXX" */
char fld_name[80];
};
struct lu_client_fld {
+ /* client side proc entry */
cfs_proc_dir_entry_t *fld_proc_dir;
+
+ /* list of exports client FLD knows about */
struct list_head fld_exports;
+
+ /* current hash to be used to chose an export */
struct lu_fld_hash *fld_hash;
+
+ /* exports count */
int fld_count;
+
+ /* lock protecting exports list and fld_hash */
spinlock_t fld_lock;
+
+ /* client fld proc entry name */
char fld_name[80];
};