From 7da4760cfac317e4ee8fcc564c04135f7e5ac08b Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 13 Nov 1999 15:37:07 +0000 Subject: [PATCH] Added pgc_page_pos(). Don't forget to unhash buffers when freeing them. --- lib/pagecache.c | 9 +++++++++ lib/pagecache.h | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/pagecache.c b/lib/pagecache.c index 1ffb1886..16291620 100644 --- a/lib/pagecache.c +++ b/lib/pagecache.c @@ -162,6 +162,7 @@ get_page(struct page_cache *c, sh_off_t key) { /* There are only dirty pages here */ p = HEAD(c->dirty_pages); + ASSERT(p->n.next); flush_page(c, p); } ASSERT(!p->lock_count); @@ -206,6 +207,7 @@ pgc_cleanup(struct page_cache *c) { ASSERT(!(p->flags & PG_FLAG_DIRTY) && !p->lock_count); rem_node(&p->n); + rem_node(&p->hn); c->free_count--; c->total_count--; free(p); @@ -289,6 +291,7 @@ pgc_put(struct page_cache *c, struct page *p) } else { + rem_node(&p->hn); free(p); c->total_count--; } @@ -319,6 +322,12 @@ pgc_read_data(struct page_cache *c, int fd, sh_off_t pos, uns *len) return p->data + offset; } +sh_off_t +pgc_page_pos(struct page_cache *c, struct page *p) +{ + return PAGE_NUMBER(p->key); +} + #ifdef TEST int main(int argc, char **argv) diff --git a/lib/pagecache.h b/lib/pagecache.h index 5c2661a0..7598f345 100644 --- a/lib/pagecache.h +++ b/lib/pagecache.h @@ -33,5 +33,6 @@ struct page *pgc_get(struct page_cache *, int fd, sh_off_t); /* Get page for wri void pgc_put(struct page_cache *, struct page *); /* Release page */ void pgc_mark_dirty(struct page_cache *, struct page *); /* Mark locked page as dirty */ byte *pgc_read_data(struct page_cache *, int fd, sh_off_t, uns *); /* Partial reading */ +sh_off_t pgc_page_pos(struct page_cache *, struct page *); /* Get page position */ #endif -- 2.39.2