예제 #1
0
        /*
         * public static bool HasChildIncore(RedFS_Inode wip, int level, long sfbn)
         * {
         *  if (level == 1)
         *  {
         *      RedBufL1 wbl1 = (RedBufL1)wip.FindOrInsertOrRemoveBuf(FIR_OPTYPE.FIND, 1, sfbn, null, null);
         *      if (wbl1.get_numchildptrs_incore() != 0) return true;
         *      else return false;
         *  }
         *  else if (level == 2)
         *  {
         *      RedBufL2 wbl2 = (RedBufL2)wip.FindOrInsertOrRemoveBuf(FIR_OPTYPE.FIND, 2, sfbn, null, null);
         *      if (wbl2.get_numchildptrs_incore() != 0) return true;
         *      else return false;
         *  }
         *  else
         *  {
         *      DEFS.ASSERT(false, "Dont pass wrong arguments");
         *      return false;
         *  }
         * }
         */

        public static bool HasChildIncoreOld(RedFS_Inode wip, int level, long sfbn)
        {
            DEFS.ASSERT(level > 0, "Incorrect level to HasChildIncore()");
            if (level == 1)
            {
                int count0 = wip.L0list.Count;
                int span1  = 1024;

                for (int i = 0; i < count0; i++)
                {
                    RedBufL0 wbl0 = (RedBufL0)wip.L0list.ElementAt(i);
                    if (wbl0.m_start_fbn >= sfbn && wbl0.m_start_fbn < (sfbn + span1))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            else
            {
                int count1 = wip.L1list.Count;
                int span2  = 1024 * 1024;

                for (int i = 0; i < count1; i++)
                {
                    RedBufL1 wbl1 = (RedBufL1)wip.L1list.ElementAt(i);
                    if (wbl1.m_start_fbn >= sfbn && wbl1.m_start_fbn < (sfbn + span2))
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }
        public int get_numchildptrs_incore()
        {
            int count = 0;

            for (int i = 0; i < 1024; i++)
            {
                if (m_chdptr[i] != null)
                {
                    RedBufL1 wbl1 = (RedBufL1)m_chdptr[i];
                    DEFS.ASSERT(wbl1.m_dbn == get_child_dbn(i), "Mismatch in get_incore L2 () 2@ " + i);
                    count++;
                }
            }
            return(count);
        }
예제 #3
0
        private Red_Buffer allocate_wb(BLK_TYPE type)
        {
            Red_Buffer wb = null;

            switch (type)
            {
            case BLK_TYPE.REGULAR_FILE_L1:
                wb = new RedBufL1(0);
                break;

            case BLK_TYPE.REGULAR_FILE_L2:
                wb = new RedBufL2(0);
                break;
            }
            DEFS.ASSERT(wb != null, "Wrong request for allocate_wb(), type = " + type);
            return(wb);
        }