diff mbox

[RESEND] btrfs: Don't return extent in fiemap if we meet with a hole.

Message ID 1277102222-3310-1-git-send-email-tao.ma@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tao Ma June 21, 2010, 6:37 a.m. UTC
None
diff mbox

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index b177ed3..7eb4d77 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2951,7 +2951,7 @@  int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	u64 disko = 0;
 	struct extent_map *em = NULL;
 	struct extent_state *cached_state = NULL;
-	int end = 0;
+	int end = 0, hole = 0;
 	u64 em_start = 0, em_len = 0;
 	unsigned long emflags;
 	ret = 0;
@@ -2978,12 +2978,13 @@  int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
 		disko = 0;
 		flags = 0;
+		hole = 0;
 
 		if (em->block_start == EXTENT_MAP_LAST_BYTE) {
 			end = 1;
 			flags |= FIEMAP_EXTENT_LAST;
 		} else if (em->block_start == EXTENT_MAP_HOLE) {
-			flags |= FIEMAP_EXTENT_UNWRITTEN;
+			hole = 1;
 		} else if (em->block_start == EXTENT_MAP_INLINE) {
 			flags |= (FIEMAP_EXTENT_DATA_INLINE |
 				  FIEMAP_EXTENT_NOT_ALIGNED);
@@ -3015,10 +3016,12 @@  int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 			end = 1;
 		}
 
-		ret = fiemap_fill_next_extent(fieinfo, em_start, disko,
-					em_len, flags);
-		if (ret)
-			goto out_free;
+		if (!hole) {
+			ret = fiemap_fill_next_extent(fieinfo, em_start, disko,
+						      em_len, flags);
+			if (ret)
+				goto out_free;
+		}
 	}
 out_free:
 	free_extent_map(em);