[2/4] btrfs-progs: ctree: return earlier for btrfs_previous_item
diff mbox

Message ID 1463456878-17550-3-git-send-email-quwenruo@cn.fujitsu.com
State New
Headers show

Commit Message

Qu Wenruo May 17, 2016, 3:47 a.m. UTC
Btrfs_previous_item() has a parameter to specify minimal objectid to
return.

But surprisingly it doesn't use it at all.
Although that's OK, but it would take years long for large tree, so
return it earlier.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 ctree.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Sterba May 17, 2016, 12:50 p.m. UTC | #1
On Tue, May 17, 2016 at 11:47:56AM +0800, Qu Wenruo wrote:
> Btrfs_previous_item() has a parameter to specify minimal objectid to
> return.
> 
> But surprisingly it doesn't use it at all.
> Although that's OK, but it would take years long for large tree, so
> return it earlier.

This makes it closer to the kernel implementation, but still not equal,
there are some more shortcuts. Can you please port them as well? This
patch is independent of the rest so I'd take it separatelly.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Qu Wenruo May 18, 2016, 12:40 a.m. UTC | #2
David Sterba wrote on 2016/05/17 14:50 +0200:
> On Tue, May 17, 2016 at 11:47:56AM +0800, Qu Wenruo wrote:
>> Btrfs_previous_item() has a parameter to specify minimal objectid to
>> return.
>>
>> But surprisingly it doesn't use it at all.
>> Although that's OK, but it would take years long for large tree, so
>> return it earlier.
>
> This makes it closer to the kernel implementation, but still not equal,
> there are some more shortcuts. Can you please port them as well? This
> patch is independent of the rest so I'd take it separatelly.
>
>
Thanks, I just forgot that we can refer to kernel implement.

I'll submit it as a separate patch soon.

Thanks,
Qu


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/ctree.c b/ctree.c
index 079696e..3a9f417 100644
--- a/ctree.c
+++ b/ctree.c
@@ -2894,6 +2894,8 @@  int btrfs_previous_item(struct btrfs_root *root,
 		btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
 		if (found_key.type == type)
 			return 0;
+		if (found_key.objectid < min_objectid)
+			break;
 	}
 	return 1;
 }