Whamcloud - gitweb
(1) add mdt_sync support. but we also need device_sync & object_sync supporting.
authorhuanghua <huanghua>
Wed, 21 Jun 2006 07:47:27 +0000 (07:47 +0000)
committerhuanghua <huanghua>
Wed, 21 Jun 2006 07:47:27 +0000 (07:47 +0000)
(2) ajust some code of the mdt_handler.c for forward reference.
(3) removed some used variables.

lustre/include/lustre_req_layout.h
lustre/mdt/mdt_handler.c
lustre/ptlrpc/layout.c

index 61decbf..bc9b7cd 100644 (file)
@@ -91,6 +91,7 @@ extern const struct req_format RQF_SEQ_QUERY;
 extern const struct req_format RQF_FLD_QUERY;
 extern const struct req_format RQF_MDS_GETSTATUS;
 extern const struct req_format RQF_MDS_STATFS;
+extern const struct req_format RQF_MDS_SYNC;
 extern const struct req_format RQF_MDS_GETXATTR;
 extern const struct req_format RQF_MDS_SETXATTR;
 extern const struct req_format RQF_MDS_GETATTR;
index 6e3bb8e..415acb8 100644 (file)
  */
 unsigned long mdt_num_threads;
 
+struct mdt_handler {
+        const char *mh_name;
+        int         mh_fail_id;
+        __u32       mh_opc;
+        __u32       mh_flags;
+        int (*mh_act)(struct mdt_thread_info *info);
+
+        const struct req_format *mh_fmt;
+};
+
+enum mdt_handler_flags {
+        /*
+         * struct mdt_body is passed in the incoming message, and object
+         * identified by this fid exists on disk.
+         */
+        HABEO_CORPUS = (1 << 0),
+        /*
+         * struct ldlm_request is passed in the incoming message.
+         */
+        HABEO_CLAVIS = (1 << 1),
+        /*
+         * this request has fixed reply format, so that reply message can be
+         * packed by generic code.
+         */
+        HABEO_REFERO = (1 << 2)
+};
+
+struct mdt_opc_slice {
+        __u32               mos_opc_start;
+        int                 mos_opc_end;
+        struct mdt_handler *mos_hs;
+};
+
+static struct mdt_opc_slice mdt_handlers[];
+
 static int                    mdt_handle    (struct ptlrpc_request *req);
 static struct mdt_device     *mdt_dev       (struct lu_device *d);
+static int mdt_unpack_req_pack_rep(struct mdt_thread_info *info, __u32 flags);
 
 static struct lu_context_key       mdt_thread_key;
 static struct lu_object_operations mdt_obj_ops;
 
