From patchwork Fri Jul 20 19:12:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mitch Harder X-Patchwork-Id: 1222221 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 54D5BE0038 for ; Fri, 20 Jul 2012 19:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908Ab2GTTMr (ORCPT ); Fri, 20 Jul 2012 15:12:47 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:49725 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434Ab2GTTMq (ORCPT ); Fri, 20 Jul 2012 15:12:46 -0400 Received: by ghrr11 with SMTP id r11so4333560ghr.19 for ; Fri, 20 Jul 2012 12:12:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=0kPZoXy9TTXQCKJSuRWFMUVt9XWdrTIjfcIbDExvpN4=; b=Q3vLS2V4GRhkl8HBe1GQc3XZnIfttaaz601VyODcHwDIDqQEiQAcfbD5mAD1CYbMs2 oNp+SAkAQMAwTmCc9LwkvPzUa9wb5HUs2cR1jjxuAUwEQiG4cjIKnD7MJHVC/lPPrN+n GWT+VFbVhf77vvHwhSxkusEi55P04ehqL/o0QmeZIXlpkySDvrf4NUYTTmkmzn8bBfBK lZdkuHC15o3e/3Ymzs4lat+lAfmz1fpMRgqAU69msEdS3Ha3ziw4vT1wdBOytb81wwxo lSPF59Mi3Pvtg8L087rDxGu/4B/nyBqVGRdwHokSOXGWDw+N3KvElmoiq3meEzYSsDUj aHFw== Received: by 10.236.75.163 with SMTP id z23mr6698759yhd.3.1342811565927; Fri, 20 Jul 2012 12:12:45 -0700 (PDT) Received: from zero-p.gateway.2wire.net (108-84-253-144.lightspeed.moblal.sbcglobal.net. [108.84.253.144]) by mx.google.com with ESMTPS id t22sm5736271anh.20.2012.07.20.12.12.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 Jul 2012 12:12:45 -0700 (PDT) From: Mitch Harder To: linux-btrfs@vger.kernel.org Cc: Mitch Harder Subject: [PATCH v2 1/2] Btrfs: Check INCOMPAT flags on remount with lzo compression Date: Fri, 20 Jul 2012 14:12:37 -0500 Message-Id: <1342811558-5303-1-git-send-email-mitch.harder@sabayonlinux.org> X-Mailer: git-send-email 1.7.8.6 X-Gm-Message-State: ALoCoQmyZJ4eYSxP/dlIXUXk9m/t9533LYX69f3Og/Co6tVxGDCidbm44FLquwus68T/wq1X7Fqp Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In support of the recently added capability to remount with lzo compression, check the compression INCOMPAT flags when remounting with lzo compression, and set the flags if necessary. Signed-off-by: Mitch Harder --- v1-v2: - Remove extraneous formatting change. fs/btrfs/ctree.h | 1 + fs/btrfs/super.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index a0ee2f8..8bee032 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3094,6 +3094,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); /* super.c */ int btrfs_parse_options(struct btrfs_root *root, char *options); +void btrfs_chk_lzo_incompat(struct btrfs_root *root); int btrfs_sync_fs(struct super_block *sb, int wait); void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...); void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 26da344..f3a5967 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -401,6 +401,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) compress_type = "lzo"; info->compress_type = BTRFS_COMPRESS_LZO; btrfs_set_opt(info->mount_opt, COMPRESS); + btrfs_chk_lzo_incompat(root); } else if (strncmp(args[0].from, "no", 2) == 0) { compress_type = "no"; info->compress_type = BTRFS_COMPRESS_NONE; @@ -587,6 +588,23 @@ out: } /* + * Check the INCOMPAT features in the super block, and set the + * LZO INCOMPAT flag if it has not been set. + */ +void btrfs_chk_lzo_incompat(struct btrfs_root *root) +{ + struct btrfs_super_block *disk_super; + u64 features; + + disk_super = root->fs_info->super_copy; + features = btrfs_super_incompat_flags(disk_super); + if (!(features & BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO)) { + features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO; + btrfs_set_super_incompat_flags(disk_super, features); + } +} + +/* * Parse mount options that are required early in the mount process. * * All other options will be parsed on much later in the mount process and