Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp206040ybr; Fri, 22 May 2020 04:49:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNC+YX8ZbUFYkscX/5mSp4lb1hmrhJ+gfNPCXx0cN7geYhZY3/Hv32hkm2eJq4RShjidyS X-Received: by 2002:a05:6402:2c4:: with SMTP id b4mr2619629edx.331.1590148187517; Fri, 22 May 2020 04:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590148187; cv=none; d=google.com; s=arc-20160816; b=DiUVzV2TOyGri9SCskmEcYxrV3eVjHhglLhTqc+F38i+ekhsr4gmiOTbVobv0tGHPj b3E2KvHSzvJs3WTgarngwlUi2v2fgmki83G5F/1OtAH0cuSl01/l1RvwtfmzYK5qrkIq tSmVSN0+LCgjaPPqYXBTUzdf32zFlFC58t7P25HQIcMZGkVXxwTRez6s7B2XolJ2nEtI umkqQIdnTOL7Kr8thjFLr2NCz7j7cGeVqyUUEok7vatX4priv1t6O6Jk9r+gHq9UYcX4 XhkGhEGKlYd/P6/+u6X241gdWGX/8+AxwTLI0jMVy3IyHoBAiG6O1BVw/gQekO26VMvw Z1fQ== 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=wSf5y8pzGK3ZPXx7i1ZGd2j8CNi3r4S4luK5VjUBSkk=; b=kFn8E3trC11hKXQs7URCv8Xxu/7TGKcftYjIteUgb2/pLo+QkVsVC7VY74bcQsXciM NQ/Crz4vOxp/yCwpgGwA5lwO00QCQIqARSomx4Ve0ise2nA2IBsJZgLuQecT5XpskCsV ddGVohec7DPA6x3AJIa849LkxABfWmOSbxTFYrnO+uPicb08uinWWKWNeWlqkwpuC5YX ORoWTV5OEG/vELiyHAsh3tfCmizJnS4D1dEA8qWgE+OGh933p5w0BKKjbreDKjpCkcBq WaKCL7ttDAkp8ZWE2H4fGeibMHBW9IQ8wm7szfHv/yyX2CA3x959F5jEp0SwY6UMmbKv eL8A== 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 dp6si6074710ejc.472.2020.05.22.04.49.15; Fri, 22 May 2020 04:49:47 -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 S1728783AbgEVLsx (ORCPT + 99 others); Fri, 22 May 2020 07:48:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:35406 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728495AbgEVLsw (ORCPT ); Fri, 22 May 2020 07:48:52 -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 18949AE41; Fri, 22 May 2020 11:48:53 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7834A1E126B; Fri, 22 May 2020 13:48:48 +0200 (CEST) Date: Fri, 22 May 2020 13:48:48 +0200 From: Jan Kara To: ira.weiny@intel.com Cc: linux-ext4@vger.kernel.org, Andreas Dilger , "Theodore Y. Ts'o" , Jan Kara , Eric Biggers , Al Viro , Dan Williams , Dave Chinner , Christoph Hellwig , Jeff Moyer , "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 7/8] fs/ext4: Introduce DAX inode flag Message-ID: <20200522114848.GC14199@quack2.suse.cz> References: <20200521191313.261929-1-ira.weiny@intel.com> <20200521191313.261929-8-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521191313.261929-8-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 Thu 21-05-20 12:13:12, ira.weiny@intel.com wrote: > From: Ira Weiny > > Add a flag to preserve FS_XFLAG_DAX in the ext4 inode. > > Set the flag to be user visible and changeable. Set the flag to be > inherited. Allow applications to change the flag at any time with the > exception of if VERITY or ENCRYPT is set. > > Disallow setting VERITY or ENCRYPT if DAX is set. > > Finally, on regular files, flag the inode to not be cached to facilitate > changing S_DAX on the next creation of the inode. > > Signed-off-by: Ira Weiny ... > @@ -303,6 +318,16 @@ static int ext4_ioctl_setflags(struct inode *inode, > unsigned int jflag; > struct super_block *sb = inode->i_sb; > > + if (ext4_test_inode_flag(inode, EXT4_INODE_DAX)) { > + if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY) || > + ext4_test_inode_flag(inode, EXT4_INODE_ENCRYPT) || > + ext4_test_inode_state(inode, > + EXT4_STATE_VERITY_IN_PROGRESS)) { > + err = -EOPNOTSUPP; > + goto flags_out; > + } > + } The way this check is implemented wouldn't IMO do what we need... It doesn't check the flags that are being set but just the current inode state. I think it should rather be: if ((flags ^ oldflags) & EXT4_INODE_DAX_FL) { ... } And perhaps move this to a place in ext4_ioctl_setflags() where we check other similar conflicts. And then we should check conflicts with the journal flag as well, as I mentioned in reply to the first patch. There it is more complicated by the fact that we should disallow setting of both EXT4_INODE_DAX_FL and EXT4_JOURNAL_DATA_FL at the same time so the checks will be somewhat more complicated. Honza > + > /* Is it quota file? Do not allow user to mess with it */ > if (ext4_is_quota_file(inode)) > goto flags_out; -- Jan Kara SUSE Labs, CR