Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp302619ybb; Wed, 15 Apr 2020 01:35:00 -0700 (PDT) X-Google-Smtp-Source: APiQypINEHs/rkwktehSwBImI19iLkd97D16cCEdPuHZ7UaQOS6kG2wQOI7teHEvYrQ/iMaqhM5B X-Received: by 2002:a17:906:3e52:: with SMTP id t18mr3871993eji.204.1586939700700; Wed, 15 Apr 2020 01:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586939700; cv=none; d=google.com; s=arc-20160816; b=bUdwPoCNwvrHNU91EO4s6VaTWoK+G64JusMV+eFyyeN75XpXZ640LpgipQgk7zynqQ 8O9uoWVCqe24Umg+Vd79bPBRvYLsjYKJGezMLhKXaZsCPzcv+z+NotOk6yby/PJk5rsU kSbq+n37riNepx3kbhnkHF9UByRgFb/2H2FJWbWBVzMPiWA4keD2GUu0J9Wld4tQZnQJ oO7Azl7xJgMkjFsz9D3h81qkoQelZRl/pUcJWi+zKc/xzbk2hVQvLhI4MqzmQ9pnEghP E5n4Z/Hg63OUK5aYuerkXgLt4Jaq0BW8MRnperkFFx+MLjlj13xfrDDuUQRKqpp9Pklo D7PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=IFxpUAABNbz//SqjcJW9RCj9wHkMy1oAIFYypxlPdBY=; b=osxAVJN5+wodxqbIuAOyVj1/M2xswqGu407ZOE6adeEu5NTdMywWyBZJwS5uXNLnal Yf5mfH1NtH7Fmph+I1eOsSlnnoScda9rQXT9IQuym+W4HyMxdiWHpSW1QuszYlCBCGfh VZtrY/n52Smp/IyptD/EEkALAy2tUIdZkCT9Xbh4Wutgek1QJefbgdUmFiU/mpUZkHiS 3mZAZRmX5CjepE4YRRizD+ZzQrfy7/K6dX75t6rNsDTuKeOFhBoRKqyxcYRZ6buLfjKv sAJ/8oeO6aLfll/BsAs7WQYuG6ttfLzjV966sy74SKsvYaVWaCv0yvwofcNos6V11zeP VjyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a62si9873867edf.579.2020.04.15.01.34.36; Wed, 15 Apr 2020 01:35:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405012AbgDNEBi (ORCPT + 99 others); Tue, 14 Apr 2020 00:01:38 -0400 Received: from mga18.intel.com ([134.134.136.126]:61616 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgDNEAs (ORCPT ); Tue, 14 Apr 2020 00:00:48 -0400 IronPort-SDR: +QZ6YAMwmEC5weDal5VlXOA3YbM7BAz7YutOeYNNIMDPtXzRdNnm1MOBrgAAf+aPRaqgtTL2Hj DcBtwuIDebuA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2020 21:00:47 -0700 IronPort-SDR: /vezDxyYNg30j1gO5/hvVLA4z6VaporjKFteFDpq7AIxmDSuWr+A+ECKUegOUqtdyh42rSGGuH fY3mM13b9f2g== X-IronPort-AV: E=Sophos;i="5.72,381,1580803200"; d="scan'208";a="241859904" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2020 21:00:46 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org, Jan Kara Cc: Ira Weiny , "Darrick J. Wong" , Dan Williams , Dave Chinner , Christoph Hellwig , "Theodore Y. Ts'o" , Jeff Moyer , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX Date: Mon, 13 Apr 2020 21:00:25 -0700 Message-Id: <20200414040030.1802884-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414040030.1802884-1-ira.weiny@intel.com> References: <20200414040030.1802884-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Ira Weiny Encryption and DAX are incompatible. Changing the DAX mode due to a change in Encryption mode is wrong without a corresponding address_space_operations update. Make the 2 options mutually exclusive by returning an error if DAX was set first. Signed-off-by: Ira Weiny --- fs/ext4/super.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 0c7c4adb664e..b14863058115 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1325,7 +1325,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, if (inode->i_ino == EXT4_ROOT_INO) return -EPERM; - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + if (WARN_ON_ONCE(IS_DAX(inode))) return -EINVAL; res = ext4_convert_inline_data(inode); @@ -1349,10 +1349,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ ext4_set_inode_flags(inode); } return res; @@ -1376,10 +1372,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, ctx, len, 0); if (!res) { ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ ext4_set_inode_flags(inode); res = ext4_mark_inode_dirty(handle, inode); if (res) -- 2.25.1