[Tux3] Patch: Freestanding kernel unit test for block operations

Liu XiaoFeng bladehliu at gmail.com
Sat Jan 17 02:19:54 PST 2009


Hi Daniel,

On Fri, Jan 16, 2009 at 12:44 PM, Daniel Phillips <phillips at phunq.net>wrote:

> Hi all,
>
>
> diff --git a/fs/hackfs/hackfs.c b/fs/hackfs/hackfs.c
> new file mode 100644
> index 0000000..afaac69
> --- /dev/null
> +++ b/fs/hackfs/hackfs.c
> @@ -0,0 +1,412 @@
> +/*
> +int fork_buffer(struct buffer_head *buffer)
> +{
> +       struct page *oldpage = buffer->b_page;
> +       struct address_space *mapping = oldpage->mapping;
> +//     struct inode *inode = mapping->host;
> +//     struct sb *sb = tux_sb(inode->i_sb);
> +//     tuxnode_t *tuxnode = tux_inode(inode);
> +       unsigned newdelta = 1 & DELTA_MASK;
> +//     struct list_head *inode_dirty_list = &tuxnode->dirty;
> +       static struct list_head *inode_dirty_list;
> +       unsigned blocksize = 1 << 10;
> +
> +       // Use read_mapping_page to bring the full page uptodate
> +       // Take the page lock (protects the buffer list)
> +       lock_page(oldpage);
> +       while (!PageUptodate(oldpage)) {
> +               unlock_page(oldpage);
> +               oldpage = read_mapping_page(mapping, oldpage->index, NULL);
> +               lock_page(oldpage);
> +       }
> +
> +       // The fork happened while waiting for the page lock?
> +       if (bufdelta(buffer) == newdelta) {
> +               unlock_page(oldpage);
> +               return 0;
> +       }
> +
> +       // Allocate a new page and put buffers on it
> +       struct page *newpage = alloc_pages(0, GFP_KERNEL);
> +       create_empty_buffers(newpage, blocksize, 0);


I think here is a BUG:
  create_empty_buffers(newpage, blocksize, 0) ->
    ...
    spin_lock(&newpage->mapping->private_lock);
    ...
  But newpage->mapping == NULL!



> +
> +       // Copy page data
> +       memcpy(page_address(newpage), page_address(oldpage),
> PAGE_CACHE_SIZE);
>


> _______________________________________________
> Tux3 mailing list
> Tux3 at tux3.org
> http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phunq.net/pipermail/tux3/attachments/20090117/f5521b03/attachment-0001.html>
-------------- next part --------------
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3


More information about the Tux3 mailing list