ctree.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  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. #ifndef __BTRFS__
  19. #define __BTRFS__
  20. #include <linux/fs.h>
  21. #include <linux/buffer_head.h>
  22. #include <linux/workqueue.h>
  23. #include <linux/completion.h>
  24. #include "bit-radix.h"
  25. struct btrfs_trans_handle;
  26. struct btrfs_transaction;
  27. extern struct kmem_cache *btrfs_trans_handle_cachep;
  28. extern struct kmem_cache *btrfs_transaction_cachep;
  29. extern struct kmem_cache *btrfs_bit_radix_cachep;
  30. extern struct kmem_cache *btrfs_path_cachep;
  31. #define BTRFS_MAGIC "_BtRfS_M"
  32. #define BTRFS_ROOT_TREE_OBJECTID 1ULL
  33. #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
  34. #define BTRFS_FS_TREE_OBJECTID 3ULL
  35. #define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
  36. #define BTRFS_FIRST_FREE_OBJECTID 5ULL
  37. /*
  38. * we can actually store much bigger names, but lets not confuse the rest
  39. * of linux
  40. */
  41. #define BTRFS_NAME_LEN 255
  42. /* 32 bytes in various csum fields */
  43. #define BTRFS_CSUM_SIZE 32
  44. /* four bytes for CRC32 */
  45. #define BTRFS_CRC32_SIZE 4
  46. #define BTRFS_EMPTY_DIR_SIZE 6
  47. #define BTRFS_FT_UNKNOWN 0
  48. #define BTRFS_FT_REG_FILE 1
  49. #define BTRFS_FT_DIR 2
  50. #define BTRFS_FT_CHRDEV 3
  51. #define BTRFS_FT_BLKDEV 4
  52. #define BTRFS_FT_FIFO 5
  53. #define BTRFS_FT_SOCK 6
  54. #define BTRFS_FT_SYMLINK 7
  55. #define BTRFS_FT_MAX 8
  56. /*
  57. * the key defines the order in the tree, and so it also defines (optimal)
  58. * block layout. objectid corresonds to the inode number. The flags
  59. * tells us things about the object, and is a kind of stream selector.
  60. * so for a given inode, keys with flags of 1 might refer to the inode
  61. * data, flags of 2 may point to file data in the btree and flags == 3
  62. * may point to extents.
  63. *
  64. * offset is the starting byte offset for this key in the stream.
  65. *
  66. * btrfs_disk_key is in disk byte order. struct btrfs_key is always
  67. * in cpu native order. Otherwise they are identical and their sizes
  68. * should be the same (ie both packed)
  69. */
  70. struct btrfs_disk_key {
  71. __le64 objectid;
  72. __le32 flags;
  73. __le64 offset;
  74. } __attribute__ ((__packed__));
  75. struct btrfs_key {
  76. u64 objectid;
  77. u32 flags;
  78. u64 offset;
  79. } __attribute__ ((__packed__));
  80. /*
  81. * every tree block (leaf or node) starts with this header.
  82. */
  83. struct btrfs_header {
  84. u8 csum[BTRFS_CSUM_SIZE];
  85. u8 fsid[16]; /* FS specific uuid */
  86. __le64 blocknr; /* which block this node is supposed to live in */
  87. __le64 generation;
  88. __le64 owner;
  89. __le16 nritems;
  90. __le16 flags;
  91. u8 level;
  92. } __attribute__ ((__packed__));
  93. #define BTRFS_MAX_LEVEL 8
  94. #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->blocksize - \
  95. sizeof(struct btrfs_header)) / \
  96. (sizeof(struct btrfs_disk_key) + sizeof(u64)))
  97. #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
  98. #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->blocksize))
  99. #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
  100. sizeof(struct btrfs_item) - \
  101. sizeof(struct btrfs_file_extent_item))
  102. struct buffer_head;
  103. /*
  104. * the super block basically lists the main trees of the FS
  105. * it currently lacks any block count etc etc
  106. */
  107. struct btrfs_super_block {
  108. u8 csum[BTRFS_CSUM_SIZE];
  109. /* the first 3 fields must match struct btrfs_header */
  110. u8 fsid[16]; /* FS specific uuid */
  111. __le64 blocknr; /* this block number */
  112. __le64 magic;
  113. __le64 generation;
  114. __le64 root;
  115. __le64 total_blocks;
  116. __le64 blocks_used;
  117. __le64 root_dir_objectid;
  118. __le32 blocksize;
  119. } __attribute__ ((__packed__));
  120. /*
  121. * A leaf is full of items. offset and size tell us where to find
  122. * the item in the leaf (relative to the start of the data area)
  123. */
  124. struct btrfs_item {
  125. struct btrfs_disk_key key;
  126. __le32 offset;
  127. __le16 size;
  128. } __attribute__ ((__packed__));
  129. /*
  130. * leaves have an item area and a data area:
  131. * [item0, item1....itemN] [free space] [dataN...data1, data0]
  132. *
  133. * The data is separate from the items to get the keys closer together
  134. * during searches.
  135. */
  136. struct btrfs_leaf {
  137. struct btrfs_header header;
  138. struct btrfs_item items[];
  139. } __attribute__ ((__packed__));
  140. /*
  141. * all non-leaf blocks are nodes, they hold only keys and pointers to
  142. * other blocks
  143. */
  144. struct btrfs_key_ptr {
  145. struct btrfs_disk_key key;
  146. __le64 blockptr;
  147. } __attribute__ ((__packed__));
  148. struct btrfs_node {
  149. struct btrfs_header header;
  150. struct btrfs_key_ptr ptrs[];
  151. } __attribute__ ((__packed__));
  152. /*
  153. * btrfs_paths remember the path taken from the root down to the leaf.
  154. * level 0 is always the leaf, and nodes[1...BTRFS_MAX_LEVEL] will point
  155. * to any other levels that are present.
  156. *
  157. * The slots array records the index of the item or block pointer
  158. * used while walking the tree.
  159. */
  160. struct btrfs_path {
  161. struct buffer_head *nodes[BTRFS_MAX_LEVEL];
  162. int slots[BTRFS_MAX_LEVEL];
  163. int reada;
  164. int lowest_level;
  165. };
  166. /*
  167. * items in the extent btree are used to record the objectid of the
  168. * owner of the block and the number of references
  169. */
  170. struct btrfs_extent_item {
  171. __le32 refs;
  172. __le64 owner;
  173. } __attribute__ ((__packed__));
  174. struct btrfs_inode_timespec {
  175. __le64 sec;
  176. __le32 nsec;
  177. } __attribute__ ((__packed__));
  178. /*
  179. * there is no padding here on purpose. If you want to extent the inode,
  180. * make a new item type
  181. */
  182. struct btrfs_inode_item {
  183. __le64 generation;
  184. __le64 size;
  185. __le64 nblocks;
  186. __le64 block_group;
  187. __le32 nlink;
  188. __le32 uid;
  189. __le32 gid;
  190. __le32 mode;
  191. __le32 rdev;
  192. __le16 flags;
  193. __le16 compat_flags;
  194. struct btrfs_inode_timespec atime;
  195. struct btrfs_inode_timespec ctime;
  196. struct btrfs_inode_timespec mtime;
  197. struct btrfs_inode_timespec otime;
  198. } __attribute__ ((__packed__));
  199. struct btrfs_dir_item {
  200. struct btrfs_disk_key location;
  201. __le16 flags;
  202. __le16 name_len;
  203. u8 type;
  204. } __attribute__ ((__packed__));
  205. struct btrfs_root_item {
  206. struct btrfs_inode_item inode;
  207. __le64 root_dirid;
  208. __le64 blocknr;
  209. __le64 block_limit;
  210. __le64 blocks_used;
  211. __le32 flags;
  212. __le32 refs;
  213. struct btrfs_disk_key drop_progress;
  214. u8 drop_level;
  215. } __attribute__ ((__packed__));
  216. #define BTRFS_FILE_EXTENT_REG 0
  217. #define BTRFS_FILE_EXTENT_INLINE 1
  218. struct btrfs_file_extent_item {
  219. __le64 generation;
  220. u8 type;
  221. /*
  222. * disk space consumed by the extent, checksum blocks are included
  223. * in these numbers
  224. */
  225. __le64 disk_blocknr;
  226. __le64 disk_num_blocks;
  227. /*
  228. * the logical offset in file blocks (no csums)
  229. * this extent record is for. This allows a file extent to point
  230. * into the middle of an existing extent on disk, sharing it
  231. * between two snapshots (useful if some bytes in the middle of the
  232. * extent have changed
  233. */
  234. __le64 offset;
  235. /*
  236. * the logical number of file blocks (no csums included)
  237. */
  238. __le64 num_blocks;
  239. } __attribute__ ((__packed__));
  240. struct btrfs_csum_item {
  241. u8 csum;
  242. } __attribute__ ((__packed__));
  243. /* tag for the radix tree of block groups in ram */
  244. #define BTRFS_BLOCK_GROUP_DIRTY 0
  245. #define BTRFS_BLOCK_GROUP_AVAIL 1
  246. #define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
  247. #define BTRFS_BLOCK_GROUP_DATA 1
  248. struct btrfs_block_group_item {
  249. __le64 used;
  250. u8 flags;
  251. } __attribute__ ((__packed__));
  252. struct btrfs_block_group_cache {
  253. struct btrfs_key key;
  254. struct btrfs_block_group_item item;
  255. struct radix_tree_root *radix;
  256. u64 first_free;
  257. u64 last_alloc;
  258. u64 pinned;
  259. u64 last_prealloc;
  260. int data;
  261. int cached;
  262. };
  263. struct btrfs_fs_info {
  264. struct btrfs_root *extent_root;
  265. struct btrfs_root *tree_root;
  266. struct radix_tree_root fs_roots_radix;
  267. struct radix_tree_root pending_del_radix;
  268. struct radix_tree_root pinned_radix;
  269. struct radix_tree_root block_group_radix;
  270. struct radix_tree_root block_group_data_radix;
  271. struct radix_tree_root extent_map_radix;
  272. struct radix_tree_root extent_ins_radix;
  273. u64 generation;
  274. u64 last_trans_committed;
  275. struct btrfs_transaction *running_transaction;
  276. struct btrfs_super_block *disk_super;
  277. struct btrfs_super_block super_copy;
  278. struct buffer_head *sb_buffer;
  279. struct super_block *sb;
  280. struct inode *btree_inode;
  281. struct mutex trans_mutex;
  282. struct mutex fs_mutex;
  283. struct list_head trans_list;
  284. struct list_head dead_roots;
  285. struct delayed_work trans_work;
  286. struct kobject super_kobj;
  287. struct completion kobj_unregister;
  288. int do_barriers;
  289. int closing;
  290. };
  291. /*
  292. * in ram representation of the tree. extent_root is used for all allocations
  293. * and for the extent tree extent_root root.
  294. */
  295. struct btrfs_root {
  296. struct buffer_head *node;
  297. struct buffer_head *commit_root;
  298. struct btrfs_root_item root_item;
  299. struct btrfs_key root_key;
  300. struct btrfs_fs_info *fs_info;
  301. struct inode *inode;
  302. struct kobject root_kobj;
  303. struct completion kobj_unregister;
  304. struct rw_semaphore snap_sem;
  305. u64 objectid;
  306. u64 last_trans;
  307. u32 blocksize;
  308. u32 type;
  309. u64 highest_inode;
  310. u64 last_inode_alloc;
  311. int ref_cows;
  312. struct btrfs_key defrag_progress;
  313. int defrag_running;
  314. int defrag_level;
  315. char *name;
  316. };
  317. /* the lower bits in the key flags defines the item type */
  318. #define BTRFS_KEY_TYPE_MAX 256
  319. #define BTRFS_KEY_TYPE_SHIFT 24
  320. #define BTRFS_KEY_TYPE_MASK (((u32)BTRFS_KEY_TYPE_MAX - 1) << \
  321. BTRFS_KEY_TYPE_SHIFT)
  322. /*
  323. * inode items have the data typically returned from stat and store other
  324. * info about object characteristics. There is one for every file and dir in
  325. * the FS
  326. */
  327. #define BTRFS_INODE_ITEM_KEY 1
  328. /* reserve 2-15 close to the inode for later flexibility */
  329. /*
  330. * dir items are the name -> inode pointers in a directory. There is one
  331. * for every name in a directory.
  332. */
  333. #define BTRFS_DIR_ITEM_KEY 16
  334. #define BTRFS_DIR_INDEX_KEY 17
  335. /*
  336. * extent data is for file data
  337. */
  338. #define BTRFS_EXTENT_DATA_KEY 18
  339. /*
  340. * csum items have the checksums for data in the extents
  341. */
  342. #define BTRFS_CSUM_ITEM_KEY 19
  343. /* reserve 20-31 for other file stuff */
  344. /*
  345. * root items point to tree roots. There are typically in the root
  346. * tree used by the super block to find all the other trees
  347. */
  348. #define BTRFS_ROOT_ITEM_KEY 32
  349. /*
  350. * extent items are in the extent map tree. These record which blocks
  351. * are used, and how many references there are to each block
  352. */
  353. #define BTRFS_EXTENT_ITEM_KEY 33
  354. /*
  355. * block groups give us hints into the extent allocation trees. Which
  356. * blocks are free etc etc
  357. */
  358. #define BTRFS_BLOCK_GROUP_ITEM_KEY 34
  359. /*
  360. * string items are for debugging. They just store a short string of
  361. * data in the FS
  362. */
  363. #define BTRFS_STRING_ITEM_KEY 253
  364. static inline u64 btrfs_block_group_used(struct btrfs_block_group_item *bi)
  365. {
  366. return le64_to_cpu(bi->used);
  367. }
  368. static inline void btrfs_set_block_group_used(struct
  369. btrfs_block_group_item *bi,
  370. u64 val)
  371. {
  372. bi->used = cpu_to_le64(val);
  373. }
  374. static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
  375. {
  376. return le64_to_cpu(i->generation);
  377. }
  378. static inline void btrfs_set_inode_generation(struct btrfs_inode_item *i,
  379. u64 val)
  380. {
  381. i->generation = cpu_to_le64(val);
  382. }
  383. static inline u64 btrfs_inode_size(struct btrfs_inode_item *i)
  384. {
  385. return le64_to_cpu(i->size);
  386. }
  387. static inline void btrfs_set_inode_size(struct btrfs_inode_item *i, u64 val)
  388. {
  389. i->size = cpu_to_le64(val);
  390. }
  391. static inline u64 btrfs_inode_nblocks(struct btrfs_inode_item *i)
  392. {
  393. return le64_to_cpu(i->nblocks);
  394. }
  395. static inline void btrfs_set_inode_nblocks(struct btrfs_inode_item *i, u64 val)
  396. {
  397. i->nblocks = cpu_to_le64(val);
  398. }
  399. static inline u64 btrfs_inode_block_group(struct btrfs_inode_item *i)
  400. {
  401. return le64_to_cpu(i->block_group);
  402. }
  403. static inline void btrfs_set_inode_block_group(struct btrfs_inode_item *i,
  404. u64 val)
  405. {
  406. i->block_group = cpu_to_le64(val);
  407. }
  408. static inline u32 btrfs_inode_nlink(struct btrfs_inode_item *i)
  409. {
  410. return le32_to_cpu(i->nlink);
  411. }
  412. static inline void btrfs_set_inode_nlink(struct btrfs_inode_item *i, u32 val)
  413. {
  414. i->nlink = cpu_to_le32(val);
  415. }
  416. static inline u32 btrfs_inode_uid(struct btrfs_inode_item *i)
  417. {
  418. return le32_to_cpu(i->uid);
  419. }
  420. static inline void btrfs_set_inode_uid(struct btrfs_inode_item *i, u32 val)
  421. {
  422. i->uid = cpu_to_le32(val);
  423. }
  424. static inline u32 btrfs_inode_gid(struct btrfs_inode_item *i)
  425. {
  426. return le32_to_cpu(i->gid);
  427. }
  428. static inline void btrfs_set_inode_gid(struct btrfs_inode_item *i, u32 val)
  429. {
  430. i->gid = cpu_to_le32(val);
  431. }
  432. static inline u32 btrfs_inode_mode(struct btrfs_inode_item *i)
  433. {
  434. return le32_to_cpu(i->mode);
  435. }
  436. static inline void btrfs_set_inode_mode(struct btrfs_inode_item *i, u32 val)
  437. {
  438. i->mode = cpu_to_le32(val);
  439. }
  440. static inline u32 btrfs_inode_rdev(struct btrfs_inode_item *i)
  441. {
  442. return le32_to_cpu(i->rdev);
  443. }
  444. static inline void btrfs_set_inode_rdev(struct btrfs_inode_item *i, u32 val)
  445. {
  446. i->rdev = cpu_to_le32(val);
  447. }
  448. static inline u16 btrfs_inode_flags(struct btrfs_inode_item *i)
  449. {
  450. return le16_to_cpu(i->flags);
  451. }
  452. static inline void btrfs_set_inode_flags(struct btrfs_inode_item *i, u16 val)
  453. {
  454. i->flags = cpu_to_le16(val);
  455. }
  456. static inline u16 btrfs_inode_compat_flags(struct btrfs_inode_item *i)
  457. {
  458. return le16_to_cpu(i->compat_flags);
  459. }
  460. static inline void btrfs_set_inode_compat_flags(struct btrfs_inode_item *i,
  461. u16 val)
  462. {
  463. i->compat_flags = cpu_to_le16(val);
  464. }
  465. static inline u64 btrfs_timespec_sec(struct btrfs_inode_timespec *ts)
  466. {
  467. return le64_to_cpu(ts->sec);
  468. }
  469. static inline void btrfs_set_timespec_sec(struct btrfs_inode_timespec *ts,
  470. u64 val)
  471. {
  472. ts->sec = cpu_to_le64(val);
  473. }
  474. static inline u32 btrfs_timespec_nsec(struct btrfs_inode_timespec *ts)
  475. {
  476. return le32_to_cpu(ts->nsec);
  477. }
  478. static inline void btrfs_set_timespec_nsec(struct btrfs_inode_timespec *ts,
  479. u32 val)
  480. {
  481. ts->nsec = cpu_to_le32(val);
  482. }
  483. static inline u32 btrfs_extent_refs(struct btrfs_extent_item *ei)
  484. {
  485. return le32_to_cpu(ei->refs);
  486. }
  487. static inline void btrfs_set_extent_refs(struct btrfs_extent_item *ei, u32 val)
  488. {
  489. ei->refs = cpu_to_le32(val);
  490. }
  491. static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei)
  492. {
  493. return le64_to_cpu(ei->owner);
  494. }
  495. static inline void btrfs_set_extent_owner(struct btrfs_extent_item *ei, u64 val)
  496. {
  497. ei->owner = cpu_to_le64(val);
  498. }
  499. static inline u64 btrfs_node_blockptr(struct btrfs_node *n, int nr)
  500. {
  501. return le64_to_cpu(n->ptrs[nr].blockptr);
  502. }
  503. static inline void btrfs_set_node_blockptr(struct btrfs_node *n, int nr,
  504. u64 val)
  505. {
  506. n->ptrs[nr].blockptr = cpu_to_le64(val);
  507. }
  508. static inline u32 btrfs_item_offset(struct btrfs_item *item)
  509. {
  510. return le32_to_cpu(item->offset);
  511. }
  512. static inline void btrfs_set_item_offset(struct btrfs_item *item, u32 val)
  513. {
  514. item->offset = cpu_to_le32(val);
  515. }
  516. static inline u32 btrfs_item_end(struct btrfs_item *item)
  517. {
  518. return le32_to_cpu(item->offset) + le16_to_cpu(item->size);
  519. }
  520. static inline u16 btrfs_item_size(struct btrfs_item *item)
  521. {
  522. return le16_to_cpu(item->size);
  523. }
  524. static inline void btrfs_set_item_size(struct btrfs_item *item, u16 val)
  525. {
  526. item->size = cpu_to_le16(val);
  527. }
  528. static inline u16 btrfs_dir_flags(struct btrfs_dir_item *d)
  529. {
  530. return le16_to_cpu(d->flags);
  531. }
  532. static inline void btrfs_set_dir_flags(struct btrfs_dir_item *d, u16 val)
  533. {
  534. d->flags = cpu_to_le16(val);
  535. }
  536. static inline u8 btrfs_dir_type(struct btrfs_dir_item *d)
  537. {
  538. return d->type;
  539. }
  540. static inline void btrfs_set_dir_type(struct btrfs_dir_item *d, u8 val)
  541. {
  542. d->type = val;
  543. }
  544. static inline u16 btrfs_dir_name_len(struct btrfs_dir_item *d)
  545. {
  546. return le16_to_cpu(d->name_len);
  547. }
  548. static inline void btrfs_set_dir_name_len(struct btrfs_dir_item *d, u16 val)
  549. {
  550. d->name_len = cpu_to_le16(val);
  551. }
  552. static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
  553. struct btrfs_disk_key *disk)
  554. {
  555. cpu->offset = le64_to_cpu(disk->offset);
  556. cpu->flags = le32_to_cpu(disk->flags);
  557. cpu->objectid = le64_to_cpu(disk->objectid);
  558. }
  559. static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk,
  560. struct btrfs_key *cpu)
  561. {
  562. disk->offset = cpu_to_le64(cpu->offset);
  563. disk->flags = cpu_to_le32(cpu->flags);
  564. disk->objectid = cpu_to_le64(cpu->objectid);
  565. }
  566. static inline u64 btrfs_disk_key_objectid(struct btrfs_disk_key *disk)
  567. {
  568. return le64_to_cpu(disk->objectid);
  569. }
  570. static inline void btrfs_set_disk_key_objectid(struct btrfs_disk_key *disk,
  571. u64 val)
  572. {
  573. disk->objectid = cpu_to_le64(val);
  574. }
  575. static inline u64 btrfs_disk_key_offset(struct btrfs_disk_key *disk)
  576. {
  577. return le64_to_cpu(disk->offset);
  578. }
  579. static inline void btrfs_set_disk_key_offset(struct btrfs_disk_key *disk,
  580. u64 val)
  581. {
  582. disk->offset = cpu_to_le64(val);
  583. }
  584. static inline u32 btrfs_disk_key_flags(struct btrfs_disk_key *disk)
  585. {
  586. return le32_to_cpu(disk->flags);
  587. }
  588. static inline void btrfs_set_disk_key_flags(struct btrfs_disk_key *disk,
  589. u32 val)
  590. {
  591. disk->flags = cpu_to_le32(val);
  592. }
  593. static inline u32 btrfs_disk_key_type(struct btrfs_disk_key *key)
  594. {
  595. return le32_to_cpu(key->flags) >> BTRFS_KEY_TYPE_SHIFT;
  596. }
  597. static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key,
  598. u32 val)
  599. {
  600. u32 flags = btrfs_disk_key_flags(key);
  601. BUG_ON(val >= BTRFS_KEY_TYPE_MAX);
  602. val = val << BTRFS_KEY_TYPE_SHIFT;
  603. flags = (flags & ~BTRFS_KEY_TYPE_MASK) | val;
  604. btrfs_set_disk_key_flags(key, flags);
  605. }
  606. static inline u32 btrfs_key_type(struct btrfs_key *key)
  607. {
  608. return key->flags >> BTRFS_KEY_TYPE_SHIFT;
  609. }
  610. static inline void btrfs_set_key_type(struct btrfs_key *key, u32 val)
  611. {
  612. BUG_ON(val >= BTRFS_KEY_TYPE_MAX);
  613. val = val << BTRFS_KEY_TYPE_SHIFT;
  614. key->flags = (key->flags & ~(BTRFS_KEY_TYPE_MASK)) | val;
  615. }
  616. static inline u64 btrfs_header_blocknr(struct btrfs_header *h)
  617. {
  618. return le64_to_cpu(h->blocknr);
  619. }
  620. static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
  621. {
  622. h->blocknr = cpu_to_le64(blocknr);
  623. }
  624. static inline u64 btrfs_header_generation(struct btrfs_header *h)
  625. {
  626. return le64_to_cpu(h->generation);
  627. }
  628. static inline void btrfs_set_header_generation(struct btrfs_header *h,
  629. u64 val)
  630. {
  631. h->generation = cpu_to_le64(val);
  632. }
  633. static inline u64 btrfs_header_owner(struct btrfs_header *h)
  634. {
  635. return le64_to_cpu(h->owner);
  636. }
  637. static inline void btrfs_set_header_owner(struct btrfs_header *h,
  638. u64 val)
  639. {
  640. h->owner = cpu_to_le64(val);
  641. }
  642. static inline u16 btrfs_header_nritems(struct btrfs_header *h)
  643. {
  644. return le16_to_cpu(h->nritems);
  645. }
  646. static inline void btrfs_set_header_nritems(struct btrfs_header *h, u16 val)
  647. {
  648. h->nritems = cpu_to_le16(val);
  649. }
  650. static inline u16 btrfs_header_flags(struct btrfs_header *h)
  651. {
  652. return le16_to_cpu(h->flags);
  653. }
  654. static inline void btrfs_set_header_flags(struct btrfs_header *h, u16 val)
  655. {
  656. h->flags = cpu_to_le16(val);
  657. }
  658. static inline int btrfs_header_level(struct btrfs_header *h)
  659. {
  660. return h->level;
  661. }
  662. static inline void btrfs_set_header_level(struct btrfs_header *h, int level)
  663. {
  664. BUG_ON(level > BTRFS_MAX_LEVEL);
  665. h->level = level;
  666. }
  667. static inline int btrfs_is_leaf(struct btrfs_node *n)
  668. {
  669. return (btrfs_header_level(&n->header) == 0);
  670. }
  671. static inline u64 btrfs_root_blocknr(struct btrfs_root_item *item)
  672. {
  673. return le64_to_cpu(item->blocknr);
  674. }
  675. static inline void btrfs_set_root_blocknr(struct btrfs_root_item *item, u64 val)
  676. {
  677. item->blocknr = cpu_to_le64(val);
  678. }
  679. static inline u64 btrfs_root_dirid(struct btrfs_root_item *item)
  680. {
  681. return le64_to_cpu(item->root_dirid);
  682. }
  683. static inline void btrfs_set_root_dirid(struct btrfs_root_item *item, u64 val)
  684. {
  685. item->root_dirid = cpu_to_le64(val);
  686. }
  687. static inline u32 btrfs_root_refs(struct btrfs_root_item *item)
  688. {
  689. return le32_to_cpu(item->refs);
  690. }
  691. static inline void btrfs_set_root_refs(struct btrfs_root_item *item, u32 val)
  692. {
  693. item->refs = cpu_to_le32(val);
  694. }
  695. static inline u32 btrfs_root_flags(struct btrfs_root_item *item)
  696. {
  697. return le32_to_cpu(item->flags);
  698. }
  699. static inline void btrfs_set_root_flags(struct btrfs_root_item *item, u32 val)
  700. {
  701. item->flags = cpu_to_le32(val);
  702. }
  703. static inline void btrfs_set_root_blocks_used(struct btrfs_root_item *item,
  704. u64 val)
  705. {
  706. item->blocks_used = cpu_to_le64(val);
  707. }
  708. static inline u64 btrfs_root_blocks_used(struct btrfs_root_item *item)
  709. {
  710. return le64_to_cpu(item->blocks_used);
  711. }
  712. static inline void btrfs_set_root_block_limit(struct btrfs_root_item *item,
  713. u64 val)
  714. {
  715. item->block_limit = cpu_to_le64(val);
  716. }
  717. static inline u64 btrfs_root_block_limit(struct btrfs_root_item *item)
  718. {
  719. return le64_to_cpu(item->block_limit);
  720. }
  721. static inline u64 btrfs_super_blocknr(struct btrfs_super_block *s)
  722. {
  723. return le64_to_cpu(s->blocknr);
  724. }
  725. static inline void btrfs_set_super_blocknr(struct btrfs_super_block *s, u64 val)
  726. {
  727. s->blocknr = cpu_to_le64(val);
  728. }
  729. static inline u64 btrfs_super_generation(struct btrfs_super_block *s)
  730. {
  731. return le64_to_cpu(s->generation);
  732. }
  733. static inline void btrfs_set_super_generation(struct btrfs_super_block *s,
  734. u64 val)
  735. {
  736. s->generation = cpu_to_le64(val);
  737. }
  738. static inline u64 btrfs_super_root(struct btrfs_super_block *s)
  739. {
  740. return le64_to_cpu(s->root);
  741. }
  742. static inline void btrfs_set_super_root(struct btrfs_super_block *s, u64 val)
  743. {
  744. s->root = cpu_to_le64(val);
  745. }
  746. static inline u64 btrfs_super_total_blocks(struct btrfs_super_block *s)
  747. {
  748. return le64_to_cpu(s->total_blocks);
  749. }
  750. static inline void btrfs_set_super_total_blocks(struct btrfs_super_block *s,
  751. u64 val)
  752. {
  753. s->total_blocks = cpu_to_le64(val);
  754. }
  755. static inline u64 btrfs_super_blocks_used(struct btrfs_super_block *s)
  756. {
  757. return le64_to_cpu(s->blocks_used);
  758. }
  759. static inline void btrfs_set_super_blocks_used(struct btrfs_super_block *s,
  760. u64 val)
  761. {
  762. s->blocks_used = cpu_to_le64(val);
  763. }
  764. static inline u32 btrfs_super_blocksize(struct btrfs_super_block *s)
  765. {
  766. return le32_to_cpu(s->blocksize);
  767. }
  768. static inline void btrfs_set_super_blocksize(struct btrfs_super_block *s,
  769. u32 val)
  770. {
  771. s->blocksize = cpu_to_le32(val);
  772. }
  773. static inline u64 btrfs_super_root_dir(struct btrfs_super_block *s)
  774. {
  775. return le64_to_cpu(s->root_dir_objectid);
  776. }
  777. static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64
  778. val)
  779. {
  780. s->root_dir_objectid = cpu_to_le64(val);
  781. }
  782. static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
  783. {
  784. return (u8 *)l->items;
  785. }
  786. static inline int btrfs_file_extent_type(struct btrfs_file_extent_item *e)
  787. {
  788. return e->type;
  789. }
  790. static inline void btrfs_set_file_extent_type(struct btrfs_file_extent_item *e,
  791. u8 val)
  792. {
  793. e->type = val;
  794. }
  795. static inline char *btrfs_file_extent_inline_start(struct
  796. btrfs_file_extent_item *e)
  797. {
  798. return (char *)(&e->disk_blocknr);
  799. }
  800. static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
  801. {
  802. return (unsigned long)(&((struct
  803. btrfs_file_extent_item *)NULL)->disk_blocknr) + datasize;
  804. }
  805. static inline u32 btrfs_file_extent_inline_len(struct btrfs_item *e)
  806. {
  807. struct btrfs_file_extent_item *fe = NULL;
  808. return btrfs_item_size(e) - (unsigned long)(&fe->disk_blocknr);
  809. }
  810. static inline u64 btrfs_file_extent_disk_blocknr(struct btrfs_file_extent_item
  811. *e)
  812. {
  813. return le64_to_cpu(e->disk_blocknr);
  814. }
  815. static inline void btrfs_set_file_extent_disk_blocknr(struct
  816. btrfs_file_extent_item
  817. *e, u64 val)
  818. {
  819. e->disk_blocknr = cpu_to_le64(val);
  820. }
  821. static inline u64 btrfs_file_extent_generation(struct btrfs_file_extent_item *e)
  822. {
  823. return le64_to_cpu(e->generation);
  824. }
  825. static inline void btrfs_set_file_extent_generation(struct
  826. btrfs_file_extent_item *e,
  827. u64 val)
  828. {
  829. e->generation = cpu_to_le64(val);
  830. }
  831. static inline u64 btrfs_file_extent_disk_num_blocks(struct
  832. btrfs_file_extent_item *e)
  833. {
  834. return le64_to_cpu(e->disk_num_blocks);
  835. }
  836. static inline void btrfs_set_file_extent_disk_num_blocks(struct
  837. btrfs_file_extent_item
  838. *e, u64 val)
  839. {
  840. e->disk_num_blocks = cpu_to_le64(val);
  841. }
  842. static inline u64 btrfs_file_extent_offset(struct btrfs_file_extent_item *e)
  843. {
  844. return le64_to_cpu(e->offset);
  845. }
  846. static inline void btrfs_set_file_extent_offset(struct btrfs_file_extent_item
  847. *e, u64 val)
  848. {
  849. e->offset = cpu_to_le64(val);
  850. }
  851. static inline u64 btrfs_file_extent_num_blocks(struct btrfs_file_extent_item
  852. *e)
  853. {
  854. return le64_to_cpu(e->num_blocks);
  855. }
  856. static inline void btrfs_set_file_extent_num_blocks(struct
  857. btrfs_file_extent_item *e,
  858. u64 val)
  859. {
  860. e->num_blocks = cpu_to_le64(val);
  861. }
  862. static inline struct btrfs_root *btrfs_sb(struct super_block *sb)
  863. {
  864. return sb->s_fs_info;
  865. }
  866. static inline void btrfs_check_bounds(void *vptr, size_t len,
  867. void *vcontainer, size_t container_len)
  868. {
  869. char *ptr = vptr;
  870. char *container = vcontainer;
  871. WARN_ON(ptr < container);
  872. WARN_ON(ptr + len > container + container_len);
  873. }
  874. static inline void btrfs_memcpy(struct btrfs_root *root,
  875. void *dst_block,
  876. void *dst, const void *src, size_t nr)
  877. {
  878. btrfs_check_bounds(dst, nr, dst_block, root->fs_info->sb->s_blocksize);
  879. memcpy(dst, src, nr);
  880. }
  881. static inline void btrfs_memmove(struct btrfs_root *root,
  882. void *dst_block,
  883. void *dst, void *src, size_t nr)
  884. {
  885. btrfs_check_bounds(dst, nr, dst_block, root->fs_info->sb->s_blocksize);
  886. memmove(dst, src, nr);
  887. }
  888. static inline int btrfs_set_root_name(struct btrfs_root *root,
  889. const char *name, int len)
  890. {
  891. /* if we already have a name just free it */
  892. if (root->name)
  893. kfree(root->name);
  894. root->name = kmalloc(len+1, GFP_KERNEL);
  895. if (!root->name)
  896. return -ENOMEM;
  897. memcpy(root->name, name, len);
  898. root->name[len] ='\0';
  899. return 0;
  900. }
  901. /* helper function to cast into the data area of the leaf. */
  902. #define btrfs_item_ptr(leaf, slot, type) \
  903. ((type *)(btrfs_leaf_data(leaf) + \
  904. btrfs_item_offset((leaf)->items + (slot))))
  905. /* mount option defines and helpers */
  906. #define BTRFS_MOUNT_SUBVOL 0x000001
  907. #define btrfs_clear_opt(o, opt) o &= ~BTRFS_MOUNT_##opt
  908. #define btrfs_set_opt(o, opt) o |= BTRFS_MOUNT_##opt
  909. #define btrfs_test_opt(sb, opt) (BTRFS_SB(sb)->s_mount_opt & \
  910. BTRFS_MOUNT_##opt)
  911. /* extent-tree.c */
  912. int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
  913. struct btrfs_root *root);
  914. int btrfs_copy_pinned(struct btrfs_root *root, struct radix_tree_root *copy);
  915. struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
  916. btrfs_fs_info *info,
  917. u64 blocknr);
  918. struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
  919. struct btrfs_block_group_cache
  920. *hint, u64 search_start,
  921. int data, int owner);
  922. int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
  923. struct btrfs_root *root);
  924. struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
  925. struct btrfs_root *root, u64 hint,
  926. u64 empty_size);
  927. int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
  928. struct btrfs_root *root, u64 owner,
  929. u64 num_blocks, u64 empty_size, u64 search_start,
  930. u64 search_end, struct btrfs_key *ins, int data);
  931. int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
  932. struct buffer_head *buf);
  933. int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
  934. *root, u64 blocknr, u64 num_blocks, int pin);
  935. int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
  936. struct btrfs_root *root,
  937. struct radix_tree_root *unpin_radix);
  938. int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
  939. struct btrfs_root *root,
  940. u64 blocknr, u64 num_blocks);
  941. int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
  942. struct btrfs_root *root);
  943. int btrfs_free_block_groups(struct btrfs_fs_info *info);
  944. int btrfs_read_block_groups(struct btrfs_root *root);
  945. /* ctree.c */
  946. int btrfs_cow_block(struct btrfs_trans_handle *trans, struct btrfs_root
  947. *root, struct buffer_head *buf, struct buffer_head
  948. *parent, int parent_slot, struct buffer_head
  949. **cow_ret);
  950. int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
  951. *root, struct btrfs_path *path, u32 data_size);
  952. int btrfs_truncate_item(struct btrfs_trans_handle *trans,
  953. struct btrfs_root *root,
  954. struct btrfs_path *path,
  955. u32 new_size);
  956. int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
  957. *root, struct btrfs_key *key, struct btrfs_path *p, int
  958. ins_len, int cow);
  959. int btrfs_realloc_node(struct btrfs_trans_handle *trans,
  960. struct btrfs_root *root, struct buffer_head *parent,
  961. int cache_only, u64 *last_ret);
  962. void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
  963. struct btrfs_path *btrfs_alloc_path(void);
  964. void btrfs_free_path(struct btrfs_path *p);
  965. void btrfs_init_path(struct btrfs_path *p);
  966. int btrfs_del_item(struct btrfs_trans_handle *trans, struct btrfs_root *root,
  967. struct btrfs_path *path);
  968. int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
  969. *root, struct btrfs_key *key, void *data, u32 data_size);
  970. int btrfs_insert_empty_item(struct btrfs_trans_handle *trans, struct btrfs_root
  971. *root, struct btrfs_path *path, struct btrfs_key
  972. *cpu_key, u32 data_size);
  973. int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
  974. int btrfs_leaf_free_space(struct btrfs_root *root, struct btrfs_leaf *leaf);
  975. int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
  976. *root);
  977. /* root-item.c */
  978. int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
  979. struct btrfs_key *key);
  980. int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
  981. *root, struct btrfs_key *key, struct btrfs_root_item
  982. *item);
  983. int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
  984. *root, struct btrfs_key *key, struct btrfs_root_item
  985. *item);
  986. int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
  987. btrfs_root_item *item, struct btrfs_key *key);
  988. int btrfs_find_dead_roots(struct btrfs_root *root);
  989. /* dir-item.c */
  990. int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
  991. *root, const char *name, int name_len, u64 dir,
  992. struct btrfs_key *location, u8 type);
  993. struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
  994. struct btrfs_root *root,
  995. struct btrfs_path *path, u64 dir,
  996. const char *name, int name_len,
  997. int mod);
  998. struct btrfs_dir_item *
  999. btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
  1000. struct btrfs_root *root,
  1001. struct btrfs_path *path, u64 dir,
  1002. u64 objectid, const char *name, int name_len,
  1003. int mod);
  1004. struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
  1005. struct btrfs_path *path,
  1006. const char *name, int name_len);
  1007. int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
  1008. struct btrfs_root *root,
  1009. struct btrfs_path *path,
  1010. struct btrfs_dir_item *di);
  1011. /* inode-map.c */
  1012. int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
  1013. struct btrfs_root *fs_root,
  1014. u64 dirid, u64 *objectid);
  1015. int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid);
  1016. /* inode-item.c */
  1017. int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
  1018. *root, u64 objectid, struct btrfs_inode_item
  1019. *inode_item);
  1020. int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
  1021. *root, struct btrfs_path *path,
  1022. struct btrfs_key *location, int mod);
  1023. /* file-item.c */
  1024. int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
  1025. struct btrfs_root *root,
  1026. u64 objectid, u64 pos, u64 offset,
  1027. u64 disk_num_blocks,
  1028. u64 num_blocks);
  1029. int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
  1030. struct btrfs_root *root,
  1031. struct btrfs_path *path, u64 objectid,
  1032. u64 blocknr, int mod);
  1033. int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
  1034. struct btrfs_root *root,
  1035. u64 objectid, u64 offset,
  1036. char *data, size_t len);
  1037. struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
  1038. struct btrfs_root *root,
  1039. struct btrfs_path *path,
  1040. u64 objectid, u64 offset,
  1041. int cow);
  1042. int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
  1043. struct btrfs_root *root, struct btrfs_path *path,
  1044. u64 isize);
  1045. /* inode.c */
  1046. int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page);
  1047. int btrfs_readpage(struct file *file, struct page *page);
  1048. void btrfs_delete_inode(struct inode *inode);
  1049. void btrfs_read_locked_inode(struct inode *inode);
  1050. int btrfs_write_inode(struct inode *inode, int wait);
  1051. void btrfs_dirty_inode(struct inode *inode);
  1052. struct inode *btrfs_alloc_inode(struct super_block *sb);
  1053. void btrfs_destroy_inode(struct inode *inode);
  1054. int btrfs_init_cachep(void);
  1055. void btrfs_destroy_cachep(void);
  1056. int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
  1057. unsigned long arg);
  1058. long btrfs_compat_ioctl(struct file *file, unsigned int cmd,
  1059. unsigned long arg);
  1060. struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
  1061. struct btrfs_root *root);
  1062. int btrfs_commit_write(struct file *file, struct page *page,
  1063. unsigned from, unsigned to);
  1064. int btrfs_get_block(struct inode *inode, sector_t iblock,
  1065. struct buffer_head *result, int create);
  1066. struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
  1067. size_t page_offset, u64 start, u64 end,
  1068. int create);
  1069. int btrfs_update_inode(struct btrfs_trans_handle *trans,
  1070. struct btrfs_root *root,
  1071. struct inode *inode);
  1072. /* file.c */
  1073. int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end);
  1074. extern struct file_operations btrfs_file_operations;
  1075. int btrfs_drop_extents(struct btrfs_trans_handle *trans,
  1076. struct btrfs_root *root, struct inode *inode,
  1077. u64 start, u64 end, u64 *hint_block);
  1078. /* tree-defrag.c */
  1079. int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
  1080. struct btrfs_root *root, int cache_only);
  1081. /* sysfs.c */
  1082. int btrfs_init_sysfs(void);
  1083. void btrfs_exit_sysfs(void);
  1084. int btrfs_sysfs_add_super(struct btrfs_fs_info *fs);
  1085. int btrfs_sysfs_add_root(struct btrfs_root *root);
  1086. void btrfs_sysfs_del_root(struct btrfs_root *root);
  1087. void btrfs_sysfs_del_super(struct btrfs_fs_info *root);
  1088. #endif