Whamcloud - gitweb
b=21825 doxygen comments for CMM
authorMikhail Pershin <tappro@sun.com>
Thu, 19 Aug 2010 15:22:42 +0000 (19:22 +0400)
committerMikhail Pershin <tappro@sun.com>
Thu, 19 Aug 2010 15:22:42 +0000 (19:22 +0400)
i=di.wang

lustre/cmm/cmm_device.c
lustre/cmm/cmm_internal.h
lustre/cmm/cmm_lproc.c
lustre/cmm/cmm_object.c
lustre/cmm/cmm_split.c
lustre/cmm/mdc_device.c
lustre/cmm/mdc_internal.h
lustre/cmm/mdc_object.c

index acf5241..2105222 100644 (file)
  *
  * Author: Mike Pershin <tappro@clusterfs.com>
  */
-
+/**
+ * \addtogroup cmm
+ * @{
+ */
 #ifndef EXPORT_SYMTAB
 # define EXPORT_SYMTAB
 #endif
@@ -143,6 +146,10 @@ static int cmm_llog_ctxt_get(const struct lu_env *env, struct md_device *m,
 }
 
 #ifdef HAVE_QUOTA_SUPPORT
+/**
+ * \name Quota functions
+ * @{
+ */
 static int cmm_quota_notify(const struct lu_env *env, struct md_device *m)
 {
         struct cmm_device *cmm_dev = md2cmm_dev(m);
@@ -375,6 +382,7 @@ static int cmm_quota_finvalidate(const struct lu_env *env, struct md_device *m,
                                                                type);
         RETURN(rc);
 }
