diff options
author | Josef Bacik <jbacik@redhat.com> | 2008-07-24 12:17:14 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:05 -0400 |
commit | 7b1287662304c3cb05cb38f5e3e2d69f386e8f10 (patch) | |
tree | bb589bfc3854f801b4098f2f2140e42a2f9e8071 /fs/btrfs/ctree.h | |
parent | 33268eaf0b3db5e2bd12c0ada81a8e8f87a46d68 (diff) |
Btrfs: Create orphan inode records to prevent lost files after a crash
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index f87d7263f2d7..012ad529cb18 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -74,6 +74,9 @@ struct btrfs_ordered_sum; | |||
74 | /* directory objectid inside the root tree */ | 74 | /* directory objectid inside the root tree */ |
75 | #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL | 75 | #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL |
76 | 76 | ||
77 | /* orhpan objectid for tracking unlinked/truncated files */ | ||
78 | #define BTRFS_ORPHAN_OBJECTID -5ULL | ||
79 | |||
77 | /* | 80 | /* |
78 | * All files have objectids higher than this. | 81 | * All files have objectids higher than this. |
79 | */ | 82 | */ |
@@ -646,6 +649,9 @@ struct btrfs_root { | |||
646 | 649 | ||
647 | /* the dirty list is only used by non-reference counted roots */ | 650 | /* the dirty list is only used by non-reference counted roots */ |
648 | struct list_head dirty_list; | 651 | struct list_head dirty_list; |
652 | |||
653 | spinlock_t orphan_lock; | ||
654 | struct list_head orphan_list; | ||
649 | }; | 655 | }; |
650 | 656 | ||
651 | /* | 657 | /* |
@@ -657,6 +663,7 @@ struct btrfs_root { | |||
657 | #define BTRFS_INODE_ITEM_KEY 1 | 663 | #define BTRFS_INODE_ITEM_KEY 1 |
658 | #define BTRFS_INODE_REF_KEY 2 | 664 | #define BTRFS_INODE_REF_KEY 2 |
659 | #define BTRFS_XATTR_ITEM_KEY 8 | 665 | #define BTRFS_XATTR_ITEM_KEY 8 |
666 | #define BTRFS_ORPHAN_ITEM_KEY 9 | ||
660 | /* reserve 2-15 close to the inode for later flexibility */ | 667 | /* reserve 2-15 close to the inode for later flexibility */ |
661 | 668 | ||
662 | /* | 669 | /* |
@@ -1560,6 +1567,13 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, | |||
1560 | struct btrfs_path *path, u64 dir, | 1567 | struct btrfs_path *path, u64 dir, |
1561 | const char *name, u16 name_len, | 1568 | const char *name, u16 name_len, |
1562 | int mod); | 1569 | int mod); |
1570 | |||
1571 | /* orphan.c */ | ||
1572 | int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans, | ||
1573 | struct btrfs_root *root, u64 offset); | ||
1574 | int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, | ||
1575 | struct btrfs_root *root, u64 offset); | ||
1576 | |||
1563 | /* inode-map.c */ | 1577 | /* inode-map.c */ |
1564 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, | 1578 | int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, |
1565 | struct btrfs_root *fs_root, | 1579 | struct btrfs_root *fs_root, |