private void CheckSumBuf(RedFS_Inode wip, Red_Buffer wb) { lock (fpcache_buf) { if (fpcache_cnt == 1024) { fpcache_cnt = 0; clogfile.Write(fpcache_buf, 0, fpcache_buf.Length); clogfile.Flush(); } if (wb.get_level() == 0 && wip.get_wiptype() == WIP_TYPE.REGULAR_FILE) { fingerprintCLOG fpt = (fingerprintCLOG)fptemp; fpt.fsid = wip.get_filefsid(); fpt.inode = wip.get_ino(); fpt.fbn = (int)wb.get_start_fbn(); fpt.dbn = wb.get_ondisk_dbn(); fpt.cnt = (int)clogfile.Position; byte[] hash = md5.ComputeHash(wb.buf_to_data()); for (int i = 0; i < 16; i++) { fpt.fp[i] = hash[i]; } fptemp.get_bytes(fpcache_buf, fpcache_cnt * fptemp.get_size()); fpcache_cnt++; } } }
public static void dumplistcontents(List <Red_Buffer> list) { DEFS.DEBUGCLR("DIMP", "Dumping list contents"); for (int idx = 0; idx < list.Count; idx++) { Red_Buffer wb = (Red_Buffer)list.ElementAt(idx); DEFS.DEBUG("DUMPLIST", "-> (" + wb.get_level() + ")" + wb.get_ondisk_dbn() + " l=" + wb.get_start_fbn() + " isdirty = " + ((RedBufL0)wb).is_dirty); } }
public void decrement_refcount(int fsid, Red_Buffer wb, bool isinodefilel0) { if (wb.get_level() == 0 && isinodefilel0) { m_wrloader.mod_refcount(fsid, wb.get_ondisk_dbn(), REFCNT_OP.DECREMENT_REFCOUNT, wb, isinodefilel0); } else { m_wrloader.mod_refcount(fsid, wb.get_ondisk_dbn(), REFCNT_OP.DECREMENT_REFCOUNT, null, false); } }
/* * Below three functions are exposed for public. * MP Safe function, can take long if there * are too many updates to be made. */ public void touch_refcount(Red_Buffer wb, bool isinodefilel0) { DEFS.ASSERT(wb != null, "touch refcount needs the wb"); if (wb.get_touchrefcnt_needed() == false)// || wb.get_ondisk_dbn() == 0) { return; } else { //DEFS.DEBUG("-REF-", "CTH refcount for dbn = " + wb.get_ondisk_dbn() + " inofile = " + isinodefilel0); wb.set_touchrefcnt_needed(false); } if (wb.get_level() == 0 && isinodefilel0) { m_wrloader.mod_refcount(0, wb.get_ondisk_dbn(), REFCNT_OP.TOUCH_REFCOUNT, wb, true); } else { DEFS.ASSERT(wb.get_level() > 0, "touch_refcount is only for indirects only, except for ino-L0!"); m_wrloader.mod_refcount(0, wb.get_ondisk_dbn(), REFCNT_OP.TOUCH_REFCOUNT, wb, false); } }
public void mod_refcount(int fsid, int dbn, REFCNT_OP optype, Red_Buffer wb, bool isinodefilel0) { DEFS.ASSERT(optype == REFCNT_OP.INCREMENT_REFCOUNT || /*optype == REFCNT_OP.DECREMENT_REFCOUNT ||*/ optype == REFCNT_OP.TOUCH_REFCOUNT || /*optype == REFCNT_OP.DO_LOAD || */ optype == REFCNT_OP.INCREMENT_REFCOUNT_ALLOC || optype == REFCNT_OP.DECREMENT_REFCOUNT_ONDEALLOC, "Wrong param in mod_refcount"); DEFS.ASSERT(isinodefilel0 || (wb == null || wb.get_level() > 0), "wrong type to mod_refcount " + isinodefilel0 + (wb == null)); UpdateReqI r = new UpdateReqI(); r.optype = optype; r.dbn = dbn; r.fsid = fsid; switch (optype) { case REFCNT_OP.INCREMENT_REFCOUNT: case REFCNT_OP.INCREMENT_REFCOUNT_ALLOC: r.value = 1; break; //case REFCNT_OP.DECREMENT_REFCOUNT: case REFCNT_OP.DECREMENT_REFCOUNT_ONDEALLOC: r.value = -1; break; case REFCNT_OP.TOUCH_REFCOUNT: //case REFCNT_OP.DO_LOAD: r.value = 0; break; } r.blktype = (wb != null) ? ((isinodefilel0) ? BLK_TYPE.PUBLIC_INODE_FILE_L0 : wb.get_blk_type()) : ((optype == REFCNT_OP.INCREMENT_REFCOUNT_ALLOC || optype == REFCNT_OP.DECREMENT_REFCOUNT_ONDEALLOC)? BLK_TYPE.IGNORE : BLK_TYPE.REGULAR_FILE_L0); if (wb != null && (wb.get_level() > 0 || BLK_TYPE.PUBLIC_INODE_FILE_L0 == r.blktype)) { lock (tfile0) { CONFIG.Encrypt_Data_ForWrite(tmpiodatatfileW, wb.buf_to_data()); tfile0.Seek((long)tfilefbn * 4096, SeekOrigin.Begin); tfile0.Write(tmpiodatatfileW, 0, 4096); //DEFS.DEBUG("ENCY", "Wrote : " + OPS.ChecksumPageWRLoader(wb.buf_to_data())); r.tfbn = tfilefbn; tfilefbn++; } } else { r.tfbn = -1; } if (optype != REFCNT_OP.INCREMENT_REFCOUNT_ALLOC && optype != REFCNT_OP.DECREMENT_REFCOUNT && optype != REFCNT_OP.DECREMENT_REFCOUNT_ONDEALLOC && optype != REFCNT_OP.TOUCH_REFCOUNT) { DEFS.DEBUG("REFCNT", "Queued update for " + r.blktype + ", dbn = " + r.dbn + ", and operation = " + r.optype + ", transaction offset : " + r.tfbn); } GLOBALQ.m_reqi_queue.Add(r); }