Whamcloud - gitweb
LU-5153 fld: lsf_lock in update_from_controller 31/10631/5
authorPatrick Farrell <paf@cray.com>
Mon, 9 Jun 2014 18:26:27 +0000 (13:26 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 16 Jun 2014 01:56:59 +0000 (01:56 +0000)
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 <paf@cray.com>
Change-Id: I3dcc9a53589d128343d9f386eaf7265f39ff5840
Reviewed-on: http://review.whamcloud.com/10631
Tested-by: Jenkins
Reviewed-by: wangdi <di.wang@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/fld/fld_handler.c
lustre/fld/fld_index.c
lustre/fld/fld_internal.h

index fbf0369..eae79ea 100644 (file)
@@ -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);
                }
index bcd795e..56042a0 100644 (file)
@@ -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));
index 515cf88..ae8dce1 100644 (file)
  *
  * 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 <sequence_range, node_index> 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 <umka@clusterfs.com>
  * Author: Tom WangDi <wangdi@clusterfs.com>
  */