From: yury Date: Mon, 26 Jun 2006 12:11:31 +0000 (+0000) Subject: - added "hash" proc tunable to client FLD; X-Git-Tag: v1_8_0_110~486^2~1541 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=8328a5d61e2579aaf84b601ea701128000f3492a;p=fs%2Flustre-release.git - added "hash" proc tunable to client FLD; - fixes in FLD procfs. --- diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index 7570fe8..a25a79c 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -54,6 +54,8 @@ enum { FLD_HTABLE_MASK = FLD_HTABLE_SIZE - 1 }; +extern struct lu_fld_hash fld_hash[3]; + #define FLD_SERVICE_WATCHDOG_TIMEOUT (obd_timeout * 1000) int fld_index_handle_insert(struct lu_server_fld *fld, diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index 9b3218d..33856cc 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -161,7 +161,7 @@ fld_dht_hash(struct lu_client_fld *fld, __u64 seq) 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 @@ -183,7 +183,10 @@ fld_client_get_export(struct lu_client_fld *fld, __u64 seq) 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, @@ -209,7 +212,7 @@ fld_client_add_export(struct lu_client_fld *fld, 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); diff --git a/lustre/fld/lproc_fld.c b/lustre/fld/lproc_fld.c index ec4d6f9..d0988d1 100644 --- a/lustre/fld/lproc_fld.c +++ b/lustre/fld/lproc_fld.c @@ -61,9 +61,12 @@ fld_proc_read_targets(char *page, char **start, off_t off, 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; @@ -74,10 +77,63 @@ fld_proc_read_targets(char *page, char **start, off_t off, 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 diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index 09a8297..bff3911 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -43,21 +43,45 @@ struct lu_fld_hash { }; 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]; };