Exemple #1
0
 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);
     }
 }
        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 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);
        }
Exemple #5
0
        /*
         * 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 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);
        }
Exemple #7
0
 public void increment_refcount(int fsid, Red_Buffer wb, bool isinodefilel0)
 {
     m_wrloader.mod_refcount(fsid, wb.get_ondisk_dbn(), REFCNT_OP.INCREMENT_REFCOUNT, wb, isinodefilel0);
 }