From patchwork Thu Jun 7 17:28:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: james harvey X-Patchwork-Id: 10453269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35B8E60234 for ; Thu, 7 Jun 2018 17:28:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24042297F0 for ; Thu, 7 Jun 2018 17:28:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1858329952; Thu, 7 Jun 2018 17:28:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4A46297F0 for ; Thu, 7 Jun 2018 17:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933701AbeFGR2I (ORCPT ); Thu, 7 Jun 2018 13:28:08 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36603 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933198AbeFGR2H (ORCPT ); Thu, 7 Jun 2018 13:28:07 -0400 Received: by mail-oi0-f65.google.com with SMTP id 14-v6so9363557oie.3 for ; Thu, 07 Jun 2018 10:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=gnEO5GdLOAMcHEVxKj7xCqoSRALb3IKWaKcnx/Csl4g=; b=E/AdG9I/QEv5UWLnO7hsfdn5LjEWJm55JU4pYSEotimEIBJscJw9mttijuGpO/sSlw 9TnW2yY07MPEA6pbQWReUTQlwcAdeslT9lUX7v3MhsNA3AMiJQxSYDkoC4blD3DFjJTU ZU3j1gs+yqrGS8/nRSLBzkbn43CpBKj2FN3eNHmvwZAag4cEgm6UjubvcChTM/sovLR0 FpfEMWzUmW5Ffip3zPJukyHhERQLC3b5OOP6Y9J6J57R0BTv0kCIHXZOXKqj42nOln5d ByKHmwxa11wH8QTiIz6T87T+HWL/DzmccDrgXsbG1kJp3DWChtSnP5fcupfKkVllSu0d eD/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gnEO5GdLOAMcHEVxKj7xCqoSRALb3IKWaKcnx/Csl4g=; b=rTKkWssrrueQ+4rHFKULlQ1nwFy+auEQd0i5021tlYB5spgiRcQJAFlJ/w9vqX99s4 05/BzsrYIyK674UFGNQOTid3L1sbMFkqSu5JFG8KXOxYVtW8wJUddNQaGBvE7CjyP3Et DiNKYEAOBUjhl/4kZogTtQT6I7bFcffxyNyvaQnBACxuRFZn7E1/KqbRk1qVmEF/fORj DqyJhvJtgn6PBZh/qaQs9aU4lIVIG91iqfaPwMMyr9bjotwZSKH1zg5RP+9kym1dD+EC pdns/BRvKIJug4UXLWwN6jmAPUZ6+gcihq6A+cq3hVWGyedal3RQWmzNdQWL86CwOlBJ MdMA== X-Gm-Message-State: APt69E00ZRw1+X0tbV1NOKztC/scZHm1mSitbyIVe8vETDU5ykALrVVG ScBuuuTrLXIEy7XtV08Iyg7XmOOSUy5QrptHsqhfGw== X-Google-Smtp-Source: ADUXVKIygyxUx3HpB1TsEcBC2sIZ45/gINsFZavPJGts6Evq4oBmGp1IZmYt6OPpoNXPcRt0gtck3IDkZ4fKljWJ1l8= X-Received: by 2002:aca:389:: with SMTP id 131-v6mr1276031oid.306.1528392486350; Thu, 07 Jun 2018 10:28:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:3535:0:0:0:0:0 with HTTP; Thu, 7 Jun 2018 10:28:05 -0700 (PDT) From: james harvey Date: Thu, 7 Jun 2018 13:28:05 -0400 Message-ID: Subject: [PATCH v3 (Only) 1/3] btrfs-progs: map-logical: look at next leaf if slot > items To: Btrfs BTRFS Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP btrfs-map-logical -l 10955980800 -b 4096 No extent found at range [10955980800,10955984896) But, this extent exists. btrfs-debug-tree shows: item 202 key (10955976704 EXTENT_ITEM 4096) itemoff 8772 itemsize 37 refs 1 gen 62656 flags DATA shared data backref parent 142655488 count 1 ... item 0 key (10955980800 EXTENT_ITEM 4096) itemoff 16246 itemsize 37 refs 1 gen 62656 flags DATA shared data backref parent 128958464 count 1 The code searches for (logical, 0, 0), and looks forward then backward. It needs to go to the next leaf when slot > number of items on this leaf. Signed-off-by: James Harvey --- btrfs-map-logical.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.0 -- 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 diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index 7a8bcff9..8a4228a4 100644 --- a/btrfs-map-logical.c +++ b/btrfs-map-logical.c @@ -65,6 +65,14 @@ static int map_one_extent(struct btrfs_fs_info *fs_info, BUG_ON(ret == 0); ret = 0; + if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { + ret = btrfs_next_leaf(fs_info->extent_root, path); + if (ret > 0) + ret = -ENOENT; + if (ret) + goto out; + } + again: btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); if ((search_foward && key.objectid < logical) ||