disk-io.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  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 <linux/buffer_head.h> // for block_sync_page
  26. #include "ctree.h"
  27. #include "disk-io.h"
  28. #include "transaction.h"
  29. #include "btrfs_inode.h"
  30. #include "volumes.h"
  31. #include "print-tree.h"
  32. #if 0
  33. static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
  34. {
  35. if (extent_buffer_blocknr(buf) != btrfs_header_blocknr(buf)) {
  36. printk(KERN_CRIT "buf blocknr(buf) is %llu, header is %llu\n",
  37. (unsigned long long)extent_buffer_blocknr(buf),
  38. (unsigned long long)btrfs_header_blocknr(buf));
  39. return 1;
  40. }
  41. return 0;
  42. }
  43. #endif
  44. static struct extent_io_ops btree_extent_io_ops;
  45. struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
  46. u64 bytenr, u32 blocksize)
  47. {
  48. struct inode *btree_inode = root->fs_info->btree_inode;
  49. struct extent_buffer *eb;
  50. eb = find_extent_buffer(&BTRFS_I(btree_inode)->io_tree,
  51. bytenr, blocksize, GFP_NOFS);
  52. return eb;
  53. }
  54. struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
  55. u64 bytenr, u32 blocksize)
  56. {
  57. struct inode *btree_inode = root->fs_info->btree_inode;
  58. struct extent_buffer *eb;
  59. eb = alloc_extent_buffer(&BTRFS_I(btree_inode)->io_tree,
  60. bytenr, blocksize, NULL, GFP_NOFS);
  61. return eb;
  62. }
  63. struct extent_map *btree_get_extent(struct inode *inode, struct page *page,
  64. size_t page_offset, u64 start, u64 len,
  65. int create)
  66. {
  67. struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
  68. struct extent_map *em;
  69. int ret;
  70. again:
  71. spin_lock(&em_tree->lock);
  72. em = lookup_extent_mapping(em_tree, start, len);
  73. spin_unlock(&em_tree->lock);
  74. if (em) {
  75. goto out;
  76. }
  77. em = alloc_extent_map(GFP_NOFS);
  78. if (!em) {
  79. em = ERR_PTR(-ENOMEM);
  80. goto out;
  81. }
  82. em->start = 0;
  83. em->len = i_size_read(inode);
  84. em->block_start = 0;
  85. em->bdev = inode->i_sb->s_bdev;
  86. spin_lock(&em_tree->lock);
  87. ret = add_extent_mapping(em_tree, em);
  88. spin_unlock(&em_tree->lock);
  89. if (ret == -EEXIST) {
  90. free_extent_map(em);
  91. em = NULL;
  92. goto again;
  93. } else if (ret) {
  94. em = ERR_PTR(ret);
  95. }
  96. out:
  97. return em;
  98. }
  99. u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len)
  100. {
  101. return crc32c(seed, data, len);
  102. }
  103. void btrfs_csum_final(u32 crc, char *result)
  104. {
  105. *(__le32 *)result = ~cpu_to_le32(crc);
  106. }
  107. static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
  108. int verify)
  109. {
  110. char result[BTRFS_CRC32_SIZE];
  111. unsigned long len;
  112. unsigned long cur_len;
  113. unsigned long offset = BTRFS_CSUM_SIZE;
  114. char *map_token = NULL;
  115. char *kaddr;
  116. unsigned long map_start;
  117. unsigned long map_len;
  118. int err;
  119. u32 crc = ~(u32)0;
  120. len = buf->len - offset;
  121. while(len > 0) {
  122. err = map_private_extent_buffer(buf, offset, 32,
  123. &map_token, &kaddr,
  124. &map_start, &map_len, KM_USER0);
  125. if (err) {
  126. printk("failed to map extent buffer! %lu\n",
  127. offset);
  128. return 1;
  129. }
  130. cur_len = min(len, map_len - (offset - map_start));
  131. crc = btrfs_csum_data(root, kaddr + offset - map_start,
  132. crc, cur_len);
  133. len -= cur_len;
  134. offset += cur_len;
  135. unmap_extent_buffer(buf, map_token, KM_USER0);
  136. }
  137. btrfs_csum_final(crc, result);
  138. if (verify) {
  139. int from_this_trans = 0;
  140. if (root->fs_info->running_transaction &&
  141. btrfs_header_generation(buf) ==
  142. root->fs_info->running_transaction->transid)
  143. from_this_trans = 1;
  144. /* FIXME, this is not good */
  145. if (from_this_trans == 0 &&
  146. memcmp_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE)) {
  147. u32 val;
  148. u32 found = 0;
  149. memcpy(&found, result, BTRFS_CRC32_SIZE);
  150. read_extent_buffer(buf, &val, 0, BTRFS_CRC32_SIZE);
  151. printk("btrfs: %s checksum verify failed on %llu "
  152. "wanted %X found %X from_this_trans %d\n",
  153. root->fs_info->sb->s_id,
  154. buf->start, val, found, from_this_trans);
  155. return 1;
  156. }
  157. } else {
  158. write_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE);
  159. }
  160. return 0;
  161. }
  162. int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
  163. {
  164. struct extent_io_tree *tree;
  165. u64 start = (u64)page->index << PAGE_CACHE_SHIFT;
  166. u64 found_start;
  167. int found_level;
  168. unsigned long len;
  169. struct extent_buffer *eb;
  170. tree = &BTRFS_I(page->mapping->host)->io_tree;
  171. if (page->private == EXTENT_PAGE_PRIVATE)
  172. goto out;
  173. if (!page->private)
  174. goto out;
  175. len = page->private >> 2;
  176. if (len == 0) {
  177. WARN_ON(1);
  178. }
  179. eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
  180. read_extent_buffer_pages(tree, eb, start + PAGE_CACHE_SIZE, 1,
  181. btree_get_extent);
  182. btrfs_clear_buffer_defrag(eb);
  183. found_start = btrfs_header_bytenr(eb);
  184. if (found_start != start) {
  185. printk("warning: eb start incorrect %Lu buffer %Lu len %lu\n",
  186. start, found_start, len);
  187. WARN_ON(1);
  188. goto err;
  189. }
  190. if (eb->first_page != page) {
  191. printk("bad first page %lu %lu\n", eb->first_page->index,
  192. page->index);
  193. WARN_ON(1);
  194. goto err;
  195. }
  196. if (!PageUptodate(page)) {
  197. printk("csum not up to date page %lu\n", page->index);
  198. WARN_ON(1);
  199. goto err;
  200. }
  201. found_level = btrfs_header_level(eb);
  202. csum_tree_block(root, eb, 0);
  203. err:
  204. free_extent_buffer(eb);
  205. out:
  206. return 0;
  207. }
  208. static int btree_writepage_io_hook(struct page *page, u64 start, u64 end)
  209. {
  210. struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
  211. csum_dirty_buffer(root, page);
  212. return 0;
  213. }
  214. static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio)
  215. {
  216. struct btrfs_root *root = BTRFS_I(inode)->root;
  217. u64 offset;
  218. offset = bio->bi_sector << 9;
  219. if (offset == BTRFS_SUPER_INFO_OFFSET) {
  220. bio->bi_bdev = root->fs_info->sb->s_bdev;
  221. submit_bio(rw, bio);
  222. return 0;
  223. }
  224. return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio);
  225. }
  226. static int btree_writepage(struct page *page, struct writeback_control *wbc)
  227. {
  228. struct extent_io_tree *tree;
  229. tree = &BTRFS_I(page->mapping->host)->io_tree;
  230. return extent_write_full_page(tree, page, btree_get_extent, wbc);
  231. }
  232. static int btree_writepages(struct address_space *mapping,
  233. struct writeback_control *wbc)
  234. {
  235. struct extent_io_tree *tree;
  236. tree = &BTRFS_I(mapping->host)->io_tree;
  237. if (wbc->sync_mode == WB_SYNC_NONE) {
  238. u64 num_dirty;
  239. u64 start = 0;
  240. unsigned long thresh = 96 * 1024 * 1024;
  241. if (wbc->for_kupdate)
  242. return 0;
  243. if (current_is_pdflush()) {
  244. thresh = 96 * 1024 * 1024;
  245. } else {
  246. thresh = 8 * 1024 * 1024;
  247. }
  248. num_dirty = count_range_bits(tree, &start, (u64)-1,
  249. thresh, EXTENT_DIRTY);
  250. if (num_dirty < thresh) {
  251. return 0;
  252. }
  253. }
  254. return extent_writepages(tree, mapping, btree_get_extent, wbc);
  255. }
  256. int btree_readpage(struct file *file, struct page *page)
  257. {
  258. struct extent_io_tree *tree;
  259. tree = &BTRFS_I(page->mapping->host)->io_tree;
  260. return extent_read_full_page(tree, page, btree_get_extent);
  261. }
  262. static int btree_releasepage(struct page *page, gfp_t gfp_flags)
  263. {
  264. struct extent_io_tree *tree;
  265. struct extent_map_tree *map;
  266. int ret;
  267. tree = &BTRFS_I(page->mapping->host)->io_tree;
  268. map = &BTRFS_I(page->mapping->host)->extent_tree;
  269. ret = try_release_extent_mapping(map, tree, page, gfp_flags);
  270. if (ret == 1) {
  271. ClearPagePrivate(page);
  272. set_page_private(page, 0);
  273. page_cache_release(page);
  274. }
  275. return ret;
  276. }
  277. static void btree_invalidatepage(struct page *page, unsigned long offset)
  278. {
  279. struct extent_io_tree *tree;
  280. tree = &BTRFS_I(page->mapping->host)->io_tree;
  281. extent_invalidatepage(tree, page, offset);
  282. btree_releasepage(page, GFP_NOFS);
  283. }
  284. #if 0
  285. static int btree_writepage(struct page *page, struct writeback_control *wbc)
  286. {
  287. struct buffer_head *bh;
  288. struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
  289. struct buffer_head *head;
  290. if (!page_has_buffers(page)) {
  291. create_empty_buffers(page, root->fs_info->sb->s_blocksize,
  292. (1 << BH_Dirty)|(1 << BH_Uptodate));
  293. }
  294. head = page_buffers(page);
  295. bh = head;
  296. do {
  297. if (buffer_dirty(bh))
  298. csum_tree_block(root, bh, 0);
  299. bh = bh->b_this_page;
  300. } while (bh != head);
  301. return block_write_full_page(page, btree_get_block, wbc);
  302. }
  303. #endif
  304. static struct address_space_operations btree_aops = {
  305. .readpage = btree_readpage,
  306. .writepage = btree_writepage,
  307. .writepages = btree_writepages,
  308. .releasepage = btree_releasepage,
  309. .invalidatepage = btree_invalidatepage,
  310. .sync_page = block_sync_page,
  311. };
  312. int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize)
  313. {
  314. struct extent_buffer *buf = NULL;
  315. struct inode *btree_inode = root->fs_info->btree_inode;
  316. int ret = 0;
  317. buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
  318. if (!buf)
  319. return 0;
  320. read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree,
  321. buf, 0, 0, btree_get_extent);
  322. free_extent_buffer(buf);
  323. return ret;
  324. }
  325. static int close_all_devices(struct btrfs_fs_info *fs_info)
  326. {
  327. struct list_head *list;
  328. struct list_head *next;
  329. struct btrfs_device *device;
  330. list = &fs_info->fs_devices->devices;
  331. list_for_each(next, list) {
  332. device = list_entry(next, struct btrfs_device, dev_list);
  333. if (device->bdev && device->bdev != fs_info->sb->s_bdev)
  334. close_bdev_excl(device->bdev);
  335. device->bdev = NULL;
  336. }
  337. return 0;
  338. }
  339. struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
  340. u32 blocksize)
  341. {
  342. struct extent_buffer *buf = NULL;
  343. struct inode *btree_inode = root->fs_info->btree_inode;
  344. struct extent_io_tree *io_tree;
  345. u64 end;
  346. int ret;
  347. io_tree = &BTRFS_I(btree_inode)->io_tree;
  348. buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
  349. if (!buf)
  350. return NULL;
  351. read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, buf, 0, 1,
  352. btree_get_extent);
  353. if (buf->flags & EXTENT_CSUM)
  354. return buf;
  355. end = buf->start + PAGE_CACHE_SIZE - 1;
  356. if (test_range_bit(io_tree, buf->start, end, EXTENT_CSUM, 1)) {
  357. buf->flags |= EXTENT_CSUM;
  358. return buf;
  359. }
  360. lock_extent(io_tree, buf->start, end, GFP_NOFS);
  361. if (test_range_bit(io_tree, buf->start, end, EXTENT_CSUM, 1)) {
  362. buf->flags |= EXTENT_CSUM;
  363. goto out_unlock;
  364. }
  365. ret = csum_tree_block(root, buf, 1);
  366. set_extent_bits(io_tree, buf->start, end, EXTENT_CSUM, GFP_NOFS);
  367. buf->flags |= EXTENT_CSUM;
  368. out_unlock:
  369. unlock_extent(io_tree, buf->start, end, GFP_NOFS);
  370. return buf;
  371. }
  372. int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
  373. struct extent_buffer *buf)
  374. {
  375. struct inode *btree_inode = root->fs_info->btree_inode;
  376. if (btrfs_header_generation(buf) ==
  377. root->fs_info->running_transaction->transid)
  378. clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree,
  379. buf);
  380. return 0;
  381. }
  382. int wait_on_tree_block_writeback(struct btrfs_root *root,
  383. struct extent_buffer *buf)
  384. {
  385. struct inode *btree_inode = root->fs_info->btree_inode;
  386. wait_on_extent_buffer_writeback(&BTRFS_I(btree_inode)->io_tree,
  387. buf);
  388. return 0;
  389. }
  390. static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
  391. u32 stripesize, struct btrfs_root *root,
  392. struct btrfs_fs_info *fs_info,
  393. u64 objectid)
  394. {
  395. root->node = NULL;
  396. root->inode = NULL;
  397. root->commit_root = NULL;
  398. root->sectorsize = sectorsize;
  399. root->nodesize = nodesize;
  400. root->leafsize = leafsize;
  401. root->stripesize = stripesize;
  402. root->ref_cows = 0;
  403. root->track_dirty = 0;
  404. root->fs_info = fs_info;
  405. root->objectid = objectid;
  406. root->last_trans = 0;
  407. root->highest_inode = 0;
  408. root->last_inode_alloc = 0;
  409. root->name = NULL;
  410. root->in_sysfs = 0;
  411. INIT_LIST_HEAD(&root->dirty_list);
  412. memset(&root->root_key, 0, sizeof(root->root_key));
  413. memset(&root->root_item, 0, sizeof(root->root_item));
  414. memset(&root->defrag_progress, 0, sizeof(root->defrag_progress));
  415. memset(&root->root_kobj, 0, sizeof(root->root_kobj));
  416. init_completion(&root->kobj_unregister);
  417. root->defrag_running = 0;
  418. root->defrag_level = 0;
  419. root->root_key.objectid = objectid;
  420. return 0;
  421. }
  422. static int find_and_setup_root(struct btrfs_root *tree_root,
  423. struct btrfs_fs_info *fs_info,
  424. u64 objectid,
  425. struct btrfs_root *root)
  426. {
  427. int ret;
  428. u32 blocksize;
  429. __setup_root(tree_root->nodesize, tree_root->leafsize,
  430. tree_root->sectorsize, tree_root->stripesize,
  431. root, fs_info, objectid);
  432. ret = btrfs_find_last_root(tree_root, objectid,
  433. &root->root_item, &root->root_key);
  434. BUG_ON(ret);
  435. blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
  436. root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
  437. blocksize);
  438. BUG_ON(!root->node);
  439. return 0;
  440. }
  441. struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_fs_info *fs_info,
  442. struct btrfs_key *location)
  443. {
  444. struct btrfs_root *root;
  445. struct btrfs_root *tree_root = fs_info->tree_root;
  446. struct btrfs_path *path;
  447. struct extent_buffer *l;
  448. u64 highest_inode;
  449. u32 blocksize;
  450. int ret = 0;
  451. root = kzalloc(sizeof(*root), GFP_NOFS);
  452. if (!root)
  453. return ERR_PTR(-ENOMEM);
  454. if (location->offset == (u64)-1) {
  455. ret = find_and_setup_root(tree_root, fs_info,
  456. location->objectid, root);
  457. if (ret) {
  458. kfree(root);
  459. return ERR_PTR(ret);
  460. }
  461. goto insert;
  462. }
  463. __setup_root(tree_root->nodesize, tree_root->leafsize,
  464. tree_root->sectorsize, tree_root->stripesize,
  465. root, fs_info, location->objectid);
  466. path = btrfs_alloc_path();
  467. BUG_ON(!path);
  468. ret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);
  469. if (ret != 0) {
  470. if (ret > 0)
  471. ret = -ENOENT;
  472. goto out;
  473. }
  474. l = path->nodes[0];
  475. read_extent_buffer(l, &root->root_item,
  476. btrfs_item_ptr_offset(l, path->slots[0]),
  477. sizeof(root->root_item));
  478. memcpy(&root->root_key, location, sizeof(*location));
  479. ret = 0;
  480. out:
  481. btrfs_release_path(root, path);
  482. btrfs_free_path(path);
  483. if (ret) {
  484. kfree(root);
  485. return ERR_PTR(ret);
  486. }
  487. blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
  488. root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
  489. blocksize);
  490. BUG_ON(!root->node);
  491. insert:
  492. root->ref_cows = 1;
  493. ret = btrfs_find_highest_inode(root, &highest_inode);
  494. if (ret == 0) {
  495. root->highest_inode = highest_inode;
  496. root->last_inode_alloc = highest_inode;
  497. }
  498. return root;
  499. }
  500. struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info,
  501. u64 root_objectid)
  502. {
  503. struct btrfs_root *root;
  504. if (root_objectid == BTRFS_ROOT_TREE_OBJECTID)
  505. return fs_info->tree_root;
  506. if (root_objectid == BTRFS_EXTENT_TREE_OBJECTID)
  507. return fs_info->extent_root;
  508. root = radix_tree_lookup(&fs_info->fs_roots_radix,
  509. (unsigned long)root_objectid);
  510. return root;
  511. }
  512. struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
  513. struct btrfs_key *location)
  514. {
  515. struct btrfs_root *root;
  516. int ret;
  517. if (location->objectid == BTRFS_ROOT_TREE_OBJECTID)
  518. return fs_info->tree_root;
  519. if (location->objectid == BTRFS_EXTENT_TREE_OBJECTID)
  520. return fs_info->extent_root;
  521. root = radix_tree_lookup(&fs_info->fs_roots_radix,
  522. (unsigned long)location->objectid);
  523. if (root)
  524. return root;
  525. root = btrfs_read_fs_root_no_radix(fs_info, location);
  526. if (IS_ERR(root))
  527. return root;
  528. ret = radix_tree_insert(&fs_info->fs_roots_radix,
  529. (unsigned long)root->root_key.objectid,
  530. root);
  531. if (ret) {
  532. free_extent_buffer(root->node);
  533. kfree(root);
  534. return ERR_PTR(ret);
  535. }
  536. ret = btrfs_find_dead_roots(fs_info->tree_root,
  537. root->root_key.objectid, root);
  538. BUG_ON(ret);
  539. return root;
  540. }
  541. struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
  542. struct btrfs_key *location,
  543. const char *name, int namelen)
  544. {
  545. struct btrfs_root *root;
  546. int ret;
  547. root = btrfs_read_fs_root_no_name(fs_info, location);
  548. if (!root)
  549. return NULL;
  550. if (root->in_sysfs)
  551. return root;
  552. ret = btrfs_set_root_name(root, name, namelen);
  553. if (ret) {
  554. free_extent_buffer(root->node);
  555. kfree(root);
  556. return ERR_PTR(ret);
  557. }
  558. ret = btrfs_sysfs_add_root(root);
  559. if (ret) {
  560. free_extent_buffer(root->node);
  561. kfree(root->name);
  562. kfree(root);
  563. return ERR_PTR(ret);
  564. }
  565. root->in_sysfs = 1;
  566. return root;
  567. }
  568. #if 0
  569. static int add_hasher(struct btrfs_fs_info *info, char *type) {
  570. struct btrfs_hasher *hasher;
  571. hasher = kmalloc(sizeof(*hasher), GFP_NOFS);
  572. if (!hasher)
  573. return -ENOMEM;
  574. hasher->hash_tfm = crypto_alloc_hash(type, 0, CRYPTO_ALG_ASYNC);
  575. if (!hasher->hash_tfm) {
  576. kfree(hasher);
  577. return -EINVAL;
  578. }
  579. spin_lock(&info->hash_lock);
  580. list_add(&hasher->list, &info->hashers);
  581. spin_unlock(&info->hash_lock);
  582. return 0;
  583. }
  584. #endif
  585. static int btrfs_congested_fn(void *congested_data, int bdi_bits)
  586. {
  587. struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data;
  588. int ret = 0;
  589. struct list_head *cur;
  590. struct btrfs_device *device;
  591. struct backing_dev_info *bdi;
  592. list_for_each(cur, &info->fs_devices->devices) {
  593. device = list_entry(cur, struct btrfs_device, dev_list);
  594. bdi = blk_get_backing_dev_info(device->bdev);
  595. if (bdi && bdi_congested(bdi, bdi_bits)) {
  596. ret = 1;
  597. break;
  598. }
  599. }
  600. return ret;
  601. }
  602. void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
  603. {
  604. struct list_head *cur;
  605. struct btrfs_device *device;
  606. struct btrfs_fs_info *info;
  607. info = (struct btrfs_fs_info *)bdi->unplug_io_data;
  608. list_for_each(cur, &info->fs_devices->devices) {
  609. device = list_entry(cur, struct btrfs_device, dev_list);
  610. bdi = blk_get_backing_dev_info(device->bdev);
  611. if (bdi->unplug_io_fn) {
  612. bdi->unplug_io_fn(bdi, page);
  613. }
  614. }
  615. }
  616. static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
  617. {
  618. bdi_init(bdi);
  619. bdi->ra_pages = default_backing_dev_info.ra_pages * 4;
  620. bdi->state = 0;
  621. bdi->capabilities = default_backing_dev_info.capabilities;
  622. bdi->unplug_io_fn = btrfs_unplug_io_fn;
  623. bdi->unplug_io_data = info;
  624. bdi->congested_fn = btrfs_congested_fn;
  625. bdi->congested_data = info;
  626. return 0;
  627. }
  628. struct btrfs_root *open_ctree(struct super_block *sb,
  629. struct btrfs_fs_devices *fs_devices)
  630. {
  631. u32 sectorsize;
  632. u32 nodesize;
  633. u32 leafsize;
  634. u32 blocksize;
  635. u32 stripesize;
  636. struct btrfs_root *extent_root = kmalloc(sizeof(struct btrfs_root),
  637. GFP_NOFS);
  638. struct btrfs_root *tree_root = kmalloc(sizeof(struct btrfs_root),
  639. GFP_NOFS);
  640. struct btrfs_fs_info *fs_info = kmalloc(sizeof(*fs_info),
  641. GFP_NOFS);
  642. struct btrfs_root *chunk_root = kmalloc(sizeof(struct btrfs_root),
  643. GFP_NOFS);
  644. struct btrfs_root *dev_root = kmalloc(sizeof(struct btrfs_root),
  645. GFP_NOFS);
  646. int ret;
  647. int err = -EIO;
  648. struct btrfs_super_block *disk_super;
  649. if (!extent_root || !tree_root || !fs_info) {
  650. err = -ENOMEM;
  651. goto fail;
  652. }
  653. INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS);
  654. INIT_LIST_HEAD(&fs_info->trans_list);
  655. INIT_LIST_HEAD(&fs_info->dead_roots);
  656. INIT_LIST_HEAD(&fs_info->hashers);
  657. spin_lock_init(&fs_info->hash_lock);
  658. spin_lock_init(&fs_info->delalloc_lock);
  659. spin_lock_init(&fs_info->new_trans_lock);
  660. memset(&fs_info->super_kobj, 0, sizeof(fs_info->super_kobj));
  661. init_completion(&fs_info->kobj_unregister);
  662. sb_set_blocksize(sb, 4096);
  663. fs_info->running_transaction = NULL;
  664. fs_info->last_trans_committed = 0;
  665. fs_info->tree_root = tree_root;
  666. fs_info->extent_root = extent_root;
  667. fs_info->chunk_root = chunk_root;
  668. fs_info->dev_root = dev_root;
  669. fs_info->fs_devices = fs_devices;
  670. INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots);
  671. INIT_LIST_HEAD(&fs_info->space_info);
  672. btrfs_mapping_init(&fs_info->mapping_tree);
  673. fs_info->sb = sb;
  674. fs_info->throttles = 0;
  675. fs_info->mount_opt = 0;
  676. fs_info->max_extent = (u64)-1;
  677. fs_info->max_inline = 8192 * 1024;
  678. fs_info->delalloc_bytes = 0;
  679. setup_bdi(fs_info, &fs_info->bdi);
  680. fs_info->btree_inode = new_inode(sb);
  681. fs_info->btree_inode->i_ino = 1;
  682. fs_info->btree_inode->i_nlink = 1;
  683. fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size;
  684. fs_info->btree_inode->i_mapping->a_ops = &btree_aops;
  685. fs_info->btree_inode->i_mapping->backing_dev_info = &fs_info->bdi;
  686. extent_io_tree_init(&BTRFS_I(fs_info->btree_inode)->io_tree,
  687. fs_info->btree_inode->i_mapping,
  688. GFP_NOFS);
  689. extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree,
  690. GFP_NOFS);
  691. BTRFS_I(fs_info->btree_inode)->io_tree.ops = &btree_extent_io_ops;
  692. extent_io_tree_init(&fs_info->free_space_cache,
  693. fs_info->btree_inode->i_mapping, GFP_NOFS);
  694. extent_io_tree_init(&fs_info->block_group_cache,
  695. fs_info->btree_inode->i_mapping, GFP_NOFS);
  696. extent_io_tree_init(&fs_info->pinned_extents,
  697. fs_info->btree_inode->i_mapping, GFP_NOFS);
  698. extent_io_tree_init(&fs_info->pending_del,
  699. fs_info->btree_inode->i_mapping, GFP_NOFS);
  700. extent_io_tree_init(&fs_info->extent_ins,
  701. fs_info->btree_inode->i_mapping, GFP_NOFS);
  702. fs_info->do_barriers = 1;
  703. fs_info->closing = 0;
  704. fs_info->total_pinned = 0;
  705. fs_info->last_alloc = 0;
  706. fs_info->last_data_alloc = 0;
  707. fs_info->extra_alloc_bits = 0;
  708. fs_info->extra_data_alloc_bits = 0;
  709. #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
  710. INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info);
  711. #else
  712. INIT_DELAYED_WORK(&fs_info->trans_work, btrfs_transaction_cleaner);
  713. #endif
  714. BTRFS_I(fs_info->btree_inode)->root = tree_root;
  715. memset(&BTRFS_I(fs_info->btree_inode)->location, 0,
  716. sizeof(struct btrfs_key));
  717. insert_inode_hash(fs_info->btree_inode);
  718. mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
  719. mutex_init(&fs_info->trans_mutex);
  720. mutex_init(&fs_info->fs_mutex);
  721. #if 0
  722. ret = add_hasher(fs_info, "crc32c");
  723. if (ret) {
  724. printk("btrfs: failed hash setup, modprobe cryptomgr?\n");
  725. err = -ENOMEM;
  726. goto fail_iput;
  727. }
  728. #endif
  729. __setup_root(4096, 4096, 4096, 4096, tree_root,
  730. fs_info, BTRFS_ROOT_TREE_OBJECTID);
  731. fs_info->sb_buffer = read_tree_block(tree_root,
  732. BTRFS_SUPER_INFO_OFFSET,
  733. 4096);
  734. if (!fs_info->sb_buffer)
  735. goto fail_iput;
  736. read_extent_buffer(fs_info->sb_buffer, &fs_info->super_copy, 0,
  737. sizeof(fs_info->super_copy));
  738. read_extent_buffer(fs_info->sb_buffer, fs_info->fsid,
  739. (unsigned long)btrfs_super_fsid(fs_info->sb_buffer),
  740. BTRFS_FSID_SIZE);
  741. disk_super = &fs_info->super_copy;
  742. if (!btrfs_super_root(disk_super))
  743. goto fail_sb_buffer;
  744. if (btrfs_super_num_devices(disk_super) != fs_devices->num_devices) {
  745. printk("Btrfs: wanted %llu devices, but found %llu\n",
  746. (unsigned long long)btrfs_super_num_devices(disk_super),
  747. (unsigned long long)fs_devices->num_devices);
  748. goto fail_sb_buffer;
  749. }
  750. nodesize = btrfs_super_nodesize(disk_super);
  751. leafsize = btrfs_super_leafsize(disk_super);
  752. sectorsize = btrfs_super_sectorsize(disk_super);
  753. stripesize = btrfs_super_stripesize(disk_super);
  754. tree_root->nodesize = nodesize;
  755. tree_root->leafsize = leafsize;
  756. tree_root->sectorsize = sectorsize;
  757. tree_root->stripesize = stripesize;
  758. sb_set_blocksize(sb, sectorsize);
  759. i_size_write(fs_info->btree_inode,
  760. btrfs_super_total_bytes(disk_super));
  761. if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC,
  762. sizeof(disk_super->magic))) {
  763. printk("btrfs: valid FS not found on %s\n", sb->s_id);
  764. goto fail_sb_buffer;
  765. }
  766. mutex_lock(&fs_info->fs_mutex);
  767. ret = btrfs_read_sys_array(tree_root);
  768. BUG_ON(ret);
  769. blocksize = btrfs_level_size(tree_root,
  770. btrfs_super_chunk_root_level(disk_super));
  771. __setup_root(nodesize, leafsize, sectorsize, stripesize,
  772. chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID);
  773. chunk_root->node = read_tree_block(chunk_root,
  774. btrfs_super_chunk_root(disk_super),
  775. blocksize);
  776. BUG_ON(!chunk_root->node);
  777. ret = btrfs_read_chunk_tree(chunk_root);
  778. BUG_ON(ret);
  779. blocksize = btrfs_level_size(tree_root,
  780. btrfs_super_root_level(disk_super));
  781. tree_root->node = read_tree_block(tree_root,
  782. btrfs_super_root(disk_super),
  783. blocksize);
  784. if (!tree_root->node)
  785. goto fail_sb_buffer;
  786. ret = find_and_setup_root(tree_root, fs_info,
  787. BTRFS_EXTENT_TREE_OBJECTID, extent_root);
  788. if (ret)
  789. goto fail_tree_root;
  790. extent_root->track_dirty = 1;
  791. ret = find_and_setup_root(tree_root, fs_info,
  792. BTRFS_DEV_TREE_OBJECTID, dev_root);
  793. dev_root->track_dirty = 1;
  794. if (ret)
  795. goto fail_extent_root;
  796. btrfs_read_block_groups(extent_root);
  797. fs_info->generation = btrfs_super_generation(disk_super) + 1;
  798. mutex_unlock(&fs_info->fs_mutex);
  799. return tree_root;
  800. fail_extent_root:
  801. free_extent_buffer(extent_root->node);
  802. fail_tree_root:
  803. mutex_unlock(&fs_info->fs_mutex);
  804. free_extent_buffer(tree_root->node);
  805. fail_sb_buffer:
  806. free_extent_buffer(fs_info->sb_buffer);
  807. extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree);
  808. fail_iput:
  809. iput(fs_info->btree_inode);
  810. fail:
  811. close_all_devices(fs_info);
  812. kfree(extent_root);
  813. kfree(tree_root);
  814. bdi_destroy(&fs_info->bdi);
  815. kfree(fs_info);
  816. return ERR_PTR(err);
  817. }
  818. int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
  819. *root)
  820. {
  821. int ret;
  822. struct extent_buffer *super = root->fs_info->sb_buffer;
  823. struct inode *btree_inode = root->fs_info->btree_inode;
  824. struct super_block *sb = root->fs_info->sb;
  825. if (!btrfs_test_opt(root, NOBARRIER))
  826. blkdev_issue_flush(sb->s_bdev, NULL);
  827. set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, super);
  828. ret = sync_page_range_nolock(btree_inode, btree_inode->i_mapping,
  829. super->start, super->len);
  830. if (!btrfs_test_opt(root, NOBARRIER))
  831. blkdev_issue_flush(sb->s_bdev, NULL);
  832. return ret;
  833. }
  834. int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
  835. {
  836. radix_tree_delete(&fs_info->fs_roots_radix,
  837. (unsigned long)root->root_key.objectid);
  838. if (root->in_sysfs)
  839. btrfs_sysfs_del_root(root);
  840. if (root->inode)
  841. iput(root->inode);
  842. if (root->node)
  843. free_extent_buffer(root->node);
  844. if (root->commit_root)
  845. free_extent_buffer(root->commit_root);
  846. if (root->name)
  847. kfree(root->name);
  848. kfree(root);
  849. return 0;
  850. }
  851. static int del_fs_roots(struct btrfs_fs_info *fs_info)
  852. {
  853. int ret;
  854. struct btrfs_root *gang[8];
  855. int i;
  856. while(1) {
  857. ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,
  858. (void **)gang, 0,
  859. ARRAY_SIZE(gang));
  860. if (!ret)
  861. break;
  862. for (i = 0; i < ret; i++)
  863. btrfs_free_fs_root(fs_info, gang[i]);
  864. }
  865. return 0;
  866. }
  867. int close_ctree(struct btrfs_root *root)
  868. {
  869. int ret;
  870. struct btrfs_trans_handle *trans;
  871. struct btrfs_fs_info *fs_info = root->fs_info;
  872. fs_info->closing = 1;
  873. btrfs_transaction_flush_work(root);
  874. mutex_lock(&fs_info->fs_mutex);
  875. btrfs_defrag_dirty_roots(root->fs_info);
  876. trans = btrfs_start_transaction(root, 1);
  877. ret = btrfs_commit_transaction(trans, root);
  878. /* run commit again to drop the original snapshot */
  879. trans = btrfs_start_transaction(root, 1);
  880. btrfs_commit_transaction(trans, root);
  881. ret = btrfs_write_and_wait_transaction(NULL, root);
  882. BUG_ON(ret);
  883. write_ctree_super(NULL, root);
  884. mutex_unlock(&fs_info->fs_mutex);
  885. if (fs_info->delalloc_bytes) {
  886. printk("btrfs: at unmount delalloc count %Lu\n",
  887. fs_info->delalloc_bytes);
  888. }
  889. if (fs_info->extent_root->node)
  890. free_extent_buffer(fs_info->extent_root->node);
  891. if (fs_info->tree_root->node)
  892. free_extent_buffer(fs_info->tree_root->node);
  893. if (root->fs_info->chunk_root->node);
  894. free_extent_buffer(root->fs_info->chunk_root->node);
  895. if (root->fs_info->dev_root->node);
  896. free_extent_buffer(root->fs_info->dev_root->node);
  897. free_extent_buffer(fs_info->sb_buffer);
  898. btrfs_free_block_groups(root->fs_info);
  899. del_fs_roots(fs_info);
  900. filemap_write_and_wait(fs_info->btree_inode->i_mapping);
  901. extent_io_tree_empty_lru(&fs_info->free_space_cache);
  902. extent_io_tree_empty_lru(&fs_info->block_group_cache);
  903. extent_io_tree_empty_lru(&fs_info->pinned_extents);
  904. extent_io_tree_empty_lru(&fs_info->pending_del);
  905. extent_io_tree_empty_lru(&fs_info->extent_ins);
  906. extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree);
  907. truncate_inode_pages(fs_info->btree_inode->i_mapping, 0);
  908. iput(fs_info->btree_inode);
  909. #if 0
  910. while(!list_empty(&fs_info->hashers)) {
  911. struct btrfs_hasher *hasher;
  912. hasher = list_entry(fs_info->hashers.next, struct btrfs_hasher,
  913. hashers);
  914. list_del(&hasher->hashers);
  915. crypto_free_hash(&fs_info->hash_tfm);
  916. kfree(hasher);
  917. }
  918. #endif
  919. close_all_devices(fs_info);
  920. btrfs_mapping_tree_free(&fs_info->mapping_tree);
  921. bdi_destroy(&fs_info->bdi);
  922. kfree(fs_info->extent_root);
  923. kfree(fs_info->tree_root);
  924. kfree(fs_info->chunk_root);
  925. kfree(fs_info->dev_root);
  926. return 0;
  927. }
  928. int btrfs_buffer_uptodate(struct extent_buffer *buf)
  929. {
  930. struct inode *btree_inode = buf->first_page->mapping->host;
  931. return extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf);
  932. }
  933. int btrfs_set_buffer_uptodate(struct extent_buffer *buf)
  934. {
  935. struct inode *btree_inode = buf->first_page->mapping->host;
  936. return set_extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree,
  937. buf);
  938. }
  939. void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
  940. {
  941. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  942. u64 transid = btrfs_header_generation(buf);
  943. struct inode *btree_inode = root->fs_info->btree_inode;
  944. if (transid != root->fs_info->generation) {
  945. printk(KERN_CRIT "transid mismatch buffer %llu, found %Lu running %Lu\n",
  946. (unsigned long long)buf->start,
  947. transid, root->fs_info->generation);
  948. WARN_ON(1);
  949. }
  950. set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf);
  951. }
  952. void btrfs_throttle(struct btrfs_root *root)
  953. {
  954. struct backing_dev_info *bdi;
  955. bdi = root->fs_info->sb->s_bdev->bd_inode->i_mapping->backing_dev_info;
  956. if (root->fs_info->throttles && bdi_write_congested(bdi)) {
  957. #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
  958. congestion_wait(WRITE, HZ/20);
  959. #else
  960. blk_congestion_wait(WRITE, HZ/20);
  961. #endif
  962. }
  963. }
  964. void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
  965. {
  966. balance_dirty_pages_ratelimited_nr(
  967. root->fs_info->btree_inode->i_mapping, 1);
  968. }
  969. void btrfs_set_buffer_defrag(struct extent_buffer *buf)
  970. {
  971. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  972. struct inode *btree_inode = root->fs_info->btree_inode;
  973. set_extent_bits(&BTRFS_I(btree_inode)->io_tree, buf->start,
  974. buf->start + buf->len - 1, EXTENT_DEFRAG, GFP_NOFS);
  975. }
  976. void btrfs_set_buffer_defrag_done(struct extent_buffer *buf)
  977. {
  978. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  979. struct inode *btree_inode = root->fs_info->btree_inode;
  980. set_extent_bits(&BTRFS_I(btree_inode)->io_tree, buf->start,
  981. buf->start + buf->len - 1, EXTENT_DEFRAG_DONE,
  982. GFP_NOFS);
  983. }
  984. int btrfs_buffer_defrag(struct extent_buffer *buf)
  985. {
  986. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  987. struct inode *btree_inode = root->fs_info->btree_inode;
  988. return test_range_bit(&BTRFS_I(btree_inode)->io_tree,
  989. buf->start, buf->start + buf->len - 1, EXTENT_DEFRAG, 0);
  990. }
  991. int btrfs_buffer_defrag_done(struct extent_buffer *buf)
  992. {
  993. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  994. struct inode *btree_inode = root->fs_info->btree_inode;
  995. return test_range_bit(&BTRFS_I(btree_inode)->io_tree,
  996. buf->start, buf->start + buf->len - 1,
  997. EXTENT_DEFRAG_DONE, 0);
  998. }
  999. int btrfs_clear_buffer_defrag_done(struct extent_buffer *buf)
  1000. {
  1001. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  1002. struct inode *btree_inode = root->fs_info->btree_inode;
  1003. return clear_extent_bits(&BTRFS_I(btree_inode)->io_tree,
  1004. buf->start, buf->start + buf->len - 1,
  1005. EXTENT_DEFRAG_DONE, GFP_NOFS);
  1006. }
  1007. int btrfs_clear_buffer_defrag(struct extent_buffer *buf)
  1008. {
  1009. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  1010. struct inode *btree_inode = root->fs_info->btree_inode;
  1011. return clear_extent_bits(&BTRFS_I(btree_inode)->io_tree,
  1012. buf->start, buf->start + buf->len - 1,
  1013. EXTENT_DEFRAG, GFP_NOFS);
  1014. }
  1015. int btrfs_read_buffer(struct extent_buffer *buf)
  1016. {
  1017. struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
  1018. struct inode *btree_inode = root->fs_info->btree_inode;
  1019. return read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree,
  1020. buf, 0, 1, btree_get_extent);
  1021. }
  1022. static struct extent_io_ops btree_extent_io_ops = {
  1023. .writepage_io_hook = btree_writepage_io_hook,
  1024. .submit_bio_hook = btree_submit_bio_hook,
  1025. /* note we're sharing with inode.c for the merge bio hook */
  1026. .merge_bio_hook = btrfs_merge_bio_hook,
  1027. };