Christoph Hellwig
2007-Sep-17 06:31 UTC
[Btrfs-devel] [PATCH] factor page private preparations into a helper
Not sure the name makes any sense, so if anyone has a better idea.. Signed-off-by: Christoph Hellwig <hch@lst.de> Index: btrfs-d0921c0349a9/extent_map.c ==================================================================--- btrfs-d0921c0349a9.orig/extent_map.c 2007-09-14 16:23:29.000000000 +0200 +++ btrfs-d0921c0349a9/extent_map.c 2007-09-17 15:29:47.000000000 +0200 @@ -1379,6 +1379,16 @@ static int submit_extent_page(int rw, st return ret; } +void extent_mark_page_used(struct page *page) +{ + if (!PagePrivate(page)) { + SetPagePrivate(page); + WARN_ON(!page->mapping->a_ops->invalidatepage); + set_page_private(page, 1); + page_cache_get(page); + } +} + /* * basic readpage implementation. Locked extent state structs are inserted * into the tree that are removed when the IO is done (by the end_io @@ -1405,12 +1415,7 @@ int extent_read_full_page(struct extent_ size_t iosize; size_t blocksize = inode->i_sb->s_blocksize; - if (!PagePrivate(page)) { - SetPagePrivate(page); - WARN_ON(!page->mapping->a_ops->invalidatepage); - set_page_private(page, 1); - page_cache_get(page); - } + extent_mark_page_used(page); end = page_end; lock_extent(tree, start, end, GFP_NOFS); @@ -1531,12 +1536,7 @@ int extent_write_full_page(struct extent PAGE_CACHE_SIZE - offset, KM_USER0); } - if (!PagePrivate(page)) { - SetPagePrivate(page); - set_page_private(page, 1); - WARN_ON(!page->mapping->a_ops->invalidatepage); - page_cache_get(page); - } + extent_mark_page_used(page); lock_extent(tree, start, page_end, GFP_NOFS); nr_delalloc = find_lock_delalloc_range(tree, start, page_end + 1, @@ -1672,13 +1672,7 @@ int extent_commit_write(struct extent_ma { loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; - if (!PagePrivate(page)) { - SetPagePrivate(page); - set_page_private(page, 1); - WARN_ON(!page->mapping->a_ops->invalidatepage); - page_cache_get(page); - } - + extent_mark_page_used(page); set_page_dirty(page); if (pos > inode->i_size) { @@ -1709,12 +1703,8 @@ int extent_prepare_write(struct extent_m int ret = 0; int isnew; - if (!PagePrivate(page)) { - SetPagePrivate(page); - set_page_private(page, 1); - WARN_ON(!page->mapping->a_ops->invalidatepage); - page_cache_get(page); - } + extent_mark_page_used(page); + block_start = (page_start + from) & ~((u64)blocksize - 1); block_end = (page_start + to - 1) | (blocksize - 1); orig_block_start = block_start; Index: btrfs-d0921c0349a9/extent_map.h ==================================================================--- btrfs-d0921c0349a9.orig/extent_map.h 2007-09-14 16:23:29.000000000 +0200 +++ btrfs-d0921c0349a9/extent_map.h 2007-09-17 15:29:47.000000000 +0200 @@ -105,4 +105,5 @@ sector_t extent_bmap(struct address_spac int set_range_dirty(struct extent_map_tree *tree, u64 start, u64 end); int set_state_private(struct extent_map_tree *tree, u64 start, u64 private); int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private); +void extent_mark_page_used(struct page *page); #endif Index: btrfs-d0921c0349a9/file.c ==================================================================--- btrfs-d0921c0349a9.orig/file.c 2007-09-14 16:23:29.000000000 +0200 +++ btrfs-d0921c0349a9/file.c 2007-09-17 15:29:47.000000000 +0200 @@ -543,12 +543,7 @@ static int prepare_pages(struct btrfs_ro } cancel_dirty_page(pages[i], PAGE_CACHE_SIZE); wait_on_page_writeback(pages[i]); - if (!PagePrivate(pages[i])) { - SetPagePrivate(pages[i]); - set_page_private(pages[i], 1); - WARN_ON(!pages[i]->mapping->a_ops->invalidatepage); - page_cache_get(pages[i]); - } + extent_mark_page_used(pages[i]); WARN_ON(!PageLocked(pages[i])); } return 0; Index: btrfs-d0921c0349a9/inode.c ==================================================================--- btrfs-d0921c0349a9.orig/inode.c 2007-09-14 16:23:29.000000000 +0200 +++ btrfs-d0921c0349a9/inode.c 2007-09-17 15:29:47.000000000 +0200 @@ -647,12 +647,7 @@ static int btrfs_cow_one_page(struct ino u64 page_start = page->index << PAGE_CACHE_SHIFT; u64 page_end = page_start + PAGE_CACHE_SIZE - 1; - if (!PagePrivate(page)) { - SetPagePrivate(page); - set_page_private(page, 1); - WARN_ON(!page->mapping->a_ops->invalidatepage); - page_cache_get(page); - } + extent_mark_page_used(page); lock_extent(em_tree, page_start, page_end, GFP_NOFS); set_extent_delalloc(&BTRFS_I(inode)->extent_tree, page_start,
Chris Mason
2007-Sep-17 07:07 UTC
[Btrfs-devel] [PATCH] factor page private preparations into a helper
On Mon, 17 Sep 2007 15:31:22 +0200 Christoph Hellwig <hch@lst.de> wrote:> Not sure the name makes any sense, so if anyone has a better idea..How about set_page_extent_map()? (or mapped) -chris