Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp661068ybz; Wed, 15 Apr 2020 16:09:14 -0700 (PDT) X-Google-Smtp-Source: APiQypK3HSmjm2Tz+JbHonHOJVhTIJ+7NjOHg/la/uIfdk476FW3TbaOKkKFQtWYXZIRMBvia2Y6 X-Received: by 2002:a17:906:3796:: with SMTP id n22mr6932119ejc.225.1586992154434; Wed, 15 Apr 2020 16:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586992154; cv=none; d=google.com; s=arc-20160816; b=Xb0bOinI4fjeW+KIaGLGczrd+O5NTPK7E3TUMS7ObQe/LxzZG5Qyxy+Y9KRon0HZIP HHAKOZ7hQrTLjUhCE5KFWYkF+fYFq8UpFtfx46V3eKZRpL9TZ4qhb+MGCKLrvQu1c9bU YlMnKP8R4R5ySxdcXlKl7p0mMakG5rNHt+zIMgyRZk+HyiiA/Ubj8WT0acXuYOlqrZ7X JeCNtbCSvbkWAsvgLoH3F0BGvmcbjCLbkJJa1oFlibzJd19q3l7iUICFyj+8hw84yT9O eS9fQK73mLdQtiK/69AW+NN1iR+2TLDw5WzF4CHfxMZu7vgAUNcbH5TJE7nXaqrmYLTs RRcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=g+0lHbIOPTg6oEtOdqA57pTaTWcpIrrbErucihk2d5E=; b=McQxrEwglSi3FwTfYs/lFkCoUzyw1X8J3GiB9qlTK0mv1PCE3Ks3uERymriIA4ZGga o+JTtHXdte7iuFl0L0yOIRlisy0VkN3Yrbta7xkRjhHg0aKqxmpDbnGT53rwnwziW3vM xGfYt43wqXZu+qesOftmAHCScMxJu+LKHQ89ZRsfJfk5Ik8P8sGDSnA6RUQSuXInhw+1 zdH/kh/ca2qHCuQl418g2U58qQxYpkhDijKk/EMkufjfRLHxmy/AgV4x2kXzBHvxjRGt +msenIDh3qj8PAQejvz0PrTfh/DPLma19W+CpflDfUc63D84I3hQiBejLMeu/yVbLORk u9DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oc19si5841131ejb.487.2020.04.15.16.08.50; Wed, 15 Apr 2020 16:09:14 -0700 (PDT) Received-SPF: pass (google.com: 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: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368213AbgDOMCq (ORCPT + 99 others); Wed, 15 Apr 2020 08:02:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:36694 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409739AbgDOMCn (ORCPT ); Wed, 15 Apr 2020 08:02:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 20792AED8; Wed, 15 Apr 2020 12:02:41 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 146861E1250; Wed, 15 Apr 2020 14:02:41 +0200 (CEST) Date: Wed, 15 Apr 2020 14:02:41 +0200 From: Jan Kara To: ira.weiny@intel.com Cc: linux-kernel@vger.kernel.org, Jan Kara , "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: Re: [PATCH RFC 3/8] fs/ext4: Disallow encryption if inode is DAX Message-ID: <20200415120241.GF6126@quack2.suse.cz> References: <20200414040030.1802884-1-ira.weiny@intel.com> <20200414040030.1802884-4-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200414040030.1802884-4-ira.weiny@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 13-04-20 21:00:25, ira.weiny@intel.com wrote: > 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))) Also here I don't think WARN_ON_ONCE() is warranted once we allow per-inode setting of DAX. It will then become a regular error condition... Honza > 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 > -- Jan Kara SUSE Labs, CR