From patchwork Mon Mar 31 13:53: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: 3914101 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 4D4709F357 for ; Mon, 31 Mar 2014 12:53:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 789B32039C for ; Mon, 31 Mar 2014 12:53:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A466520386 for ; Mon, 31 Mar 2014 12:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450AbaCaMxg (ORCPT ); Mon, 31 Mar 2014 08:53:36 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:52109 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752918AbaCaMxd (ORCPT ); Mon, 31 Mar 2014 08:53:33 -0400 Received: by mail-wi0-f169.google.com with SMTP id hm4so3098198wib.0 for ; Mon, 31 Mar 2014 05:53:32 -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=tUCJvZDhmJCUoJtAZBXEIpDnXJNqc65zHiuVDJ9eZx4=; b=EgZPIq+loKxQZ2zLWWOapSZqrbOvlvv267ri45yklg3Bp98A/g5WReYBFVzvlQy+YS NJdljOrd5nAORWoKEi2Q6/JE7KqSpzGknxCdI9bqYMn/r38JrygM12qz9KjDyldF4G/3 6ZT2GJbEUAS9jEg+2Mo0788WchO4ERbWYZJkXx07G4jckBt2dXVklEx3zzic6KkQkUs/ I+rQD/HD51x0TyuMzzLs1sWNQrZ6yVEFGByu29rzyJGnLkl6IC3ntWhPlVwoudGaBMBb hauxoi7kZn5AIm729R/2cxvWHle+Hp8cq0Frnaxp7PgPajBDXq3xV9EzyNABE7ji/7I+ JKNg== X-Received: by 10.180.20.71 with SMTP id l7mr12136350wie.35.1396270412510; Mon, 31 Mar 2014 05:53:32 -0700 (PDT) Received: from debian-vm3.lan (bl9-168-27.dsl.telepac.pt. [85.242.168.27]) by mx.google.com with ESMTPSA id w6sm12456024wjq.29.2014.03.31.05.53.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 05:53:31 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs: more efficient io tree navigation on wait_extent_bit Date: Mon, 31 Mar 2014 14:53:25 +0100 Message-Id: <1396274005-16360-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.10.4 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 we don't reschedule use rb_next to find the next extent state instead of a full tree search, which is more efficient and safe since we didn't release the io tree's lock. Signed-off-by: Filipe David Borba Manana --- fs/btrfs/extent_io.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index fd78c84..50a3321 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -749,6 +749,7 @@ again: * our range starts */ node = tree_search(tree, start); +process_node: if (!node) break; @@ -769,7 +770,10 @@ again: if (start > end) break; - cond_resched_lock(&tree->lock); + if (!cond_resched_lock(&tree->lock)) { + node = rb_next(node); + goto process_node; + } } out: spin_unlock(&tree->lock);