Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1175537pxu; Mon, 23 Nov 2020 13:41:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3wqrhultOwC9rtp4SNEp5GUgg610lRTuaQAUlmWYK0SO/thc5+gYlKjs3sYiVny2zxbaO X-Received: by 2002:a50:8ada:: with SMTP id k26mr1143314edk.281.1606167707289; Mon, 23 Nov 2020 13:41:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606167707; cv=none; d=google.com; s=arc-20160816; b=RrjUy6K1fM8NB0ATRUHSa0nybeLBqfu6j2JoltAuYzF+UevK7GTx0rrVzOwda23V0h BcFW/wD0naKhj2pEldyv5fQPkWDkgPvOdIoygo3l0XaX/m7MPsmlpvtHfdbAfYqebeIt /2M4x5pAdnJUUOTdO0fuK7S/AGkvqVwBnKwSAZFQSwA8CtiOKGCOpIOgiYH2TQUfUK79 Gtplnwr8o1dVzsNlFdZgjh+3qIxxH4BBNX2/+mrLAVrW8qCZtCgMrURHnOF098EfzQFC 5kabiKbBfg8PxE0hsfvII60lQBmI8yj5ErM6eO67e9VLRlETWOcpuy2tt/hK+kFVXb5x syJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=kcl+N3kHbUEjdBVvyZs8+D2ag2Smr1wH9M8/UtdP6rA=; b=lMg1iK/5tH+0uquroEajh9mOoONVR8Qh6rvs2yD5qV56H60iRjIeYyTF7w4csxFsg3 eH0G9Zlt1v8LszrWTeluq65/7wW9T0dl7mtQr+6JC3szgSpaQ13jlNPkc/jdq4SezIkW U0rRnAnquo18ucNQIeuVMb1KWYXBVkcJUXTTdgGzePz5QuIfqDTVU9MkyTrFtyoNDY92 zh9fZ4OGXZEHmoS9/m3QQy1NI+amunwmDSC58EuDjz54xcqKgnzgIfbQN30Bzy79Jo0z VRW4OaVbFkUXO3b+gxeXINfsPmNJMb0/E4bHPyuuIkqjhPjqdZGZlhbgUmw9xPrJaC5d VqVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 o17si7013000eji.599.2020.11.23.13.41.24; Mon, 23 Nov 2020 13:41:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731254AbgKWVhI (ORCPT + 99 others); Mon, 23 Nov 2020 16:37:08 -0500 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:57362 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730466AbgKWVhI (ORCPT ); Mon, 23 Nov 2020 16:37:08 -0500 Received: from dread.disaster.area (pa49-179-6-140.pa.nsw.optusnet.com.au [49.179.6.140]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id D38B658B8C4; Tue, 24 Nov 2020 08:37:03 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1khJWA-00EJp0-PA; Tue, 24 Nov 2020 08:37:02 +1100 Date: Tue, 24 Nov 2020 08:37:02 +1100 From: Dave Chinner To: "Darrick J. Wong" Cc: XiaoLi Feng , Randy Dunlap , linux-kernel@vger.kernel.org, ira.weiny@intel.com, Xiaoli Feng , linux-fsdevel Subject: Re: [PATCH] fs/stat: set attributes_mask for STATX_ATTR_DAX Message-ID: <20201123213702.GV7391@dread.disaster.area> References: <20201121003331.21342-1-xifeng@redhat.com> <21890103-fce2-bb50-7fc2-6c6d509b982f@infradead.org> <20201121011516.GD3837269@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201121011516.GD3837269@magnolia> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=YKPhNiOx c=1 sm=1 tr=0 cx=a_idp_d a=uDU3YIYVKEaHT0eX+MXYOQ==:117 a=uDU3YIYVKEaHT0eX+MXYOQ==:17 a=kj9zAlcOel0A:10 a=nNwsprhYR40A:10 a=pGLkceISAAAA:8 a=7-415B0cAAAA:8 a=zd7GPZmn2bw0TrGjmFEA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 20, 2020 at 06:03:18PM -0800, Darrick J. Wong wrote: > [Adding fsdevel to cc since this is a filesystems question] > > On Fri, Nov 20, 2020 at 04:58:09PM -0800, Randy Dunlap wrote: > > Hi, > > > > I don't know this code, but: > > > > On 11/20/20 4:33 PM, XiaoLi Feng wrote: > > > From: Xiaoli Feng > > > > > > keep attributes and attributes_mask are consistent for > > > STATX_ATTR_DAX. > > > --- > > > fs/stat.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/fs/stat.c b/fs/stat.c > > > index dacecdda2e79..914a61d256b0 100644 > > > --- a/fs/stat.c > > > +++ b/fs/stat.c > > > @@ -82,7 +82,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, > > > > > > if (IS_DAX(inode)) > > > stat->attributes |= STATX_ATTR_DAX; > > > - > > > + stat->attributes_mask |= STATX_ATTR_DAX; > > > > Why shouldn't that be: > > > > if (IS_DAX(inode)) > > stat->attributes_mask |= STATX_ATTR_DAX; > > > > or combine them, like this: > > > > if (IS_DAX(inode)) { > > stat->attributes |= STATX_ATTR_DAX; > > stat->attributes_mask |= STATX_ATTR_DAX; > > } > > > > > > and no need to delete that blank line. > > Some filesystems could support DAX but not have it enabled for this > particular file, so this won't work. > > General question: should filesystems that are /capable/ of DAX signal > this by setting the DAX bit in the attributes mask? I think so, yes. It could be set if the right bit on the inode is set, but it currently isn't so the bit in the mask is set but the bit in the attributes is not. i.e "DAX is valid status bit, but it is not set for this file". > Or is this a VFS > feature and hence here is the appropriate place to be setting the mask? Well, in the end it's a filesystem feature bit because the filesystem policy that decides whether DAX is used or not. e.g. if the block device is not DAX capable or dax=never mount option is set, we should not ever set STATX_ATTR_DAX in statx for either the attributes or attributes_mask field because the filesystem is not DAX capable. And given that we have filesystems with multiple block devices that can have different DAX capabilities, I think this statx() attr state (and mask) really has to come from the filesystem, not VFS... > Extra question: should we only set this in the attributes mask if > CONFIG_FS_DAX=y ? IMO, yes, because it will always be false on CONFIG_FS_DAX=n and so it may well as not be emitted as a supported bit in the mask. Cheers, Dave. -- Dave Chinner david@fromorbit.com