Whamcloud - gitweb
(1) remove const from md_attr in moo_attr_set(), because this md_attr may be ajusted...
authorhuanghua <huanghua>
Tue, 15 Aug 2006 04:03:13 +0000 (04:03 +0000)
committerhuanghua <huanghua>
Tue, 15 Aug 2006 04:03:13 +0000 (04:03 +0000)
(2) make mdd_lov_mdsize() & mdd_lov_cookiesize() as static inline;
(3) some other small fixes;

lustre/cmm/cmm_object.c
lustre/include/md_object.h
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/mdt/mdt_internal.h

index a275d6f..29a9ca0 100644 (file)
@@ -231,7 +231,7 @@ static int cml_attr_get(const struct lu_context *ctx, struct md_object *mo,
 }
 
 static int cml_attr_set(const struct lu_context *ctx, struct md_object *mo,
-                        const struct md_attr *attr)
+                        struct md_attr *attr)
 {
         int rc;
         ENTRY;
@@ -562,7 +562,7 @@ static int cmr_attr_get(const struct lu_context *ctx, struct md_object *mo,
 }
 
 static int cmr_attr_set(const struct lu_context *ctx, struct md_object *mo,
-                        const struct md_attr *attr)
+                        struct md_attr *attr)
 {
         RETURN(-EFAULT);
 }
