From patchwork Thu Jun 5 12:22:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4304531 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A5304BEEA7 for ; Thu, 5 Jun 2014 11:24:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC25E20179 for ; Thu, 5 Jun 2014 11:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F31D2016C for ; Thu, 5 Jun 2014 11:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751762AbaFELYZ (ORCPT ); Thu, 5 Jun 2014 07:24:25 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:35178 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbaFELYX (ORCPT ); Thu, 5 Jun 2014 07:24:23 -0400 Received: by mail-wg0-f49.google.com with SMTP id m15so906192wgh.8 for ; Thu, 05 Jun 2014 04:24:22 -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=8gOaw+X5pK7OAinl3PRcxZcGUZ/4Pdr/qB2SrwHLDmk=; b=Ue4S7S28vWkwRIVhvDy5saf70CF60HX9WKVZ5HA86wOxEeSpTIffhqyAdZL9I3nF74 p6G0YY/SWdsG/MV+sgcb5aT4Mg8sXqUnn/gyyPZ44gl32NBH0jEIi87mGNnKM4eKzsvq Pg+QL3U3tdm7nQ8cteoHF2xJyyw/vWaobrOJ0lB2gafN2Zbi29UmYq43vRyJMsAq/I6B d8ncXwqXoIAhxwyIReGZ+xpNEwHEII02wZjPc9Uyj3+k0B/dCZnaHtIj5w4wEmHE0R0W 7fLpIf5Jtc3fiAqA7k6cH6MGM1TTlVVkr6IMD8IE1Z013lnHpezhSDf/EFlVnD9/psAE wxyA== X-Received: by 10.180.221.163 with SMTP id qf3mr14751952wic.56.1401967462524; Thu, 05 Jun 2014 04:24:22 -0700 (PDT) Received: from debian-vm3.lan (bl13-158-240.dsl.telepac.pt. [85.246.158.240]) by mx.google.com with ESMTPSA id bl3sm2142476wib.9.2014.06.05.04.24.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Jun 2014 04:24:21 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 1/3] Btrfs: make sure we retry if we couldn't get the page Date: Thu, 5 Jun 2014 13:22:24 +0100 Message-Id: <1401970946-25269-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 In inode.c:btrfs_page_exists_in_range(), if we can't get the page we need to retry. However we weren't retrying because we weren't setting page to NULL, which makes the while loop exit immediately and will make us call page_cache_release after exiting the loop which is incorrect because our page get didn't succeed. This could also make us return true when we shouldn't. Signed-off-by: Filipe David Borba Manana --- fs/btrfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 38d1e7b..cdbd20e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6777,8 +6777,10 @@ bool btrfs_page_exists_in_range(struct inode *inode, loff_t start, loff_t end) break; /* TODO: Is this relevant for this use case? */ } - if (!page_cache_get_speculative(page)) + if (!page_cache_get_speculative(page)) { + page = NULL; continue; + } /* * Has the page moved?