disk-io.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #include <linux/module.h>
  2. #include <linux/fs.h>
  3. #include <linux/blkdev.h>
  4. #include <linux/crypto.h>
  5. #include <linux/scatterlist.h>
  6. #include <linux/swap.h>
  7. #include <linux/radix-tree.h>
  8. #include "ctree.h"
  9. #include "disk-io.h"
  10. #include "transaction.h"
  11. #include "btrfs_inode.h"
  12. struct dev_lookup {
  13. u64 block_start;
  14. u64 num_blocks;
  15. struct block_device *bdev;
  16. };
  17. u64 bh_blocknr(struct buffer_head *bh)
  18. {
  19. int blkbits = bh->b_page->mapping->host->i_blkbits;
  20. u64 blocknr = bh->b_page->index << (PAGE_CACHE_SHIFT - blkbits);
  21. unsigned long offset;
  22. if (PageHighMem(bh->b_page))
  23. offset = (unsigned long)bh->b_data;
  24. else
  25. offset = bh->b_data - (char *)page_address(bh->b_page);
  26. blocknr += offset >> (PAGE_CACHE_SHIFT - blkbits);
  27. return blocknr;
  28. }
  29. static int check_tree_block(struct btrfs_root *root, struct buffer_head *buf)
  30. {
  31. struct btrfs_node *node = btrfs_buffer_node(buf);
  32. if (bh_blocknr(buf) != btrfs_header_blocknr(&node->header)) {
  33. BUG();
  34. }
  35. return 0;
  36. }
  37. struct buffer_head *btrfs_find_tree_block(struct btrfs_root *root, u64 blocknr)
  38. {
  39. struct address_space *mapping = root->fs_info->btree_inode->i_mapping;
  40. int blockbits = root->fs_info->sb->s_blocksize_bits;
  41. unsigned long index = blocknr >> (PAGE_CACHE_SHIFT - blockbits);
  42. struct page *page;
  43. struct buffer_head *bh;
  44. struct buffer_head *head;
  45. struct buffer_head *ret = NULL;
  46. page = find_lock_page(mapping, index);
  47. if (!page)
  48. return NULL;
  49. if (!page_has_buffers(page))
  50. goto out_unlock;
  51. head = page_buffers(page);
  52. bh = head;
  53. do {
  54. if (buffer_mapped(bh) && bh_blocknr(bh) == blocknr) {
  55. ret = bh;
  56. get_bh(bh);
  57. goto out_unlock;
  58. }
  59. bh = bh->b_this_page;
  60. } while (bh != head);
  61. out_unlock:
  62. unlock_page(page);
  63. if (ret) {
  64. touch_buffer(ret);
  65. }
  66. page_cache_release(page);
  67. return ret;
  68. }
  69. static int map_bh_to_logical(struct btrfs_root *root, struct buffer_head *bh,
  70. u64 logical)
  71. {
  72. struct dev_lookup *lookup[2];
  73. char b[BDEVNAME_SIZE];
  74. int ret;
  75. root = root->fs_info->dev_root;
  76. ret = radix_tree_gang_lookup(&root->fs_info->dev_radix,
  77. (void **)lookup,
  78. (unsigned long)logical,
  79. ARRAY_SIZE(lookup));
  80. if (ret == 0 || lookup[0]->block_start > logical ||
  81. lookup[0]->block_start + lookup[0]->num_blocks <= logical) {
  82. ret = -ENOENT;
  83. goto out;
  84. }
  85. bh->b_bdev = lookup[0]->bdev;
  86. bh->b_blocknr = logical - lookup[0]->block_start;
  87. printk("logical mapping %Lu to %lu bdev %s\n", logical, bh->b_blocknr, bdevname(bh->b_bdev, b));
  88. set_buffer_mapped(bh);
  89. ret = 0;
  90. out:
  91. return ret;
  92. }
  93. struct buffer_head *btrfs_find_create_tree_block(struct btrfs_root *root,
  94. u64 blocknr)
  95. {
  96. struct address_space *mapping = root->fs_info->btree_inode->i_mapping;
  97. int blockbits = root->fs_info->sb->s_blocksize_bits;
  98. unsigned long index = blocknr >> (PAGE_CACHE_SHIFT - blockbits);
  99. struct page *page;
  100. struct buffer_head *bh;
  101. struct buffer_head *head;
  102. struct buffer_head *ret = NULL;
  103. int err;
  104. u64 first_block = index << (PAGE_CACHE_SHIFT - blockbits);
  105. page = grab_cache_page(mapping, index);
  106. if (!page)
  107. return NULL;
  108. if (!page_has_buffers(page))
  109. create_empty_buffers(page, root->fs_info->sb->s_blocksize, 0);
  110. head = page_buffers(page);
  111. bh = head;
  112. do {
  113. if (!buffer_mapped(bh)) {
  114. err = map_bh_to_logical(root, bh, first_block);
  115. BUG_ON(err);
  116. }
  117. if (bh_blocknr(bh) == blocknr) {
  118. ret = bh;
  119. get_bh(bh);
  120. goto out_unlock;
  121. }
  122. bh = bh->b_this_page;
  123. first_block++;
  124. } while (bh != head);
  125. out_unlock:
  126. unlock_page(page);
  127. if (ret)
  128. touch_buffer(ret);
  129. page_cache_release(page);
  130. return ret;
  131. }
  132. static int btree_get_block(struct inode *inode, sector_t iblock,
  133. struct buffer_head *bh, int create)
  134. {
  135. int err;
  136. struct btrfs_root *root = BTRFS_I(bh->b_page->mapping->host)->root;
  137. err = map_bh_to_logical(root, bh, iblock);
  138. return err;
  139. }
  140. int btrfs_csum_data(struct btrfs_root * root, char *data, size_t len,
  141. char *result)
  142. {
  143. struct scatterlist sg;
  144. struct crypto_hash *tfm = root->fs_info->hash_tfm;
  145. struct hash_desc desc;
  146. int ret;
  147. desc.tfm = tfm;
  148. desc.flags = 0;
  149. sg_init_one(&sg, data, len);
  150. spin_lock(&root->fs_info->hash_lock);
  151. ret = crypto_hash_digest(&desc, &sg, 1, result);
  152. spin_unlock(&root->fs_info->hash_lock);
  153. if (ret) {
  154. printk("sha256 digest failed\n");
  155. }
  156. return ret;
  157. }
  158. static int csum_tree_block(struct btrfs_root *root, struct buffer_head *bh,
  159. int verify)
  160. {
  161. char result[BTRFS_CSUM_SIZE];
  162. int ret;
  163. struct btrfs_node *node;
  164. ret = btrfs_csum_data(root, bh->b_data + BTRFS_CSUM_SIZE,
  165. bh->b_size - BTRFS_CSUM_SIZE, result);
  166. if (ret)
  167. return ret;
  168. if (verify) {
  169. if (memcmp(bh->b_data, result, BTRFS_CSUM_SIZE)) {
  170. printk("checksum verify failed on %Lu\n",
  171. bh_blocknr(bh));
  172. return 1;
  173. }
  174. } else {
  175. node = btrfs_buffer_node(bh);
  176. memcpy(node->header.csum, result, BTRFS_CSUM_SIZE);
  177. }
  178. return 0;
  179. }
  180. static int btree_writepage(struct page *page, struct writeback_control *wbc)
  181. {
  182. struct buffer_head *bh;
  183. struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
  184. struct buffer_head *head;
  185. if (!page_has_buffers(page)) {
  186. create_empty_buffers(page, root->fs_info->sb->s_blocksize,
  187. (1 << BH_Dirty)|(1 << BH_Uptodate));
  188. }
  189. head = page_buffers(page);
  190. bh = head;
  191. do {
  192. if (buffer_dirty(bh))
  193. csum_tree_block(root, bh, 0);
  194. bh = bh->b_this_page;
  195. } while (bh != head);
  196. return block_write_full_page(page, btree_get_block, wbc);
  197. }
  198. static int btree_readpage(struct file * file, struct page * page)
  199. {
  200. return block_read_full_page(page, btree_get_block);
  201. }
  202. static struct address_space_operations btree_aops = {
  203. .readpage = btree_readpage,
  204. .writepage = btree_writepage,
  205. .sync_page = block_sync_page,
  206. };
  207. struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr)
  208. {
  209. struct buffer_head *bh = NULL;
  210. bh = btrfs_find_create_tree_block(root, blocknr);
  211. if (!bh)
  212. return bh;
  213. if (buffer_uptodate(bh))
  214. goto uptodate;
  215. lock_buffer(bh);
  216. if (!buffer_uptodate(bh)) {
  217. get_bh(bh);
  218. bh->b_end_io = end_buffer_read_sync;
  219. submit_bh(READ, bh);
  220. wait_on_buffer(bh);
  221. if (!buffer_uptodate(bh))
  222. goto fail;
  223. csum_tree_block(root, bh, 1);
  224. } else {
  225. unlock_buffer(bh);
  226. }
  227. uptodate:
  228. if (check_tree_block(root, bh))
  229. BUG();
  230. return bh;
  231. fail:
  232. brelse(bh);
  233. return NULL;
  234. }
  235. int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
  236. struct buffer_head *buf)
  237. {
  238. WARN_ON(atomic_read(&buf->b_count) == 0);
  239. mark_buffer_dirty(buf);
  240. return 0;
  241. }
  242. int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
  243. struct buffer_head *buf)
  244. {
  245. WARN_ON(atomic_read(&buf->b_count) == 0);
  246. clear_buffer_dirty(buf);
  247. return 0;
  248. }
  249. static int __setup_root(int blocksize,
  250. struct btrfs_root *root,
  251. struct btrfs_fs_info *fs_info,
  252. u64 objectid)
  253. {
  254. root->node = NULL;
  255. root->inode = NULL;
  256. root->commit_root = NULL;
  257. root->blocksize = blocksize;
  258. root->ref_cows = 0;
  259. root->fs_info = fs_info;
  260. root->objectid = objectid;
  261. root->last_trans = 0;
  262. root->highest_inode = 0;
  263. root->last_inode_alloc = 0;
  264. memset(&root->root_key, 0, sizeof(root->root_key));
  265. memset(&root->root_item, 0, sizeof(root->root_item));
  266. return 0;
  267. }
  268. static int find_and_setup_root(int blocksize,
  269. struct btrfs_root *tree_root,
  270. struct btrfs_fs_info *fs_info,
  271. u64 objectid,
  272. struct btrfs_root *root)
  273. {
  274. int ret;
  275. __setup_root(blocksize, root, fs_info, objectid);
  276. ret = btrfs_find_last_root(tree_root, objectid,
  277. &root->root_item, &root->root_key);
  278. BUG_ON(ret);
  279. root->node = read_tree_block(root,
  280. btrfs_root_blocknr(&root->root_item));
  281. BUG_ON(!root->node);
  282. return 0;
  283. }
  284. struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
  285. struct btrfs_key *location)
  286. {
  287. struct btrfs_root *root;
  288. struct btrfs_root *tree_root = fs_info->tree_root;
  289. struct btrfs_path *path;
  290. struct btrfs_leaf *l;
  291. u64 highest_inode;
  292. int ret = 0;
  293. printk("read_fs_root looking for %Lu %Lu %u\n", location->objectid, location->offset, location->flags);
  294. root = radix_tree_lookup(&fs_info->fs_roots_radix,
  295. (unsigned long)location->objectid);
  296. if (root) {
  297. printk("found %p in cache\n", root);
  298. return root;
  299. }
  300. root = kmalloc(sizeof(*root), GFP_NOFS);
  301. if (!root) {
  302. printk("failed1\n");
  303. return ERR_PTR(-ENOMEM);
  304. }
  305. if (location->offset == (u64)-1) {
  306. ret = find_and_setup_root(fs_info->sb->s_blocksize,
  307. fs_info->tree_root, fs_info,
  308. location->objectid, root);
  309. if (ret) {
  310. printk("failed2\n");
  311. kfree(root);
  312. return ERR_PTR(ret);
  313. }
  314. goto insert;
  315. }
  316. __setup_root(fs_info->sb->s_blocksize, root, fs_info,
  317. location->objectid);
  318. path = btrfs_alloc_path();
  319. BUG_ON(!path);
  320. ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);
  321. if (ret != 0) {
  322. printk("internal search_slot gives us %d\n", ret);
  323. if (ret > 0)
  324. ret = -ENOENT;
  325. goto out;
  326. }
  327. l = btrfs_buffer_leaf(path->nodes[0]);
  328. memcpy(&root->root_item,
  329. btrfs_item_ptr(l, path->slots[0], struct btrfs_root_item),
  330. sizeof(root->root_item));
  331. memcpy(&root->root_key, location, sizeof(*location));
  332. ret = 0;
  333. out:
  334. btrfs_release_path(root, path);
  335. btrfs_free_path(path);
  336. if (ret) {
  337. kfree(root);
  338. return ERR_PTR(ret);
  339. }
  340. root->node = read_tree_block(root,
  341. btrfs_root_blocknr(&root->root_item));
  342. BUG_ON(!root->node);
  343. insert:
  344. printk("inserting %p\n", root);
  345. root->ref_cows = 1;
  346. ret = radix_tree_insert(&fs_info->fs_roots_radix,
  347. (unsigned long)root->root_key.objectid,
  348. root);
  349. if (ret) {
  350. printk("radix_tree_insert gives us %d\n", ret);
  351. brelse(root->node);
  352. kfree(root);
  353. return ERR_PTR(ret);
  354. }
  355. ret = btrfs_find_highest_inode(root, &highest_inode);
  356. if (ret == 0) {
  357. root->highest_inode = highest_inode;
  358. root->last_inode_alloc = highest_inode;
  359. printk("highest inode is %Lu\n", highest_inode);
  360. }
  361. printk("all worked\n");
  362. return root;
  363. }
  364. struct btrfs_root *open_ctree(struct super_block *sb)
  365. {
  366. struct btrfs_root *extent_root = kmalloc(sizeof(struct btrfs_root),
  367. GFP_NOFS);
  368. struct btrfs_root *dev_root = kmalloc(sizeof(struct btrfs_root),
  369. GFP_NOFS);
  370. struct btrfs_root *tree_root = kmalloc(sizeof(struct btrfs_root),
  371. GFP_NOFS);
  372. struct btrfs_fs_info *fs_info = kmalloc(sizeof(*fs_info),
  373. GFP_NOFS);
  374. int ret;
  375. struct btrfs_super_block *disk_super;
  376. struct dev_lookup *dev_lookup;
  377. init_bit_radix(&fs_info->pinned_radix);
  378. init_bit_radix(&fs_info->pending_del_radix);
  379. INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS);
  380. INIT_RADIX_TREE(&fs_info->dev_radix, GFP_NOFS);
  381. sb_set_blocksize(sb, 4096);
  382. fs_info->running_transaction = NULL;
  383. fs_info->tree_root = tree_root;
  384. fs_info->extent_root = extent_root;
  385. fs_info->dev_root = dev_root;
  386. fs_info->sb = sb;
  387. fs_info->btree_inode = new_inode(sb);
  388. fs_info->btree_inode->i_ino = 1;
  389. fs_info->btree_inode->i_nlink = 1;
  390. fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size;
  391. fs_info->btree_inode->i_mapping->a_ops = &btree_aops;
  392. BTRFS_I(fs_info->btree_inode)->root = tree_root;
  393. memset(&BTRFS_I(fs_info->btree_inode)->location, 0,
  394. sizeof(struct btrfs_key));
  395. insert_inode_hash(fs_info->btree_inode);
  396. mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
  397. fs_info->hash_tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
  398. spin_lock_init(&fs_info->hash_lock);
  399. if (!fs_info->hash_tfm || IS_ERR(fs_info->hash_tfm)) {
  400. printk("failed to allocate sha256 hash\n");
  401. return NULL;
  402. }
  403. mutex_init(&fs_info->trans_mutex);
  404. mutex_init(&fs_info->fs_mutex);
  405. memset(&fs_info->current_insert, 0, sizeof(fs_info->current_insert));
  406. memset(&fs_info->last_insert, 0, sizeof(fs_info->last_insert));
  407. __setup_root(sb->s_blocksize, dev_root,
  408. fs_info, BTRFS_DEV_TREE_OBJECTID);
  409. __setup_root(sb->s_blocksize, tree_root,
  410. fs_info, BTRFS_ROOT_TREE_OBJECTID);
  411. dev_lookup = kmalloc(sizeof(*dev_lookup), GFP_NOFS);
  412. dev_lookup->block_start = 0;
  413. dev_lookup->num_blocks = (u32)-2;
  414. dev_lookup->bdev = sb->s_bdev;
  415. ret = radix_tree_insert(&fs_info->dev_radix, (u32)-2, dev_lookup);
  416. BUG_ON(ret);
  417. fs_info->sb_buffer = read_tree_block(tree_root,
  418. BTRFS_SUPER_INFO_OFFSET /
  419. sb->s_blocksize);
  420. if (!fs_info->sb_buffer)
  421. return NULL;
  422. disk_super = (struct btrfs_super_block *)fs_info->sb_buffer->b_data;
  423. if (!btrfs_super_root(disk_super))
  424. return NULL;
  425. radix_tree_delete(&fs_info->dev_radix, (u32)-2);
  426. dev_lookup->block_start = btrfs_super_device_block_start(disk_super);
  427. dev_lookup->num_blocks = btrfs_super_device_num_blocks(disk_super);
  428. ret = radix_tree_insert(&fs_info->dev_radix,
  429. dev_lookup->block_start +
  430. dev_lookup->num_blocks, dev_lookup);
  431. BUG_ON(ret);
  432. fs_info->disk_super = disk_super;
  433. dev_root->node = read_tree_block(tree_root,
  434. btrfs_super_device_root(disk_super));
  435. tree_root->node = read_tree_block(tree_root,
  436. btrfs_super_root(disk_super));
  437. BUG_ON(!tree_root->node);
  438. mutex_lock(&fs_info->fs_mutex);
  439. ret = find_and_setup_root(sb->s_blocksize, tree_root, fs_info,
  440. BTRFS_EXTENT_TREE_OBJECTID, extent_root);
  441. BUG_ON(ret);
  442. fs_info->generation = btrfs_super_generation(disk_super) + 1;
  443. memset(&fs_info->kobj, 0, sizeof(fs_info->kobj));
  444. kobj_set_kset_s(fs_info, btrfs_subsys);
  445. kobject_set_name(&fs_info->kobj, "%s", sb->s_id);
  446. kobject_register(&fs_info->kobj);
  447. mutex_unlock(&fs_info->fs_mutex);
  448. return tree_root;
  449. }
  450. int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
  451. *root)
  452. {
  453. struct buffer_head *bh = root->fs_info->sb_buffer;
  454. btrfs_set_super_root(root->fs_info->disk_super,
  455. bh_blocknr(root->fs_info->tree_root->node));
  456. lock_buffer(bh);
  457. WARN_ON(atomic_read(&bh->b_count) < 1);
  458. clear_buffer_dirty(bh);
  459. csum_tree_block(root, bh, 0);
  460. bh->b_end_io = end_buffer_write_sync;
  461. get_bh(bh);
  462. submit_bh(WRITE, bh);
  463. wait_on_buffer(bh);
  464. if (!buffer_uptodate(bh)) {
  465. WARN_ON(1);
  466. return -EIO;
  467. }
  468. return 0;
  469. }
  470. static int free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
  471. {
  472. radix_tree_delete(&fs_info->fs_roots_radix,
  473. (unsigned long)root->root_key.objectid);
  474. if (root->inode)
  475. iput(root->inode);
  476. if (root->node)
  477. brelse(root->node);
  478. if (root->commit_root)
  479. brelse(root->commit_root);
  480. kfree(root);
  481. return 0;
  482. }
  483. int del_fs_roots(struct btrfs_fs_info *fs_info)
  484. {
  485. int ret;
  486. struct btrfs_root *gang[8];
  487. int i;
  488. while(1) {
  489. ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,
  490. (void **)gang, 0,
  491. ARRAY_SIZE(gang));
  492. if (!ret)
  493. break;
  494. for (i = 0; i < ret; i++)
  495. free_fs_root(fs_info, gang[i]);
  496. }
  497. return 0;
  498. }
  499. static int free_dev_radix(struct btrfs_fs_info *fs_info)
  500. {
  501. struct dev_lookup *lookup[8];
  502. struct block_device *super_bdev = fs_info->sb->s_bdev;
  503. int ret;
  504. int i;
  505. while(1) {
  506. ret = radix_tree_gang_lookup(&fs_info->dev_radix,
  507. (void **)lookup, 0,
  508. ARRAY_SIZE(lookup));
  509. if (!ret)
  510. break;
  511. for (i = 0; i < ret; i++) {
  512. if (lookup[i]->bdev != super_bdev)
  513. close_bdev_excl(lookup[i]->bdev);
  514. radix_tree_delete(&fs_info->dev_radix,
  515. lookup[i]->block_start +
  516. lookup[i]->num_blocks);
  517. kfree(lookup[i]);
  518. }
  519. }
  520. return 0;
  521. }
  522. int close_ctree(struct btrfs_root *root)
  523. {
  524. int ret;
  525. struct btrfs_trans_handle *trans;
  526. struct btrfs_fs_info *fs_info = root->fs_info;
  527. mutex_lock(&fs_info->fs_mutex);
  528. trans = btrfs_start_transaction(root, 1);
  529. btrfs_commit_transaction(trans, root);
  530. /* run commit again to drop the original snapshot */
  531. trans = btrfs_start_transaction(root, 1);
  532. btrfs_commit_transaction(trans, root);
  533. ret = btrfs_write_and_wait_transaction(NULL, root);
  534. BUG_ON(ret);
  535. write_ctree_super(NULL, root);
  536. mutex_unlock(&fs_info->fs_mutex);
  537. if (fs_info->extent_root->node)
  538. btrfs_block_release(fs_info->extent_root,
  539. fs_info->extent_root->node);
  540. if (fs_info->dev_root->node)
  541. btrfs_block_release(fs_info->dev_root,
  542. fs_info->dev_root->node);
  543. if (fs_info->tree_root->node)
  544. btrfs_block_release(fs_info->tree_root,
  545. fs_info->tree_root->node);
  546. btrfs_block_release(root, fs_info->sb_buffer);
  547. crypto_free_hash(fs_info->hash_tfm);
  548. truncate_inode_pages(fs_info->btree_inode->i_mapping, 0);
  549. iput(fs_info->btree_inode);
  550. free_dev_radix(fs_info);
  551. del_fs_roots(fs_info);
  552. kfree(fs_info->extent_root);
  553. kfree(fs_info->tree_root);
  554. kobject_unregister(&fs_info->kobj);
  555. return 0;
  556. }
  557. void btrfs_block_release(struct btrfs_root *root, struct buffer_head *buf)
  558. {
  559. brelse(buf);
  560. }