slab: Update the ctor/dtor interface
[akaros.git] / kern / src / blockdev.c
index 8e4f3b5..434051b 100644 (file)
@@ -20,10 +20,14 @@ struct kmem_cache *breq_kcache;
 
 void block_init(void)
 {
-       breq_kcache = kmem_cache_create("block_reqs", sizeof(struct block_request),
-                                       __alignof__(struct block_request), 0, 0, 0);
-       bh_kcache = kmem_cache_create("buffer_heads", sizeof(struct buffer_head),
-                                     __alignof__(struct buffer_head), 0, 0, 0);
+       breq_kcache = kmem_cache_create("block_reqs",
+                                       sizeof(struct block_request),
+                                       __alignof__(struct block_request), 0,
+                                       NULL, 0, 0, NULL);
+       bh_kcache = kmem_cache_create("buffer_heads",
+                                     sizeof(struct buffer_head),
+                                     __alignof__(struct buffer_head), 0,
+                                     NULL, 0, 0, NULL);
 
        #ifdef CONFIG_EXT2FS
        /* Now probe for and init the block device for the ext2 ram disk */
@@ -38,10 +42,9 @@ void block_init(void)
        kref_init(&ram_bd->b_kref, fake_release, 1);
        pm_init(&ram_bd->b_pm, &block_pm_op, ram_bd);
        ram_bd->b_data = _binary_mnt_ext2fs_img_start;
-       strncpy(ram_bd->b_name, "RAMDISK", BDEV_INLINE_NAME);
-       ram_bd->b_name[BDEV_INLINE_NAME - 1] = '\0';
+       strlcpy(ram_bd->b_name, "RAMDISK", BDEV_INLINE_NAME);
        /* Connect it to the file system */
-       struct file *ram_bf = make_device("/dev/ramdisk", S_IRUSR | S_IWUSR,
+       struct file *ram_bf = make_device("/dev_vfs/ramdisk", S_IRUSR | S_IWUSR,
                                          __S_IFBLK, &block_f_op);
        /* make sure the inode tracks the right pm (not it's internal one) */
        ram_bf->f_dentry->d_inode->i_mapping = &ram_bd->b_pm;
@@ -187,11 +190,11 @@ struct buffer_head *bdev_get_buffer(struct block_device *bdev,
        if (!blk_num)
                warn("Asking for the 0th block of a bdev...");
        /* Make sure there's a page in the page cache.  Should always be one. */
-       error = pm_load_page(pm, blk_num / blk_per_pg, &page); 
+       error = pm_load_page(pm, blk_num / blk_per_pg, &page);
        if (error)
                panic("Failed to load page! (%d)", error);
        my_buf = page2kva(page) + blk_offset;
-       assert(atomic_read(&page->pg_flags) & PG_BUFFER);
+       atomic_or(&page->pg_flags, PG_BUFFER);
 retry:
        bh = (struct buffer_head*)page->pg_private;
        prev = 0;
@@ -276,7 +279,7 @@ void bdev_dirty_buffer(struct buffer_head *bh)
  * reclaiming will be in page sized chunks from the page cache. */
 void bdev_put_buffer(struct buffer_head *bh)
 {
-       page_decref(bh->bh_page);
+       pm_put_page(bh->bh_page);
 }
 
 /* Block device page map ops: */