亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? cache.c

?? be文件系統(tǒng)實(shí)現(xiàn)的源碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
            if (ce->lock)                cel = &bc.locked;            else                cel = &bc.normal;                            /* now put this ent at the head of the appropriate list */            add_to_head(cel, ce);            if (data != NULL)                data = (void *)((char *)data + bsize);            bnum       += 1;            num_blocks -= 1;            continue;        } else {                                  /* it's not in the cache */            int        cur, cur_nblocks, num_dirty, real_nblocks, num_needed;            cache_ent *ents[NUM_FLUSH_BLOCKS];            /*               here we find out how many additional blocks in this request               are not in the cache.  the idea is that then we can do one               big i/o on that many blocks at once.            */               for(cur_nblocks=1;                cur_nblocks < num_blocks && cur_nblocks < NUM_FLUSH_BLOCKS;                cur_nblocks++) {                /* we can call hash_lookup() directly instead of                   block_lookup() because we don't care about the                    state of the busy bit of the block at this point                */                if (hash_lookup(&bc.ht, dev, bnum + cur_nblocks))                    break;            }            /*              here we try to figure out how many extra blocks we should read              for read-ahead.  we want to read as many as possible that are              not already in the cache and that don't cause us to try and               read beyond the end of the disk.            */            if ((op & CACHE_READ) && (op & CACHE_READ_AHEAD_OK) &&                (cur_nblocks * bsize) < read_ahead_size) {                for(num_needed=cur_nblocks;                    num_needed < (read_ahead_size / bsize);                    num_needed++) {                    if ((bnum + num_needed) >= max_device_blocks[dev])                        break;                    if (hash_lookup(&bc.ht, dev, bnum + num_needed))                        break;                }            } else {                num_needed = cur_nblocks;            }            /* this will get us pointers to a bunch of cache_ents we can use */            get_ents(ents, num_needed, NUM_FLUSH_BLOCKS, &real_nblocks, bsize);                        if (real_nblocks < num_needed) {                panic("don't have enough cache ents (need %d got %d %ld::%d)\n",                      num_needed, real_nblocks, bnum, num_blocks);            }            /*              There are now three variables used as limits within the ents              array.  This is how they are related:                 cur_nblocks <= num_needed <= real_nblocks              Ents from 0 to cur_nblocks-1 are going to be used to fulfill              this IO request.  Ents from cur_nblocks to num_needed-1 are              for read-ahead.  Ents from num_needed to real_nblocks are              extra blocks that get_ents() asked us to flush.  Often (and              always on writes) cur_nblocks == num_needed.              Below, we sort the list of ents so that when we flush them              they go out in order.             */                        qsort(ents, real_nblocks, sizeof(cache_ent **), cache_ent_cmp);            /*              delete each ent from its list because it will change.  also              count up how many dirty blocks there are and insert into the              hash table any new blocks so that no one else will try to               read them in when we release the cache semaphore to do our I/O.            */            for(cur=0,num_dirty=0; cur < real_nblocks; cur++) {                ce = ents[cur];                ce->flags |= CE_BUSY;                /*                   insert the new block into the hash table with its new block                   number. note that the block is still in the hash table for                    its old block number -- and it has to be until we are done                   flushing it from the cache (to prevent someone else from                   sneaking in in front of us and trying to read the same                   block that we're flushing).                */                if (cur < num_needed) {                    if (hash_insert(&bc.ht, dev, bnum + cur, ce) != 0)                        panic("could not insert cache ent for %d %ld (0x%lx)\n",                              dev, bnum + cur, (ulong)ents[cur]);                }                if (ce->dev == -1)                    continue;                                if ((ce->flags & CE_DIRTY) || ce->clone)                    num_dirty++;                if (ce->lock)                    panic("cbio: can't use locked blocks here ce @ 0x%x\n",ce);                else                    cel = &bc.normal;                                delete_from_list(cel, ce);            }            ce = NULL;            /*               we release the block cache semaphore here so that we can               go do all the i/o we need to do (flushing dirty blocks               that we're kicking out as well as reading any new data).               because all the blocks we're touching are marked busy               no one else should mess with them while we're doing this.            */            if (num_dirty || (op & CACHE_READ)) {                UNLOCK(bc.lock);                                /* this flushes any blocks we're kicking out that are dirty */                if (num_dirty && (err = flush_ents(ents, real_nblocks)) != 0) {                    printf("flush ents failed (ents @ 0x%lx, nblocks %d!\n",                           (ulong)ents, cur_nblocks);                    goto handle_err;                }                            }                        /*               now that everything is flushed to disk, go through and               make sure that the data blocks we're going to use are               the right block size for this current request (it's               possible we're kicking out some smaller blocks and need               to reallocate the data block pointer). We do this in two               steps, first free'ing everything and then going through               and doing the malloc's to try and be nice to the memory               system (i.e. allow it to coalesce stuff, etc).            */            err = 0;            for(cur=0; cur < num_needed; cur++) {                if (ents[cur]->bsize != bsize) {                    free(ents[cur]->data);                    ents[cur]->data = NULL;                    if (ents[cur]->clone) {                        free(ents[cur]->clone);                        ents[cur]->clone = NULL;                    }                }            }                            for(cur=0; cur < num_needed; cur++) {                if (ents[cur]->data == NULL) {                    ents[cur]->data  = (void *)malloc(bsize);                    ents[cur]->bsize = bsize;                }                                if (ents[cur]->data == NULL) {                    printf("cache: no memory for block (bsize %d)!\n",                           bsize);                    err = ENOMEM;                    break;                }            }            /*               if this condition is true it's a pretty serious error.               we'll try and back out gracefully but we're in pretty               deep at this point and it ain't going to be easy.            */  handle_err:            if (err) {                for(cur=0; cur < num_needed; cur++) {                    cache_ent *tmp_ce;                                        tmp_ce = (cache_ent *)hash_delete(&bc.ht,dev,bnum+cur);                    if (tmp_ce != ents[cur]) {                        panic("hash_del0: %d %ld got 0x%lx, not 0x%lx\n",                                dev, bnum+cur, (ulong)tmp_ce,                                (ulong)ents[cur]);                    }                    tmp_ce = (cache_ent *)hash_delete(&bc.ht,ents[cur]->dev,                                                        ents[cur]->block_num);                    if (tmp_ce != ents[cur]) {                        panic("hash_del1: %d %ld got 0x%lx, not 0x%lx\n",                                ents[cur]->dev, ents[cur]->block_num, (ulong)tmp_ce,                                (ulong)ents[cur]);                    }                                        ents[cur]->flags &= ~CE_BUSY;                    if (ents[cur]->data)                        free(ents[cur]->data);                    free(ents[cur]);                    ents[cur] = NULL;                    bc.cur_blocks--;                }                if (cur < real_nblocks) {                    LOCK(bc.lock);                    for(; cur < real_nblocks; cur++) {                        ents[cur]->flags &= ~CE_BUSY;                        /* we have to put them back here */                        add_to_tail(&bc.normal, ents[cur]);                    }                    UNLOCK(bc.lock);                }                return ENOMEM;            }                            /*               If we go into this if statement, the block cache lock               has *already been released* up above when we flushed the               dirty entries.  As always, since the blocks we're mucking               with are marked busy, they shouldn't get messed with.            */            err = 0;            if (num_dirty || (op & CACHE_READ)) {                /* this section performs the i/o that we need to do */                if (op & CACHE_READ) {                    err = read_into_ents(dev, bnum, ents, num_needed, bsize);                } else {                    err = 0;                }                if (err != 0) {                    printf("err %s on dev %d block %ld:%d (%d) "                           "data 0x%x, ents[0] 0x%x\n",                           strerror(errno), dev, bnum, cur_nblocks,                           bsize, data, ents[0]);                }                /*                   acquire the semaphore here so that we can go on mucking                    with the cache data structures.  We need to delete old                    block numbers from the hash table and set the new block                    number's for the blocks we just read in.  We also put the                    read-ahead blocks at the head of mru list.                */                   LOCK(bc.lock);            }            for(cur=0; cur < num_needed; cur++) {                cache_ent *tmp_ce;                                ce = ents[cur];                if (ce->dev != -1) {                    tmp_ce = hash_delete(&bc.ht, ce->dev, ce->block_num);                    if (tmp_ce == NULL || tmp_ce != ce) {                        panic("*** hash_delete failure (ce 0x%x tce 0x%x)\n",                              ce, tmp_ce);                    }                }                if (err == 0 && cur >= cur_nblocks) {                    ce->dev       = dev;                    ce->block_num = bnum + cur;                    ce->flags    &= ~CE_BUSY;                    add_to_head(&bc.normal, ce);                }            }            ce = NULL;            /*              clear the busy bit on the blocks we force-flushed and              put them on the normal list since they're now clean.            */            for(; cur < real_nblocks; cur++) {                ents[cur]->flags &= ~CE_BUSY;                                if (ents[cur]->lock)                    panic("should not have locked blocks here (ce 0x%x)\n",                          ents[cur]);                                add_to_tail(&bc.normal, ents[cur]);            }            if (err) {   /* then we have some cleanup to do */                for(cur=0; cur < num_needed; cur++) {                    cache_ent *tmp_ce;                                        /* we delete all blocks from the cache so we don't                       leave partially written blocks in the cache */                                        tmp_ce = (cache_ent *)hash_delete(&bc.ht,dev,bnum+cur);                    if (tmp_ce != ents[cur]) {                        panic("hash_del: %d %ld got 0x%lx, not 0x%lx\n",                                dev, bnum+cur, (ulong)tmp_ce,                                (ulong)ents[cur]);                    }                    ce = ents[cur];                    ce->flags &= ~CE_BUSY;                                    free(ce->data);                    ce->data = NULL;                    free(ce);                    ents[cur] = NULL;                    bc.cur_blocks--;                }                ce = NULL;                UNLOCK(bc.lock);                return err;            }            /*               last step: go through and make sure all the cache_ent               structures have the right data in them, delete old guys, etc.            */               for(cur=0; cur < cur_nblocks; cur++) {                ce = ents[cur];                                if (ce->dev != -1) {   /* then clean this guy up */                    if (ce->next || ce->prev)                        panic("ce @ 0x%x should not be in a list yet!\n", ce);                    if (ce->clone)                        free(ce->clone);                    if (ce->data == NULL)                        panic("ce @ 0x%lx has a null data ptr\n", (ulong)ce);                }                ce->dev        = dev;                ce->block_num  = bnum + cur;                ce->bsize      = bsize;                ce->flags      = CE_NORMAL;                ce->lock       = 0;                ce->clone      = NULL;                ce->func = ce->arg  = NULL;                ce->next = ce->prev = NULL;                if (op & CACHE_READ) {                    if (data)                        memcpy(data, ce->data, bsize);                } else if (op & CACHE_WRITE) {                    ce->flags  |= CE_DIRTY;                    memcpy(ce->data, data, bsize);                } else if (op & CACHE_NOOP) {                    memset(ce->data, 0, bsize);                    if (data)                        memset(data, 0, bsize);                    ce->flags |= CE_DIRTY;                }                if (op & CACHE_LOCKED) {                    ce->lock++;                    cel = &bc.locked;                } else {                    cel = &bc.normal;                }                /* now stick this puppy at the head of the mru list */                add_to_head(cel, ce);                if (dataptr) {                    *dataptr = ce->data;                }                                if (data != NULL)                    data = (void *)((char *)data + bsize);                else if (cur_nblocks != 1)                    panic("cache can't handle setting data_ptr twice!\n");            }  /* end of for(cur=0; cur < cur_nblocks; cur++) */                            bnum       += cur_nblocks;            num_blocks -= cur_nblocks;        }   /* end of else it's not in the cache */            }   /* end of while(num_blocks) */    UNLOCK(bc.lock);    return 0;}void *get_block(int dev, fs_off_t bnum, int bsize){    void *data;    if (cache_block_io(dev, bnum, NULL, 1, bsize, CACHE_READ|CACHE_LOCKED|CACHE_READ_AHEAD_OK,                       &data) != 0)        return NULL;    return data;}void *get_empty_block(int dev, fs_off_t bnum, int bsize){    void *data;    if (cache_block_io(dev, bnum, NULL, 1, bsize, CACHE_NOOP|CACHE_LOCKED,                       &data) != 0)        return NULL;    return data;}intcached_read(int dev, fs_off_t bnum, void *data, fs_off_t num_blocks, int bsize){    return cache_block_io(dev, bnum, data, num_blocks, bsize,                          CACHE_READ | CACHE_READ_AHEAD_OK, NULL);}intcached_write(int dev, fs_off_t bnum, const void *data, fs_off_t num_blocks,int bsize){    return cache_block_io(dev, bnum, (void *)data, num_blocks, bsize,                          CACHE_WRITE, NULL);}intcached_write_locked(int dev, fs_off_t bnum, const void *data,                    fs_off_t num_blocks, int bsize){    return cache_block_io(dev, bnum, (void *)data, num_blocks, bsize,                          CACHE_WRITE | CACHE_LOCKED, NULL);}voidforce_cache_flush(int dev, int prefer_log_blocks){    int        i, count = 0;    cache_ent *ce;    cache_ent *ents[NUM_FLUSH_BLOCKS];        LOCK(bc.lock);    for(ce=bc.normal.lru; ce; ce=ce->next) {        if ((ce->dev == dev) &&            (ce->flags & CE_BUSY) == 0 &&            ((ce->flags & CE_DIRTY) || ce->clone) &&             ((prefer_log_blocks && ce->func) || (prefer_log_blocks == 0))) {            ce->flags |= CE_BUSY;            ents[count++] = ce;                        if (count >= NUM_FLUSH_BLOCKS) {                break;            }       

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一二三四社区欧美黄| 激情综合色播五月| 亚洲国产欧美在线| 久久超碰97人人做人人爱| 国产福利91精品一区| 97se亚洲国产综合自在线观| 欧美日韩高清一区二区| 久久亚洲一级片| 日韩伦理av电影| 蜜臀av在线播放一区二区三区 | 美女性感视频久久| 国产成人精品综合在线观看| 欧美亚洲精品一区| 国产网红主播福利一区二区| 一区二区三区在线视频免费| 麻豆精品视频在线观看| 91在线观看视频| 精品国产一区二区精华| 一区二区三区日本| 国产高清在线观看免费不卡| 欧美三级三级三级爽爽爽| 久久久综合九色合综国产精品| 亚洲一区二区三区不卡国产欧美| 国产乱子伦一区二区三区国色天香| 日本道在线观看一区二区| 亚洲精品一区二区在线观看| 亚洲综合在线五月| 成人国产亚洲欧美成人综合网 | 欧美伊人久久大香线蕉综合69 | 国产精品国产自产拍高清av | 欧美韩日一区二区三区| 午夜av电影一区| 97久久精品人人爽人人爽蜜臀| 精品剧情v国产在线观看在线| 亚洲精品高清在线观看| 国产91色综合久久免费分享| 欧美成人aa大片| 五月天久久比比资源色| 色综合天天综合色综合av| 久久久久久一级片| 精品一区二区三区免费毛片爱| 欧美性感一区二区三区| 亚洲精品视频在线| 粉嫩av一区二区三区粉嫩| 精品日产卡一卡二卡麻豆| 亚洲18女电影在线观看| 色94色欧美sute亚洲线路一ni| 国产欧美精品在线观看| 国产尤物一区二区| 日韩一区二区精品葵司在线| 偷拍日韩校园综合在线| 欧美日韩国产综合视频在线观看 | 国产在线一区观看| 欧美一级二级在线观看| 日韩国产欧美在线播放| 91超碰这里只有精品国产| 香蕉av福利精品导航| 欧美日韩一区二区三区免费看| 亚洲永久免费视频| 欧美日免费三级在线| 性做久久久久久| 欧美男男青年gay1069videost| 亚洲va欧美va人人爽午夜| 欧美二区在线观看| 久久国产人妖系列| 久久久久久亚洲综合| 成人美女视频在线观看18| 亚洲欧洲日韩在线| 欧美亚洲动漫制服丝袜| 五月天久久比比资源色| 欧美一区二区国产| 韩国v欧美v亚洲v日本v| 亚洲国产电影在线观看| 91在线观看高清| 亚洲中国最大av网站| 制服丝袜成人动漫| 韩国精品免费视频| 国产精品久久毛片a| 国产在线不卡一卡二卡三卡四卡| 中文无字幕一区二区三区| 一本大道综合伊人精品热热| 亚洲免费观看高清完整版在线观看| 免费看日韩a级影片| 精品久久久网站| 高清在线观看日韩| 中文字幕人成不卡一区| 欧美日韩精品欧美日韩精品| 久久成人18免费观看| 亚洲欧洲av一区二区三区久久| 欧美怡红院视频| 国产乱码精品一区二区三区五月婷| 国产精品久久久99| 91麻豆精品国产综合久久久久久 | 亚洲永久精品国产| 精品国产免费人成在线观看| 91美女福利视频| 精品一区二区三区日韩| 一区二区三区在线视频免费观看 | 精品久久久久一区| 99精品欧美一区| 蜜芽一区二区三区| 中文字幕制服丝袜成人av| 在线播放日韩导航| 成人精品亚洲人成在线| 日韩激情中文字幕| 日韩一区欧美一区| 久久在线观看免费| 欧美群妇大交群中文字幕| 国产成人av福利| 日韩精品每日更新| 一区二区在线观看视频在线观看| 欧美成人猛片aaaaaaa| 91福利国产成人精品照片| 国产一区二区三区电影在线观看| 亚洲电影你懂得| 国产精品欧美精品| 日韩精品专区在线影院重磅| 日本韩国精品在线| 成人av午夜电影| 国产乱子伦视频一区二区三区 | 亚洲妇女屁股眼交7| 国产精品免费人成网站| 欧美成人官网二区| 欧美精品免费视频| 色久综合一二码| www..com久久爱| 风间由美一区二区av101| 日本女人一区二区三区| 亚洲国产精品一区二区久久恐怖片| 国产精品久久三区| 日本一区二区在线不卡| 久久精品在这里| 久久影院视频免费| 欧美精品一区二区三区四区 | 丰满放荡岳乱妇91ww| 久久69国产一区二区蜜臀| 三级影片在线观看欧美日韩一区二区| 亚洲欧美国产77777| 国产精品高清亚洲| 国产精品久久免费看| 亚洲国产精品v| 中文字幕不卡在线观看| 中文字幕免费不卡在线| 国产欧美日韩在线观看| 久久久蜜桃精品| 久久久另类综合| 国产情人综合久久777777| 日本一区二区免费在线观看视频| 26uuu欧美| 久久精品夜夜夜夜久久| 日本一区二区三区久久久久久久久不 | 欧美日韩www| 91精品国产一区二区人妖| 日韩一区二区三区高清免费看看 | 91精品国产黑色紧身裤美女| 欧美肥妇bbw| 精品国偷自产国产一区| 久久精品夜色噜噜亚洲a∨| 日本一区二区三区国色天香| 国产精品免费看片| 一区2区3区在线看| 天堂在线一区二区| 激情六月婷婷久久| 国产成人精品亚洲日本在线桃色 | 欧美乱妇一区二区三区不卡视频 | 欧美日韩亚洲综合| 91精品国产aⅴ一区二区| 精品88久久久久88久久久| 国产女人aaa级久久久级| 亚洲欧美福利一区二区| 视频一区国产视频| 国产精品12区| 日本韩国欧美在线| 精品噜噜噜噜久久久久久久久试看 | 国产女人18毛片水真多成人如厕| 国产精品理论在线观看| 夜夜夜精品看看| 精品亚洲欧美一区| av网站一区二区三区| 欧美剧在线免费观看网站| xfplay精品久久| 亚洲免费在线观看| 青青草伊人久久| 成人高清在线视频| 911精品国产一区二区在线| 久久精品夜夜夜夜久久| 依依成人综合视频| 国产一区二区精品久久| 色噜噜狠狠成人中文综合| 欧美大片在线观看一区二区| 中文字幕永久在线不卡| 三级影片在线观看欧美日韩一区二区 | 国产性天天综合网| 亚洲国产成人av网| 成人夜色视频网站在线观看| 精品视频在线免费| 国产精品人妖ts系列视频| 日本女优在线视频一区二区| 97久久精品人人澡人人爽| 日韩欧美国产系列|