From 8ea8bdf2159df202063eae8f249d925d972afab0 Mon Sep 17 00:00:00 2001 From: tappro Date: Sun, 16 Jul 2006 12:51:52 +0000 Subject: [PATCH] update handle_last_unlink() --- lustre/mdt/mdt_lib.c | 75 ++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 6a9677e..49b40d3 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -44,47 +44,52 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo, const struct req_format *fmt) { + struct mdt_body *body; int rc = 0; ENTRY; - /* only for reg files and if that object will be deleted */ - if (lu_object_is_dying(&mo->mot_header)) { - rc = mo_attr_get(info->mti_ctxt, mdt_object_child(mo), - &info->mti_attr); - if (rc == 0 && S_ISREG(info->mti_attr.la_mode)) { - struct mdt_body *body; - struct lov_mds_md *lmm; - - /* reply should contains more data, - * so we need to extend it */ - req_capsule_extend(&info->mti_pill, fmt); - - body = req_capsule_server_get(&info->mti_pill, - &RMF_MDT_BODY); - lmm = req_capsule_server_get(&info->mti_pill, - &RMF_MDT_MD); - - mdt_pack_attr2body(body, &info->mti_attr, - mdt_object_fid(mo)); - -/*TODO: lmm data & llog cookie - rc = mo_xattr_get(info->mti_ctxt, mdt_object_child(o), - lmm, info->mti_mdt->mdt_max_mdsize, - XATTR_NAME_LOV); - if (rc >= 0) { - if (S_ISDIR(info->mti_attr.la_mode)) - body->valid |= OBD_MD_FLDIREA; - else - body->valid |= OBD_MD_FLEASIZE; - body->eadatasize = rc; - rc = 0; - } -*/ - } + + rc = mo_attr_get(info->mti_ctxt, mdt_object_child(mo), + &info->mti_attr); + if (rc) + RETURN(rc); + + body = req_capsule_server_get(&info->mti_pill, + &RMF_MDT_BODY); + mdt_pack_attr2body(body, &info->mti_attr, mdt_object_fid(mo)); + + /* if last unlinked object reference so client should destroy ost + * objects*/ + if (S_ISREG(info->mti_attr.la_mode) && + info->mti_attr.la_nlink == 0 && mo->mot_header.loh_ref == 1) { + struct lov_mds_md *lmm; + + CERROR("Last object!\n"); + /* reply should contains more data, + * * so we need to extend it */ + req_capsule_extend(&info->mti_pill, fmt); + + lmm = req_capsule_server_get(&info->mti_pill, + &RMF_MDT_MD); + + + /*TODO: lmm data & llog cookie + * rc = mo_xattr_get(info->mti_ctxt, mdt_object_child(o), + * lmm, info->mti_mdt->mdt_max_mdsize, + * XATTR_NAME_LOV); + * if (rc >= 0) { + * if (S_ISDIR(info->mti_attr.la_mode)) + * body->valid |= OBD_MD_FLDIREA; + * else + * body->valid |= OBD_MD_FLEASIZE; + * body->eadatasize = rc; + * rc = 0; + * } + */ } + RETURN(rc); } - /* unpacking */ static int mdt_setattr_unpack(struct mdt_thread_info *info) { -- 1.8.3.1