static int llog_lvfs_destroy(struct llog_handle *handle) { struct dentry *fdentry; struct obdo *oa; struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd; char *dir; void *th; struct inode *inode; int rc, rc1; ENTRY; dir = MOUNT_CONFIGS_DIR; fdentry = handle->lgh_file->f_dentry; inode = fdentry->d_parent->d_inode; if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) { struct lvfs_run_ctxt saved; struct vfsmount *mnt = mntget(handle->lgh_file->f_vfsmnt); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); dget(fdentry); rc = llog_lvfs_close(handle); if (rc == 0) { LOCK_INODE_MUTEX_PARENT(inode); rc = ll_vfs_unlink(inode, fdentry, mnt); UNLOCK_INODE_MUTEX(inode); } mntput(mnt); dput(fdentry); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); RETURN(rc); } OBDO_ALLOC(oa); if (oa == NULL) RETURN(-ENOMEM); oa->o_id = handle->lgh_id.lgl_oid; oa->o_seq = handle->lgh_id.lgl_oseq; oa->o_generation = handle->lgh_id.lgl_ogen; #undef o_generation oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLGENER; rc = llog_lvfs_close(handle); if (rc) GOTO(out, rc); th = fsfilt_start_log(obd, inode, FSFILT_OP_UNLINK, NULL, 1); if (IS_ERR(th)) { CERROR("fsfilt_start failed: %ld\n", PTR_ERR(th)); GOTO(out, rc = PTR_ERR(th)); } rc = obd_destroy(handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL, NULL); rc1 = fsfilt_commit(obd, inode, th, 0); if (rc == 0 && rc1 != 0) rc = rc1; out: OBDO_FREE(oa); RETURN(rc); }
int llu_objects_destroy(struct ptlrpc_request *req, struct inode *dir) { struct mdt_body *body; struct lov_mds_md *eadata; struct lov_stripe_md *lsm = NULL; struct obd_trans_info oti = { 0 }; struct obdo *oa; int rc; ENTRY; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if (!(body->valid & OBD_MD_FLEASIZE)) RETURN(0); if (body->eadatasize == 0) { CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n"); GOTO(out, rc = -EPROTO); } /* The MDS sent back the EA because we unlinked the last reference * to this file. Use this EA to unlink the objects on the OST. * It's opaque so we don't swab here; we leave it to obd_unpackmd() to * check it is complete and sensible. */ eadata = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD, body->eadatasize); LASSERT(eadata != NULL); rc = obd_unpackmd(llu_i2obdexp(dir), &lsm, eadata,body->eadatasize); if (rc < 0) { CERROR("obd_unpackmd: %d\n", rc); GOTO(out, rc); } LASSERT(rc >= sizeof(*lsm)); OBDO_ALLOC(oa); if (oa == NULL) GOTO(out_free_memmd, rc = -ENOMEM); oa->o_id = lsm->lsm_object_id; oa->o_seq = lsm->lsm_object_seq; oa->o_mode = body->mode & S_IFMT; oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP; obdo_from_inode(oa, NULL, &llu_i2info(dir)->lli_fid, 0); if (body->valid & OBD_MD_FLCOOKIE) { oa->o_valid |= OBD_MD_FLCOOKIE; oti.oti_logcookies = req_capsule_server_sized_get(&req->rq_pill, &RMF_LOGCOOKIES, sizeof(struct llog_cookie) * lsm->lsm_stripe_count); if (oti.oti_logcookies == NULL) { oa->o_valid &= ~OBD_MD_FLCOOKIE; body->valid &= ~OBD_MD_FLCOOKIE; } } rc = obd_destroy(llu_i2obdexp(dir), oa, lsm, &oti, NULL, NULL); OBDO_FREE(oa); if (rc) CERROR("obd destroy objid 0x"LPX64" error %d\n", lsm->lsm_object_id, rc); out_free_memmd: obd_free_memmd(llu_i2obdexp(dir), &lsm); out: return rc; }
static int llog_lvfs_destroy(const struct lu_env *env, struct llog_handle *handle) { struct dentry *fdentry; struct obdo *oa; struct obd_device *obd = handle->lgh_ctxt->loc_exp->exp_obd; char *dir; void *th; struct inode *inode; int rc, rc1; dir = MOUNT_CONFIGS_DIR; LASSERT(handle->lgh_file); fdentry = handle->lgh_file->f_dentry; inode = fdentry->d_parent->d_inode; if (strcmp(fdentry->d_parent->d_name.name, dir) == 0) { struct lvfs_run_ctxt saved; struct vfsmount *mnt = mntget(handle->lgh_file->f_vfsmnt); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); dget(fdentry); rc = llog_lvfs_close(env, handle); if (rc == 0) { mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT); rc = ll_vfs_unlink(inode, fdentry, mnt); mutex_unlock(&inode->i_mutex); } mntput(mnt); dput(fdentry); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); return rc; } OBDO_ALLOC(oa); if (oa == NULL) return -ENOMEM; oa->o_oi = handle->lgh_id.lgl_oi; oa->o_generation = handle->lgh_id.lgl_ogen; #undef o_generation oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLGENER; rc = llog_lvfs_close(env, handle); if (rc) GOTO(out, rc); th = fsfilt_start_log(obd, inode, FSFILT_OP_UNLINK, NULL, 1); if (IS_ERR(th)) { CERROR("fsfilt_start failed: %ld\n", PTR_ERR(th)); GOTO(out, rc = PTR_ERR(th)); } rc = obd_destroy(NULL, handle->lgh_ctxt->loc_exp, oa, NULL, NULL, NULL, NULL); rc1 = fsfilt_commit(obd, inode, th, 0); if (rc == 0 && rc1 != 0) rc = rc1; out: OBDO_FREE(oa); return rc; }