From patchwork Tue May 7 06:15:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2532121 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7DDD13FC5A for ; Tue, 7 May 2013 06:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756830Ab3EGG15 (ORCPT ); Tue, 7 May 2013 02:27:57 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:1039 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756621Ab3EGG14 (ORCPT ); Tue, 7 May 2013 02:27:56 -0400 X-IronPort-AV: E=Sophos;i="4.87,627,1363104000"; d="scan'208";a="7204209" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 07 May 2013 14:25:04 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r476A2JD020172; Tue, 7 May 2013 14:10:03 +0800 Received: from [127.0.0.1] ([10.167.233.203]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013050714090848-1043745 ; Tue, 7 May 2013 14:09:08 +0800 Message-ID: <51889BF1.1000300@cn.fujitsu.com> Date: Tue, 07 May 2013 14:15:13 +0800 From: Wang Shilong User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Linux Btrfs CC: Jan Schmidt Subject: [PATCH] Btrfs: save us a mutex_lock usage when doing quota rescan X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/07 14:09:08, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/07 14:09:10, Serialize complete at 2013/05/07 14:09:10 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If qgroup_rescan worker is in progress, we should ignore the extent that has not been dealt with qgroup_rescan worker,just let them dealt later otherwise we may get wrong qgroup accounting. However, we have checked this before find_all_roots() without spin_lock. When doing qgroup accounting, we don't have to check it again, because during this period,qgroup_rescan worker can deal with more extents and qgroup_rescan_extent->objectid can only go larger, so here the check is unnecessary. Just remove this check, so that we don't need hold qgroup_rescan_lock when doing qgroup accounting. Signed-off-by: Wang Shilong --- fs/btrfs/qgroup.c | 9 --------- 1 files changed, 0 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index d059d86..2710784 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1445,15 +1445,7 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans, if (ret < 0) return ret; - mutex_lock(&fs_info->qgroup_rescan_lock); spin_lock(&fs_info->qgroup_lock); - if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) { - if (fs_info->qgroup_rescan_progress.objectid <= node->bytenr) { - ret = 0; - goto unlock; - } - } - quota_root = fs_info->quota_root; if (!quota_root) goto unlock; @@ -1492,7 +1484,6 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans, unlock: spin_unlock(&fs_info->qgroup_lock); - mutex_unlock(&fs_info->qgroup_rescan_lock); ulist_free(roots); return ret;