本文整理汇总了C++中page_index函数的典型用法代码示例。如果您正苦于以下问题:C++ page_index函数的具体用法?C++ page_index怎么用?C++ page_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_index函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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++;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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++;
}