Whamcloud - gitweb
LU-5502 lod: add a high-level description of the LOD layer
[fs/lustre-release.git] / lustre / lod / lod_dev.c
index 8a6743d..96d2ac9 100644 (file)
  * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
  * Author: Mikhail Pershin <mike.pershin@intel.com>
  */
+/**
+ * The Logical Object Device (LOD) layer manages access to striped
+ * objects (both regular files and directories). It implements the DT
+ * device and object APIs and is responsible for creating, storing,
+ * and loading striping information as an extended attribute of the
+ * underlying OSD object. LOD is the server side analog of the LOV and
+ * LMV layers on the client side.
+ *
+ * Metadata LU object stack (layers of the same compound LU object,
+ * all have the same FID):
+ *
+ *        MDT
+ *         |      MD API
+ *        MDD
+ *         |      DT API
+ *        LOD
+ *       /   \    DT API
+ *     OSD   OSP
+ *
+ * During LOD object initialization the localness or remoteness of the
+ * object FID dictates the choice between OSD and OSP.
+ *
+ * An LOD object (file or directory) with N stripes (each has a
+ * different FID):
+ *
+ *          LOD
+ *           |
+ *   +---+---+---+...+
+ *   |   |   |   |   |
+ *   S0  S1  S2  S3  S(N-1)  OS[DP] objects, seen as DT objects by LOD
+ *
+ * When upper layers must access an object's stripes (which are
+ * themselves OST or MDT LU objects) LOD finds these objects by their
+ * FIDs and stores them as an array of DT object pointers on the
+ * object. Declarations and operations on LOD objects are received by
+ * LOD (as DT object operations) and performed on the underlying
+ * OS[DP] object and (as needed) on the stripes. From the perspective
+ * of LOD, a stripe-less file (created by mknod() or open with
+ * O_LOV_DELAY_CREATE) is an object which does not yet have stripes,
+ * while a non-striped directory (created by mkdir()) is an object
+ * which will never have stripes.
+ *
+ * The LOD layer also implements a small subset of the OBD device API
+ * to support MDT stack initialization and finalization (an MDD device
+ * connects and disconnects itself to and from the underlying LOD
+ * device), and pool management. In turn LOD uses the OBD device API
+ * to connect it self to the underlying OSD, and to connect itself to
+ * OSP devices representing the MDTs and OSTs that bear the stripes of
+ * its objects.
+ */
 
 #define DEBUG_SUBSYSTEM S_MDS
 
@@ -142,7 +192,7 @@ static int lod_cleanup_desc_tgts(const struct lu_env *env,
 {
        struct lu_device  *next;
        int rc = 0;
-       int i;
+       unsigned int i;
 
        lod_getref(ltd);
        if (ltd->ltd_tgts_size <= 0) {
@@ -289,12 +339,10 @@ static int lod_process_config(const struct lu_env *env,
        }
 
        case LCFG_PARAM: {
-               struct lprocfs_static_vars  v = { 0 };
-               struct obd_device         *obd = lod2obd(lod);
+               struct obd_device *obd = lod2obd(lod);
 
-               lprocfs_lod_init_vars(&v);
-
-               rc = class_process_proc_param(PARAM_LOV, v.obd_vars, lcfg, obd);
+               rc = class_process_proc_seq_param(PARAM_LOV, obd->obd_vars,
+                                                 lcfg, obd);
                if (rc > 0)
                        rc = 0;
                GOTO(out, rc);
@@ -337,7 +385,8 @@ static int lod_recovery_complete(const struct lu_env *env,
 {
        struct lod_device   *lod = lu2lod_dev(dev);
        struct lu_device    *next = &lod->lod_child->dd_lu_dev;
-       int                  i, rc;
+       unsigned int         i;
+       int                  rc;
        ENTRY;
 
        LASSERT(lod->lod_recovery_completed == 0);
@@ -471,7 +520,8 @@ static int lod_sync(const struct lu_env *env, struct dt_device *dev)
 {
        struct lod_device   *lod = dt2lod_dev(dev);
        struct lod_ost_desc *ost;
-       int                  rc = 0, i;
+       unsigned int         i;
+       int                  rc = 0;
        ENTRY;
 
        lod_getref(&lod->lod_ost_descs);
@@ -816,6 +866,7 @@ static void lod_key_fini(const struct lu_context *ctx,
                info->lti_ea_store = NULL;
                info->lti_ea_store_size = 0;
        }
+       lu_buf_free(&info->lti_linkea_buf);
        OBD_FREE_PTR(info);
 }
 
@@ -854,7 +905,8 @@ static int lod_obd_get_info(const struct lu_env *env, struct obd_export *exp,
                struct obd_device       *obd = exp->exp_obd;
                struct lod_device       *d;
                struct lod_ost_desc     *ost;
-               int                     i, rc = 1;
+               unsigned int            i;
+               int                     rc = 1;
 
                if (!obd->obd_set_up || obd->obd_stopping)
                        RETURN(-EAGAIN);
@@ -891,7 +943,6 @@ static struct obd_ops lod_obd_device_ops = {
 
 static int __init lod_mod_init(void)
 {
-       struct lprocfs_static_vars  lvars = { 0 };
        struct obd_type *type;
        int rc;
 
@@ -899,11 +950,9 @@ static int __init lod_mod_init(void)
        if (rc)
                return rc;
 
-       lprocfs_lod_init_vars(&lvars);
-
        rc = class_register_type(&lod_obd_device_ops, NULL, true, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                                lvars.module_vars,
+                                NULL,
 #endif
                                 LUSTRE_LOD_NAME, &lod_device_type);
        if (rc) {
@@ -917,18 +966,18 @@ static int __init lod_mod_init(void)
                return rc;
 
        type = class_search_type(LUSTRE_LOD_NAME);
-       type->typ_procsym = lprocfs_register("lov", proc_lustre_root,
-                                            NULL, NULL);
-       if (IS_ERR(type->typ_procsym))
+       type->typ_procsym = lprocfs_seq_register("lov", proc_lustre_root,
+                                                NULL, NULL);
+       if (IS_ERR(type->typ_procsym)) {
                CERROR("lod: can't create compat entry \"lov\": %d\n",
                       (int)PTR_ERR(type->typ_procsym));
+               type->typ_procsym = NULL;
+       }
        return rc;
 }
 
 static void __exit lod_mod_exit(void)
 {
-       lprocfs_try_remove_proc_entry("lov", proc_lustre_root);
-
        class_unregister_type(LUSTRE_LOD_NAME);
        lu_kmem_fini(lod_caches);
 }