btrfs_drop_extents: handle BTRFS_INODE_REF_KEY types
authorYan <yanzheng@21cn.com>
Tue, 5 Feb 2008 20:40:36 +0000 (15:40 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:04:00 +0000 (11:04 -0400)
It's possible "key.type == BTRFS_INODE_REF_KEY" and "key.offset >= end".

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/file.c

index 184bde1cfc3d3871a38c385984f1f9bb6c68f1bd..bfa4149c053dcaa101018cd93386ddb47db1d128 100644 (file)
@@ -507,11 +507,12 @@ next_slot:
                slot = path->slots[0];
                ret = 0;
                btrfs_item_key_to_cpu(leaf, &key, slot);
-
-               if (key.offset >= end || key.objectid != inode->i_ino) {
+               if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY &&
+                   key.offset >= end) {
                        goto out;
                }
-               if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY) {
+               if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY ||
+                   key.objectid != inode->i_ino) {
                        goto out;
                }
                if (recow) {