From: Patrick Farrell Date: Mon, 9 Jun 2014 18:26:27 +0000 (-0500) Subject: LU-5153 fld: lsf_lock in update_from_controller X-Git-Tag: 2.6.0-RC1~112 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f288434cd97d4ce6314054ff73fe0e9ee03eb139 LU-5153 fld: lsf_lock in update_from_controller The lsf_lock mutex must be held for calls to fld_index_create, and is currently taken before calls to fld_insert_entry. This patch adds a comment and an assertion to fld_insert_entry, and takes the mutex for the call in fld_update_from_controller. Also adds subsystem description from Di Wang to header file. Signed-off-by: Patrick Farrell Change-Id: I3dcc9a53589d128343d9f386eaf7265f39ff5840 Reviewed-on: http://review.whamcloud.com/10631 Tested-by: Jenkins Reviewed-by: wangdi Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index fbf0369..eae79ea 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -180,7 +180,10 @@ int fld_update_from_controller(const struct lu_env *env, if (lsra->lsra_lsr[i].lsr_index != index) GOTO(out, rc = -EINVAL); + mutex_lock(&fld->lsf_lock); rc1 = fld_insert_entry(env, fld, &lsra->lsra_lsr[i]); + mutex_unlock(&fld->lsf_lock); + if (rc1 != 0) GOTO(out, rc = rc1); } diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index bcd795e..56042a0 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -159,6 +159,8 @@ out: * changed between declare and create. * Because the fld entry can only be increamental, so we will only check * whether it can be merged from the left. + * + * Caller must hold fld->lsf_lock **/ int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld, const struct lu_seq_range *new_range, struct thandle *th) @@ -261,6 +263,19 @@ int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld, RETURN(rc); } +/** + * insert entry in fld store. + * + * \param env relevant lu_env + * \param fld fld store + * \param range range to be inserted + * + * \retval 0 success + * \retval -ve error + * + * Caller must hold fld->lsf_lock + **/ + int fld_insert_entry(const struct lu_env *env, struct lu_server_fld *fld, const struct lu_seq_range *range) @@ -269,6 +284,8 @@ int fld_insert_entry(const struct lu_env *env, int rc; ENTRY; + LASSERT(mutex_is_locked(&fld->lsf_lock)); + th = dt_trans_create(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev)); if (IS_ERR(th)) RETURN(PTR_ERR(th)); diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index 515cf88..ae8dce1 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -35,6 +35,24 @@ * * lustre/fld/fld_internal.h * + * Subsystem Description: + * FLD is FID Location Database, which stores where (IE, on which MDT) + * FIDs are located. + * The database is basically a record file, each record consists of a FID + * sequence range, MDT/OST index, and flags. The FLD for the whole FS + * is only stored on the sequence controller(MDT0) right now, but each target + * also has its local FLD, which only stores the local sequence. + * + * The FLD subsystem usually has two tasks: + * 1. maintain the database, i.e. when the sequence controller allocates + * new sequence ranges to some nodes, it will call the FLD API to insert the + * location information in FLDB. + * + * 2. Handle requests from other nodes, i.e. if client needs to know where + * the FID is located, if it can not find the information in the local cache, + * it will send a FLD lookup RPC to the FLD service, and the FLD service will + * look up the FLDB entry and return the location information to client. + * * Author: Yury Umanets * Author: Tom WangDi */