/* * This needs to undo what gfile_create does. * See also dir_release. */ static OSKIT_COMDECL_U file_release(oskit_file_t *f) { gfile_t *file; unsigned newcount; file = (gfile_t *)f; VERIFY_OR_PANIC(file, "file"); newcount = --file->count; if (newcount == 0) { int rc; oskit_filesystem_release(&file->fs->fsi); rc = hashtab_remove(dentrytab, (hashtab_key_t) file->dentry, 0, 0); assert(rc == HASHTAB_SUCCESS); dput(file->dentry); kfree(file); } return newcount; }
oskit_s32_t oskit_packet_dispatcher_delete(oskit_pd_t *pd, oskit_s32_t fid) { oskit_s32_t hterr; osenv_assert(pd); switch (pd->ft) { case OSKIT_PD_FILTER_DPF_INTERP: oskit_dpf_delete(fid); break; default: return OSKIT_E_NOTIMPL; } hterr = hashtab_remove(pd->ht, (hashtab_key_t) fid, hashremove, 0); if (hterr != HASHTAB_SUCCESS) { return OSKIT_E_UNEXPECTED; } return 0; }
void user_del(struct user *user) { hashtab_remove(users, user->nick); free(user); }
/* Resume the deduping process that happens during the initial scanning. * We also use it as a building block in the run-time map creation * process as well, just by initializing the variables accordingly. * P2D tuple consists of iodedupID to indicate which dedup block does * this pblk map into. * * @param[in] buf * @param[in] len * @param[in] ioblkID * @param[in] initflag * @param[in] lastblk_flag */ int resumeDeduping(unsigned char *buf, __u16 len, __u32 ioblkID, int initflag, int lastblk_flag, int rw_flag) { //uint32_t ptime; /* To be noted when event occurs, is this needed? TODO int ret; __u32 iodedupID; unsigned long long stime=0, etime=0; //savemem unsigned char dig[HASHLEN + MAGIC_SIZE]; unsigned char *dig = malloc(HASHLEN + MAGIC_SIZE); unsigned char *key = NULL; d2pv_datum *dedupd2pv = NULL, *d2pv = NULL; D2P_tuple_t *d2p = NULL; #ifdef STRICT_NO_HASH_COLLISION unsigned char *oldbuf = NULL; //savemem unsigned char debugkey[HASHLEN + MAGIC_SIZE]; unsigned char* debugkey = malloc(HASHLEN + MAGIC_SIZE); #endif #if defined(DEDUPING_DEBUG_SSS) fprintf(stdout, "In %s\n", __FUNCTION__); #endif /* Buf will always have "len" == BLKSIZE. No leftovers. */ #ifdef DEBUG_SS assert(len == BLKSIZE || lastblk_flag == ZEROBLK_FLAG); assert(initflag == INIT_STAGE || initflag == NOINIT_STAGE); #endif if (len != 0) /* Not a zero blk */ { assert(buf != NULL); memset(dig, 0, HASHLEN); stime = gettime(); /* START IODEDUP map-update-get-hash time */ if (getHashKey(buf, len, dig)) RET_ERR("getHashKey() returned error\n"); etime = gettime(); /* END IODEDUP map-update-get-hash */ ACCESSTIME_PRINT("iodedmap-map-update-component-get-hash time: %llu\n", etime - stime); key = (unsigned char*)dig; #if defined(SIMREPLAY_DEBUG_SS_DONE) printf("Content metadata update: buf=%s\n", (char*)buf); printf("Content metadata update: md5="); puts((char*)dig); #endif if (cmaphit_flag && !disksimflag) { assert(REALDISK_SCANNING_NOCOLLECTFORMAT_VMBUNCHREPLAY);//assert(0); //no need to update metadata if this is read request with //metadata hit, and disk is real, not simulated! return 0; } else if (cmaphit_flag) /* read with metadata hit but disk simulated */ { //ideally, i.e. if traces are perfect, then //no need to update metadata here, just return, but.... d2pv_datum *curr_d2pv = NULL; //but if the traces dont have consistent read/write requests, //in some cases of metadata-hit followed by cccahe-miss, the //following assert fails! work-around below... curr_d2pv = (d2pv_datum*) hashtab_search(deduptab.table, key); #ifndef INCONSISTENT_TRACES assert(curr_d2pv != NULL); #endif //work-around: //since we have already updated the content-cache with //the "offending content", we have to update the existing //metadata of this ioblk with new dhashkey, and also add //that new d2pv entry into deduptab (or update existing //dedupd2pv for the new dhashkey, if that is the case) d2pv_datum *cmaphit_d2pv = NULL; //found during metadata hit d2pv_datum *trace_d2pv = NULL; //due to inconsistent trace, //if disk is being simulated #ifdef INCONSISTENT_TRACES D2P_tuple_t *trace_d2p = NULL; #endif cmaphit_d2pv = getDedupMap(cmaphit_iodedupID); assert(cmaphit_d2pv != NULL); trace_d2pv = (d2pv_datum*) hashtab_search(deduptab.table, key); if (cmaphit_d2pv == trace_d2pv) curr_d2pv = cmaphit_d2pv; //true if trace is consistent #ifndef INCONSISTENT_TRACES else RET_ERR("inconsistence why?\n"); #else else //begin: fix for inconsistent trace { //trace is inconsistent, so we have to do some //impromptu metadata updates:- if (trace_d2pv == NULL) { __u32 iodedupID; trace_d2pv = (d2pv_datum*) calloc(1, sizeof(d2pv_datum)); INIT_LIST_HEAD(&trace_d2pv->d2pmaps); iodedupID = getNextDedupNum(initflag); trace_d2p = calloc (1, sizeof(D2P_tuple_t)); /*************************************************************** if (ccache_already_had_flag) { note_dedup_attrs(trace_d2pv, key, iodedupID, ccache_already_had_obj_ioblkID); note_d2p_tuple(trace_d2p, ccache_already_had_obj_ioblkID); } else { note_dedup_attrs(trace_d2pv, key, iodedupID, ioblkID); note_d2p_tuple(trace_d2p, ioblkID); } ***************************************************************/ /* We are here only upon a ccache miss after metadata hit, * so ccache_already_had_flag == 0 mandatory! */ //assert(ccache_already_had_flag == 0);//not true for wif note_dedup_attrs(trace_d2pv, key, iodedupID, ioblkID); note_d2p_tuple(trace_d2p, ioblkID); add_d2p_tuple_to_map(trace_d2p, trace_d2pv); ret = hashtab_insert(deduptab.table, trace_d2pv->dhashkey, trace_d2pv); setDedupMap(trace_d2pv->iodedupID, trace_d2pv); ret = updateBlockio(ioblkID, lastblk_flag, iodedupID); if (ret) RET_ERR("updateBlockio() error'ed\n"); } else { __u32 iodedupID; iodedupID = trace_d2pv->iodedupID; if (NULL == get_nondeduped_d2p(trace_d2pv, ioblkID)) { trace_d2p = calloc (1, sizeof(D2P_tuple_t)); //assert(ccache_already_had_flag == 0); //not true note_d2p_tuple(trace_d2p, ioblkID); add_d2p_tuple_to_map(trace_d2p, trace_d2pv); } ret = updateBlockio(ioblkID, lastblk_flag, iodedupID); if (ret) RET_ERR("updateBlockio() error'ed\n"); } //if current ioblk is the only one in old sector-list, //then delete cmaphit_d2pv from hash-table, else let //it stay there. if (slist_len(&cmaphit_d2pv->d2pmaps) > 1) { del_d2p_from_d2pmaps(cmaphit_d2pv, ioblkID); } else { del_d2p_from_d2pmaps(cmaphit_d2pv, ioblkID); hashtab_remove(deduptab.table, cmaphit_d2pv->dhashkey); setDedupMap(cmaphit_iodedupID, NULL); //d2pv freed } //mark trace_d2pv as curr_d2pv for self-hits/misses below! curr_d2pv = trace_d2pv; }//end: fix for inconsistent trace #endif //update the ioblkID for counts of self-hits/misses //copied from iodeduping.c, if change in 1 place, change both if (!ccache_already_had_flag) //set in __arc_add curr_d2pv->ioblkID = ioblkID; //ensure counts line up -- self else curr_d2pv->ioblkID = ccache_already_had_obj_ioblkID; return 0; }