From patchwork Tue Jan 14 12:31:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 3485751 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 DCC8B9F381 for ; Tue, 14 Jan 2014 13:16:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61C9F2020F for ; Tue, 14 Jan 2014 13:16:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4309220211 for ; Tue, 14 Jan 2014 13:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbaANNQS (ORCPT ); Tue, 14 Jan 2014 08:16:18 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:26089 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751819AbaANNQQ (ORCPT ); Tue, 14 Jan 2014 08:16:16 -0500 X-IronPort-AV: E=Sophos;i="4.95,658,1384272000"; d="scan'208";a="9415309" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 14 Jan 2014 21:12:19 +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 s0ECUO5k015722 for ; Tue, 14 Jan 2014 20:30:25 +0800 Received: from miao.fnst.cn.fujitsu.com ([10.167.226.106]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014011420291300-1067065 ; Tue, 14 Jan 2014 20:29:13 +0800 From: Miao Xie To: linux-btrfs@vger.kernel.org Subject: [PATCH V2 2/4] Btrfs: don't get the lock when adding a csum into a ordered extent Date: Tue, 14 Jan 2014 20:31:50 +0800 Message-Id: <1389702712-26638-3-git-send-email-miaox@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1389702712-26638-1-git-send-email-miaox@cn.fujitsu.com> References: <1389702712-26638-1-git-send-email-miaox@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/14 20:29:13, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/14 20:29:13, Serialize complete at 2014/01/14 20:29:13 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.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 are sure that: - one ordered extent just has one csum calculation worker, and no one access the csum list during the csum calculation except the worker. - we don't change the list and free the csum until no one reference to the ordered extent So it is safe to add csum without the lock. Signed-off-by: Miao Xie --- fs/btrfs/ordered-data.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index e4c3d56..396c6d1 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -280,16 +280,11 @@ void btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_extent *entry, struct btrfs_ordered_sum *sum) { - struct btrfs_ordered_inode_tree *tree; - - tree = &BTRFS_I(inode)->ordered_tree; - spin_lock_irq(&tree->lock); list_add_tail(&sum->list, &entry->list); WARN_ON(entry->csum_bytes_left < sum->len); entry->csum_bytes_left -= sum->len; if (entry->csum_bytes_left == 0) wake_up(&entry->wait); - spin_unlock_irq(&tree->lock); } /*