コード例 #1
0
        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++;
                }
            }
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        /*
         * public static Red_Buffer get_buf2(string who, RedFS_Inode wip, int level, int some_fbn, bool isquery)
         * {
         *  DEFS.DEBUG("getbuf", "-> " + who + "," + wip.m_ino + "," + level + "," + some_fbn + "," + isquery);
         *  Red_Buffer retbuf = wip.FindOrInsertOrRemoveBuf(FIR_OPTYPE.FIND, level, some_fbn, null, null);
         *  if (!isquery)
         *  {
         *      DEFS.ASSERT(retbuf != null, "newer get_buf2 has failed");
         *  }
         *  return retbuf;
         * }
         */
        /*
         * This can never return null, the caller *must* know that this buffer
         * is incore before calling. Must be called with a lock held on wip. But in case
         * is query is set true, then the caller is not sure if the buf is incore, in that
         * case we can return null safely.
         */

        public static Red_Buffer get_buf3(string who, RedFS_Inode wip, int level, int some_fbn, bool isquery)
        {
            List <Red_Buffer> list = null;

            switch (level)
            {
            case 0:
                list = wip.L0list;
                break;

            case 1:
                list = wip.L1list;
                break;

            case 2:
                list = wip.L2list;
                break;
            }
            DEFS.ASSERT(list != null, "List cannot be null in get_buf()");

            int start_fbn = SomeFBNToStartFBN(level, some_fbn);

            //some optimization, 10-12 mbps more.
            if (level == 1)
            {
                if (wip._lasthitbuf != null && wip._lasthitbuf.get_start_fbn() == start_fbn)
                {
                    return(wip._lasthitbuf);
                }
            }

            for (int idx = 0; idx < (list.Count); idx++)
            //for (int idx = (list.Count - 1); idx >= 0; idx--)
            {
                int        idx2 = (level == 0) ? (list.Count - idx - 1) : idx;
                Red_Buffer wb   = (Red_Buffer)list.ElementAt(idx2);
                if (wb.get_start_fbn() == start_fbn)
                {
                    //if (wb.get_level() > 0 && list.Count > 2) //like splay tree.
                    //{
                    //    list.RemoveAt(idx2);
                    //    list.Insert(0, wb);
                    //}
                    if (level == 1)
                    {
                        wip._lasthitbuf = wb;             //good opti - gives 10-12mbps more.
                    }
                    return(wb);
                }
            }

            DEFS.ASSERT(isquery, "who = " + who + ", get_buf() failed " + wip.get_ino() + "," + level + "," + some_fbn);
            return(null);
        }