index 8c8b089..da4e3aa 100644 (file)
@@ -94,8 +94,12 @@ struct md_create_spec {
 struct md_object_operations {
         int (*moo_attr_get)(const struct lu_context *ctxt, struct md_object *dt,
                             struct md_attr *attr);
+
+        /* the attr may be ajusted/fixed in various situation in MDD;
+         * so it is no longer a const.
+         */ 
         int (*moo_attr_set)(const struct lu_context *ctxt, struct md_object *dt,
-                            const struct md_attr *attr);
+                            struct md_attr *attr);
 
         int (*moo_xattr_get)(const struct lu_context *ctxt,
                              struct md_object *obj,
@@ -262,7 +266,7 @@ static inline int mo_readlink(const struct lu_context *cx, struct md_object *m,
 }
 
 static inline int mo_attr_set(const struct lu_context *cx, struct md_object *m,
-                              const struct md_attr *at)
+                              struct md_attr *at)
 {
         LASSERT(m->mo_ops->moo_attr_set);
         return m->mo_ops->moo_attr_set(cx, m, at);
index cb3dadf..0fb2599 100644 (file)
@@ -602,13 +602,13 @@ static int __mdd_xattr_set(const struct lu_context *ctxt, struct mdd_object *o,
  * and port to 
  */
 int mdd_fix_attr(const struct lu_context *ctxt, struct mdd_object *obj,
-                 const struct md_attr *ma)
+                 struct md_attr *ma)
 {
-        struct lu_attr   *la = (struct lu_attr*)&ma->ma_attr;
+        struct lu_attr   *la = &ma->ma_attr;
         struct lu_attr   *tmp_la = &mdd_ctx_info(ctxt)->mti_la;
         struct dt_object *next = mdd_object_child(obj);
         time_t            now = CURRENT_SECONDS;
-        int               rc = 0;
+        int               rc;
         ENTRY;
 
         rc = next->do_ops->do_attr_get(ctxt, next, tmp_la);
@@ -682,7 +682,7 @@ int mdd_fix_attr(const struct lu_context *ctxt, struct mdd_object *obj,
                 if (((tmp_la->la_mode & (S_ISGID | S_IXGRP)) ==
                      (S_ISGID | S_IXGRP)) && !S_ISDIR(tmp_la->la_mode)) {
                         la->la_mode &= ~S_ISGID;
-                        la->la_valid |= ATTR_MODE;
+                        la->la_valid |= LA_MODE;
                 }
         } else if (la->la_valid & LA_MODE) {
                 int mode = la->la_mode;
@@ -698,7 +698,7 @@ int mdd_fix_attr(const struct lu_context *ctxt, struct mdd_object *obj,
 
 /* set attr and LOV EA at once, return updated attr */
 static int mdd_attr_set(const struct lu_context *ctxt,
-                        struct md_object *obj, const struct md_attr *ma)
+                        struct md_object *obj, struct md_attr *ma)
 {
         struct mdd_object *mdd_obj = md2mdd_obj(obj);
         struct mdd_device *mdd = mdo2mdd(obj);
@@ -715,7 +715,7 @@ static int mdd_attr_set(const struct lu_context *ctxt,
         /* start a log jounal handle if needed */
         if (S_ISREG(mdd_object_type(mdd_obj)) &&
             ma->ma_attr.la_valid & (LA_UID | LA_GID)) {
-                mdd_lov_mdsize(ctxt, mdd, &max_size);
+                max_size = mdd_lov_mdsize(ctxt, mdd);
                 OBD_ALLOC(lmm, max_size);
                 if (lmm == NULL)
                         GOTO(cleanup, rc = -ENOMEM);
@@ -1183,7 +1183,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj,
         struct mdd_object *mdd_sobj = mdd_object_find(ctxt, mdd, lf);
         struct mdd_object *mdd_tobj = NULL;
         struct thandle *handle;
-        int rc, locked = 0;
+        int rc;
         ENTRY;
 
         if (tobj)
@@ -1686,16 +1686,12 @@ static int mdd_get_maxsize(const struct lu_context *ctx,
                            int *cookie_size)
 {
        struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
-        int rc;
-
         ENTRY;
 
-        rc = mdd_lov_mdsize(ctx, mdd, md_size);
-        if (rc)
-                RETURN(rc);
-        rc = mdd_lov_cookiesize(ctx, mdd, cookie_size);
+        *md_size =  mdd_lov_mdsize(ctx, mdd);
+        *cookie_size = mdd_lov_cookiesize(ctx, mdd);
 
-        RETURN(rc);
+        RETURN(0);
 }
 
 static void __mdd_ref_add(const struct lu_context *ctxt, struct mdd_object *obj,
index fd69c1b..17b6b0b 100644 (file)
@@ -156,8 +156,18 @@ static inline umode_t mdd_object_type(const struct mdd_object *obj)
         return lu_object_attr(&obj->mod_obj.mo_lu);
 }
 
-int mdd_lov_mdsize(const struct lu_context *ctxt, struct mdd_device *mdd,
-                   int *md_size);
-int mdd_lov_cookiesize(const struct lu_context *ctxt, struct mdd_device *mdd,
-                       int *cookie_size);
+static inline int mdd_lov_mdsize(const struct lu_context *ctxt, 
+                                 struct mdd_device *mdd)
+{
+        struct obd_device *obd = mdd2_obd(mdd);
+        return obd->u.mds.mds_max_mdsize;
+}
+
+static inline int mdd_lov_cookiesize(const struct lu_context *ctxt, 
+                                     struct mdd_device *mdd)
+{
+        struct obd_device *obd = mdd2_obd(mdd);
+        return obd->u.mds.mds_max_cookiesize;
+}
+
 #endif
index 4ecdee3..2592a1d 100644 (file)
@@ -486,7 +486,7 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
                         /* get lov ea from parent and set to lov */
                         struct lov_mds_md *__lmm;
                         int __lmm_size, returned_lmm_size;
-                        __lmm_size = mdd2_obd(mdd)->u.mds.mds_max_mdsize;
+                        __lmm_size = mdd_lov_mdsize(ctxt, mdd);
 
                         OBD_ALLOC(__lmm, __lmm_size);
                         if (__lmm == NULL)
@@ -599,19 +599,3 @@ int mdd_lov_setattr_async(const struct lu_context *ctxt, struct mdd_object *obj,
         RETURN(rc);
 }
 
-int mdd_lov_mdsize(const struct lu_context *ctxt, struct mdd_device *mdd,
-                   int *md_size)
-{
-        struct obd_device *obd = mdd2_obd(mdd);
-        *md_size = obd->u.mds.mds_max_mdsize;
-        RETURN(0);
-}
-
-int mdd_lov_cookiesize(const struct lu_context *ctxt, struct mdd_device *mdd,
-                       int *cookie_size)
-{
-        struct obd_device *obd = mdd2_obd(mdd);
-        *cookie_size = obd->u.mds.mds_max_cookiesize;
-        RETURN(0);
-}
-
index 975bd11..b416f47 100644 (file)
@@ -120,7 +120,6 @@ struct mdt_device {
         } mdt_opts;
 
         /* lock to pretect epoch and write count
-         * because we need not allocate memory, spinlock is fast.
          */
         spinlock_t                 mdt_epoch_lock;
         __u64                      mdt_io_epoch;