From patchwork Thu Jun 5 12:22:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4304541 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 751D2BEEA7 for ; Thu, 5 Jun 2014 11:24:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD59B20179 for ; Thu, 5 Jun 2014 11:24:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7EB72016C for ; Thu, 5 Jun 2014 11:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797AbaFELY3 (ORCPT ); Thu, 5 Jun 2014 07:24:29 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:57141 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbaFELY1 (ORCPT ); Thu, 5 Jun 2014 07:24:27 -0400 Received: by mail-we0-f180.google.com with SMTP id q58so927726wes.11 for ; Thu, 05 Jun 2014 04:24:25 -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:in-reply-to:references; bh=FiXhr6Bk4lajEVBJ8xOlDvEzGwWnkvgVIL313jKAI3Q=; b=TpP5lgbATbPHozrsIxesB39pqUNn21pbZStM0J7avCGyMWlMs7egtb6hvC9qHV9EUp 5rgwmGgPYic7xvui3tVMQNBW+39mLgAqoeLUNtjM3SVDPudrYln/uYX/f0cK818Pb9Vn aVFrcPD4jsF9jFEYimH9Pw+1cnHQZfE8jxqgbldtYYX48iUkmOYAjocdI6RmnFZ9C5TM w0ucwIcq0z8CRd8MZNz/xY5ru3dRAh79siruKOTjiKUGiWCA2cav+2vLSKCwVVlx7u84 yRXjZoYEifvMdUywUr14t3a4mXpL72nkxMHDZchIvlPs6W1G3tvINSPABWQvrrneX8L5 ZLxA== X-Received: by 10.194.23.135 with SMTP id m7mr57055239wjf.2.1401967465834; Thu, 05 Jun 2014 04:24:25 -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.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Jun 2014 04:24:25 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 2/3] Btrfs: make sure we retry if page is a retriable exception Date: Thu, 5 Jun 2014 13:22:25 +0100 Message-Id: <1401970946-25269-2-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401970946-25269-1-git-send-email-fdmanana@gmail.com> References: <1401970946-25269-1-git-send-email-fdmanana@gmail.com> 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 the page we get from the radix tree is an exception which should make us retry, set page to NULL in order to really retry, because otherwise we don't get another loop iteration executed (page != NULL makes the while loop exit). This also was making us call page_cache_release after exiting the loop, which isn't correct because page doesn't point to a valid page, and possibly return true from the function 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 cdbd20e..f265f41 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6767,8 +6767,10 @@ bool btrfs_page_exists_in_range(struct inode *inode, loff_t start, loff_t end) break; if (radix_tree_exception(page)) { - if (radix_tree_deref_retry(page)) + if (radix_tree_deref_retry(page)) { + page = NULL; continue; + } /* * Otherwise, shmem/tmpfs must be storing a swap entry * here as an exceptional entry: so return it without