Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Sat, 29 Jul 2006 05:57:45 +0000 (05:57 +0000)
committerwangdi <wangdi>
Sat, 29 Jul 2006 05:57:45 +0000 (05:57 +0000)
add unlink log for mdd unlink

lustre/include/lustre_mds.h
lustre/include/md_object.h
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/mds/mds_internal.h
lustre/mds/mds_log.c
lustre/mdt/mdt_lib.c
lustre/mdt/mdt_reint.c

index 7708847..f130c3d 100644 (file)
@@ -90,6 +90,13 @@ int md_lov_notity_pre(struct obd_device *obd, struct md_lov_info *mli,
 int md_lov_start_synchronize(struct obd_device *obd, struct md_lov_info *mli,
                              struct obd_device *watched,
                              void *data, int nonblock, const void *ctxt);
+int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
+                      struct lov_mds_md *lmm, int lmm_size,
+                      struct llog_cookie *logcookies, int cookies_size);
+int mds_log_op_setattr(struct obd_device *obd, struct inode *inode,
+                      struct lov_mds_md *lmm, int lmm_size,
+                      struct llog_cookie *logcookies, int cookies_size);
+
 /* ioctls for trying requests */
 #define IOC_REQUEST_TYPE                   'f'
 #define IOC_REQUEST_MIN_NR                 30
index 15c7cfe..d09c49f 100644 (file)
@@ -49,7 +49,8 @@ struct md_object;
 /* metadata attributes */
 enum ma_valid {
         MA_INODE = (1 << 0),
-        MA_LOV   = (1 << 1)
+        MA_LOV   = (1 << 1),
+        MA_COOKIE = (1 << 2)
 };
 
 struct md_attr {
@@ -57,6 +58,8 @@ struct md_attr {
         struct lu_attr          ma_attr;
         struct lov_mds_md      *ma_lmm;
         int                     ma_lmm_size;
+        struct llog_cookie     *ma_cookie;
+        int                     ma_cookie_size;
 };
 
 /*
index 9d0838a..450f954 100644 (file)
@@ -706,7 +706,10 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj,
                 /* unlink dotdot */
                 __mdd_ref_del(ctxt, mdd_pobj, handle, NULL);
         }
-
+        if (S_ISREG(ma->ma_attr.la_mode) &&
+            ma->ma_attr.la_nlink == 0 && cobj->mo_lu.lo_header->loh_ref == 1) {
+                rc = mdd_unlink_log(ctxt, mdd, mdd_cobj, ma);
+        }
 cleanup:
         mdd_unlock2(ctxt, mdd_pobj, mdd_cobj);
         mdd_trans_stop(ctxt, mdd, handle);
index c9eb3e1..de6f01b 100644 (file)
@@ -65,9 +65,10 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
                    int *lmm_size);
 int mdd_get_md(const struct lu_context *ctxt, struct md_object *obj,
                void *md, int *md_size, int lock);
-
-
+int mdd_unlink_log(const struct lu_context *ctxt, struct mdd_device *mdd, 
+                   struct mdd_object *mdd_cobj, struct md_attr *ma);
 struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx);
+
 extern struct lu_device_operations mdd_lu_ops;
 static inline int lu_device_is_mdd(struct lu_device *d)
 {
@@ -116,5 +117,8 @@ static inline struct dt_object* mdd_object_child(struct mdd_object *o)
         return container_of0(lu_object_next(mdd2lu_obj(o)),
                              struct dt_object, do_lu);
 }
-
+static inline struct obd_device *mdd2_obd(struct mdd_device *mdd)
+{
+        return mdd->mdd_md_dev.md_lu_dev.ld_obd; 
+}
 #endif
index f08bb49..544c5aa 100644 (file)
@@ -322,7 +322,7 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
                    struct mdd_object *child, struct lov_mds_md **lmm,
                    int *lmm_size)
 {
-        struct obd_device *obd = mdd->mdd_md_dev.md_lu_dev.ld_obd;
+        struct obd_device *obd = mdd2_obd(mdd);
         struct obd_export *lov_exp = obd->u.mds.mds_osc_exp;
         struct obdo *oa;
         struct lov_stripe_md *lsm = NULL;
@@ -354,3 +354,15 @@ out_oa:
         obdo_free(oa);
         RETURN(rc);
 }
+
+int mdd_unlink_log(const struct lu_context *ctxt, struct mdd_device *mdd, 
+                   struct mdd_object *mdd_cobj, struct md_attr *ma)
+{
+        struct obd_device *obd = mdd2_obd(mdd);
+        
+        if (mds_log_op_unlink(obd, NULL, ma->ma_lmm, ma->ma_lmm_size,
+                                 ma->ma_cookie, ma->ma_cookie_size)) {
+                ma->ma_valid |= MA_COOKIE;
+        }
+        return 0;
+}
index ce4bd3a..0952e43 100644 (file)
@@ -170,12 +170,6 @@ int mds_cleanup_pending(struct obd_device *obd);
 
 
 /* mds/mds_log.c */
-int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
-                      struct lov_mds_md *lmm, int lmm_size,
-                      struct llog_cookie *logcookies, int cookies_size);
-int mds_log_op_setattr(struct obd_device *obd, struct inode *inode,
-                      struct lov_mds_md *lmm, int lmm_size,
-                      struct llog_cookie *logcookies, int cookies_size);
 int mds_llog_init(struct obd_device *obd, struct obd_device *tgt, int count,
                   struct llog_catid *logid);
 int mds_llog_finish(struct obd_device *obd, int count);
index 43a63e3..a736954 100644 (file)
@@ -123,7 +123,7 @@ out:
         obd_free_memmd(mds->mds_osc_exp, &lsm);
         RETURN(rc);
 }
-
+EXPORT_SYMBOL(mds_log_op_unlink);
 int mds_log_op_setattr(struct obd_device *obd, struct inode *inode,
                       struct lov_mds_md *lmm, int lmm_size,
                       struct llog_cookie *logcookies, int cookies_size)
index ebd435a..da0ca11 100644 (file)
@@ -118,6 +118,9 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo)
                         repbody->eadatasize = ma->ma_lmm_size;
                         repbody->valid |= OBD_MD_FLEASIZE;
                 }
+                
+                if (ma->ma_cookie_size && ma->ma_valid & MA_COOKIE) 
+                        repbody->valid |= OBD_MD_FLCOOKIE;
         }
 
         RETURN(rc);
index 9a6a536..0683bf2 100644 (file)
@@ -271,6 +271,14 @@ static int mdt_reint_unlink(struct mdt_thread_info *info)
         ma->ma_lmm_size = req_capsule_get_size(&info->mti_pill,
                                                &RMF_MDT_MD, RCL_SERVER);
 
+        ma->ma_cookie = req_capsule_server_get(&info->mti_pill, 
+                                                &RMF_LOGCOOKIES);
+        ma->ma_cookie_size = req_capsule_get_size(&info->mti_pill,
+                                               &RMF_LOGCOOKIES, RCL_SERVER);
+        
+        if (!ma->ma_lmm || !ma->ma_cookie)
+                GOTO(out_unlock_parent, rc = -EINVAL);
+
         rc = mdo_unlink(info->mti_ctxt, mdt_object_child(mp),
                         mdt_object_child(mc), rr->rr_name, ma);
         if (rc)