]> mj.ucw.cz Git - libucw.git/commitdiff
Added pgc_page_pos().
authorMartin Mares <mj@ucw.cz>
Sat, 13 Nov 1999 15:37:07 +0000 (15:37 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 13 Nov 1999 15:37:07 +0000 (15:37 +0000)
Don't forget to unhash buffers when freeing them.

lib/pagecache.c
lib/pagecache.h

index 1ffb1886c7c635e09e53b4b9c430100585902e93..162916204c0fd3e5c6f60f96ba78a6b7afe84e4f 100644 (file)
@@ -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)
index 5c2661a0e04a6aedd31356d5cdd1187ffb90856c..7598f3459b80eedf9256cf738c3347e0a4c0bbd8 100644 (file)
@@ -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