+/** @} */
 #endif
 
 int cmm_iocontrol(const struct lu_env *env, struct md_device *m,
@@ -419,7 +427,9 @@ static const struct md_device_operations cmm_md_ops = {
 };
 
 extern struct lu_device_type mdc_device_type;
-
+/**
+ * Init MDC.
+ */
 static int cmm_post_init_mdc(const struct lu_env *env,
                              struct cmm_device *cmm)
 {
@@ -869,6 +879,7 @@ static void lprocfs_cmm_init_vars(struct lprocfs_static_vars *lvars)
     lvars->module_vars  = lprocfs_cmm_module_vars;
     lvars->obd_vars     = lprocfs_cmm_obd_vars;
 }
+/** @} */
 
 static int __init cmm_mod_init(void)
 {
index ae27ff2..effddc2 100644 (file)
  *
  * Author: Mike Pershin <tappro@clusterfs.com>
  */
-
+/**
+ * \defgroup cmm cmm
+ * Cluster Metadata Manager.
+ * Implementation of md interface to provide operation between MDS-es.
+ *
+ * CMM has two set of md methods, one is for local operation which uses MDD,
+ * second is for remote operations to call different MDS.
+ * When object is allocated then proper set of methods are set for it. *
+ * @{
+ */
 #ifndef _CMM_INTERNAL_H
 #define _CMM_INTERNAL_H
 
 #include <md_object.h>
 #include <lustre_acl.h>
 
-
+/**
+ * md_device extention for CMM layer.
+ */
 struct cmm_device {
+        /** md_device instance */
         struct md_device        cmm_md_dev;
-        /* device flags, taken from enum cmm_flags */
+        /** device flags, taken from enum cmm_flags */
         __u32                   cmm_flags;
-        /* underlaying device in MDS stack, usually MDD */
+        /** underlaying device in MDS stack, usually MDD */
         struct md_device       *cmm_child;
-        /* FLD client to talk to FLD */
+        /** FLD client to talk to FLD */
         struct lu_client_fld   *cmm_fld;
-        /* other MD servers in cluster */
+        /** Number of this MDS server in cluster */
         mdsno_t                 cmm_local_num;
+        /** Total number of other MDS */
         __u32                   cmm_tgt_count;
+        /** linked list of all remove MDS clients */
         cfs_list_t              cmm_targets;
+        /** lock for cmm_device::cmm_targets operations */
         cfs_spinlock_t          cmm_tgt_guard;
+        /** /proc entry with CMM data */
         cfs_proc_dir_entry_t   *cmm_proc_entry;
+        /** CMM statistic */
         struct lprocfs_stats   *cmm_stats;
 };
 
+/**
+ * CMM flags
+ */
 enum cmm_flags {
-        /*
-         * Device initialization complete.
-         */
+        /** Device initialization complete. */
         CMM_INITIALIZED = 1 << 0
 };
 
+/**
+ * Wrapper for md_device::md_ops of underlaying device cmm_child.
+ */
 static inline const struct md_device_operations *
 cmm_child_ops(struct cmm_device *d)
 {
         return d->cmm_child->md_ops;
 }
 
+/** Wrapper to get cmm_device by contained md_device */
 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
 {
         return container_of0(m, struct cmm_device, cmm_md_dev);
 }
 
+/** Wrapper to get cmm_device by contained lu_device */
 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
 {
         return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
 }
 
+/** Wrapper to get lu_device from cmm_device */
 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
 {
         return (&d->cmm_md_dev.md_lu_dev);
 }
 
 #ifdef HAVE_SPLIT_SUPPORT
+/**
+ * \ingroup split
+ * States of split operation.
+ */
 enum cmm_split_state {
         CMM_SPLIT_UNKNOWN,
         CMM_SPLIT_NONE,
@@ -106,104 +134,147 @@ enum cmm_split_state {
 };
 #endif
 
+/** CMM container for md_object. */
 struct cmm_object {
         struct md_object cmo_obj;
 };
 
-/* local CMM object */
+/**
+ * \defgroup cml cml
+ * CMM local operations.
+ * @{
+ */
+/**
+ * Local CMM object.
+ */
 struct cml_object {
+        /** cmm_object instance. */
         struct cmm_object    cmm_obj;
 #ifdef HAVE_SPLIT_SUPPORT
-        /* split state of object (for dirs only)*/
+        /** split state of object (for dirs only) */
         enum cmm_split_state clo_split;
 #endif
 };
+/** @} */
 
-/* remote CMM object */
+/**
+ * \defgroup cmr cmr
+ * CMM remote operations.
+ * @{
+ */
+/**
+ * Remote CMM object.
+ */
 struct cmr_object {
+        /** cmm_object instance */
         struct cmm_object cmm_obj;
-        /* mds number where object is placed */
+        /** mds number where object is placed */
         mdsno_t           cmo_num;
 };
+/** @} */
 
 enum {
         CMM_SPLIT_PAGE_COUNT = 1
 };
 
+/**
+ * CMM thread info.
+ * This is storage for all variables used in CMM functions and it is needed as
+ * stack replacement.
+ */
 struct cmm_thread_info {
         struct md_attr        cmi_ma;
         struct lu_buf         cmi_buf;
         struct lu_fid         cmi_fid; /* used for le/cpu conversions */
         struct lu_rdpg        cmi_rdpg;
-        /* pointers to pages for readpage. */
+        /** pointers to pages for readpage. */
         struct page          *cmi_pages[CMM_SPLIT_PAGE_COUNT];
         struct md_op_spec     cmi_spec;
         struct lmv_stripe_md  cmi_lmv;
         char                  cmi_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
-
-        /* Ops object filename */
+        /** Ops object filename */
         struct lu_name        cti_name;
 };
 
+/**
+ * Wrapper to get cmm_device from cmm_object.
+ */
 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
 {
         return (md2cmm_dev(md_obj2dev(&c->cmo_obj)));
 }
 
+/**
+ * Get cmm_device from related lu_device.
+ */
 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
 {
         //LASSERT(lu_device_is_cmm(o->lo_dev));
         return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
 }
 
-/* get cmm object from md_object */
+/**
+ * Get cmm object from corresponding md_object.
+ */
 static inline struct cmm_object *md2cmm_obj(struct md_object *o)
 {
         return container_of0(o, struct cmm_object, cmo_obj);
 }
-/* get lower-layer object */
+
+/**
+ * Get next lower-layer md_object from current cmm_object.
+ */
 static inline struct md_object *cmm2child_obj(struct cmm_object *o)
 {
         return (o ? lu2md(lu_object_next(&o->cmo_obj.mo_lu)) : NULL);
 }
 
+/**
+ * Extract lu_fid from corresponding cmm_object.
+ */
 static inline struct lu_fid* cmm2fid(struct cmm_object *obj)
 {
        return &(obj->cmo_obj.mo_lu.lo_header->loh_fid);
 }
 
 struct cmm_thread_info *cmm_env_info(const struct lu_env *env);
-
-/* cmm_object.c */
 struct lu_object *cmm_object_alloc(const struct lu_env *env,
                                    const struct lu_object_header *hdr,
                                    struct lu_device *);
-
-/*
- * local CMM object operations. cml_...
+/**
+ * \addtogroup cml
+ * @{
  */
+/** Get cml_object from lu_object. */
 static inline struct cml_object *lu2cml_obj(struct lu_object *o)
 {
         return container_of0(o, struct cml_object, cmm_obj.cmo_obj.mo_lu);
 }
+/** Get cml_object from md_object. */
 static inline struct cml_object *md2cml_obj(struct md_object *mo)
 {
         return container_of0(mo, struct cml_object, cmm_obj.cmo_obj);
 }
+/** Get cml_object from cmm_object */
 static inline struct cml_object *cmm2cml_obj(struct cmm_object *co)
 {
         return container_of0(co, struct cml_object, cmm_obj);
 }
+/** @} */
 
 int cmm_upcall(const struct lu_env *env, struct md_device *md,
                enum md_upcall_event ev, void *data);
 
 #ifdef HAVE_SPLIT_SUPPORT
+/**
+ * \defgroup split split
+ * @{
+ */
 
 #define CMM_MD_SIZE(stripes)  (sizeof(struct lmv_stripe_md) +  \
                                (stripes) * sizeof(struct lu_fid))
 
-/* cmm_split.c */
+/** Get and initialize lu_bug from cmm_thread_info. */
 static inline struct lu_buf *cmm_buf_get(const struct lu_env *env,
                                          void *area, ssize_t len)
 {
@@ -217,14 +288,12 @@ static inline struct lu_buf *cmm_buf_get(const struct lu_env *env,
 
 int cmm_split_check(const struct lu_env *env, struct md_object *mp,
                     const char *name);
-
 int cmm_split_expect(const struct lu_env *env, struct md_object *mo,
                      struct md_attr *ma, int *split);
-
 int cmm_split_dir(const struct lu_env *env, struct md_object *mo);
-
 int cmm_split_access(const struct lu_env *env, struct md_object *mo,
                      mdl_mode_t lm);
+/** @} */
 #endif
 
 int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid,
@@ -235,8 +304,10 @@ int cmm_procfs_fini(struct cmm_device *cmm);
 
 void cmm_lprocfs_time_start(const struct lu_env *env);
 void cmm_lprocfs_time_end(const struct lu_env *env, struct cmm_device *cmm,
-                         int idx);
-
+                          int idx);
+/**
+ * CMM counters.
+ */
 enum {
         LPROC_CMM_SPLIT_CHECK,
         LPROC_CMM_SPLIT,
@@ -247,3 +318,4 @@ enum {
 
 #endif /* __KERNEL__ */
 #endif /* _CMM_INTERNAL_H */
+/** @} */
index dd4f766..fe2f6f2 100644 (file)
 #include <lustre/lustre_idl.h>
 
 #include "cmm_internal.h"
-
+/**
+ * \addtogroup cmm
+ * @{
+ */
 static const char *cmm_counter_names[LPROC_CMM_NR] = {
         [LPROC_CMM_SPLIT_CHECK] = "split_check",
         [LPROC_CMM_SPLIT]       = "split",
@@ -116,7 +119,8 @@ void cmm_lprocfs_time_start(const struct lu_env *env)
 }
 
 void cmm_lprocfs_time_end(const struct lu_env *env, struct cmm_device *cmm,
-                         int idx)
+                          int idx)
 {
         lu_lprocfs_time_end(env, cmm->cmm_stats, idx);
 }
+/** @} */
index 191cf3e..feb7b89 100644 (file)
 #include <lustre_fid.h>
 #include "cmm_internal.h"
 #include "mdc_internal.h"
-
+/**
+ * \ingroup cmm
+ * Lookup MDS number \a mds by FID \a fid.
+ *
+ * \param fid FID of object to find MDS
+ * \param mds mds number to return.
+ */
 int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid,
                    mdsno_t *mds, const struct lu_env *env)
 {
@@ -77,6 +83,10 @@ int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid,
         RETURN (rc);
 }
 
+/**
+ * \addtogroup cml
+ * @{
+ */
 static const struct md_object_operations cml_mo_ops;
 static const struct md_dir_operations    cml_dir_ops;
 static const struct lu_object_operations cml_obj_ops;
@@ -85,6 +95,10 @@ static const struct md_object_operations cmr_mo_ops;
 static const struct md_dir_operations    cmr_dir_ops;
 static const struct lu_object_operations cmr_obj_ops;
 
+/**
+ * \ingroup cmm
+ * Allocate CMM object.
+ */
 struct lu_object *cmm_object_alloc(const struct lu_env *env,
                                    const struct lu_object_header *loh,
                                    struct lu_device *ld)
@@ -139,18 +153,17 @@ struct lu_object *cmm_object_alloc(const struct lu_env *env,
         RETURN(lo);
 }
 
-/*
- * CMM has two types of objects - local and remote. They have different set
- * of operations so we are avoiding multiple checks in code.
+/**
+ * Get local child device.
  */
-
-/* get local child device */
 static struct lu_device *cml_child_dev(struct cmm_device *d)
 {
         return &d->cmm_child->md_lu_dev;
 }
 
-/* lu_object operations */
+/**
+ * Free cml_object.
+ */
 static void cml_object_free(const struct lu_env *env,
                             struct lu_object *lo)
 {
@@ -159,6 +172,9 @@ static void cml_object_free(const struct lu_env *env,
         OBD_FREE_PTR(clo);
 }
 
+/**
+ * Initialize cml_object.
+ */
 static int cml_object_init(const struct lu_env *env, struct lu_object *lo,
                            const struct lu_object_conf *unused)
 {
@@ -204,7 +220,11 @@ static const struct lu_object_operations cml_obj_ops = {
         .loo_object_print   = cml_object_print
 };
 
-/* CMM local md_object operations */
+/**
+ * \name CMM local md_object operations.
+ * All of them call just corresponding operations on next layer.
+ * @{
+ */
 static int cml_object_create(const struct lu_env *env,
                              struct md_object *mo,
                              const struct md_op_spec *spec,
@@ -395,8 +415,16 @@ static const struct md_object_operations cml_mo_ops = {
         .moo_version_set   = cml_version_set,
         .moo_path          = cml_path,
 };
+/** @} */
 
-/* md_dir operations */
+/**
+ * \name CMM local md_dir_operations.
+ * @{
+ */
+/**
+ * cml lookup object fid by name.
+ * This returns only FID by name.
+ */
 static int cml_lookup(const struct lu_env *env, struct md_object *mo_p,
                       const struct lu_name *lname, struct lu_fid *lf,
                       struct md_op_spec *spec)
@@ -416,6 +444,9 @@ static int cml_lookup(const struct lu_env *env, struct md_object *mo_p,
 
 }
 
+/**
+ * Helper to return lock mode. Used in split cases only.
+ */
 static mdl_mode_t cml_lock_mode(const struct lu_env *env,
                                 struct md_object *mo, mdl_mode_t lm)
 {
@@ -429,6 +460,17 @@ static mdl_mode_t cml_lock_mode(const struct lu_env *env,
         RETURN(rc);
 }
 
+/**
+ * Create operation for cml.
+ * Objects are local, but split can happen.
+ * If split is not needed this will call next layer mdo_create().
+ *
+ * \param mo_p Parent directory. Local object.
+ * \param lname name of file to create.
+ * \param mo_c Child object. It has no real inode yet.
+ * \param spec creation specification.
+ * \param ma child object attributes.
+ */
 static int cml_create(const struct lu_env *env, struct md_object *mo_p,
                       const struct lu_name *lname, struct md_object *mo_c,
                       struct md_op_spec *spec, struct md_attr *ma)
@@ -457,11 +499,13 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p,
          * lock.
          */
         if (spec->sp_cr_mode == MDL_EX) {
-                /*
-                 * Try to split @mo_p. If split is ok, -ERESTART is returned and
-                 * current thread will not peoceed with create. Instead it sends
-                 * -ERESTART to client to let it know that correct MDT should be
-                 * chosen.
+                /**
+                 * Split cases:
+                 * - Try to split \a mo_p upon each create operation.
+                 *   If split is ok, -ERESTART is returned and current thread
+                 *   will not peoceed with create. Instead it sends -ERESTART
+                 *   to client to let it know that correct MDT must be chosen.
+                 * \see cmm_split_dir()
                  */
                 rc = cmm_split_dir(env, mo_p);
                 if (rc)
@@ -473,10 +517,11 @@ static int cml_create(const struct lu_env *env, struct md_object *mo_p,
         }
 
         if (spec != NULL && spec->sp_ck_split) {
-                /*
-                 * Check for possible split directory and let caller know that
+                /**
+                 * - Directory is split already. Let the caller know that
                  * it should tell client that directory is split and operation
                  * should repeat to correct MDT.
+                 * \see cmm_split_check()
                  */
                 rc = cmm_split_check(env, mo_p, lname->ln_name);
                 if (rc)
@@ -494,6 +539,7 @@ out:
         return rc;
 }
 
+/** Call mdo_create_data() on next layer. All objects are local. */
 static int cml_create_data(const struct lu_env *env, struct md_object *p,
                            struct md_object *o,
                            const struct md_op_spec *spec,
@@ -506,6 +552,7 @@ static int cml_create_data(const struct lu_env *env, struct md_object *p,
         RETURN(rc);
 }
 
+/** Call mdo_link() on next layer. All objects are local. */
 static int cml_link(const struct lu_env *env, struct md_object *mo_p,
                     struct md_object *mo_s, const struct lu_name *lname,
                     struct md_attr *ma)
@@ -517,6 +564,7 @@ static int cml_link(const struct lu_env *env, struct md_object *mo_p,
         RETURN(rc);
 }
 
+/** Call mdo_unlink() on next layer. All objects are local. */
 static int cml_unlink(const struct lu_env *env, struct md_object *mo_p,
                       struct md_object *mo_c, const struct lu_name *lname,
                       struct md_attr *ma)
@@ -528,6 +576,11 @@ static int cml_unlink(const struct lu_env *env, struct md_object *mo_p,
         RETURN(rc);
 }
 
+/**
+ * \ingroup cmm
+ * Get mode of object.
+ * Used in both cml and cmr hence can produce RPC to another server.
+ */
 static int cmm_mode_get(const struct lu_env *env, struct md_device *md,
                         const struct lu_fid *lf, struct md_attr *ma,
                         int *remote)
@@ -561,6 +614,11 @@ static int cmm_mode_get(const struct lu_env *env, struct md_device *md,
         RETURN(rc);
 }
 
+/**
+ * \ingroup cmm
+ * Set ctime for object.
+ * Used in both cml and cmr hence can produce RPC to another server.
+ */
 static int cmm_rename_ctime(const struct lu_env *env, struct md_device *md,
                             const struct lu_fid *lf, struct md_attr *ma)
 {
@@ -578,6 +636,7 @@ static int cmm_rename_ctime(const struct lu_env *env, struct md_device *md,
         RETURN(rc);
 }
 
+/** Helper to output debug information about rename operation. */
 static inline void cml_rename_warn(const char *fname,
                                   struct md_object *mo_po,
                                   struct md_object *mo_pn,
@@ -606,6 +665,20 @@ static inline void cml_rename_warn(const char *fname,
                       t_name, err);
 }
 
+/**
+ * Rename operation for cml.
+ *
+ * This is the most complex cross-reference operation. It may consist of up to 4
+ * MDS server and require several RPCs to be sent.
+ *
+ * \param mo_po Old parent object.
+ * \param mo_pn New parent object.
+ * \param lf FID of object to rename.
+ * \param ls_name Source file name.
+ * \param mo_t target object. Should be NULL here.
+ * \param lt_name Name of target file.
+ * \param ma object attributes.
+ */
 static int cml_rename(const struct lu_env *env, struct md_object *mo_po,
                       struct md_object *mo_pn, const struct lu_fid *lf,
                       const struct lu_name *ls_name, struct md_object *mo_t,
@@ -622,8 +695,10 @@ static int cml_rename(const struct lu_env *env, struct md_object *mo_po,
                 RETURN(rc);
 
         if (mo_t && lu_object_exists(&mo_t->mo_lu) < 0) {
-                /* XXX: mo_t is remote object and there is RPC to unlink it.
-                 * before that, do local sanity check for rename first. */
+                /**
+                 * \note \a mo_t is remote object and there is RPC to unlink it.
+                 * Before that, do local sanity check for rename first.
+                 */
                 if (!remote) {
                         struct md_object *mo_s = md_object_find_slice(env,
                                                         md_obj2dev(mo_po), lf);
@@ -650,8 +725,8 @@ static int cml_rename(const struct lu_env *env, struct md_object *mo_po,
                         RETURN(rc);
 
                 /*
-                 * XXX: @ma will be changed after mo_ref_del, but we will use
-                 * it for mdo_rename later, so save it before mo_ref_del.
+                 * /note \a ma will be changed after mo_ref_del(), but we will use
+                 * it for mdo_rename() later, so save it before mo_ref_del().
                  */
                 cmi = cmm_env_info(env);
                 tmp_ma = &cmi->cmi_ma;
@@ -664,8 +739,10 @@ static int cml_rename(const struct lu_env *env, struct md_object *mo_po,
                 mo_t = NULL;
         }
 
-        /* XXX: for src on remote MDS case, change its ctime before local
-         * rename. Firstly, do local sanity check for rename if necessary. */
+        /**
+         * \note for src on remote MDS case, change its ctime before local
+         * rename. Firstly, do local sanity check for rename if necessary.
+         */
         if (remote) {
                 if (!tmp_ma) {
                         rc = mo_permission(env, NULL, md_object_next(mo_po),
@@ -723,6 +800,10 @@ static int cml_rename(const struct lu_env *env, struct md_object *mo_po,
         RETURN(rc);
 }
 
+/**
+ * Rename target partial operation.
+ * Used for cross-ref rename.
+ */
 static int cml_rename_tgt(const struct lu_env *env, struct md_object *mo_p,
                           struct md_object *mo_t, const struct lu_fid *lf,
                           const struct lu_name *lname, struct md_attr *ma)
@@ -734,7 +815,11 @@ static int cml_rename_tgt(const struct lu_env *env, struct md_object *mo_p,
                             md_object_next(mo_t), lf, lname, ma);
         RETURN(rc);
 }
-/* used only in case of rename_tgt() when target is not exist */
+
+/**
+ * Name insert only operation.
+ * used only in case of rename_tgt() when target doesn't exist.
+ */
 static int cml_name_insert(const struct lu_env *env, struct md_object *p,
                            const struct lu_name *lname, const struct lu_fid *lf,
                            const struct md_attr *ma)
@@ -747,6 +832,10 @@ static int cml_name_insert(const struct lu_env *env, struct md_object *p,
         RETURN(rc);
 }
 
+/**
+ * \ingroup cmm
+ * Check two fids are not subdirectories.
+ */
 static int cmm_is_subdir(const struct lu_env *env, struct md_object *mo,
                          const struct lu_fid *fid, struct lu_fid *sfid)
 {
@@ -778,24 +867,37 @@ static const struct md_dir_operations cml_dir_ops = {
         .mdo_rename_tgt  = cml_rename_tgt,
         .mdo_create_data = cml_create_data
 };
+/** @} */
+/** @} */
 
-/* -------------------------------------------------------------------
- * remote CMM object operations. cmr_...
+/**
+ * \addtogroup cmr
+ * @{
  */
+/**
+ * \name cmr helpers
+ * @{
+ */
+/** Get cmr_object from lu_object. */
 static inline struct cmr_object *lu2cmr_obj(struct lu_object *o)
 {
         return container_of0(o, struct cmr_object, cmm_obj.cmo_obj.mo_lu);
 }
+/** Get cmr_object from md_object. */
 static inline struct cmr_object *md2cmr_obj(struct md_object *mo)
 {
         return container_of0(mo, struct cmr_object, cmm_obj.cmo_obj);
 }
+/** Get cmr_object from cmm_object. */
 static inline struct cmr_object *cmm2cmr_obj(struct cmm_object *co)
 {
         return container_of0(co, struct cmr_object, cmm_obj);
 }
+/** @} */
 
-/* get proper child device from MDCs */
+/**
+ * Get proper child device from MDCs.
+ */
 static struct lu_device *cmr_child_dev(struct cmm_device *d, __u32 num)
 {
         struct lu_device *next = NULL;
@@ -812,7 +914,9 @@ static struct lu_device *cmr_child_dev(struct cmm_device *d, __u32 num)
         return next;
 }
 
-/* lu_object operations */
+/**
+ * Free cmr_object.
+ */
 static void cmr_object_free(const struct lu_env *env,
                             struct lu_object *lo)
 {
@@ -821,6 +925,9 @@ static void cmr_object_free(const struct lu_env *env,
         OBD_FREE_PTR(cro);
 }
 
+/**
+ * Initialize cmr object.
+ */
 static int cmr_object_init(const struct lu_env *env, struct lu_object *lo,
                            const struct lu_object_conf *unused)
 {
@@ -848,6 +955,9 @@ static int cmr_object_init(const struct lu_env *env, struct lu_object *lo,
         RETURN(rc);
 }
 
+/**
+ * Output lu_object data.
+ */
 static int cmr_object_print(const struct lu_env *env, void *cookie,
                             lu_printer_t p, const struct lu_object *lo)
 {
@@ -855,13 +965,25 @@ static int cmr_object_print(const struct lu_env *env, void *cookie,
         return (*p)(env, cookie, "[remote](mds_num=%d)", cro->cmo_num);
 }
 
+/**
+ * Cmr instance of lu_object_operations.
+ */
 static const struct lu_object_operations cmr_obj_ops = {
         .loo_object_init    = cmr_object_init,
         .loo_object_free    = cmr_object_free,
         .loo_object_print   = cmr_object_print
 };
 
-/* CMM remote md_object operations. All are invalid */
+/**
+ * \name cmr remote md_object operations.
+ * All operations here are invalid and return errors. There is no local object
+ * so these operations return two kinds of error:
+ * -# -EFAULT if operation is prohibited.
+ * -# -EREMOTE if operation can be done just to notify upper level about remote
+ *  object.
+ *
+ * @{
+ */
 static int cmr_object_create(const struct lu_env *env,
                              struct md_object *mo,
                              const struct md_op_spec *spec,
@@ -967,20 +1089,29 @@ static int cmr_object_sync(const struct lu_env *env, struct md_object *mo)
         return -EFAULT;
 }
 
+/**
+ * cmr moo_version_get().
+ */
 static dt_obj_version_t cmr_version_get(const struct lu_env *env,
                                         struct md_object *mo)
 {
-        /* Don't check remote object version */
+        /** Don't check remote object version */
         return 0;
 }
 
+
+/**
+ * cmr moo_version_set().
+ * No need to update remote object version here, it is done as a part
+ * of reintegration of partial operation on the remote server.
+ */
 static void cmr_version_set(const struct lu_env *env, struct md_object *mo,
                             dt_obj_version_t version)
 {
-        /* No need to update remote object version here, it is done as a part
-         * of reintegration of partial operation on the remote server */
+        return;
 }
 
+/** Set of md_object_operations for cmr. */
 static const struct md_object_operations cmr_mo_ops = {
         .moo_permission    = cmr_permission,
         .moo_attr_get      = cmr_attr_get,
@@ -1002,8 +1133,20 @@ static const struct md_object_operations cmr_mo_ops = {
         .moo_version_set   = cmr_version_set,
         .moo_path          = cmr_path,
 };
+/** @} */
 
-/* remote part of md_dir operations */
+/**
+ * \name cmr md_dir operations.
+ *
+ * All methods below are cross-ref by nature. They consist of remote call and
+ * local operation. Due to future rollback functionality there are several
+ * limitations for such methods:
+ * -# remote call should be done at first to do epoch negotiation between all
+ * MDS involved and to avoid the RPC inside transaction.
+ * -# only one RPC can be sent - also due to epoch negotiation.
+ * For more details see rollback HLD/DLD.
+ * @{
+ */
 static int cmr_lookup(const struct lu_env *env, struct md_object *mo_p,
                       const struct lu_name *lname, struct lu_fid *lf,
                       struct md_op_spec *spec)
@@ -1016,20 +1159,22 @@ static int cmr_lookup(const struct lu_env *env, struct md_object *mo_p,
         return -EREMOTE;
 }
 
+/** Return lock mode. */
 static mdl_mode_t cmr_lock_mode(const struct lu_env *env,
                                 struct md_object *mo, mdl_mode_t lm)
 {
         return MDL_MINMODE;
 }
 
-/*
- * All methods below are cross-ref by nature. They consist of remote call and
- * local operation. Due to future rollback functionality there are several
- * limitations for such methods:
- * 1) remote call should be done at first to do epoch negotiation between all
- * MDS involved and to avoid the RPC inside transaction.
- * 2) only one RPC can be sent - also due to epoch negotiation.
- * For more details see rollback HLD/DLD.
+/**
+ * Create operation for cmr.
+ * Remote object creation and local name insert.
+ *
+ * \param mo_p Parent directory. Local object.
+ * \param lchild_name name of file to create.
+ * \param mo_c Child object. It has no real inode yet.
+ * \param spec creation specification.
+ * \param ma child object attributes.
  */
 static int cmr_create(const struct lu_env *env, struct md_object *mo_p,
                       const struct lu_name *lchild_name, struct md_object *mo_c,
@@ -1091,10 +1236,9 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p,
         if (rc)
                 RETURN(rc);
 
-        /* Remote object creation and local name insert. */
-        /*
-         * XXX: @ma will be changed after mo_object_create, but we will use
-         * it for mdo_name_insert later, so save it before mo_object_create.
+        /**
+         * \note \a ma will be changed after mo_object_create(), but we will use
+         * it for mdo_name_insert() later, so save it before mo_object_create().
          */
         *tmp_ma = *ma;
         rc = mo_object_create(env, md_object_next(mo_c), spec, ma);
@@ -1115,6 +1259,18 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p,
         RETURN(rc);
 }
 
+/**
+ * Link operations for cmr.
+ *
+ * The link RPC is always issued to the server where source parent is living.
+ * The first operation to do is object nlink increment on remote server.
+ * Second one is local mdo_name_insert().
+ *
+ * \param mo_p parent directory. It is local.
+ * \param mo_s source object to link. It is remote.
+ * \param lname Name of link file.
+ * \param ma object attributes.
+ */
 static int cmr_link(const struct lu_env *env, struct md_object *mo_p,
                     struct md_object *mo_s, const struct lu_name *lname,
                     struct md_attr *ma)
@@ -1153,6 +1309,18 @@ static int cmr_link(const struct lu_env *env, struct md_object *mo_p,
         RETURN(rc);
 }
 
+/**
+ * Unlink operations for cmr.
+ *
+ * The unlink RPC is always issued to the server where parent is living. Hence
+ * the first operation to do is object unlink on remote server. Second one is
+ * local mdo_name_remove().
+ *
+ * \param mo_p parent md_object. It is local.
+ * \param mo_c child object to be unlinked. It is remote.
+ * \param lname Name of file to unlink.
+ * \param ma object attributes.
+ */
 static int cmr_unlink(const struct lu_env *env, struct md_object *mo_p,
                       struct md_object *mo_c, const struct lu_name *lname,
                       struct md_attr *ma)
@@ -1169,8 +1337,8 @@ static int cmr_unlink(const struct lu_env *env, struct md_object *mo_p,
                 RETURN(rc);
 
         /*
-         * XXX: @ma will be changed after mo_ref_del, but we will use
-         * it for mdo_name_remove later, so save it before mo_ref_del.
+         * \note \a ma will be changed after mo_ref_del, but we will use
+         * it for mdo_name_remove() later, so save it before mo_ref_del().
          */
         cmi = cmm_env_info(env);
         tmp_ma = &cmi->cmi_ma;
@@ -1192,6 +1360,7 @@ static int cmr_unlink(const struct lu_env *env, struct md_object *mo_p,
         RETURN(rc);
 }
 
+/** Helper which outputs error message during cmr_rename() */
 static inline void cmr_rename_warn(const char *fname,
                                   struct md_object *mo_po,
                                   struct md_object *mo_pn,
@@ -1208,6 +1377,20 @@ static inline void cmr_rename_warn(const char *fname,
               PFID(lf), s_name, t_name, err);
 }
 
+/**
+ * Rename operation for cmr.
+ *
+ * This is the most complex cross-reference operation. It may consist of up to 4
+ * MDS server and require several RPCs to be sent.
+ *
+ * \param mo_po Old parent object.
+ * \param mo_pn New parent object.
+ * \param lf FID of object to rename.
+ * \param ls_name Source file name.
+ * \param mo_t target object. Should be NULL here.
+ * \param lt_name Name of target file.
+ * \param ma object attributes.
+ */
 static int cmr_rename(const struct lu_env *env,
                       struct md_object *mo_po, struct md_object *mo_pn,
                       const struct lu_fid *lf, const struct lu_name *ls_name,
@@ -1232,16 +1415,18 @@ static int cmr_rename(const struct lu_env *env,
         if (rc)
                 RETURN(rc);
 
-        /*
-         * XXX: @ma maybe changed after mdo_rename_tgt, but we will use it
-         * for mdo_name_remove later, so save it before mdo_rename_tgt.
+        /**
+         * \todo \a ma maybe changed after mdo_rename_tgt(), but we will use it
+         * for mdo_name_remove() later, so save it before mdo_rename_tgt.
          */
         cmi = cmm_env_info(env);
         tmp_ma = &cmi->cmi_ma;
         *tmp_ma = *ma;
-        /* the mo_pn is remote directory, so we cannot even know if there is
-         * mo_t or not. Therefore mo_t is NULL here but remote server should do
-         * lookup and process this further */
+        /**
+         * \note The \a mo_pn is remote directory, so we cannot even know if there is
+         * \a mo_t or not. Therefore \a mo_t is NULL here but remote server should do
+         * lookup and process this further.
+         */
         rc = mdo_rename_tgt(env, md_object_next(mo_pn),
                             NULL/* mo_t */, lf, lt_name, ma);
         if (rc)
@@ -1268,8 +1453,10 @@ static int cmr_rename(const struct lu_env *env,
         RETURN(rc);
 }
 
-/* part of cross-ref rename(). Used to insert new name in new parent
- * and unlink target */
+/**
+ * Part of cross-ref rename().
+ * Used to insert new name in new parent and unlink target.
+ */
 static int cmr_rename_tgt(const struct lu_env *env,
                           struct md_object *mo_p, struct md_object *mo_t,
                           const struct lu_fid *lf, const struct lu_name *lname,
@@ -1313,7 +1500,10 @@ static int cmr_rename_tgt(const struct lu_env *env,
         }
         RETURN(rc);
 }
-
+/** @} */
+/**
+ * The md_dir_operations for cmr.
+ */
 static const struct md_dir_operations cmr_dir_ops = {
         .mdo_is_subdir   = cmm_is_subdir,
         .mdo_lookup      = cmr_lookup,
@@ -1324,3 +1514,4 @@ static const struct md_dir_operations cmr_dir_ops = {
         .mdo_rename      = cmr_rename,
         .mdo_rename_tgt  = cmr_rename_tgt
 };
+/** @} */
index 8c047df..5871a81 100644 (file)
 #include "cmm_internal.h"
 #include "mdc_internal.h"
 
+/**
+ * \addtogroup split
+ * @{
+ */
 enum {
         CMM_SPLIT_SIZE =  128 * 1024
 };
 
-/*
- * This function checks if passed @name come to correct server (local MDT). If
- * not - return -ERESTART and let client know that dir was split and client
- * needs to chose correct stripe.
+/**
+ * This function checks if passed \a name come to correct server (local MDT).
+ *
+ * \param mp Parent directory
+ * \param name Name to lookup
+ * \retval  -ERESTART Let client know that dir was split and client needs to
+ * chose correct stripe.
  */
 int cmm_split_check(const struct lu_env *env, struct md_object *mp,
                     const char *name)
@@ -108,17 +115,16 @@ int cmm_split_check(const struct lu_env *env, struct md_object *mp,
         if (ma->ma_lmv->mea_count != 0) {
                 int idx;
 
-                /*
-                 * Get stripe by name to check the name belongs to master dir,
-                 * otherwise return the -ERESTART
+                /**
+                 * This gets stripe by name to check the name belongs to master
+                 * dir, otherwise return the -ERESTART
                  */
                 idx = mea_name2idx(ma->ma_lmv, name, strlen(name));
 
-                /*
-                 * Check if name came to correct MDT server. We suppose that if
-                 * client does not know about split, it sends create operation
-                 * to master MDT. And this is master job to say it that dir got
-                 * split and client should orward request to correct MDT. This
+                /**
+                 * When client does not know about split, it sends create() to
+                 * the master MDT and master replay back if directory is split.
+                 * So client should orward request to correct MDT. This
                  * is why we check here if stripe zero or not. Zero stripe means
                  * master stripe. If stripe calculated from name is not zero -
                  * return -ERESTART.
@@ -141,9 +147,9 @@ out:
         return rc;
 }
 
-/*
- * Return preferable access mode to caller taking into account possible split
- * and the fact of existing not splittable dirs in principle.
+/**
+ * Return preferable access mode to the caller taking into account the split
+ * case and the fact of existing not splittable dirs.
  */
 int cmm_split_access(const struct lu_env *env, struct md_object *mo,
                      mdl_mode_t lm)
@@ -181,7 +187,13 @@ int cmm_split_access(const struct lu_env *env, struct md_object *mo,
         RETURN(MDL_MINMODE);
 }
 
-/* Check if split is expected for current thread. */
+/**
+ * Check if split is expected for current thread.
+ *
+ * \param mo Directory to split.
+ * \param ma md attributes.
+ * \param split Flag to save split information.
+ */
 int cmm_split_expect(const struct lu_env *env, struct md_object *mo,
                      struct md_attr *ma, int *split)
 {
@@ -250,9 +262,9 @@ static inline void cmm_object_put(const struct lu_env *env,
         lu_object_put(env, &o->cmo_obj.mo_lu);
 }
 
-/*
- * Allocate new on passed @mc for slave object which is going to create there
- * soon.
+/**
+ * Allocate new FID on passed \a mc for slave object which is going to
+ * create there soon.
  */
 static int cmm_split_fid_alloc(const struct lu_env *env,
                                struct cmm_device *cmm,
@@ -266,7 +278,7 @@ static int cmm_split_fid_alloc(const struct lu_env *env,
 
         cfs_down(&mc->mc_fid_sem);
 
-        /* Alloc new fid on @mc. */
+        /* Alloc new fid on \a mc. */
         rc = obd_fid_alloc(mc->mc_desc.cl_exp, fid, NULL);
         if (rc > 0)
                 rc = 0;
@@ -275,7 +287,9 @@ static int cmm_split_fid_alloc(const struct lu_env *env,
         RETURN(rc);
 }
 
-/* Allocate new slave object on passed @mc */
+/**
+ * Allocate new slave object on passed \a mc.
+ */
 static int cmm_split_slave_create(const struct lu_env *env,
                                   struct cmm_device *cmm,
                                   struct mdc_device *mc,
@@ -313,9 +327,9 @@ static int cmm_split_slave_create(const struct lu_env *env,
         RETURN(rc);
 }
 
-/*
- * Create so many slaves as number of stripes. This is called in split time
- * before sending pages to slaves.
+/**
+ * Create so many slaves as number of stripes.
+ * This is called in split time before sending pages to slaves.
  */
 static int cmm_split_slaves_create(const struct lu_env *env,
                                    struct md_object *mo,
@@ -366,6 +380,9 @@ static inline int cmm_split_special_entry(struct lu_dirent *ent)
         return 0;
 }
 
+/**
+ * Convert string to the lu_name structure.
+ */
 static inline struct lu_name *cmm_name(const struct lu_env *env,
                                        char *name, int buflen)
 {
@@ -383,9 +400,9 @@ static inline struct lu_name *cmm_name(const struct lu_env *env,
         return lname;
 }
 
-/*
- * Remove one entry from local MDT. Do not corrupt byte order in page, it will
- * be sent to remote MDT.
+/**
+ * Helper for cmm_split_remove_page(). It removes one entry from local MDT.
+ * Do not corrupt byte order in page, it will be sent to remote MDT.
  */
 static int cmm_split_remove_entry(const struct lu_env *env,
                                   struct md_object *mo,
@@ -414,8 +431,8 @@ static int cmm_split_remove_entry(const struct lu_env *env,
         if (lu_object_exists(&obj->cmo_obj.mo_lu) > 0)
                 is_dir = S_ISDIR(lu_object_attr(&obj->cmo_obj.mo_lu));
         else
-                /*
-                 * XXX: These days only cross-ref dirs are possible, so for the
+                /**
+                 * \note These days only cross-ref dirs are possible, so for the
                  * sake of simplicity, in split, we suppose that all cross-ref
                  * names point to directory and do not do additional getattr to
                  * remote MDT.
@@ -428,8 +445,8 @@ static int cmm_split_remove_entry(const struct lu_env *env,
 
         memcpy(name, ent->lde_name, le16_to_cpu(ent->lde_namelen));
         lname = cmm_name(env, name, le16_to_cpu(ent->lde_namelen) + 1);
-        /*
-         * When split, no need update parent's ctime,
+        /**
+         * \note When split, no need update parent's ctime,
          * and no permission check for name_remove.
          */
         ma->ma_attr.la_ctime = 0;
@@ -446,11 +463,10 @@ static int cmm_split_remove_entry(const struct lu_env *env,
         if (rc)
                 GOTO(cleanup, rc);
 
-        /*
-         * This @ent will be transferred to slave MDS and insert there, so in
-         * the slave MDS, we should know whether this object is dir or not, so
-         * use the highest bit of the hash to indicate that (because we do not
-         * use highest bit of hash).
+        /**
+         * \note For each entry transferred to the slave MDS we should know
+         * whether this object is dir or not. Therefore the highest bit of the
+         * hash is used to indicate that (it is unused for hash purposes anyway).
          */
         if (is_dir) {
                 ent->lde_hash = le64_to_cpu(ent->lde_hash);
@@ -462,9 +478,9 @@ cleanup:
         return rc;
 }
 
-/*
- * Remove all entries from passed page. These entries are going to remote MDT
- * and thus should be removed locally.
+/**
+ * Remove all entries from passed page.
+ * These entries are going to remote MDT and thus should be removed locally.
  */
 static int cmm_split_remove_page(const struct lu_env *env,
                                  struct md_object *mo,
@@ -506,7 +522,10 @@ unmap:
         return rc;
 }
 
-/* Send one page to remote MDT for creating entries there. */
+/**
+ * Send one page of entries to the slave MDT.
+ * This page contains entries to be created there.
+ */
 static int cmm_split_send_page(const struct lu_env *env,
                                struct md_object *mo,
                                struct lu_rdpg *rdpg,
@@ -527,7 +546,7 @@ static int cmm_split_send_page(const struct lu_env *env,
         RETURN(rc);
 }
 
-/* Read one page of entries from local MDT. */
+/** Read one page of entries from local MDT. */
 static int cmm_split_read_page(const struct lu_env *env,
                                struct md_object *mo,
                                struct lu_rdpg *rdpg)
@@ -540,9 +559,8 @@ static int cmm_split_read_page(const struct lu_env *env,
         RETURN(rc);
 }
 
-/*
- * This function performs migration of all pages with entries which fit into one
- * stripe and one hash segment.
+/**
+ * This function performs migration of each directory stripe to its MDS.
  */
 static int cmm_split_process_stripe(const struct lu_env *env,
                                     struct md_object *mo,
@@ -558,21 +576,24 @@ static int cmm_split_process_stripe(const struct lu_env *env,
                 struct lu_dirpage *ldp;
                 __u32 len = 0;
 
-                /* Read one page from local MDT. */
+                /** - Read one page of entries from local MDT. */
                 rc = cmm_split_read_page(env, mo, rdpg);
                 if (rc) {
                         CERROR("Error in readpage: %d\n", rc);
                         RETURN(rc);
                 }
 
-                /* Remove local entries which are going to remite MDT. */
+                /** - Remove local entries which are going to remite MDT. */
                 rc = cmm_split_remove_page(env, mo, rdpg, end, &len);
                 if (rc) {
                         CERROR("Error in remove stripe entries: %d\n", rc);
                         RETURN(rc);
                 }
 
-                /* Send entries page to slave MDT. */
+                /**
+                 * - Send entries page to slave MDT and repeat while there are
+                 * more pages.
+                 */
                 if (len > 0) {
                         rc = cmm_split_send_page(env, mo, rdpg, lf, len);
                         if (rc) {
@@ -593,6 +614,11 @@ static int cmm_split_process_stripe(const struct lu_env *env,
         RETURN(rc);
 }
 
+/**
+ * Directory scanner for split operation.
+ *
+ * It calculates hashes for names and organizes files to stripes.
+ */
 static int cmm_split_process_dir(const struct lu_env *env,
                                  struct md_object *mo,
                                  struct md_attr *ma)
@@ -615,7 +641,12 @@ static int cmm_split_process_dir(const struct lu_env *env,
         }
 
         hash_segment = MAX_HASH_SIZE;
+        /** Whole hash range is divided on segments by number of MDS-es. */
         do_div(hash_segment, cmm->cmm_tgt_count + 1);
+        /**
+         * For each segment the cmm_split_process_stripe() is called to move
+         * entries on new server.
+         */
         for (i = 1; i < cmm->cmm_tgt_count + 1; i++) {
                 struct lu_fid *lf;
                 __u64 hash_end;
@@ -643,6 +674,11 @@ cleanup:
         return rc;
 }
 
+/**
+ * Directory splitting.
+ *
+ * Big directory can be split eventually.
+ */
 int cmm_split_dir(const struct lu_env *env, struct md_object *mo)
 {
         struct cmm_device *cmm = cmm_obj2dev(md2cmm_obj(mo));
@@ -656,7 +692,7 @@ int cmm_split_dir(const struct lu_env *env, struct md_object *mo)
         LASSERT(S_ISDIR(lu_object_attr(&mo->mo_lu)));
         memset(ma, 0, sizeof(*ma));
 
-        /* Step1: Checking whether the dir needs to be split. */
+        /** - Step1: Checking whether the dir needs to be split. */
         rc = cmm_split_expect(env, mo, ma, &split);
         if (rc)
                 GOTO(out, rc);
@@ -670,8 +706,8 @@ int cmm_split_dir(const struct lu_env *env, struct md_object *mo)
         CWARN("Dir "DFID" is going to split (size: "LPU64")\n",
               PFID(lu_object_fid(&mo->mo_lu)), ma->ma_attr.la_size);
 
-        /*
-         * Disable transacrions for split, since there will be so many trans in
+        /**
+         * /note Disable transactions for split, since there will be so many trans in
          * this one ops, conflict with current recovery design.
          */
         rc = cmm_upcall(env, &cmm->cmm_md_dev, MD_NO_TRANS, NULL);
@@ -680,27 +716,27 @@ int cmm_split_dir(const struct lu_env *env, struct md_object *mo)
                 GOTO(out, rc);
         }
 
-        /* Step2: Prepare the md memory */
+        /** - Step2: Prepare the md memory */
         ma->ma_lmv_size = CMM_MD_SIZE(cmm->cmm_tgt_count + 1);
         OBD_ALLOC(ma->ma_lmv, ma->ma_lmv_size);
         if (ma->ma_lmv == NULL)
                 GOTO(out, rc = -ENOMEM);
 
-        /* Step3: Create slave objects and fill the ma->ma_lmv */
+        /** - Step3: Create slave objects and fill the ma->ma_lmv */
         rc = cmm_split_slaves_create(env, mo, ma);
         if (rc) {
                 CERROR("Can't create slaves for split, rc %d\n", rc);
                 GOTO(cleanup, rc);
         }
 
-        /* Step4: Scan and split the object. */
+        /** - Step4: Scan and split the object. */
         rc = cmm_split_process_dir(env, mo, ma);
         if (rc) {
                 CERROR("Can't scan and split, rc %d\n", rc);
                 GOTO(cleanup, rc);
         }
 
-        /* Step5: Set mea to the master object. */
+        /** - Step5: Set mea to the master object. */
         buf = cmm_buf_get(env, ma->ma_lmv, ma->ma_lmv_size);
         rc = mo_xattr_set(env, md_object_next(mo), buf,
                           MDS_LMV_MD_NAME, 0);
@@ -712,8 +748,8 @@ int cmm_split_dir(const struct lu_env *env, struct md_object *mo)
         /* set flag in cmm_object */
         md2cml_obj(mo)->clo_split = CMM_SPLIT_DONE;
 
-        /*
-         * Finally, split succeed, tell client to repeat opetartion on correct
+        /**
+         * Finally, split succeed, tell client to repeat opetartion on correct
          * MDT.
          */
         CWARN("Dir "DFID" has been split\n", PFID(lu_object_fid(&mo->mo_lu)));
@@ -725,3 +761,4 @@ out:
         cmm_lprocfs_time_end(env, cmm, LPROC_CMM_SPLIT);
         return rc;
 }
+/** @} */
index 339540b..0f5ad10 100644 (file)
 #include "mdc_internal.h"
 
 static const struct lu_device_operations mdc_lu_ops;
-
-static inline int lu_device_is_mdc(struct lu_device *ld)
-{
-       return ergo(ld != NULL && ld->ld_ops != NULL,
-                    ld->ld_ops == &mdc_lu_ops);
-}
-
+/**
+ * \addtogroup cmm_mdc
+ * @{
+ */
+/**
+ * The md_device_operation for mdc. It is empty.
+ */
 static const struct md_device_operations mdc_md_ops = { 0 };
 
+/**
+ * Upcall handler in mdc. Analog of obd_device::o_notify().
+ */
 static int mdc_obd_update(struct obd_device *host,
                           struct obd_device *watched,
                           enum obd_notify_event ev, void *owner, void *data)
@@ -92,10 +95,14 @@ static int mdc_obd_update(struct obd_device *host,
 
         RETURN(rc);
 }
-/* MDC OBD is set up already and connected to the proper MDS
+/**
+ * Add new mdc device.
+ * Invoked by configuration command LCFG_ADD_MDC.
+ *
+ * MDC OBD is set up already and connected to the proper MDS
  * mdc_add_obd() find that obd by uuid and connects to it.
- * Local MDT uuid is used for connection
- * */
+ * Local MDT uuid is used for connection.
+ */
 static int mdc_obd_add(const struct lu_env *env,
                        struct mdc_device *mc, struct lustre_cfg *cfg)
 {
@@ -182,6 +189,12 @@ static int mdc_obd_add(const struct lu_env *env,
         RETURN(rc);
 }
 
+/**
+ * Delete mdc device.
+ * Called when configuration command LCFG_CLEANUP is issued.
+ *
+ * This disconnects MDC OBD and cleanup it.
+ */
 static int mdc_obd_del(const struct lu_env *env, struct mdc_device *mc,
                        struct lustre_cfg *cfg)
 {
@@ -223,6 +236,10 @@ static int mdc_obd_del(const struct lu_env *env, struct mdc_device *mc,
         RETURN(0);
 }
 
+/**
+ * Process config command. Passed to the mdc from mdt.
+ * Supports two commands only - LCFG_ADD_MDC and LCFG_CLEANUP
+ */
 static int mdc_process_config(const struct lu_env *env,
                               struct lu_device *ld,
                               struct lustre_cfg *cfg)
@@ -244,11 +261,17 @@ static int mdc_process_config(const struct lu_env *env,
         RETURN(rc);
 }
 
+/**
+ * lu_device_operations instance for mdc.
+ */
 static const struct lu_device_operations mdc_lu_ops = {
         .ldo_object_alloc   = mdc_object_alloc,
         .ldo_process_config = mdc_process_config
 };
 
+/**
+ * Initialize proper easize and cookie size.
+ */
 void cmm_mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc,
                       int max_mdsize, int max_cookiesize)
 {
@@ -258,12 +281,14 @@ void cmm_mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc,
         obd->u.cli.cl_max_mds_cookiesize = max_cookiesize;
 }
 
+/** Start mdc device */
 static int mdc_device_init(const struct lu_env *env, struct lu_device *ld,
                            const char *name, struct lu_device *next)
 {
         return 0;
 }
 
+/** Stop mdc device. */
 static struct lu_device *mdc_device_fini(const struct lu_env *env,
                                          struct lu_device *ld)
 {
@@ -271,6 +296,7 @@ static struct lu_device *mdc_device_fini(const struct lu_env *env,
         RETURN (NULL);
 }
 
+/** Allocate new mdc device */
 static struct lu_device *mdc_device_alloc(const struct lu_env *env,
                                           struct lu_device_type *ldt,
                                           struct lustre_cfg *cfg)
@@ -293,6 +319,7 @@ static struct lu_device *mdc_device_alloc(const struct lu_env *env,
         RETURN (ld);
 }
 
+/** Free mdc device */
 static struct lu_device *mdc_device_free(const struct lu_env *env,
                                          struct lu_device *ld)
 {
@@ -306,13 +333,13 @@ static struct lu_device *mdc_device_free(const struct lu_env *env,
         return NULL;
 }
 
-/* context key constructor/destructor: mdc_key_init, mdc_key_fini */
+/** context key constructor/destructor: mdc_key_init, mdc_key_fini */
 LU_KEY_INIT_FINI(mdc, struct mdc_thread_info);
 
-/* context key: mdc_thread_key */
+/** context key: mdc_thread_key */
 LU_CONTEXT_KEY_DEFINE(mdc, LCT_MD_THREAD|LCT_CL_THREAD);
 
-/* type constructor/destructor: mdc_type_init, mdc_type_fini */
+/** type constructor/destructor: mdc_type_init, mdc_type_fini */
 LU_TYPE_INIT_FINI(mdc, &mdc_thread_key);
 
 static struct lu_device_type_operations mdc_device_type_ops = {
@@ -335,3 +362,4 @@ struct lu_device_type mdc_device_type = {
         .ldt_ops      = &mdc_device_type_ops,
         .ldt_ctx_tags = LCT_MD_THREAD|LCT_CL_THREAD
 };
+/** @} */
index 8cf22be..820bd41 100644 (file)
 #include <lustre_net.h>
 #include <obd.h>
 #include <md_object.h>
-
+/**
+ * \addtogroup cmm
+ * @{
+ */
+/**
+ * \defgroup cmm_mdc cmm_mdc
+ *
+ * This is mdc wrapper device to work with old MDC obd-based devices.
+ * @{
+ */
+/**
+ * MDC client description.
+ */
 struct mdc_cli_desc {
-        /* uuid of remote MDT to connect */
+        /** uuid of remote MDT to connect */
         struct obd_uuid          cl_srv_uuid;
-        /* mdc uuid */
+        /** mdc uuid */
         struct obd_uuid          cl_cli_uuid;
-        /* export of mdc obd */
+        /** export of mdc obd */
         struct obd_export        *cl_exp;
 };
 
+/**
+ * MDC device.
+ */
 struct mdc_device {
+        /** md_device instance for MDC */
         struct md_device        mc_md_dev;
-        /* other MD servers in cluster */
+        /** other MD servers in cluster */
         cfs_list_t              mc_linkage;
+        /** number of current device */
         mdsno_t                 mc_num;
+        /** mdc client description */
         struct mdc_cli_desc     mc_desc;
+        /** Protects ??*/
         cfs_semaphore_t         mc_fid_sem;
 };
 
+/**
+ * mdc thread info. Local storage for varios data.
+ */
 struct mdc_thread_info {
+        /** Storage for md_op_data */
         struct md_op_data       mci_opdata;
+        /** Storage for ptlrpc request */
         struct ptlrpc_request  *mci_req;
 };
 
+/** mdc object. */
 struct mdc_object {
+        /** md_object instance for mdc_object */
         struct md_object        mco_obj;
 };
 
+/** Get lu_device from mdc_device. */
 static inline struct lu_device *mdc2lu_dev(struct mdc_device *mc)
 {
         return (&mc->mc_md_dev.md_lu_dev);
 }
 
+/** Get mdc_device from md_device. */
 static inline struct mdc_device *md2mdc_dev(struct md_device *md)
 {
         return container_of0(md, struct mdc_device, mc_md_dev);
 }
 
+/** Get mdc_device from mdc_object. */
 static inline struct mdc_device *mdc_obj2dev(struct mdc_object *mco)
 {
         return (md2mdc_dev(md_obj2dev(&mco->mco_obj)));
 }
 
+/** Get mdc_object from lu_object. */
 static inline struct mdc_object *lu2mdc_obj(struct lu_object *lo)
 {
         return container_of0(lo, struct mdc_object, mco_obj.mo_lu);
 }
 
+/** Get mdc_object from md_object. */
 static inline struct mdc_object *md2mdc_obj(struct md_object *mo)
 {
         return container_of0(mo, struct mdc_object, mco_obj);
 }
 
+/** Get mdc_device from lu_device. */
 static inline struct mdc_device *lu2mdc_dev(struct lu_device *ld)
 {
         return container_of0(ld, struct mdc_device, mc_md_dev.md_lu_dev);
@@ -116,6 +148,7 @@ void cmm_mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc,
 int mdc_send_page(struct cmm_device *cmm, const struct lu_env *env,
                   struct md_object *mo, struct page *page, __u32 end);
 #endif
-
+/** @} */
+/** @} */
 #endif /* __KERNEL__ */
 #endif /* _CMM_MDC_INTERNAL_H */
index 191cbbf..d373f0b 100644 (file)
@@ -57,35 +57,45 @@ static const struct md_dir_operations mdc_dir_ops;
 static const struct lu_object_operations mdc_obj_ops;
 
 extern struct lu_context_key mdc_thread_key;
-
+/**
+ * \addtogroup cmm_mdc
+ * @{
+ */
+/**
+ * Allocate new mdc object.
+ */
 struct lu_object *mdc_object_alloc(const struct lu_env *env,
                                    const struct lu_object_header *hdr,
                                    struct lu_device *ld)
 {
-       struct mdc_object *mco;
+        struct mdc_object *mco;
         ENTRY;
 
-       OBD_ALLOC_PTR(mco);
-       if (mco != NULL) {
-               struct lu_object *lo;
+        OBD_ALLOC_PTR(mco);
+        if (mco != NULL) {
+                struct lu_object *lo;
 
-               lo = &mco->mco_obj.mo_lu;
+                lo = &mco->mco_obj.mo_lu;
                 lu_object_init(lo, NULL, ld);
                 mco->mco_obj.mo_ops = &mdc_mo_ops;
                 mco->mco_obj.mo_dir_ops = &mdc_dir_ops;
                 lo->lo_ops = &mdc_obj_ops;
                 RETURN(lo);
-       } else
-               RETURN(NULL);
+        } else
+                RETURN(NULL);
 }
 
+/** Free current mdc object */
 static void mdc_object_free(const struct lu_env *env, struct lu_object *lo)
 {
         struct mdc_object *mco = lu2mdc_obj(lo);
-       lu_object_fini(lo);
+        lu_object_fini(lo);
         OBD_FREE_PTR(mco);
 }
 
+/**
+ * Initialize mdc object. All of them have loh_attr::LOHA_REMOTE set.
+ */
 static int mdc_object_init(const struct lu_env *env, struct lu_object *lo,
                            const struct lu_object_conf *unused)
 {
@@ -94,12 +104,21 @@ static int mdc_object_init(const struct lu_env *env, struct lu_object *lo,
         RETURN(0);
 }
 
+/**
+ * Instance of lu_object_operations for mdc.
+ */
 static const struct lu_object_operations mdc_obj_ops = {
         .loo_object_init    = mdc_object_init,
         .loo_object_free    = mdc_object_free,
 };
 
-/* md_object_operations */
+/**
+ * \name The set of md_object_operations.
+ * @{
+ */
+/**
+ * Get mdc_thread_info from lu_context
+ */
 static
 struct mdc_thread_info *mdc_info_get(const struct lu_env *env)
 {
@@ -110,6 +129,9 @@ struct mdc_thread_info *mdc_info_get(const struct lu_env *env)
         return mci;
 }
 
+/**
+ * Initialize mdc_thread_info.
+ */
 static
 struct mdc_thread_info *mdc_info_init(const struct lu_env *env)
 {
@@ -118,6 +140,9 @@ struct mdc_thread_info *mdc_info_init(const struct lu_env *env)
         return mci;
 }
 
+/**
+ * Convert attributes from mdt_body to the md_attr.
+ */
 static void mdc_body2attr(struct mdt_body *body, struct md_attr *ma)
 {
         struct lu_attr *la = &ma->ma_attr;
@@ -149,6 +174,9 @@ static void mdc_body2attr(struct mdt_body *body, struct md_attr *ma)
         ma->ma_valid = MA_INODE;
 }
 
+/**
+ * Fill the md_attr \a ma with attributes from request.
+ */
 static int mdc_req2attr_update(const struct lu_env *env,
                                struct md_attr *ma)
 {
@@ -242,6 +270,9 @@ static int mdc_req2attr_update(const struct lu_env *env,
         RETURN(0);
 }
 
+/**
+ * The md_object_operations::moo_attr_get() in mdc.
+ */
 static int mdc_attr_get(const struct lu_env *env, struct md_object *mo,
                         struct md_attr *ma)
 {
@@ -272,6 +303,9 @@ static int mdc_attr_get(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
+/**
+ * Helper to init timspec \a t.
+ */
 static inline struct timespec *mdc_attr_time(struct timespec *t, __u64 seconds)
 {
         t->tv_sec = seconds;
@@ -279,8 +313,10 @@ static inline struct timespec *mdc_attr_time(struct timespec *t, __u64 seconds)
         return t;
 }
 
-/*
- * XXX: It is only used for set ctime when rename's source on remote MDS.
+/**
+ * The md_object_operations::moo_attr_set() in mdc.
+ *
+ * \note It is only used for set ctime when rename's source on remote MDS.
  */
 static int mdc_attr_set(const struct lu_env *env, struct md_object *mo,
                         const struct md_attr *ma)
@@ -331,6 +367,9 @@ static int mdc_attr_set(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
+/**
+ * The md_object_operations::moo_object_create() in mdc.
+ */
 static int mdc_object_create(const struct lu_env *env,
                              struct md_object *mo,
                              const struct md_op_spec *spec,
@@ -408,6 +447,9 @@ static int mdc_object_create(const struct lu_env *env,
         RETURN(rc);
 }
 
+/**
+ * The md_object_operations::moo_ref_add() in mdc.
+ */
 static int mdc_ref_add(const struct lu_env *env, struct md_object *mo,
                        const struct md_attr *ma)
 {
@@ -453,6 +495,9 @@ static int mdc_ref_add(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
+/**
+ * The md_object_operations::moo_ref_del() in mdc.
+ */
 static int mdc_ref_del(const struct lu_env *env, struct md_object *mo,
                        struct md_attr *ma)
 {
@@ -500,6 +545,7 @@ static int mdc_ref_del(const struct lu_env *env, struct md_object *mo,
 }
 
 #ifdef HAVE_SPLIT_SUPPORT
+/** Send page with directory entries to another MDS. */
 int mdc_send_page(struct cmm_device *cm, const struct lu_env *env,
                   struct md_object *mo, struct page *page, __u32 offset)
 {
@@ -515,6 +561,9 @@ int mdc_send_page(struct cmm_device *cm, const struct lu_env *env,
 }
 #endif
 
+/**
+ * Instance of md_object_operations for mdc.
+ */
 static const struct md_object_operations mdc_mo_ops = {
         .moo_attr_get       = mdc_attr_get,
         .moo_attr_set       = mdc_attr_set,
@@ -522,8 +571,15 @@ static const struct md_object_operations mdc_mo_ops = {
         .moo_ref_add        = mdc_ref_add,
         .moo_ref_del        = mdc_ref_del,
 };
+/** @} */
 
-/* md_dir_operations */
+/**
+ * \name The set of md_dir_operations.
+ * @{
+ */
+/**
+ * The md_dir_operations::mdo_rename_tgt in mdc.
+ */
 static int mdc_rename_tgt(const struct lu_env *env, struct md_object *mo_p,
                           struct md_object *mo_t, const struct lu_fid *lf,
                           const struct lu_name *lname, struct md_attr *ma)
@@ -576,10 +632,13 @@ static int mdc_rename_tgt(const struct lu_env *env, struct md_object *mo_p,
 
         RETURN(rc);
 }
-/*
- * Return resulting fid in sfid
- * 0: fids are not relatives
- * fid: fid at which search stopped
+/**
+ * Check the fids are not relatives.
+ * The md_dir_operations::mdo_is_subdir() in mdc.
+ *
+ * Return resulting fid in sfid.
+ * \retval \a sfid = 0 fids are not relatives
+ * \retval \a sfid = FID at which search stopped
  */
 static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo,
                          const struct lu_fid *fid, struct lu_fid *sfid)
@@ -607,7 +666,9 @@ static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
+/** Instance of md_dir_operations for mdc. */
 static const struct md_dir_operations mdc_dir_ops = {
         .mdo_is_subdir   = mdc_is_subdir,
         .mdo_rename_tgt  = mdc_rename_tgt
 };
+/** @} */