+
 static int mdt_getstatus(struct mdt_thread_info *info)
 {
         struct md_device *next  = info->mti_mdt->mdt_child;
@@ -137,8 +174,10 @@ void mdt_pack_attr2body(struct mdt_body *b, struct lu_attr *attr)
 
 static int mdt_getattr_pack_msg(struct mdt_thread_info *info)
 {
+#ifdef MDT_CODE
         const struct mdt_body *body = info->mti_body;
         struct req_capsule *pill = &info->mti_pill;
+#endif
         struct md_object *next = mdt_object_child(info->mti_object);
         struct lu_attr *la = &info->mti_attr;
         int rc;
@@ -214,8 +253,10 @@ static int mdt_getattr_internal(struct mdt_thread_info *info)
         struct mdt_body  *repbody;
         struct lu_attr *la = &info->mti_attr;
         int rc;
+#ifdef MDT_CODE
         void *buffer;
         int length;
+#endif
         ENTRY;
 
         rc = mo_attr_get(info->mti_ctxt, next, la);
@@ -556,6 +597,61 @@ static int mdt_sync(struct mdt_thread_info *info)
         return -EOPNOTSUPP;
 }
 
+#ifdef MDT_CODE
+static int mdt_device_sync(struct mdt_device *mdt)
+{
+        return 0;
+}
+
+static int mdt_object_sync(struct mdt_object *m)
+{
+        return 0;
+}
+
+static int mdt_sync(struct mdt_thread_info *info)
+{
+        struct mdt_body *body;
+        struct req_capsule *pill = &info->mti_pill;
+        int rc;
+        ENTRY;
+        
+        req_capsule_set(pill, &RQF_MDS_SYNC);
+
+        body = req_capsule_client_get(pill, &RMF_MDT_BODY);
+        if (body == NULL)
+                RETURN(-EINVAL);
+
+        if (fid_seq(&body->fid1) == 0) {
+                /* sync the whole device */
+                rc = req_capsule_pack(pill);
+                if (rc == 0)
+                        rc = mdt_device_sync(info->mti_mdt);
+        } else {
+                /* sync an object */
+                rc = mdt_unpack_req_pack_rep(info, HABEO_CORPUS | HABEO_REFERO);
+                if (rc != 0) 
+                        RETURN(rc);
+
+                rc = mdt_object_sync(info->mti_object);
+                if (rc != 0)
+                        RETURN(rc);
+
+                rc = mo_attr_get(info->mti_ctxt, 
+                                 mdt_object_child(info->mti_object), 
+                                 &info->mti_attr);
+                if (rc != 0)
+                        RETURN(rc);
+
+                body = req_capsule_server_get(pill, &RMF_MDT_BODY);
+                mdt_pack_attr2body(body, &info->mti_attr);
+                body->fid1 = *mdt_object_fid(info->mti_object);
+                body->valid |= OBD_MD_FLID;
+        }
+        RETURN(rc);
+}
+#endif
+
+
 static int mdt_handle_quotacheck(struct mdt_thread_info *info)
 {
         return -EOPNOTSUPP;
@@ -769,40 +865,6 @@ struct mdt_object *mdt_object_find_lock(const struct lu_context *ctxt,
         return o;
 }
 
-struct mdt_handler {
-        const char *mh_name;
-        int         mh_fail_id;
-        __u32       mh_opc;
-        __u32       mh_flags;
-        int (*mh_act)(struct mdt_thread_info *info);
-
-        const struct req_format *mh_fmt;
-};
-
-enum mdt_handler_flags {
-        /*
-         * struct mdt_body is passed in the incoming message, and object
-         * identified by this fid exists on disk.
-         */
-        HABEO_CORPUS = (1 << 0),
-        /*
-         * struct ldlm_request is passed in the incoming message.
-         */
-        HABEO_CLAVIS = (1 << 1),
-        /*
-         * this request has fixed reply format, so that reply message can be
-         * packed by generic code.
-         */
-        HABEO_REFERO = (1 << 2)
-};
-
-struct mdt_opc_slice {
-        __u32               mos_opc_start;
-        int                 mos_opc_end;
-        struct mdt_handler *mos_hs;
-};
-
-static struct mdt_opc_slice mdt_handlers[];
 
 static struct mdt_handler *mdt_handler_find(__u32 opc)
 {
@@ -2433,7 +2495,7 @@ DEF_MDT_HNDL_F(0,                         REINT,        mdt_reint),
 DEF_MDT_HNDL_0(HABEO_CORPUS,              CLOSE,        mdt_close),
 DEF_MDT_HNDL_0(0,                         DONE_WRITING, mdt_done_writing),
 DEF_MDT_HNDL_0(0,                         PIN,          mdt_pin),
-DEF_MDT_HNDL_0(HABEO_CORPUS,              SYNC,         mdt_sync),
+DEF_MDT_HNDL_0(0,                         SYNC,         mdt_sync),
 DEF_MDT_HNDL_0(0,                         QUOTACHECK,   mdt_handle_quotacheck),
 DEF_MDT_HNDL_0(0,                         QUOTACTL,     mdt_handle_quotactl)
 };
index 1d84e53..f2a5ace 100644 (file)
@@ -413,6 +413,10 @@ const struct req_format RQF_MDS_STATFS =
         DEFINE_REQ_FMT0("MDS_STATFS", empty, mds_statfs_server);
 EXPORT_SYMBOL(RQF_MDS_STATFS);
 
+const struct req_format RQF_MDS_SYNC =
+        DEFINE_REQ_FMT0("MDS_SYNC", mdt_body_only, mdt_body_only);
+EXPORT_SYMBOL(RQF_MDS_SYNC);
+
 const struct req_format RQF_MDS_GETATTR =
         DEFINE_REQ_FMT0("MDS_GETATTR", mdt_body_only, mds_getattr_server);
 EXPORT_SYMBOL(RQF_MDS_GETATTR);