disk-io.c 16 KB

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