From ac7151f4b963c8b2278c5afab9fd759c66fe80b6 Mon Sep 17 00:00:00 2001 From: wangdi Date: Sat, 29 Jul 2006 05:57:45 +0000 Subject: [PATCH] Branch: b_new_cmd add unlink log for mdd unlink --- lustre/include/lustre_mds.h | 7 +++++++ lustre/include/md_object.h | 5 ++++- lustre/mdd/mdd_handler.c | 5 ++++- lustre/mdd/mdd_internal.h | 10 +++++++--- lustre/mdd/mdd_lov.c | 14 +++++++++++++- lustre/mds/mds_internal.h | 6 ------ lustre/mds/mds_log.c | 2 +- lustre/mdt/mdt_lib.c | 3 +++ lustre/mdt/mdt_reint.c | 8 ++++++++ 9 files changed, 47 insertions(+), 13 deletions(-) diff --git a/lustre/include/lustre_mds.h b/lustre/include/lustre_mds.h index 7708847..f130c3d 100644 --- a/lustre/include/lustre_mds.h +++ b/lustre/include/lustre_mds.h @@ -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 diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 15c7cfe..d09c49f 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -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; }; /* diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 9d0838a..450f954 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -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); diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index c9eb3e1..de6f01b 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -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 diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index f08bb49..544c5aa 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -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; +} diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index ce4bd3a..0952e43 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -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); diff --git a/lustre/mds/mds_log.c b/lustre/mds/mds_log.c index 43a63e3..a736954 100644 --- a/lustre/mds/mds_log.c +++ b/lustre/mds/mds_log.c @@ -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) diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index ebd435a..da0ca11 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -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); diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 9a6a536..0683bf2 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -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) -- 1.8.3.1