[PATCH] ext3: add support for extent_map API

From: Jens Axboe
Date: Tue Jan 15 2008 - 04:06:08 EST


Just a port of Chris' ext2 version.

Signed-off-by: Jens Axboe <jens.axboe@xxxxxxxxxx>
---
fs/ext3/ialloc.c | 2 ++
fs/ext3/inode.c | 18 ++++++++++++++++++
fs/ext3/super.c | 2 ++
include/linux/ext3_fs_i.h | 3 +++
4 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 1bc8cd8..94fdb46 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -23,6 +23,7 @@
#include <linux/buffer_head.h>
#include <linux/random.h>
#include <linux/bitops.h>
+#include <linux/extent_map.h>

#include <asm/byteorder.h>

@@ -579,6 +580,7 @@ got:
ei->i_dtime = 0;
ei->i_block_alloc_info = NULL;
ei->i_block_group = group;
+ extent_map_tree_init(&ei->extent_tree);

ext3_set_inode_flags(inode);
if (IS_DIRSYNC(inode))
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 9b162cd..55e677d 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -36,6 +36,7 @@
#include <linux/mpage.h>
#include <linux/uio.h>
#include <linux/bio.h>
+#include <linux/extent_map.h>
#include "xattr.h"
#include "acl.h"

@@ -228,8 +229,10 @@ void ext3_delete_inode (struct inode * inode)
else
ext3_free_inode(handle, inode);
ext3_journal_stop(handle);
+ remove_extent_mappings(&EXT3_I(inode)->extent_tree, 0, (u64) -1);
return;
no_delete:
+ remove_extent_mappings(&EXT3_I(inode)->extent_tree, 0, (u64) -1);
clear_inode(inode); /* We must guarantee clearing of inode... */
}

@@ -993,6 +996,17 @@ get_block:
return ret;
}

+static struct extent_map *ext3_map_extent(struct address_space *mapping,
+ struct page *page, size_t page_offset,
+ u64 start, u64 len, int create,
+ gfp_t gfp_mask)
+{
+ struct extent_map_tree *tree = &EXT3_I(mapping->host)->extent_tree;
+
+ return map_extent_get_block(tree, mapping, start, len, create, gfp_mask,
+ ext3_get_block);
+}
+
/*
* `handle' can be NULL if create is zero
*/
@@ -1780,6 +1794,7 @@ static const struct address_space_operations ext3_ordered_aops = {
.releasepage = ext3_releasepage,
.direct_IO = ext3_direct_IO,
.migratepage = buffer_migrate_page,
+ .map_extent = ext3_map_extent,
};

static const struct address_space_operations ext3_writeback_aops = {
@@ -1794,6 +1809,7 @@ static const struct address_space_operations ext3_writeback_aops = {
.releasepage = ext3_releasepage,
.direct_IO = ext3_direct_IO,
.migratepage = buffer_migrate_page,
+ .map_extent = ext3_map_extent,
};

static const struct address_space_operations ext3_journalled_aops = {
@@ -1807,6 +1823,7 @@ static const struct address_space_operations ext3_journalled_aops = {
.bmap = ext3_bmap,
.invalidatepage = ext3_invalidatepage,
.releasepage = ext3_releasepage,
+ .map_extent = ext3_map_extent,
};

void ext3_set_aops(struct inode *inode)
@@ -2785,6 +2802,7 @@ void ext3_read_inode(struct inode * inode)
init_special_inode(inode, inode->i_mode,
new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
}
+ extent_map_tree_init(&ei->extent_tree);
brelse (iloc.bh);
ext3_set_inode_flags(inode);
return;
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index cb14de1..8bc026f 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -469,6 +469,7 @@ static void ext3_destroy_inode(struct inode *inode)
false);
dump_stack();
}
+ remove_extent_mappings(&EXT3_I(inode)->extent_tree, 0, (u64) -1);
kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
}

@@ -481,6 +482,7 @@ static void init_once(struct kmem_cache * cachep, void *foo)
init_rwsem(&ei->xattr_sem);
#endif
mutex_init(&ei->truncate_mutex);
+ extent_map_tree_init(&ei->extent_tree);
inode_init_once(&ei->vfs_inode);
}

diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
index 7894dd0..db7bab2 100644
--- a/include/linux/ext3_fs_i.h
+++ b/include/linux/ext3_fs_i.h
@@ -20,6 +20,7 @@
#include <linux/rbtree.h>
#include <linux/seqlock.h>
#include <linux/mutex.h>
+#include <linux/extent_map.h>

/* data type for block offset of block group */
typedef int ext3_grpblk_t;
@@ -142,6 +143,8 @@ struct ext3_inode_info {
*/
struct mutex truncate_mutex;
struct inode vfs_inode;
+
+ struct extent_map_tree extent_tree;
};

#endif /* _LINUX_EXT3_FS_I */
--
1.5.4.rc2.84.gf85fd


--Y/WcH0a6A93yCHGr
Content-Type: text/x-patch; charset=us-ascii
Content-Disposition: inline; filename="0005-loop-fastfs-support.patch"