summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorJosef Bacik2008-07-24 18:17:14 +0200
committerChris Mason2008-09-25 17:04:05 +0200
commit7b1287662304c3cb05cb38f5e3e2d69f386e8f10 (patch)
treebb589bfc3854f801b4098f2f2140e42a2f9e8071 /fs/btrfs/ctree.h
parentBtrfs: Add ACL support (diff)
downloadkernel-qcow2-linux-7b1287662304c3cb05cb38f5e3e2d69f386e8f10.tar.gz
kernel-qcow2-linux-7b1287662304c3cb05cb38f5e3e2d69f386e8f10.tar.xz
kernel-qcow2-linux-7b1287662304c3cb05cb38f5e3e2d69f386e8f10.zip
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.h14
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;
/* directory objectid inside the root tree */
#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
+/* orhpan objectid for tracking unlinked/truncated files */
+#define BTRFS_ORPHAN_OBJECTID -5ULL
+
/*
* All files have objectids higher than this.
*/
@@ -646,6 +649,9 @@ struct btrfs_root {
/* the dirty list is only used by non-reference counted roots */
struct list_head dirty_list;
+
+ spinlock_t orphan_lock;
+ struct list_head orphan_list;
};
/*
@@ -657,6 +663,7 @@ struct btrfs_root {
#define BTRFS_INODE_ITEM_KEY 1
#define BTRFS_INODE_REF_KEY 2
#define BTRFS_XATTR_ITEM_KEY 8
+#define BTRFS_ORPHAN_ITEM_KEY 9
/* reserve 2-15 close to the inode for later flexibility */
/*
@@ -1560,6 +1567,13 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
struct btrfs_path *path, u64 dir,
const char *name, u16 name_len,
int mod);
+
+/* orphan.c */
+int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, u64 offset);
+int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, u64 offset);
+
/* inode-map.c */
int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
struct btrfs_root *fs_root,