From patchwork Thu Sep 12 08:08:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 2876751 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 E441C9F486 for ; Thu, 12 Sep 2013 08:08:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 344F3202E6 for ; Thu, 12 Sep 2013 08:08:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEBB2202DB for ; Thu, 12 Sep 2013 08:08:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754845Ab3ILIId (ORCPT ); Thu, 12 Sep 2013 04:08:33 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:29545 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754391Ab3ILIII (ORCPT ); Thu, 12 Sep 2013 04:08:08 -0400 X-IronPort-AV: E=Sophos;i="4.90,889,1371052800"; d="scan'208";a="8502287" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 12 Sep 2013 16:04:31 +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 r8C87cWY015391 for ; Thu, 12 Sep 2013 16:07:40 +0800 Received: from localhost.localdomain ([10.167.226.57]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013091216051758-1449937 ; Thu, 12 Sep 2013 16:05:17 +0800 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: quwenruo@cn.fujitsu.com Subject: [PATCH v2 9/9] btrfs: Replace thread_pool_size with workqueue default value Date: Thu, 12 Sep 2013 16:08:24 +0800 Message-Id: <1378973304-11693-10-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1378973304-11693-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1378973304-11693-1-git-send-email-quwenruo@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/12 16:05:17, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/12 16:05:19, Serialize complete at 2013/09/12 16:05:19 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.8 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 The original btrfs_workers uses the fs_info->thread_pool_size as the max_active, and the previous patches followed this way. But the kernel workqueue has the default value(0) for workqueue, and workqueue itself has some threshold mechanism to prevent creating too many threads, so we should use the default value. Since the thread_pool_size algorithm is not used, related codes should also be changed. Signed-off-by: Qu Wenruo --- fs/btrfs/disk-io.c | 12 +++++++----- fs/btrfs/super.c | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a61e1fe..0446d27 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -750,9 +750,11 @@ int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info) { - unsigned long limit = min_t(unsigned long, - info->thread_pool_size, - info->fs_devices->open_devices); + unsigned long limit; + limit = info->thread_pool_size ? + min_t(unsigned long, info->thread_pool_size, + info->fs_devices->open_devices) : + info->fs_devices->open_devices; return 256 * limit; } @@ -2191,8 +2193,8 @@ int open_ctree(struct super_block *sb, INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_WAIT); spin_lock_init(&fs_info->reada_lock); - fs_info->thread_pool_size = min_t(unsigned long, - num_online_cpus() + 2, 8); + /* use the default value of kernel workqueue */ + fs_info->thread_pool_size = 0; INIT_LIST_HEAD(&fs_info->ordered_roots); spin_lock_init(&fs_info->ordered_root_lock); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 63e653c..ccf412f 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -898,8 +898,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) if (info->alloc_start != 0) seq_printf(seq, ",alloc_start=%llu", (unsigned long long)info->alloc_start); - if (info->thread_pool_size != min_t(unsigned long, - num_online_cpus() + 2, 8)) + if (info->thread_pool_size) seq_printf(seq, ",thread_pool=%d", info->thread_pool_size); if (btrfs_test_opt(root, COMPRESS)) { if (info->compress_type == BTRFS_COMPRESS_ZLIB)