From patchwork Thu Sep 19 15:48:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2912071 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 A050B9F1F1 for ; Thu, 19 Sep 2013 15:48:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AC82203F0 for ; Thu, 19 Sep 2013 15:48:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703F3203EA for ; Thu, 19 Sep 2013 15:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752892Ab3ISPsO (ORCPT ); Thu, 19 Sep 2013 11:48:14 -0400 Received: from dkim1.fusionio.com ([66.114.96.53]:36557 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797Ab3ISPsN (ORCPT ); Thu, 19 Sep 2013 11:48:13 -0400 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id 0B3F17C06AC for ; Thu, 19 Sep 2013 09:48:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1379605693; bh=VaK8i/ZQKL6+//CFE/3eQCPPg3aJrqzLTGForbdffPk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=s+ZUshXWvqrqkQtwzCVLZBKYB5wL2DOb/TUBCeqwsw7KrX4eLXKFRaI3cXwgocsaE C+g7hwF9u5RvNWgpfLVsyryhS177Wixil2LP8u6j2FLrcvbAq9FY2nNd4PR+29k/y/ v5wfi5rbscomMuPqSjaNDeSwuQscocCfVkqxO7ow= X-ASG-Debug-ID: 1379605692-0421b5021f406c30001-6jHSXT Received: from CAS2.int.fusionio.com (cas2.int.fusionio.com [10.101.1.41]) by mx2.fusionio.com with ESMTP id 7K38Ku6JtAY4cYp6 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Thu, 19 Sep 2013 09:48:12 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (10.101.1.160) by mail.fusionio.com (10.101.1.41) with Microsoft SMTP Server (TLS) id 14.3.158.1; Thu, 19 Sep 2013 09:48:11 -0600 From: Josef Bacik To: CC: , , , , Subject: [PATCH 2/2] Btrfs: stop caching thread if extetn_commit_sem is contended Date: Thu, 19 Sep 2013 11:48:08 -0400 X-ASG-Orig-Subj: [PATCH 2/2] Btrfs: stop caching thread if extetn_commit_sem is contended Message-ID: <1379605688-987-2-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1379605688-987-1-git-send-email-jbacik@fusionio.com> References: <1379605688-987-1-git-send-email-jbacik@fusionio.com> MIME-Version: 1.0 X-Originating-IP: [10.101.1.160] X-Barracuda-Connect: cas2.int.fusionio.com[10.101.1.41] X-Barracuda-Start-Time: 1379605692 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=BSF_SC0_MISMATCH_TO X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.140754 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 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_SIGNED, 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 We can starve out the transaction commit with a bunch of caching threads all running at the same time. This is because we will only drop the extent_commit_sem if we need_resched(), which isn't likely to happen since we will be reading a lot from the disk so have already schedule()'ed plenty. Alex observed that he could starve out a transaction commit for up to a minute with 32 caching threads all running at once. This will allow us to drop the extent_commit_sem to allow the transaction commit to swap the commit_root out and then all the cachers will start back up. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index cfb3cf7..cc074c34 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -442,7 +442,8 @@ next: if (ret) break; - if (need_resched()) { + if (need_resched() || + rwsem_is_contended(&fs_info->extent_commit_sem)) { caching_ctl->progress = last; btrfs_release_path(path); up_read(&fs_info->extent_commit_sem);