From patchwork Tue Aug 23 20:02:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 1089752 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7NK2ks3007043 for ; Tue, 23 Aug 2011 20:03:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753585Ab1HWUCz (ORCPT ); Tue, 23 Aug 2011 16:02:55 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:56659 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756114Ab1HWUCz (ORCPT ); Tue, 23 Aug 2011 16:02:55 -0400 Received: by mail-bw0-f46.google.com with SMTP id 11so372435bke.19 for ; Tue, 23 Aug 2011 13:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=vTUgtpUX/+9JEW4ra7ZUqKuTk69/82I1E8diEH67Yvw=; b=qm3E9wf3FzXfJkyR1czcG1reAH6sAJ5O4ATntnmzE8sL4vJ8G07EFQ2MOXO3TLUz/W IWhXB2exfo9/IYrBHk+UXNuqB2k/QNSywnGs9reu6h5A16ht89+2hRjeUN+k7M1EYJx1 IRPljLeVDfGQQAY1CR90/t7qcv/bEQjzYXfzo= Received: by 10.204.157.144 with SMTP id b16mr2010741bkx.286.1314129774323; Tue, 23 Aug 2011 13:02:54 -0700 (PDT) Received: from localhost ([31.28.235.172]) by mx.google.com with ESMTPS id r24sm83300bkr.26.2011.08.23.13.02.52 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Aug 2011 13:02:53 -0700 (PDT) From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Hugo Mills , idryomov@gmail.com Subject: [PATCH 19/21] Btrfs: add skip_restripe mount option Date: Tue, 23 Aug 2011 23:02:00 +0300 Message-Id: <1314129722-31601-20-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1314129722-31601-1-git-send-email-idryomov@gmail.com> References: <1314129722-31601-1-git-send-email-idryomov@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 23 Aug 2011 20:03:07 +0000 (UTC) Since restriper kthread starts involuntarily on mount and can suck cpu and memory bandwidth add a mount option to forcefully skip it. The restriper in that case hangs around in paused state and can be resumed from userspace when it's convenient. Signed-off-by: Ilya Dryomov --- fs/btrfs/ctree.h | 1 + fs/btrfs/super.c | 8 +++++++- fs/btrfs/volumes.c | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8e764d9..0eaa08d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1432,6 +1432,7 @@ struct btrfs_ioctl_defrag_range_args { #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) +#define BTRFS_MOUNT_SKIP_RESTRIPE (1 << 18) #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 15634d4..1ef8c33 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -162,7 +162,7 @@ enum { Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, - Opt_inode_cache, Opt_err, + Opt_inode_cache, Opt_skip_restripe, Opt_err, }; static match_table_t tokens = { @@ -195,6 +195,7 @@ static match_table_t tokens = { {Opt_subvolrootid, "subvolrootid=%d"}, {Opt_defrag, "autodefrag"}, {Opt_inode_cache, "inode_cache"}, + {Opt_skip_restripe, "skip_restripe"}, {Opt_err, NULL}, }; @@ -381,6 +382,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) printk(KERN_INFO "btrfs: enabling auto defrag"); btrfs_set_opt(info->mount_opt, AUTO_DEFRAG); break; + case Opt_skip_restripe: + btrfs_set_opt(info->mount_opt, SKIP_RESTRIPE); + break; case Opt_err: printk(KERN_INFO "btrfs: unrecognized mount option " "'%s'\n", p); @@ -729,6 +733,8 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) seq_puts(seq, ",autodefrag"); if (btrfs_test_opt(root, INODE_MAP_CACHE)) seq_puts(seq, ",inode_cache"); + if (btrfs_test_opt(root, SKIP_RESTRIPE)) + seq_puts(seq, ",skip_restripe"); return 0; } diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index bfe2b03..d8958e2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2756,13 +2756,24 @@ static int restriper_kthread(void *data) { struct restripe_control *rctl = (struct restripe_control *)data; struct btrfs_fs_info *fs_info = rctl->fs_info; - int ret; + int ret = 0; mutex_lock(&fs_info->restripe_mutex); - printk(KERN_INFO "btrfs: continuing restripe\n"); + if (btrfs_test_opt(fs_info->tree_root, SKIP_RESTRIPE)) { + mutex_lock(&fs_info->volume_mutex); + set_restripe_control(rctl, 0); + mutex_unlock(&fs_info->volume_mutex); + + printk(KERN_INFO "btrfs: force skipping restripe\n"); + goto out; + } else { + printk(KERN_INFO "btrfs: continuing restripe\n"); + } + ret = btrfs_restripe(rctl, 1); +out: mutex_unlock(&fs_info->restripe_mutex); return ret; }