Re: [PATCH] 2.6.11-mm1 "nobh" support for ext3 writeback mode

From: Andrew Morton
Date: Fri Mar 04 2005 - 20:52:18 EST


Badari Pulavarty <pbadari@xxxxxxxxxx> wrote:
>
> iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);

It would still be nice to add a comment in here...

> + if (test_opt(inode->i_sb, NOBH) && !page_has_buffers(page)) {
> + if (!PageUptodate(page)) {
> + struct buffer_head map_bh;
> + bh = &map_bh;
> + bh->b_state = 0;
> + clear_buffer_mapped(bh);
> + ext3_get_block(inode, iblock, bh, 0);
> + if (!buffer_mapped(bh))
> + goto unlock;
> + err = -EIO;
> + set_bh_page(bh, page, 0);
> + bh->b_this_page = 0;
> + bh->b_size = 1 << inode->i_blkbits;
> + ll_rw_block(READ, 1, &bh);
> + wait_on_buffer(bh);
> + if (!buffer_uptodate(bh))
> + goto unlock;
> + SetPageMappedToDisk(page);
> + }
> + kaddr = kmap_atomic(page, KM_USER0);
> + memset(kaddr + offset, 0, length);
> + flush_dcache_page(page);
> + kunmap_atomic(kaddr, KM_USER0);
> + set_page_dirty(page);
> + err = 0;
> + goto unlock;
> + }
> +
> if (!page_has_buffers(page))
> create_empty_buffers(page, blocksize, 0);

Given that we're about to go add buffers to the page, why not do that
first, and use the page's own buffer_head rather than cooking up a local
one? Then we can simply use sb_bread().

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/