本文整理汇总了C++中page_index函数的典型用法代码示例。如果您正苦于以下问题:C++ page_index函数的具体用法?C++ page_index怎么用?C++ page_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_index函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sizeof
aku_Status PageHeader::add_entry( const aku_ParamId param
, const aku_Timestamp timestamp
, const aku_MemRange &range )
{
if (count != 0) {
// Require >= timestamp
if (timestamp < page_index(count - 1)->timestamp) {
return AKU_EBAD_ARG;
}
}
const auto SPACE_REQUIRED = sizeof(aku_Entry) // entry header
+ range.length // data size (in bytes)
+ sizeof(aku_EntryIndexRecord); // offset inside page_index
const auto ENTRY_SIZE = sizeof(aku_Entry) + range.length;
if (!range.length) {
return AKU_EBAD_DATA;
}
if (SPACE_REQUIRED > get_free_space()) {
return AKU_EOVERFLOW;
}
char* free_slot = payload + next_offset;
aku_Entry* entry = reinterpret_cast<aku_Entry*>(free_slot);
entry->param_id = param;
entry->length = range.length;
memcpy((void*)&entry->value, range.address, range.length);
page_index(count)->offset = next_offset;
page_index(count)->timestamp = timestamp;
next_offset += ENTRY_SIZE;
count++;
return AKU_SUCCESS;
}
开发者ID:nickman,项目名称:Akumuli,代码行数:34,代码来源:page.cpp
示例2: __tux3_test_set_page_writeback
static void __tux3_test_set_page_writeback(struct page *page, int old_writeback)
{
struct address_space *mapping = page->mapping;
if (mapping) {
struct backing_dev_info *bdi = mapping->backing_dev_info;
unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags);
if (!old_writeback) {
/* If PageForked(), don't touch tag */
if (!PageForked(page))
radix_tree_tag_set(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_WRITEBACK);
if (bdi_cap_account_writeback(bdi))
__inc_bdi_stat(bdi, BDI_WRITEBACK);
}
/* If PageForked(), don't touch tag */
if (!PageDirty(page) && !PageForked(page))
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_DIRTY);
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_TOWRITE);
spin_unlock_irqrestore(&mapping->tree_lock, flags);
}
if (!old_writeback) {
account_page_writeback(page);
tux3_accout_set_writeback(page);
}
}
开发者ID:AbhijeetPawar,项目名称:tux3,代码行数:33,代码来源:buffer_writebacklib.c
示例3: test_set_page_writeback
int test_set_page_writeback(struct page *page)
{
struct address_space *mapping = page_mapping(page);
int ret;
if (mapping) {
struct backing_dev_info *bdi = mapping->backing_dev_info;
unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags);
ret = TestSetPageWriteback(page);
if (!ret) {
radix_tree_tag_set(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_WRITEBACK);
if (bdi_cap_account_writeback(bdi))
__inc_bdi_stat(bdi, BDI_WRITEBACK);
}
if (!PageDirty(page))
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_DIRTY);
spin_unlock_irqrestore(&mapping->tree_lock, flags);
} else {
ret = TestSetPageWriteback(page);
}
if (!ret)
inc_zone_page_state(page, NR_WRITEBACK);
return ret;
}
开发者ID:khenam,项目名称:ardrone-kernel,代码行数:31,代码来源:page-writeback.c
示例4: test_set_page_writeback
int test_set_page_writeback(struct page *page)
{
struct address_space *mapping = page_mapping(page);
int ret;
if (mapping) {
unsigned long flags;
write_lock_irqsave(&mapping->tree_lock, flags);
ret = TestSetPageWriteback(page);
if (!ret)
radix_tree_tag_set(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_WRITEBACK);
if (!PageDirty(page))
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_DIRTY);
write_unlock_irqrestore(&mapping->tree_lock, flags);
} else {
ret = TestSetPageWriteback(page);
}
if (!ret)
inc_zone_page_state(page, NR_WRITEBACK);
return ret;
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:27,代码来源:page-writeback.c
示例5: ik_munmap_from_segment
void
ik_munmap_from_segment(ikptr base, unsigned long int size, ikpcb* pcb){
assert(base >= pcb->memory_base);
assert((base+size) <= pcb->memory_end);
assert(size == align_to_next_page(size));
unsigned int* p =
((unsigned int*)(long)(pcb->segment_vector)) + page_index(base);
unsigned int* s =
((unsigned int*)(long)(pcb->dirty_vector)) + page_index(base);
unsigned int* q = p + page_index(size);
while(p < q){
assert(*p != hole_mt);
*p = hole_mt; /* holes */
*s = 0;
p++; s++;
}
ikpage* r = pcb->uncached_pages;
if (r){
ikpage* cache = pcb->cached_pages;
do{
r->base = base;
ikpage* next = r->next;
r->next = cache;
cache = r;
r = next;
base += pagesize;
size -= pagesize;
} while(r && size);
pcb->cached_pages = cache;
pcb->uncached_pages = r;
}
if(size){
ik_munmap(base, size);
}
}
开发者ID:hyln9,项目名称:ikarus,代码行数:35,代码来源:ikarus-runtime.c
示例6: set_segment_type
static void
set_segment_type(ikptr base, unsigned long int size, unsigned int type, ikpcb* pcb){
assert(base >= pcb->memory_base);
assert((base+size) <= pcb->memory_end);
assert(size == align_to_next_page(size));
unsigned int* p = pcb->segment_vector + page_index(base);
unsigned int* q = p + page_index(size);
while(p < q){
*p = type;
p++;
}
}
开发者ID:hyln9,项目名称:ikarus,代码行数:12,代码来源:ikarus-runtime.c
示例7: test_clear_page_writeback
int test_clear_page_writeback(struct page *page)
{
struct address_space *mapping = page_mapping(page);
int ret;
if (mapping) {
struct backing_dev_info *bdi = mapping->backing_dev_info;
unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags);
ret = TestClearPageWriteback(page);
if (ret) {
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_WRITEBACK);
if (bdi_cap_account_writeback(bdi)) {
__dec_bdi_stat(bdi, BDI_WRITEBACK);
__bdi_writeout_inc(bdi);
}
}
spin_unlock_irqrestore(&mapping->tree_lock, flags);
} else {
ret = TestClearPageWriteback(page);
}
if (ret)
dec_zone_page_state(page, NR_WRITEBACK);
return ret;
}
开发者ID:khenam,项目名称:ardrone-kernel,代码行数:28,代码来源:page-writeback.c
示例8: page_index
const aku_Entry *PageHeader::read_entry_at(uint32_t index) const {
if (index < count) {
auto offset = page_index(index)->offset;
return read_entry(offset);
}
return 0;
}
开发者ID:nickman,项目名称:Akumuli,代码行数:7,代码来源:page.cpp
示例9: nilfs_bh_debug
void nilfs_bh_debug(const char *fname, int line, struct buffer_head *bh,
const char *m, ...)
{
struct page *page = bh->b_page;
int len;
char b[MSIZ];
va_list args;
len = snprintf(b, MSIZ, "BH %p ", bh);
va_start(args, m);
len += vsnprintf(b + len, MSIZ - len, m, args);
va_end(args);
if (bh == NULL) {
printk(KERN_DEBUG "%s: bh=NULL %s at %d\n", b, fname, line);
return;
}
len += snprintf(b + len, MSIZ - len,
": page=%p cnt=%d blk#=%llu lst=%d",
page, atomic_read(&bh->b_count),
(unsigned long long)bh->b_blocknr,
!list_empty(&bh->b_assoc_buffers));
if (page)
len += snprintf(b + len, MSIZ - len,
" pagecnt=%d pageindex=%lu",
page_count(page), page_index(page));
len += snprintf(b + len, MSIZ - len, " %s(%d) state=", fname, line);
len += snprint_bh_state(b + len, MSIZ - len, bh);
printk(KERN_DEBUG "%s\n", b);
}
开发者ID:franjoweb,项目名称:liquid_chocolate_ics_kernel,代码行数:31,代码来源:debug.c
示例10: ikrt_set_code_reloc_vector
ikptr
ikrt_set_code_reloc_vector(ikptr code, ikptr vec, ikpcb* pcb){
ref(code, off_code_reloc_vector) = vec;
ik_relocate_code(code-vector_tag);
((unsigned int*)(long)pcb->dirty_vector)[page_index(code)] = -1;
return void_object;
}
开发者ID:hyln9,项目名称:ikarus,代码行数:7,代码来源:ikarus-runtime.c
示例11: __set_page_dirty_nobuffers
/*
* For address_spaces which do not use buffers. Just tag the page as dirty in
* its radix tree.
*
* This is also used when a single buffer is being dirtied: we want to set the
* page dirty in that case, but not all the buffers. This is a "bottom-up"
* dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying.
*
* Most callers have locked the page, which pins the address_space in memory.
* But zap_pte_range() does not lock the page, however in that case the
* mapping is pinned by the vma's ->vm_file reference.
*
* We take care to handle the case where the page was truncated from the
* mapping by re-checking page_mapping() inside tree_lock.
*/
int __set_page_dirty_nobuffers(struct page *page)
{
if (!TestSetPageDirty(page)) {
struct address_space *mapping = page_mapping(page);
struct address_space *mapping2;
if (!mapping)
return 1;
spin_lock_irq(&mapping->tree_lock);
mapping2 = page_mapping(page);
if (mapping2) { /* Race with truncate? */
BUG_ON(mapping2 != mapping);
WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
account_page_dirtied(page, mapping);
radix_tree_tag_set(&mapping->page_tree,
page_index(page), PAGECACHE_TAG_DIRTY);
}
spin_unlock_irq(&mapping->tree_lock);
if (mapping->host) {
/* !PageAnon && !swapper_space */
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
}
return 1;
}
return 0;
}
开发者ID:printusrzero,项目名称:hwp6s-kernel,代码行数:42,代码来源:page-writeback.c
示例12: dump_lniobuf
void dump_lniobuf(struct niobuf_local *nb)
{
CDEBUG(D_RPCTRACE,
"niobuf_local: file_offset="LPD64", len=%d, page=%p, rc=%d\n",
nb->lnb_file_offset, nb->lnb_len, nb->lnb_page, nb->lnb_rc);
CDEBUG(D_RPCTRACE, "nb->page: index = %ld\n",
nb->lnb_page ? page_index(nb->lnb_page) : -1);
}
开发者ID:EMSL-MSC,项目名称:lustre-release,代码行数:8,代码来源:debug.c
示例13: _nfs_find_request
/*
* Find a request
*/
static inline struct nfs_page *
_nfs_find_request(struct inode *inode, struct page *page)
{
struct list_head *head, *pos;
unsigned long pg_idx = page_index(page);
head = &inode->u.nfs_i.writeback;
list_for_each_prev(pos, head) {
struct nfs_page *req = nfs_inode_wb_entry(pos);
unsigned long found_idx = page_index(req->wb_page);
if (pg_idx < found_idx)
continue;
if (pg_idx != found_idx)
break;
req->wb_count++;
return req;
}
return NULL;
}
开发者ID:hugh712,项目名称:Jollen,代码行数:23,代码来源:write.c
示例14: __tux3_set_page_dirty
/*
* Copy of __set_page_dirty() without __mark_inode_dirty(). Caller
* decides whether mark inode dirty or not.
*/
static void __tux3_set_page_dirty(struct page *page,
struct address_space *mapping, int warn)
{
spin_lock_irq(&mapping->tree_lock);
if (page->mapping) { /* Race with truncate? */
WARN_ON_ONCE(warn && !PageUptodate(page));
account_page_dirtied(page, mapping);
radix_tree_tag_set(&mapping->page_tree,
page_index(page), PAGECACHE_TAG_DIRTY);
}
spin_unlock_irq(&mapping->tree_lock);
}
开发者ID:OGAWAHirofumi,项目名称:tux3,代码行数:16,代码来源:buffer.c
示例15: nfs_inode_add_request
/*
* Insert a write request into an inode
* Note: we sort the list in order to be able to optimize nfs_find_request()
* & co. for the 'write append' case. For 2.5 we may want to consider
* some form of hashing so as to perform well on random writes.
*/
static inline void
nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
{
struct list_head *pos, *head;
unsigned long pg_idx = page_index(req->wb_page);
if (!list_empty(&req->wb_hash))
return;
if (!NFS_WBACK_BUSY(req))
printk(KERN_ERR "NFS: unlocked request attempted hashed!\n");
head = &inode->u.nfs_i.writeback;
if (list_empty(head))
igrab(inode);
list_for_each_prev(pos, head) {
struct nfs_page *entry = nfs_inode_wb_entry(pos);
if (page_index(entry->wb_page) < pg_idx)
break;
}
inode->u.nfs_i.npages++;
list_add(&req->wb_hash, pos);
req->wb_count++;
}
开发者ID:hugh712,项目名称:Jollen,代码行数:28,代码来源:write.c
示例16: nilfs_bmap_data_get_key
/*
* Internal use only
*/
__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
const struct buffer_head *bh)
{
struct buffer_head *pbh;
__u64 key;
key = page_index(bh->b_page) << (PAGE_SHIFT -
bmap->b_inode->i_blkbits);
for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page)
key++;
return key;
}
开发者ID:faddat,项目名称:linux-mainline-next,代码行数:16,代码来源:bmap.c
示例17: __tux3_set_page_dirty_account
/*
* Copy of __set_page_dirty() without __mark_inode_dirty(). Caller
* decides whether mark inode dirty or not.
*/
void __tux3_set_page_dirty_account(struct page *page,
struct address_space *mapping, int warn)
{
unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags);
if (page->mapping) { /* Race with truncate? */
WARN_ON_ONCE(warn && !PageUptodate(page));
account_page_dirtied(page, mapping);
radix_tree_tag_set(&mapping->page_tree,
page_index(page), PAGECACHE_TAG_DIRTY);
}
spin_unlock_irqrestore(&mapping->tree_lock, flags);
}
开发者ID:daiyy,项目名称:linux-tux3,代码行数:18,代码来源:filemap_mmap.c
示例18: ik_delete_pcb
void ik_delete_pcb(ikpcb* pcb){
ikpage* p = pcb->cached_pages;
pcb->cached_pages = 0;
pcb->uncached_pages = 0;
while(p){
ik_munmap(p->base, pagesize);
p = p->next;
}
ik_munmap(pcb->cached_pages_base, pcb->cached_pages_size);
{
int i;
for(i=0; i<generation_count; i++){
ik_ptr_page* p = pcb->protected_list[i];
while(p){
ik_ptr_page* next = p->next;
ik_munmap((ikptr)(long)p, pagesize);
p = next;
}
}
}
ikptr base = pcb->memory_base;
ikptr end = pcb->memory_end;
unsigned int* segment_vec = pcb->segment_vector;
long int i = page_index(base);
long int j = page_index(end);
while(i < j){
unsigned int t = segment_vec[i];
if(t != hole_mt){
ik_munmap((ikptr)(i<<pageshift), pagesize);
}
i++;
}
long int vecsize = (segment_index(end) - segment_index(base)) * pagesize;
ik_munmap((ikptr)(long)pcb->dirty_vector_base, vecsize);
ik_munmap((ikptr)(long)pcb->segment_vector_base, vecsize);
ik_free(pcb, sizeof(ikpcb));
}
开发者ID:hyln9,项目名称:ikarus,代码行数:37,代码来源:ikarus-runtime.c
示例19: __nilfs_clear_page_dirty
/*
* NILFS2 needs clear_page_dirty() in the following two cases:
*
* 1) For B-tree node pages and data pages of the dat/gcdat, NILFS2 clears
* page dirty flags when it copies back pages from the shadow cache
* (gcdat->{i_mapping,i_btnode_cache}) to its original cache
* (dat->{i_mapping,i_btnode_cache}).
*
* 2) Some B-tree operations like insertion or deletion may dispose buffers
* in dirty state, and this needs to cancel the dirty state of their pages.
*/
int __nilfs_clear_page_dirty(struct page *page)
{
struct address_space *mapping = page->mapping;
if (mapping) {
spin_lock_irq(&mapping->tree_lock);
if (test_bit(PG_dirty, &page->flags)) {
radix_tree_tag_clear(&mapping->page_tree,
page_index(page),
PAGECACHE_TAG_DIRTY);
spin_unlock_irq(&mapping->tree_lock);
return clear_page_dirty_for_io(page);
}
spin_unlock_irq(&mapping->tree_lock);
return 0;
}
return TestClearPageDirty(page);
}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:29,代码来源:page.c
示例20: __dcache_find_get_entry
static struct dentry *
__dcache_find_get_entry(struct dentry *parent, u64 idx,
struct ceph_readdir_cache_control *cache_ctl)
{
struct inode *dir = d_inode(parent);
struct dentry *dentry;
unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1;
loff_t ptr_pos = idx * sizeof(struct dentry *);
pgoff_t ptr_pgoff = ptr_pos >> PAGE_SHIFT;
if (ptr_pos >= i_size_read(dir))
return NULL;
if (!cache_ctl->page || ptr_pgoff != page_index(cache_ctl->page)) {
ceph_readdir_cache_release(cache_ctl);
cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff);
if (!cache_ctl->page) {
dout(" page %lu not found\n", ptr_pgoff);
return ERR_PTR(-EAGAIN);
}
/* reading/filling the cache are serialized by
i_mutex, no need to use page lock */
unlock_page(cache_ctl->page);
cache_ctl->dentries = kmap(cache_ctl->page);
}
cache_ctl->index = idx & idx_mask;
rcu_read_lock();
spin_lock(&parent->d_lock);
/* check i_size again here, because empty directory can be
* marked as complete while not holding the i_mutex. */
if (ceph_dir_is_complete_ordered(dir) && ptr_pos < i_size_read(dir))
dentry = cache_ctl->dentries[cache_ctl->index];
else
dentry = NULL;
spin_unlock(&parent->d_lock);
if (dentry && !lockref_get_not_dead(&dentry->d_lockref))
dentry = NULL;
rcu_read_unlock();
return dentry ? : ERR_PTR(-EAGAIN);
}
开发者ID:acton393,项目名称:linux,代码行数:42,代码来源:dir.c
注:本文中的page_index函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论