disk-io.c 16 KB

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