From patchwork Thu Apr 24 14:15:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4051221 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C56FE9F1F4 for ; Thu, 24 Apr 2014 13:15:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D941A20295 for ; Thu, 24 Apr 2014 13:15:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA1812028D for ; Thu, 24 Apr 2014 13:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756798AbaDXNPu (ORCPT ); Thu, 24 Apr 2014 09:15:50 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:33479 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753344AbaDXNPt (ORCPT ); Thu, 24 Apr 2014 09:15:49 -0400 Received: by mail-wg0-f52.google.com with SMTP id b13so1037877wgh.35 for ; Thu, 24 Apr 2014 06:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=U7aIsVHl6YTbH9Hf0aCAHigaXA8oxYiPyTdvCr9Wn6Y=; b=za/N0N7Qezm2Mcj6NhpFuj1dU9O6e+3dzLv8UlZKnl9/qn3lRPIuBDEVPf+2+g5zQh 77aCQXdloqtI3ImnFXRudZVnpgVWIrS1T5WlNdZv0Ui+sECLj4CGIQqrqTFwyZOC9SkN cGOVnSqzcVqTBohIlYy7TWivpKKskfKhCB123Ii2T+cafJ7CRNivuA2FXF40qG5EwggA Rxt8RoYLSPjgZ8wxq9FtvNbchJW8PajH+vxRjib8Hj227a+fm6RdRnDHTYLQRkkLQP9v +BqPXfEAlqXNZ4BElTN7hVpuVupusoh/p7Zil9OySpp10JOzonNxEs6n7Lwn0UU2o9Ct 4fmw== X-Received: by 10.194.7.196 with SMTP id l4mr91593wja.92.1398345347877; Thu, 24 Apr 2014 06:15:47 -0700 (PDT) Received: from debian-vm3.lan (bl10-196-46.dsl.telepac.pt. [85.243.196.46]) by mx.google.com with ESMTPSA id by1sm6175209wjc.26.2014.04.24.06.15.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Apr 2014 06:15:47 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs: use correct key when repeating search for extent item Date: Thu, 24 Apr 2014 15:15:28 +0100 Message-Id: <1398348929-1827-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If skinny metadata is enabled and our first tree search fails to find a skinny extent item, we may repeat a tree search for a "fat" extent item (if the previous item in the leaf is not the "fat" extent we're looking for). However we were not setting the new key's objectid to the right value, as we previously used the same key variable to peek at the previous item in the leaf, which has a different objectid. So just set the right objectid to avoid modifying/deleting a wrong item if we repeat the tree search. Signed-off-by: Filipe David Borba Manana --- fs/btrfs/extent-tree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1306487..678cb35 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1542,6 +1542,7 @@ again: ret = 0; } if (ret) { + key.objectid = bytenr; key.type = BTRFS_EXTENT_ITEM_KEY; key.offset = num_bytes; btrfs_release_path(path); @@ -5719,6 +5720,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, if (ret > 0 && skinny_metadata) { skinny_metadata = false; + key.objectid = bytenr; key.type = BTRFS_EXTENT_ITEM_KEY; key.offset = num_bytes; btrfs_release_path(path);