summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-19 13:38:02 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-19 13:38:02 -0400
commiteb3bd5da6698fd2d24cf7f04e065e0c521cbc354 (patch)
tree13e304b7f4a9cf5a1c556d75157b52cd874217c5
parent8c973943bb862d466967f28d87e23b889ea5693f (diff)
inline file data in extents
-rw-r--r--ctree.h32
-rw-r--r--print-tree.c6
2 files changed, 38 insertions, 0 deletions
diff --git a/ctree.h b/ctree.h
index 1dca9cb0..308008af 100644
--- a/ctree.h
+++ b/ctree.h
@@ -200,8 +200,12 @@ struct btrfs_root_item {
__le32 refs;
} __attribute__ ((__packed__));
+#define BTRFS_FILE_EXTENT_REG 0
+#define BTRFS_FILE_EXTENT_INLINE 1
+
struct btrfs_file_extent_item {
__le64 generation;
+ u8 type;
/*
* disk space consumed by the extent, checksum blocks are included
* in these numbers
@@ -849,6 +853,34 @@ static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
return (u8 *)l->items;
}
+static inline int btrfs_file_extent_type(struct btrfs_file_extent_item *e)
+{
+ return e->type;
+}
+static inline void btrfs_set_file_extent_type(struct btrfs_file_extent_item *e,
+ u8 val)
+{
+ e->type = val;
+}
+
+static inline char *btrfs_file_extent_inline_start(struct
+ btrfs_file_extent_item *e)
+{
+ return (char *)(&e->disk_blocknr);
+}
+
+static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
+{
+ return (unsigned long)(&((struct
+ btrfs_file_extent_item *)NULL)->disk_blocknr) + datasize;
+}
+
+static inline u32 btrfs_file_extent_inline_len(struct btrfs_item *e)
+{
+ struct btrfs_file_extent_item *fe = NULL;
+ return btrfs_item_size(e) - (unsigned long)(&fe->disk_blocknr);
+}
+
static inline u64 btrfs_file_extent_disk_blocknr(struct btrfs_file_extent_item
*e)
{
diff --git a/print-tree.c b/print-tree.c
index 12787c67..d56860bb 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -85,6 +85,12 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
case BTRFS_EXTENT_DATA_KEY:
fi = btrfs_item_ptr(l, i,
struct btrfs_file_extent_item);
+ if (btrfs_file_extent_type(fi) ==
+ BTRFS_FILE_EXTENT_INLINE) {
+ printf("\t\tinline extent data size %u\n",
+ btrfs_file_extent_inline_len(l->items + i));
+ break;
+ }
printf("\t\textent data disk block %Lu nr %Lu\n",
btrfs_file_extent_disk_blocknr(fi),
btrfs_file_extent_disk_num_blocks(fi));