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 bool read(Red_Buffer wb) { if (!initialized) { return(false); } //Array.Clear(wb.buf_to_data(), 0, 4096); OPS.BZERO(wb.buf_to_data()); total_disk_reads++; if (wb.get_ondisk_dbn() == 0) { return(true); } lock (dfile) { //DEFS.DEBUG("RAID", "Reading dbn : " + wb.get_ondisk_dbn() + " level : " + wb.get_level()); dfile.Seek((long)wb.get_ondisk_dbn() * 4096, SeekOrigin.Begin); dfile.Read(wb.buf_to_data(), 0, 4096); } return(true); }
public bool write(RedFS_Inode wip, Red_Buffer wb) { if (!initialized) { return(false); } total_disk_writes++; lock (dfile) { //DEFS.DEBUG("RAID", "Writing dbn : " + wb.get_ondisk_dbn() + " level : " + wb.get_level()); dfile.Seek((long)wb.get_ondisk_dbn() * 4096, SeekOrigin.Begin); dfile.Write(wb.buf_to_data(), 0, 4096); dfile.Flush(); wb.set_dirty(false); CheckSumBuf(wip, wb); } return(true); }
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); }