ctree.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  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, u64 objectid,
  989. struct btrfs_root *latest_root);
  990. /* dir-item.c */
  991. int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
  992. *root, const char *name, int name_len, u64 dir,
  993. struct btrfs_key *location, u8 type);
  994. struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
  995. struct btrfs_root *root,
  996. struct btrfs_path *path, u64 dir,
  997. const char *name, int name_len,
  998. int mod);
  999. struct btrfs_dir_item *
  1000. btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
  1001. struct btrfs_root *root,
  1002. struct btrfs_path *path, u64 dir,
  1003. u64 objectid, const char *name, int name_len,
  1004. int mod);
  1005. struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
  1006. struct btrfs_path *path,
  1007. const char *name, int name_len);
  1008. int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
  1009. struct btrfs_root *root,
  1010. struct btrfs_path *path,
  1011. struct btrfs_dir_item *di);
  1012. /* inode-map.c */
  1013. int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
  1014. struct btrfs_root *fs_root,
  1015. u64 dirid, u64 *objectid);
  1016. int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid);
  1017. /* inode-item.c */
  1018. int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
  1019. *root, u64 objectid, struct btrfs_inode_item
  1020. *inode_item);
  1021. int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
  1022. *root, struct btrfs_path *path,
  1023. struct btrfs_key *location, int mod);
  1024. /* file-item.c */
  1025. int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
  1026. struct btrfs_root *root,
  1027. u64 objectid, u64 pos, u64 offset,
  1028. u64 disk_num_blocks,
  1029. u64 num_blocks);
  1030. int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
  1031. struct btrfs_root *root,
  1032. struct btrfs_path *path, u64 objectid,
  1033. u64 blocknr, int mod);
  1034. int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
  1035. struct btrfs_root *root,
  1036. u64 objectid, u64 offset,
  1037. char *data, size_t len);
  1038. struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
  1039. struct btrfs_root *root,
  1040. struct btrfs_path *path,
  1041. u64 objectid, u64 offset,
  1042. int cow);
  1043. int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
  1044. struct btrfs_root *root, struct btrfs_path *path,
  1045. u64 isize);
  1046. /* inode.c */
  1047. int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page);
  1048. int btrfs_readpage(struct file *file, struct page *page);
  1049. void btrfs_delete_inode(struct inode *inode);
  1050. void btrfs_read_locked_inode(struct inode *inode);
  1051. int btrfs_write_inode(struct inode *inode, int wait);
  1052. void btrfs_dirty_inode(struct inode *inode);
  1053. struct inode *btrfs_alloc_inode(struct super_block *sb);
  1054. void btrfs_destroy_inode(struct inode *inode);
  1055. int btrfs_init_cachep(void);
  1056. void btrfs_destroy_cachep(void);
  1057. int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
  1058. unsigned long arg);
  1059. long btrfs_compat_ioctl(struct file *file, unsigned int cmd,
  1060. unsigned long arg);
  1061. struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
  1062. struct btrfs_root *root);
  1063. int btrfs_commit_write(struct file *file, struct page *page,
  1064. unsigned from, unsigned to);
  1065. int btrfs_get_block(struct inode *inode, sector_t iblock,
  1066. struct buffer_head *result, int create);
  1067. struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
  1068. size_t page_offset, u64 start, u64 end,
  1069. int create);
  1070. int btrfs_update_inode(struct btrfs_trans_handle *trans,
  1071. struct btrfs_root *root,
  1072. struct inode *inode);
  1073. /* file.c */
  1074. int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end);
  1075. extern struct file_operations btrfs_file_operations;
  1076. int btrfs_drop_extents(struct btrfs_trans_handle *trans,
  1077. struct btrfs_root *root, struct inode *inode,
  1078. u64 start, u64 end, u64 *hint_block);
  1079. /* tree-defrag.c */
  1080. int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
  1081. struct btrfs_root *root, int cache_only);
  1082. /* sysfs.c */
  1083. int btrfs_init_sysfs(void);
  1084. void btrfs_exit_sysfs(void);
  1085. int btrfs_sysfs_add_super(struct btrfs_fs_info *fs);
  1086. int btrfs_sysfs_add_root(struct btrfs_root *root);
  1087. void btrfs_sysfs_del_root(struct btrfs_root *root);
  1088. void btrfs_sysfs_del_super(struct btrfs_fs_info *root);
  1089. #endif