Btrfs: Split the extent_map code into two parts

There is now extent_map for mapping offsets in the file to disk and
extent_io for state tracking, IO submission and extent_bufers.

The new extent_map code shifts from [start,end] pairs to [start,len], and
pushes the locking out into the caller.  This allows a few performance
optimizations and is easier to use.

A number of extent_map usage bugs were fixed, mostly with failing
to remove extent_map entries when changing the file.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 8b52c69..f8a1016 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -468,10 +468,15 @@
 	err = btrfs_init_cachep();
 	if (err)
 		goto free_transaction_sys;
-	err = extent_map_init();
+
+	err = extent_io_init();
 	if (err)
 		goto free_cachep;
 
+	err = extent_map_init();
+	if (err)
+		goto free_extent_io;
+
 	err = register_filesystem(&btrfs_fs_type);
 	if (err)
 		goto free_extent_map;
@@ -479,6 +484,8 @@
 
 free_extent_map:
 	extent_map_exit();
+free_extent_io:
+	extent_io_exit();
 free_cachep:
 	btrfs_destroy_cachep();
 free_transaction_sys:
@@ -492,6 +499,7 @@
 	btrfs_exit_transaction_sys();
 	btrfs_destroy_cachep();
 	extent_map_exit();
+	extent_io_exit();
 	unregister_filesystem(&btrfs_fs_type);
 	btrfs_exit_sysfs();
 }