Btrfs: add generation field to file extent
authorChris Mason <chris.mason@oracle.com>
Tue, 27 Mar 2007 13:16:29 +0000 (09:16 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Tue, 27 Mar 2007 13:16:29 +0000 (09:16 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ctree.h
fs/btrfs/file-item.c

index a4ad39b58a4b74ddb4c9404042523759eacc3b28..c3fa12a6b59e604d6324d85fef68c9173e26a656 100644 (file)
@@ -192,6 +192,7 @@ struct btrfs_root_item {
 } __attribute__ ((__packed__));
 
 struct btrfs_file_extent_item {
+       __le64 generation;
        /*
         * disk space consumed by the extent, checksum blocks are included
         * in these numbers
@@ -764,6 +765,18 @@ static inline void btrfs_set_file_extent_disk_blocknr(struct
        e->disk_blocknr = cpu_to_le64(val);
 }
 
+static inline u64 btrfs_file_extent_generation(struct btrfs_file_extent_item *e)
+{
+       return le64_to_cpu(e->generation);
+}
+
+static inline void btrfs_set_file_extent_generation(struct
+                                                   btrfs_file_extent_item *e,
+                                                   u64 val)
+{
+       e->generation = cpu_to_le64(val);
+}
+
 static inline u64 btrfs_file_extent_disk_num_blocks(struct
                                                    btrfs_file_extent_item *e)
 {
index 4a0367d702b77857d1ee7af9ce4fedfdb8c5bbd4..09de270c5a521ec5d8b7fbc4e880a77584653430 100644 (file)
@@ -32,6 +32,7 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans,
        btrfs_set_file_extent_disk_num_blocks(item, ins.offset);
        btrfs_set_file_extent_offset(item, 0);
        btrfs_set_file_extent_num_blocks(item, ins.offset);
+       btrfs_set_file_extent_generation(item, trans->transid);
        mark_buffer_dirty(path.nodes[0]);
        *result = ins.objectid;
        btrfs_release_path(root, &path);