Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: remove all unused functions

Remove static and global declarations and/or definitions. Reduces size
of btrfs.ko by ~3.4kB.

text data bss dec hex filename
402081 7464 200 409745 64091 btrfs.ko.base
398620 7144 200 405964 631cc btrfs.ko.remove-all

Signed-off-by: David Sterba <dsterba@suse.cz>

+1 -817
-78
fs/btrfs/ctree.h
··· 1440 1440 return btrfs_stripe_offset(eb, btrfs_stripe_nr(c, nr)); 1441 1441 } 1442 1442 1443 - static inline void btrfs_set_stripe_offset_nr(struct extent_buffer *eb, 1444 - struct btrfs_chunk *c, int nr, 1445 - u64 val) 1446 - { 1447 - btrfs_set_stripe_offset(eb, btrfs_stripe_nr(c, nr), val); 1448 - } 1449 - 1450 1443 static inline u64 btrfs_stripe_devid_nr(struct extent_buffer *eb, 1451 1444 struct btrfs_chunk *c, int nr) 1452 1445 { 1453 1446 return btrfs_stripe_devid(eb, btrfs_stripe_nr(c, nr)); 1454 - } 1455 - 1456 - static inline void btrfs_set_stripe_devid_nr(struct extent_buffer *eb, 1457 - struct btrfs_chunk *c, int nr, 1458 - u64 val) 1459 - { 1460 - btrfs_set_stripe_devid(eb, btrfs_stripe_nr(c, nr), val); 1461 1447 } 1462 1448 1463 1449 /* struct btrfs_block_group_item */ ··· 1500 1514 { 1501 1515 unsigned long ptr = (unsigned long)inode_item; 1502 1516 ptr += offsetof(struct btrfs_inode_item, ctime); 1503 - return (struct btrfs_timespec *)ptr; 1504 - } 1505 - 1506 - static inline struct btrfs_timespec * 1507 - btrfs_inode_otime(struct btrfs_inode_item *inode_item) 1508 - { 1509 - unsigned long ptr = (unsigned long)inode_item; 1510 - ptr += offsetof(struct btrfs_inode_item, otime); 1511 1517 return (struct btrfs_timespec *)ptr; 1512 1518 } 1513 1519 ··· 1853 1875 return (u8 *)ptr; 1854 1876 } 1855 1877 1856 - static inline u8 *btrfs_super_fsid(struct extent_buffer *eb) 1857 - { 1858 - unsigned long ptr = offsetof(struct btrfs_super_block, fsid); 1859 - return (u8 *)ptr; 1860 - } 1861 - 1862 - static inline u8 *btrfs_header_csum(struct extent_buffer *eb) 1863 - { 1864 - unsigned long ptr = offsetof(struct btrfs_header, csum); 1865 - return (u8 *)ptr; 1866 - } 1867 - 1868 - static inline struct btrfs_node *btrfs_buffer_node(struct extent_buffer *eb) 1869 - { 1870 - return NULL; 1871 - } 1872 - 1873 - static inline struct btrfs_leaf *btrfs_buffer_leaf(struct extent_buffer *eb) 1874 - { 1875 - return NULL; 1876 - } 1877 - 1878 - static inline struct btrfs_header *btrfs_buffer_header(struct extent_buffer *eb) 1879 - { 1880 - return NULL; 1881 - } 1882 - 1883 1878 static inline int btrfs_is_leaf(struct extent_buffer *eb) 1884 1879 { 1885 1880 return btrfs_header_level(eb) == 0; ··· 2004 2053 static inline struct btrfs_root *btrfs_sb(struct super_block *sb) 2005 2054 { 2006 2055 return sb->s_fs_info; 2007 - } 2008 - 2009 - static inline int btrfs_set_root_name(struct btrfs_root *root, 2010 - const char *name, int len) 2011 - { 2012 - /* if we already have a name just free it */ 2013 - kfree(root->name); 2014 - 2015 - root->name = kmalloc(len+1, GFP_KERNEL); 2016 - if (!root->name) 2017 - return -ENOMEM; 2018 - 2019 - memcpy(root->name, name, len); 2020 - root->name[len] = '\0'; 2021 - 2022 - return 0; 2023 2056 } 2024 2057 2025 2058 static inline u32 btrfs_level_size(struct btrfs_root *root, int level) ··· 2239 2304 2240 2305 int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root 2241 2306 *root, struct btrfs_key *key, void *data, u32 data_size); 2242 - int btrfs_insert_some_items(struct btrfs_trans_handle *trans, 2243 - struct btrfs_root *root, 2244 - struct btrfs_path *path, 2245 - struct btrfs_key *cpu_key, u32 *data_size, 2246 - int nr); 2247 2307 int btrfs_insert_empty_items(struct btrfs_trans_handle *trans, 2248 2308 struct btrfs_root *root, 2249 2309 struct btrfs_path *path, ··· 2284 2354 *item); 2285 2355 int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct 2286 2356 btrfs_root_item *item, struct btrfs_key *key); 2287 - int btrfs_search_root(struct btrfs_root *root, u64 search_start, 2288 - u64 *found_objectid); 2289 2357 int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid); 2290 2358 int btrfs_find_orphan_roots(struct btrfs_root *tree_root); 2291 2359 int btrfs_set_root_node(struct btrfs_root_item *item, ··· 2422 2494 u32 min_type); 2423 2495 2424 2496 int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput); 2425 - int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput, 2426 - int sync); 2427 2497 int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, 2428 2498 struct extent_state **cached_state); 2429 2499 int btrfs_writepages(struct address_space *mapping, ··· 2505 2579 /* sysfs.c */ 2506 2580 int btrfs_init_sysfs(void); 2507 2581 void btrfs_exit_sysfs(void); 2508 - int btrfs_sysfs_add_super(struct btrfs_fs_info *fs); 2509 - int btrfs_sysfs_add_root(struct btrfs_root *root); 2510 - void btrfs_sysfs_del_root(struct btrfs_root *root); 2511 - void btrfs_sysfs_del_super(struct btrfs_fs_info *root); 2512 2582 2513 2583 /* xattr.c */ 2514 2584 ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
-38
fs/btrfs/delayed-ref.c
··· 281 281 } 282 282 283 283 /* 284 - * This checks to see if there are any delayed refs in the 285 - * btree for a given bytenr. It returns one if it finds any 286 - * and zero otherwise. 287 - * 288 - * If it only finds a head node, it returns 0. 289 - * 290 - * The idea is to use this when deciding if you can safely delete an 291 - * extent from the extent allocation tree. There may be a pending 292 - * ref in the rbtree that adds or removes references, so as long as this 293 - * returns one you need to leave the BTRFS_EXTENT_ITEM in the extent 294 - * allocation tree. 295 - */ 296 - int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr) 297 - { 298 - struct btrfs_delayed_ref_node *ref; 299 - struct btrfs_delayed_ref_root *delayed_refs; 300 - struct rb_node *prev_node; 301 - int ret = 0; 302 - 303 - delayed_refs = &trans->transaction->delayed_refs; 304 - spin_lock(&delayed_refs->lock); 305 - 306 - ref = find_ref_head(&delayed_refs->root, bytenr, NULL); 307 - if (ref) { 308 - prev_node = rb_prev(&ref->rb_node); 309 - if (!prev_node) 310 - goto out; 311 - ref = rb_entry(prev_node, struct btrfs_delayed_ref_node, 312 - rb_node); 313 - if (ref->bytenr == bytenr) 314 - ret = 1; 315 - } 316 - out: 317 - spin_unlock(&delayed_refs->lock); 318 - return ret; 319 - } 320 - 321 - /* 322 284 * helper function to update an extent delayed ref in the 323 285 * rbtree. existing and update must both have the same 324 286 * bytenr and parent
-1
fs/btrfs/delayed-ref.h
··· 166 166 167 167 struct btrfs_delayed_ref_head * 168 168 btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr); 169 - int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr); 170 169 int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans, 171 170 struct btrfs_delayed_ref_head *head); 172 171 int btrfs_find_ref_cluster(struct btrfs_trans_handle *trans,
-27
fs/btrfs/disk-io.c
··· 650 650 return 256 * limit; 651 651 } 652 652 653 - int btrfs_congested_async(struct btrfs_fs_info *info, int iodone) 654 - { 655 - return atomic_read(&info->nr_async_bios) > 656 - btrfs_async_submit_limit(info); 657 - } 658 - 659 653 static void run_one_async_start(struct btrfs_work *work) 660 654 { 661 655 struct async_submit_bio *async; ··· 1277 1283 return root; 1278 1284 } 1279 1285 1280 - struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, 1281 - u64 root_objectid) 1282 - { 1283 - struct btrfs_root *root; 1284 - 1285 - if (root_objectid == BTRFS_ROOT_TREE_OBJECTID) 1286 - return fs_info->tree_root; 1287 - if (root_objectid == BTRFS_EXTENT_TREE_OBJECTID) 1288 - return fs_info->extent_root; 1289 - 1290 - root = radix_tree_lookup(&fs_info->fs_roots_radix, 1291 - (unsigned long)root_objectid); 1292 - return root; 1293 - } 1294 - 1295 1286 struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, 1296 1287 struct btrfs_key *location) 1297 1288 { ··· 1348 1369 return ERR_PTR(ret); 1349 1370 } 1350 1371 1351 - struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info, 1352 - struct btrfs_key *location, 1353 - const char *name, int namelen) 1354 - { 1355 - return btrfs_read_fs_root_no_name(fs_info, location); 1356 1372 #if 0 1357 1373 struct btrfs_root *root; 1358 1374 int ret; ··· 1376 1402 root->in_sysfs = 1; 1377 1403 return root; 1378 1404 #endif 1379 - } 1380 1405 1381 1406 static int btrfs_congested_fn(void *congested_data, int bdi_bits) 1382 1407 {
-7
fs/btrfs/disk-io.h
··· 55 55 int btrfs_error_commit_super(struct btrfs_root *root); 56 56 struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, 57 57 u64 bytenr, u32 blocksize); 58 - struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, 59 - u64 root_objectid); 60 - struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info, 61 - struct btrfs_key *location, 62 - const char *name, int namelen); 63 58 struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, 64 59 struct btrfs_key *location); 65 60 struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, ··· 75 80 unsigned long bio_flags, u64 bio_offset, 76 81 extent_submit_bio_hook_t *submit_bio_start, 77 82 extent_submit_bio_hook_t *submit_bio_done); 78 - 79 - int btrfs_congested_async(struct btrfs_fs_info *info, int iodone); 80 83 unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info); 81 84 int btrfs_write_tree_block(struct extent_buffer *buf); 82 85 int btrfs_wait_tree_block_writeback(struct extent_buffer *buf);
-227
fs/btrfs/extent_io.c
··· 941 941 NULL, mask); 942 942 } 943 943 944 - static int clear_extent_new(struct extent_io_tree *tree, u64 start, u64 end, 945 - gfp_t mask) 946 - { 947 - return clear_extent_bit(tree, start, end, EXTENT_NEW, 0, 0, 948 - NULL, mask); 949 - } 950 - 951 944 int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, 952 945 struct extent_state **cached_state, gfp_t mask) 953 946 { ··· 954 961 { 955 962 return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, 956 963 cached_state, mask); 957 - } 958 - 959 - int wait_on_extent_writeback(struct extent_io_tree *tree, u64 start, u64 end) 960 - { 961 - return wait_extent_bit(tree, start, end, EXTENT_WRITEBACK); 962 964 } 963 965 964 966 /* ··· 1013 1025 { 1014 1026 return clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL, 1015 1027 mask); 1016 - } 1017 - 1018 - /* 1019 - * helper function to set pages and extents in the tree dirty 1020 - */ 1021 - int set_range_dirty(struct extent_io_tree *tree, u64 start, u64 end) 1022 - { 1023 - unsigned long index = start >> PAGE_CACHE_SHIFT; 1024 - unsigned long end_index = end >> PAGE_CACHE_SHIFT; 1025 - struct page *page; 1026 - 1027 - while (index <= end_index) { 1028 - page = find_get_page(tree->mapping, index); 1029 - BUG_ON(!page); 1030 - __set_page_dirty_nobuffers(page); 1031 - page_cache_release(page); 1032 - index++; 1033 - } 1034 - return 0; 1035 1028 } 1036 1029 1037 1030 /* ··· 1784 1815 check_page_locked(tree, page); 1785 1816 } 1786 1817 } while (bvec <= bvec_end); 1787 - 1788 - bio_put(bio); 1789 - } 1790 - 1791 - /* 1792 - * IO done from prepare_write is pretty simple, we just unlock 1793 - * the structs in the extent tree when done, and set the uptodate bits 1794 - * as appropriate. 1795 - */ 1796 - static void end_bio_extent_preparewrite(struct bio *bio, int err) 1797 - { 1798 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1799 - struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 1800 - struct extent_io_tree *tree; 1801 - u64 start; 1802 - u64 end; 1803 - 1804 - do { 1805 - struct page *page = bvec->bv_page; 1806 - struct extent_state *cached = NULL; 1807 - tree = &BTRFS_I(page->mapping->host)->io_tree; 1808 - 1809 - start = ((u64)page->index << PAGE_CACHE_SHIFT) + 1810 - bvec->bv_offset; 1811 - end = start + bvec->bv_len - 1; 1812 - 1813 - if (--bvec >= bio->bi_io_vec) 1814 - prefetchw(&bvec->bv_page->flags); 1815 - 1816 - if (uptodate) { 1817 - set_extent_uptodate(tree, start, end, &cached, 1818 - GFP_ATOMIC); 1819 - } else { 1820 - ClearPageUptodate(page); 1821 - SetPageError(page); 1822 - } 1823 - 1824 - unlock_extent_cached(tree, start, end, &cached, GFP_ATOMIC); 1825 - 1826 - } while (bvec >= bio->bi_io_vec); 1827 1818 1828 1819 bio_put(bio); 1829 1820 } ··· 2649 2720 } 2650 2721 2651 2722 /* 2652 - * simple commit_write call, set_range_dirty is used to mark both 2653 - * the pages and the extent records as dirty 2654 - */ 2655 - int extent_commit_write(struct extent_io_tree *tree, 2656 - struct inode *inode, struct page *page, 2657 - unsigned from, unsigned to) 2658 - { 2659 - loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; 2660 - 2661 - set_page_extent_mapped(page); 2662 - set_page_dirty(page); 2663 - 2664 - if (pos > inode->i_size) { 2665 - i_size_write(inode, pos); 2666 - mark_inode_dirty(inode); 2667 - } 2668 - return 0; 2669 - } 2670 - 2671 - int extent_prepare_write(struct extent_io_tree *tree, 2672 - struct inode *inode, struct page *page, 2673 - unsigned from, unsigned to, get_extent_t *get_extent) 2674 - { 2675 - u64 page_start = (u64)page->index << PAGE_CACHE_SHIFT; 2676 - u64 page_end = page_start + PAGE_CACHE_SIZE - 1; 2677 - u64 block_start; 2678 - u64 orig_block_start; 2679 - u64 block_end; 2680 - u64 cur_end; 2681 - struct extent_map *em; 2682 - unsigned blocksize = 1 << inode->i_blkbits; 2683 - size_t pg_offset = 0; 2684 - size_t block_off_start; 2685 - size_t block_off_end; 2686 - int err = 0; 2687 - int iocount = 0; 2688 - int ret = 0; 2689 - int isnew; 2690 - 2691 - set_page_extent_mapped(page); 2692 - 2693 - block_start = (page_start + from) & ~((u64)blocksize - 1); 2694 - block_end = (page_start + to - 1) | (blocksize - 1); 2695 - orig_block_start = block_start; 2696 - 2697 - lock_extent(tree, page_start, page_end, GFP_NOFS); 2698 - while (block_start <= block_end) { 2699 - em = get_extent(inode, page, pg_offset, block_start, 2700 - block_end - block_start + 1, 1); 2701 - if (IS_ERR_OR_NULL(em)) 2702 - goto err; 2703 - 2704 - cur_end = min(block_end, extent_map_end(em) - 1); 2705 - block_off_start = block_start & (PAGE_CACHE_SIZE - 1); 2706 - block_off_end = block_off_start + blocksize; 2707 - isnew = clear_extent_new(tree, block_start, cur_end, GFP_NOFS); 2708 - 2709 - if (!PageUptodate(page) && isnew && 2710 - (block_off_end > to || block_off_start < from)) { 2711 - void *kaddr; 2712 - 2713 - kaddr = kmap_atomic(page, KM_USER0); 2714 - if (block_off_end > to) 2715 - memset(kaddr + to, 0, block_off_end - to); 2716 - if (block_off_start < from) 2717 - memset(kaddr + block_off_start, 0, 2718 - from - block_off_start); 2719 - flush_dcache_page(page); 2720 - kunmap_atomic(kaddr, KM_USER0); 2721 - } 2722 - if ((em->block_start != EXTENT_MAP_HOLE && 2723 - em->block_start != EXTENT_MAP_INLINE) && 2724 - !isnew && !PageUptodate(page) && 2725 - (block_off_end > to || block_off_start < from) && 2726 - !test_range_bit(tree, block_start, cur_end, 2727 - EXTENT_UPTODATE, 1, NULL)) { 2728 - u64 sector; 2729 - u64 extent_offset = block_start - em->start; 2730 - size_t iosize; 2731 - sector = (em->block_start + extent_offset) >> 9; 2732 - iosize = (cur_end - block_start + blocksize) & 2733 - ~((u64)blocksize - 1); 2734 - /* 2735 - * we've already got the extent locked, but we 2736 - * need to split the state such that our end_bio 2737 - * handler can clear the lock. 2738 - */ 2739 - set_extent_bit(tree, block_start, 2740 - block_start + iosize - 1, 2741 - EXTENT_LOCKED, 0, NULL, NULL, GFP_NOFS); 2742 - ret = submit_extent_page(READ, tree, page, 2743 - sector, iosize, pg_offset, em->bdev, 2744 - NULL, 1, 2745 - end_bio_extent_preparewrite, 0, 2746 - 0, 0); 2747 - if (ret && !err) 2748 - err = ret; 2749 - iocount++; 2750 - block_start = block_start + iosize; 2751 - } else { 2752 - struct extent_state *cached = NULL; 2753 - 2754 - set_extent_uptodate(tree, block_start, cur_end, &cached, 2755 - GFP_NOFS); 2756 - unlock_extent_cached(tree, block_start, cur_end, 2757 - &cached, GFP_NOFS); 2758 - block_start = cur_end + 1; 2759 - } 2760 - pg_offset = block_start & (PAGE_CACHE_SIZE - 1); 2761 - free_extent_map(em); 2762 - } 2763 - if (iocount) { 2764 - wait_extent_bit(tree, orig_block_start, 2765 - block_end, EXTENT_LOCKED); 2766 - } 2767 - check_page_uptodate(tree, page); 2768 - err: 2769 - /* FIXME, zero out newly allocated blocks on error */ 2770 - return err; 2771 - } 2772 - 2773 - /* 2774 2723 * a helper for releasepage, this tests for areas of the page that 2775 2724 * are locked or under IO and drops the related state bits if it is safe 2776 2725 * to drop the page. ··· 2732 2925 } 2733 2926 } 2734 2927 return try_release_extent_state(map, tree, page, mask); 2735 - } 2736 - 2737 - sector_t extent_bmap(struct address_space *mapping, sector_t iblock, 2738 - get_extent_t *get_extent) 2739 - { 2740 - struct inode *inode = mapping->host; 2741 - struct extent_state *cached_state = NULL; 2742 - u64 start = iblock << inode->i_blkbits; 2743 - sector_t sector = 0; 2744 - size_t blksize = (1 << inode->i_blkbits); 2745 - struct extent_map *em; 2746 - 2747 - lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + blksize - 1, 2748 - 0, &cached_state, GFP_NOFS); 2749 - em = get_extent(inode, NULL, 0, start, blksize, 0); 2750 - unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, 2751 - start + blksize - 1, &cached_state, GFP_NOFS); 2752 - if (IS_ERR_OR_NULL(em)) 2753 - return 0; 2754 - 2755 - if (em->block_start > EXTENT_MAP_LAST_BYTE) 2756 - goto out; 2757 - 2758 - sector = (em->block_start + start - em->start) >> inode->i_blkbits; 2759 - out: 2760 - free_extent_map(em); 2761 - return sector; 2762 2928 } 2763 2929 2764 2930 /* ··· 3215 3435 unlock_page(page); 3216 3436 } 3217 3437 return 0; 3218 - } 3219 - 3220 - int wait_on_extent_buffer_writeback(struct extent_io_tree *tree, 3221 - struct extent_buffer *eb) 3222 - { 3223 - return wait_on_extent_writeback(tree, eb->start, 3224 - eb->start + eb->len - 1); 3225 3438 } 3226 3439 3227 3440 int set_extent_buffer_dirty(struct extent_io_tree *tree,
-21
fs/btrfs/extent_io.h
··· 153 153 154 154 struct extent_map_tree; 155 155 156 - static inline struct extent_state *extent_state_next(struct extent_state *state) 157 - { 158 - struct rb_node *node; 159 - node = rb_next(&state->rb_node); 160 - if (!node) 161 - return NULL; 162 - return rb_entry(node, struct extent_state, rb_node); 163 - } 164 - 165 156 typedef struct extent_map *(get_extent_t)(struct inode *inode, 166 157 struct page *page, 167 158 size_t pg_offset, ··· 228 237 struct address_space *mapping, 229 238 struct list_head *pages, unsigned nr_pages, 230 239 get_extent_t get_extent); 231 - int extent_prepare_write(struct extent_io_tree *tree, 232 - struct inode *inode, struct page *page, 233 - unsigned from, unsigned to, get_extent_t *get_extent); 234 - int extent_commit_write(struct extent_io_tree *tree, 235 - struct inode *inode, struct page *page, 236 - unsigned from, unsigned to); 237 - sector_t extent_bmap(struct address_space *mapping, sector_t iblock, 238 - get_extent_t *get_extent); 239 240 int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 240 241 __u64 start, __u64 len, get_extent_t *get_extent); 241 - int set_range_dirty(struct extent_io_tree *tree, u64 start, u64 end); 242 242 int set_state_private(struct extent_io_tree *tree, u64 start, u64 private); 243 243 int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private); 244 244 void set_page_extent_mapped(struct page *page); ··· 266 284 unsigned long src_offset, unsigned long len); 267 285 void memset_extent_buffer(struct extent_buffer *eb, char c, 268 286 unsigned long start, unsigned long len); 269 - int wait_on_extent_buffer_writeback(struct extent_io_tree *tree, 270 - struct extent_buffer *eb); 271 - int wait_on_extent_writeback(struct extent_io_tree *tree, u64 start, u64 end); 272 287 int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); 273 288 int clear_extent_buffer_dirty(struct extent_io_tree *tree, 274 289 struct extent_buffer *eb);
-15
fs/btrfs/free-space-cache.c
··· 1685 1685 "\n", count); 1686 1686 } 1687 1687 1688 - u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group) 1689 - { 1690 - struct btrfs_free_space *info; 1691 - struct rb_node *n; 1692 - u64 ret = 0; 1693 - 1694 - for (n = rb_first(&block_group->free_space_offset); n; 1695 - n = rb_next(n)) { 1696 - info = rb_entry(n, struct btrfs_free_space, offset_index); 1697 - ret += info->bytes; 1698 - } 1699 - 1700 - return ret; 1701 - } 1702 - 1703 1688 /* 1704 1689 * for a given cluster, put all of its extents back into the free 1705 1690 * space cache. If the block group passed doesn't match the block group
-1
fs/btrfs/free-space-cache.h
··· 55 55 u64 offset, u64 bytes, u64 empty_size); 56 56 void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, 57 57 u64 bytes); 58 - u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group); 59 58 int btrfs_find_space_cluster(struct btrfs_trans_handle *trans, 60 59 struct btrfs_root *root, 61 60 struct btrfs_block_group_cache *block_group,
-52
fs/btrfs/inode.c
··· 7185 7185 return 0; 7186 7186 } 7187 7187 7188 - int btrfs_start_one_delalloc_inode(struct btrfs_root *root, int delay_iput, 7189 - int sync) 7190 - { 7191 - struct btrfs_inode *binode; 7192 - struct inode *inode = NULL; 7193 - 7194 - spin_lock(&root->fs_info->delalloc_lock); 7195 - while (!list_empty(&root->fs_info->delalloc_inodes)) { 7196 - binode = list_entry(root->fs_info->delalloc_inodes.next, 7197 - struct btrfs_inode, delalloc_inodes); 7198 - inode = igrab(&binode->vfs_inode); 7199 - if (inode) { 7200 - list_move_tail(&binode->delalloc_inodes, 7201 - &root->fs_info->delalloc_inodes); 7202 - break; 7203 - } 7204 - 7205 - list_del_init(&binode->delalloc_inodes); 7206 - cond_resched_lock(&root->fs_info->delalloc_lock); 7207 - } 7208 - spin_unlock(&root->fs_info->delalloc_lock); 7209 - 7210 - if (inode) { 7211 - if (sync) { 7212 - filemap_write_and_wait(inode->i_mapping); 7213 - /* 7214 - * We have to do this because compression doesn't 7215 - * actually set PG_writeback until it submits the pages 7216 - * for IO, which happens in an async thread, so we could 7217 - * race and not actually wait for any writeback pages 7218 - * because they've not been submitted yet. Technically 7219 - * this could still be the case for the ordered stuff 7220 - * since the async thread may not have started to do its 7221 - * work yet. If this becomes the case then we need to 7222 - * figure out a way to make sure that in writepage we 7223 - * wait for any async pages to be submitted before 7224 - * returning so that fdatawait does what its supposed to 7225 - * do. 7226 - */ 7227 - btrfs_wait_ordered_range(inode, 0, (u64)-1); 7228 - } else { 7229 - filemap_flush(inode->i_mapping); 7230 - } 7231 - if (delay_iput) 7232 - btrfs_add_delayed_iput(inode); 7233 - else 7234 - iput(inode); 7235 - return 1; 7236 - } 7237 - return 0; 7238 - } 7239 - 7240 7188 static int btrfs_symlink(struct inode *dir, struct dentry *dentry, 7241 7189 const char *symname) 7242 7190 {
-25
fs/btrfs/locking.c
··· 185 185 return 0; 186 186 } 187 187 188 - /* 189 - * Very quick trylock, this does not spin or schedule. It returns 190 - * 1 with the spinlock held if it was able to take the lock, or it 191 - * returns zero if it was unable to take the lock. 192 - * 193 - * After this call, scheduling is not safe without first calling 194 - * btrfs_set_lock_blocking() 195 - */ 196 - int btrfs_try_tree_lock(struct extent_buffer *eb) 197 - { 198 - if (spin_trylock(&eb->lock)) { 199 - if (test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags)) { 200 - /* 201 - * we've got the spinlock, but the real owner is 202 - * blocking. Drop the spinlock and return failure 203 - */ 204 - spin_unlock(&eb->lock); 205 - return 0; 206 - } 207 - return 1; 208 - } 209 - /* someone else has the spinlock giveup */ 210 - return 0; 211 - } 212 - 213 188 int btrfs_tree_unlock(struct extent_buffer *eb) 214 189 { 215 190 /*
-2
fs/btrfs/locking.h
··· 21 21 22 22 int btrfs_tree_lock(struct extent_buffer *eb); 23 23 int btrfs_tree_unlock(struct extent_buffer *eb); 24 - 25 - int btrfs_try_tree_lock(struct extent_buffer *eb); 26 24 int btrfs_try_spin_lock(struct extent_buffer *eb); 27 25 28 26 void btrfs_set_lock_blocking(struct extent_buffer *eb);
-164
fs/btrfs/ref-cache.c
··· 23 23 #include "ref-cache.h" 24 24 #include "transaction.h" 25 25 26 - /* 27 - * leaf refs are used to cache the information about which extents 28 - * a given leaf has references on. This allows us to process that leaf 29 - * in btrfs_drop_snapshot without needing to read it back from disk. 30 - */ 31 - 32 - /* 33 - * kmalloc a leaf reference struct and update the counters for the 34 - * total ref cache size 35 - */ 36 - struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(struct btrfs_root *root, 37 - int nr_extents) 38 - { 39 - struct btrfs_leaf_ref *ref; 40 - size_t size = btrfs_leaf_ref_size(nr_extents); 41 - 42 - ref = kmalloc(size, GFP_NOFS); 43 - if (ref) { 44 - spin_lock(&root->fs_info->ref_cache_lock); 45 - root->fs_info->total_ref_cache_size += size; 46 - spin_unlock(&root->fs_info->ref_cache_lock); 47 - 48 - memset(ref, 0, sizeof(*ref)); 49 - atomic_set(&ref->usage, 1); 50 - INIT_LIST_HEAD(&ref->list); 51 - } 52 - return ref; 53 - } 54 - 55 - /* 56 - * free a leaf reference struct and update the counters for the 57 - * total ref cache size 58 - */ 59 - void btrfs_free_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref) 60 - { 61 - if (!ref) 62 - return; 63 - WARN_ON(atomic_read(&ref->usage) == 0); 64 - if (atomic_dec_and_test(&ref->usage)) { 65 - size_t size = btrfs_leaf_ref_size(ref->nritems); 66 - 67 - BUG_ON(ref->in_tree); 68 - kfree(ref); 69 - 70 - spin_lock(&root->fs_info->ref_cache_lock); 71 - root->fs_info->total_ref_cache_size -= size; 72 - spin_unlock(&root->fs_info->ref_cache_lock); 73 - } 74 - } 75 - 76 26 static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr, 77 27 struct rb_node *node) 78 28 { ··· 65 115 return n; 66 116 } 67 117 return NULL; 68 - } 69 - 70 - int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen, 71 - int shared) 72 - { 73 - struct btrfs_leaf_ref *ref = NULL; 74 - struct btrfs_leaf_ref_tree *tree = root->ref_tree; 75 - 76 - if (shared) 77 - tree = &root->fs_info->shared_ref_tree; 78 - if (!tree) 79 - return 0; 80 - 81 - spin_lock(&tree->lock); 82 - while (!list_empty(&tree->list)) { 83 - ref = list_entry(tree->list.next, struct btrfs_leaf_ref, list); 84 - BUG_ON(ref->tree != tree); 85 - if (ref->root_gen > max_root_gen) 86 - break; 87 - if (!xchg(&ref->in_tree, 0)) { 88 - cond_resched_lock(&tree->lock); 89 - continue; 90 - } 91 - 92 - rb_erase(&ref->rb_node, &tree->root); 93 - list_del_init(&ref->list); 94 - 95 - spin_unlock(&tree->lock); 96 - btrfs_free_leaf_ref(root, ref); 97 - cond_resched(); 98 - spin_lock(&tree->lock); 99 - } 100 - spin_unlock(&tree->lock); 101 - return 0; 102 - } 103 - 104 - /* 105 - * find the leaf ref for a given extent. This returns the ref struct with 106 - * a usage reference incremented 107 - */ 108 - struct btrfs_leaf_ref *btrfs_lookup_leaf_ref(struct btrfs_root *root, 109 - u64 bytenr) 110 - { 111 - struct rb_node *rb; 112 - struct btrfs_leaf_ref *ref = NULL; 113 - struct btrfs_leaf_ref_tree *tree = root->ref_tree; 114 - again: 115 - if (tree) { 116 - spin_lock(&tree->lock); 117 - rb = tree_search(&tree->root, bytenr); 118 - if (rb) 119 - ref = rb_entry(rb, struct btrfs_leaf_ref, rb_node); 120 - if (ref) 121 - atomic_inc(&ref->usage); 122 - spin_unlock(&tree->lock); 123 - if (ref) 124 - return ref; 125 - } 126 - if (tree != &root->fs_info->shared_ref_tree) { 127 - tree = &root->fs_info->shared_ref_tree; 128 - goto again; 129 - } 130 - return NULL; 131 - } 132 - 133 - /* 134 - * add a fully filled in leaf ref struct 135 - * remove all the refs older than a given root generation 136 - */ 137 - int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref, 138 - int shared) 139 - { 140 - int ret = 0; 141 - struct rb_node *rb; 142 - struct btrfs_leaf_ref_tree *tree = root->ref_tree; 143 - 144 - if (shared) 145 - tree = &root->fs_info->shared_ref_tree; 146 - 147 - spin_lock(&tree->lock); 148 - rb = tree_insert(&tree->root, ref->bytenr, &ref->rb_node); 149 - if (rb) { 150 - ret = -EEXIST; 151 - } else { 152 - atomic_inc(&ref->usage); 153 - ref->tree = tree; 154 - ref->in_tree = 1; 155 - list_add_tail(&ref->list, &tree->list); 156 - } 157 - spin_unlock(&tree->lock); 158 - return ret; 159 - } 160 - 161 - /* 162 - * remove a single leaf ref from the tree. This drops the ref held by the tree 163 - * only 164 - */ 165 - int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref) 166 - { 167 - struct btrfs_leaf_ref_tree *tree; 168 - 169 - if (!xchg(&ref->in_tree, 0)) 170 - return 0; 171 - 172 - tree = ref->tree; 173 - spin_lock(&tree->lock); 174 - 175 - rb_erase(&ref->rb_node, &tree->root); 176 - list_del_init(&ref->list); 177 - 178 - spin_unlock(&tree->lock); 179 - 180 - btrfs_free_leaf_ref(root, ref); 181 - return 0; 182 118 }
-24
fs/btrfs/ref-cache.h
··· 49 49 return sizeof(struct btrfs_leaf_ref) + 50 50 sizeof(struct btrfs_extent_info) * nr_extents; 51 51 } 52 - 53 - static inline void btrfs_leaf_ref_tree_init(struct btrfs_leaf_ref_tree *tree) 54 - { 55 - tree->root = RB_ROOT; 56 - INIT_LIST_HEAD(&tree->list); 57 - spin_lock_init(&tree->lock); 58 - } 59 - 60 - static inline int btrfs_leaf_ref_tree_empty(struct btrfs_leaf_ref_tree *tree) 61 - { 62 - return RB_EMPTY_ROOT(&tree->root); 63 - } 64 - 65 - void btrfs_leaf_ref_tree_init(struct btrfs_leaf_ref_tree *tree); 66 - struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(struct btrfs_root *root, 67 - int nr_extents); 68 - void btrfs_free_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); 69 - struct btrfs_leaf_ref *btrfs_lookup_leaf_ref(struct btrfs_root *root, 70 - u64 bytenr); 71 - int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref, 72 - int shared); 73 - int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen, 74 - int shared); 75 - int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); 76 52 #endif
+1 -1
fs/btrfs/relocation.c
··· 507 507 return 1; 508 508 } 509 509 510 + 510 511 static int should_ignore_root(struct btrfs_root *root) 511 512 { 512 513 struct btrfs_root *reloc_root; ··· 530 529 */ 531 530 return 1; 532 531 } 533 - 534 532 /* 535 533 * find reloc tree by address of tree root 536 534 */
-47
fs/btrfs/root-tree.c
··· 22 22 #include "print-tree.h" 23 23 24 24 /* 25 - * search forward for a root, starting with objectid 'search_start' 26 - * if a root key is found, the objectid we find is filled into 'found_objectid' 27 - * and 0 is returned. < 0 is returned on error, 1 if there is nothing 28 - * left in the tree. 29 - */ 30 - int btrfs_search_root(struct btrfs_root *root, u64 search_start, 31 - u64 *found_objectid) 32 - { 33 - struct btrfs_path *path; 34 - struct btrfs_key search_key; 35 - int ret; 36 - 37 - root = root->fs_info->tree_root; 38 - search_key.objectid = search_start; 39 - search_key.type = (u8)-1; 40 - search_key.offset = (u64)-1; 41 - 42 - path = btrfs_alloc_path(); 43 - BUG_ON(!path); 44 - again: 45 - ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); 46 - if (ret < 0) 47 - goto out; 48 - if (ret == 0) { 49 - ret = 1; 50 - goto out; 51 - } 52 - if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { 53 - ret = btrfs_next_leaf(root, path); 54 - if (ret) 55 - goto out; 56 - } 57 - btrfs_item_key_to_cpu(path->nodes[0], &search_key, path->slots[0]); 58 - if (search_key.type != BTRFS_ROOT_ITEM_KEY) { 59 - search_key.offset++; 60 - btrfs_release_path(path); 61 - goto again; 62 - } 63 - ret = 0; 64 - *found_objectid = search_key.objectid; 65 - 66 - out: 67 - btrfs_free_path(path); 68 - return ret; 69 - } 70 - 71 - /* 72 25 * lookup the root with the highest offset for a given objectid. The key we do 73 26 * find is copied into 'key'. If we find something return 0, otherwise 1, < 0 74 27 * on error.
-65
fs/btrfs/sysfs.c
··· 189 189 /* /sys/fs/btrfs/ entry */ 190 190 static struct kset *btrfs_kset; 191 191 192 - int btrfs_sysfs_add_super(struct btrfs_fs_info *fs) 193 - { 194 - int error; 195 - char *name; 196 - char c; 197 - int len = strlen(fs->sb->s_id) + 1; 198 - int i; 199 - 200 - name = kmalloc(len, GFP_NOFS); 201 - if (!name) { 202 - error = -ENOMEM; 203 - goto fail; 204 - } 205 - 206 - for (i = 0; i < len; i++) { 207 - c = fs->sb->s_id[i]; 208 - if (c == '/' || c == '\\') 209 - c = '!'; 210 - name[i] = c; 211 - } 212 - name[len] = '\0'; 213 - 214 - fs->super_kobj.kset = btrfs_kset; 215 - error = kobject_init_and_add(&fs->super_kobj, &btrfs_super_ktype, 216 - NULL, "%s", name); 217 - kfree(name); 218 - if (error) 219 - goto fail; 220 - 221 - return 0; 222 - 223 - fail: 224 - printk(KERN_ERR "btrfs: sysfs creation for super failed\n"); 225 - return error; 226 - } 227 - 228 - int btrfs_sysfs_add_root(struct btrfs_root *root) 229 - { 230 - int error; 231 - 232 - error = kobject_init_and_add(&root->root_kobj, &btrfs_root_ktype, 233 - &root->fs_info->super_kobj, 234 - "%s", root->name); 235 - if (error) 236 - goto fail; 237 - 238 - return 0; 239 - 240 - fail: 241 - printk(KERN_ERR "btrfs: sysfs creation for root failed\n"); 242 - return error; 243 - } 244 - 245 - void btrfs_sysfs_del_root(struct btrfs_root *root) 246 - { 247 - kobject_put(&root->root_kobj); 248 - wait_for_completion(&root->kobj_unregister); 249 - } 250 - 251 - void btrfs_sysfs_del_super(struct btrfs_fs_info *fs) 252 - { 253 - kobject_put(&fs->super_kobj); 254 - wait_for_completion(&fs->kobj_unregister); 255 - } 256 - 257 192 int btrfs_init_sysfs(void) 258 193 { 259 194 btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
-19
fs/btrfs/volumes.c
··· 44 44 static DEFINE_MUTEX(uuid_mutex); 45 45 static LIST_HEAD(fs_uuids); 46 46 47 - void btrfs_lock_volumes(void) 48 - { 49 - mutex_lock(&uuid_mutex); 50 - } 51 - 52 - void btrfs_unlock_volumes(void) 53 - { 54 - mutex_unlock(&uuid_mutex); 55 - } 56 - 57 47 static void lock_chunks(struct btrfs_root *root) 58 48 { 59 49 mutex_lock(&root->fs_info->chunk_mutex); ··· 3676 3686 device->fs_devices->total_rw_bytes += device->total_bytes; 3677 3687 ret = 0; 3678 3688 return ret; 3679 - } 3680 - 3681 - int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf) 3682 - { 3683 - struct btrfs_dev_item *dev_item; 3684 - 3685 - dev_item = (struct btrfs_dev_item *)offsetof(struct btrfs_super_block, 3686 - dev_item); 3687 - return read_one_dev(root, buf, dev_item); 3688 3689 } 3689 3690 3690 3691 int btrfs_read_sys_array(struct btrfs_root *root)
-3
fs/btrfs/volumes.h
··· 196 196 void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree); 197 197 int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, 198 198 int mirror_num, int async_submit); 199 - int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf); 200 199 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, 201 200 fmode_t flags, void *holder); 202 201 int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, ··· 215 216 int btrfs_shrink_device(struct btrfs_device *device, u64 new_size); 216 217 int btrfs_init_new_device(struct btrfs_root *root, char *path); 217 218 int btrfs_balance(struct btrfs_root *dev_root); 218 - void btrfs_unlock_volumes(void); 219 - void btrfs_lock_volumes(void); 220 219 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset); 221 220 int find_free_dev_extent(struct btrfs_trans_handle *trans, 222 221 struct btrfs_device *device, u64 num_bytes,