From patchwork Thu Sep 20 14:42:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Popa X-Patchwork-Id: 1485621 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 5DD93DF2D2 for ; Thu, 20 Sep 2012 14:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932249Ab2ITOnH (ORCPT ); Thu, 20 Sep 2012 10:43:07 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:50626 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932154Ab2ITOnE (ORCPT ); Thu, 20 Sep 2012 10:43:04 -0400 Received: by eekc1 with SMTP id c1so975672eek.19 for ; Thu, 20 Sep 2012 07:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=i-neo.ro; s=google; h=from:to:cc:subject:date:message-id:x-mailer; bh=sLLI/1HIEraKL9zk+kYuUpeubAJKDAFajfsMI8HbU/8=; b=qoujkCG6edtpvSMwyCJh9L21nr+htnaulXNYJ50U3Vfa0Rr9EzCdAntinSyNCICwpX yqJnL7AuTEVHDHkwqIEqdm8pWblFLFLYZdY7OiEjr3SbeWKNjpwIzVhZY2DD1diTYxtK I9OyovzEzYaRqS2t63FCCqT7NQ3+AQI3hO/C4= 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=sLLI/1HIEraKL9zk+kYuUpeubAJKDAFajfsMI8HbU/8=; b=mzrozRnwsX//yfRZYw30p1fI7xZbu+utNteLLGyd3QaCUULHNPbvLiDO7uVdwY+WZ0 A/SRdQUtj3zIquWZ1+PCutKTaHwfTeUArrh93yGGf+UjRb54bVMmQn89xIGIOeHp4dgh NFo1AzwgFJw7HuTlSI5rCpNB2p0RLLVtmlTL8VGfvycBKQJzGnsUcejuE1catJvvbkTp NDFYlW6TURWZUA78F5jHG7xWduqdIlDsLUYLtpH0C0MkfAc5b+9m/Iky6njnBZ6WoyX9 HR/ZGC21+t0v8YL+YinbMphlwVzKBRLyYtaxAAbnjYx5IN2hLfLBqzUYbkT2GRLrnf/7 3eww== Received: by 10.14.178.6 with SMTP id e6mr2491555eem.36.1348152180932; Thu, 20 Sep 2012 07:43:00 -0700 (PDT) Received: from ierdnac-hp ([188.173.2.234]) by mx.google.com with ESMTPS id e7sm16244552eep.2.2012.09.20.07.42.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 07:43:00 -0700 (PDT) Received: by ierdnac-hp (sSMTP sendmail emulation); Thu, 20 Sep 2012 17:42:12 +0300 From: Andrei Popa To: linux-btrfs@vger.kernel.org Cc: Andrei Popa Subject: [PATCH] Btrfs: make compress and nodatacow mount options mutually exclusive Date: Thu, 20 Sep 2012 17:42:11 +0300 Message-Id: <1348152131-24198-1-git-send-email-andrei.popa@i-neo.ro> X-Mailer: git-send-email 1.7.8.6 X-Gm-Message-State: ALoCoQnOzrtF0Cwq65DNhxMfuOZhNlprjlAnSWOhiFErWtqqOA7y0ypsMk72sOEsDVr08c9ayG6H Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If a filesystem is mounted with compression and then remounted by adding nodatacow, the compression is disabled but the compress flag is still visible. Also, if a filesystem is mounted with nodatacow and then remounted with compression, nodatacow flag is still present but it's not active. This patch: - removes compress flags and notifies that the compression has been disabled if the filesystem is mounted with nodatacow - removes nodatacow and nodatasum flags if mounted with compress. Signed-off-by: Andrei Popa Reviewed-by: David Sterba --- fs/btrfs/super.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 073c236..6c72832 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -382,7 +382,15 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) btrfs_set_opt(info->mount_opt, NODATASUM); break; case Opt_nodatacow: - printk(KERN_INFO "btrfs: setting nodatacow\n"); + if (!btrfs_test_opt(root, COMPRESS) || + !btrfs_test_opt(root, FORCE_COMPRESS)) { + printk(KERN_INFO "btrfs: setting nodatacow, compression disabled\n"); + } else { + printk(KERN_INFO "btrfs: setting nodatacow\n"); + } + info->compress_type = BTRFS_COMPRESS_NONE; + btrfs_clear_opt(info->mount_opt, COMPRESS); + btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); btrfs_set_opt(info->mount_opt, NODATACOW); btrfs_set_opt(info->mount_opt, NODATASUM); break; @@ -397,10 +405,14 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) compress_type = "zlib"; info->compress_type = BTRFS_COMPRESS_ZLIB; btrfs_set_opt(info->mount_opt, COMPRESS); + btrfs_clear_opt(info->mount_opt, NODATACOW); + btrfs_clear_opt(info->mount_opt, NODATASUM); } else if (strcmp(args[0].from, "lzo") == 0) { compress_type = "lzo"; info->compress_type = BTRFS_COMPRESS_LZO; btrfs_set_opt(info->mount_opt, COMPRESS); + btrfs_clear_opt(info->mount_opt, NODATACOW); + btrfs_clear_opt(info->mount_opt, NODATASUM); btrfs_set_fs_incompat(info, COMPRESS_LZO); } else if (strncmp(args[0].from, "no", 2) == 0) { compress_type = "no";