From patchwork Tue Dec 1 16:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11943341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB128C64E7B for ; Tue, 1 Dec 2020 16:59:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A7FC208FE for ; Tue, 1 Dec 2020 16:59:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KfgYPkqj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388037AbgLAQ6n (ORCPT ); Tue, 1 Dec 2020 11:58:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45425 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728168AbgLAQ6n (ORCPT ); Tue, 1 Dec 2020 11:58:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606841837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Ro4gapDF/c1vHKexZiNGzqQBi5h9f7igOkn2/s1ehI=; b=KfgYPkqjdH2p3lnep1vgh30v2tU4Wai0TvX4BaW/QBimmOn9AI98VV3YDMef30B2boDl45 3foFcNdNdiid9QdEuZO9Y7tKfFkLboYuDa7j8f0OrdkfUcTaxuz3nY5pK7xMvWRcsu/BHm 0hTzw0Wrs1xytejzWrgaVTrAJdhm3/o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-niUJn-4kNAuxnRoPOyqzVw-1; Tue, 01 Dec 2020 11:57:14 -0500 X-MC-Unique: niUJn-4kNAuxnRoPOyqzVw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E86181084427; Tue, 1 Dec 2020 16:57:12 +0000 (UTC) Received: from liberator.sandeen.net (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D32219D61; Tue, 1 Dec 2020 16:57:12 +0000 (UTC) Subject: [PATCH 1/2] uapi: fix statx attribute value overlap for DAX & MOUNT_ROOT To: torvalds@linux-foundation.org, Miklos Szeredi , Ira Weiny , David Howells Cc: linux-fsdevel@vger.kernel.org, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, xfs , linux-ext4@vger.kernel.org, Xiaoli Feng References: From: Eric Sandeen Message-ID: <7027520f-7c79-087e-1d00-743bdefa1a1e@redhat.com> Date: Tue, 1 Dec 2020 10:57:11 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org STATX_ATTR_MOUNT_ROOT and STATX_ATTR_DAX got merged with the same value, so one of them needs fixing. Move STATX_ATTR_DAX. While we're in here, clarify the value-matching scheme for some of the attributes, and explain why the value for DAX does not match. Signed-off-by: Eric Sandeen Reported-by: David Howells Reviewed-by: David Howells --- include/uapi/linux/stat.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 82cc58fe9368..9ad19eb9bbbf 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -171,9 +171,10 @@ struct statx { * be of use to ordinary userspace programs such as GUIs or ls rather than * specialised tools. * - * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS + * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags * semantically. Where possible, the numerical value is picked to correspond - * also. + * also. Note that the DAX attribute indicates that the inode is currently + * DAX-enabled, not simply that the per-inode flag has been set. */ #define STATX_ATTR_COMPRESSED 0x00000004 /* [I] File is compressed by the fs */ #define STATX_ATTR_IMMUTABLE 0x00000010 /* [I] File is marked immutable */ @@ -183,7 +184,7 @@ struct statx { #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ #define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */ #define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */ -#define STATX_ATTR_DAX 0x00002000 /* [I] File is DAX */ +#define STATX_ATTR_DAX 0x00400000 /* File is currently DAX-enabled */ #endif /* _UAPI_LINUX_STAT_H */ From patchwork Tue Dec 1 16:59:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 11943343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59F90C71156 for ; Tue, 1 Dec 2020 17:01:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F30E7206B7 for ; Tue, 1 Dec 2020 17:01:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DmJ0uvvb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729458AbgLARBK (ORCPT ); Tue, 1 Dec 2020 12:01:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57072 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbgLARBJ (ORCPT ); Tue, 1 Dec 2020 12:01:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606841983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T7i5uotD/IpTPlUrBO3NFp7pR07GWqIu1OIGoP+fxvk=; b=DmJ0uvvbaNgqpmsCw3OhxPcDdctciPugRepZMeTiXnSKo1q4e+ArPlISRhfV9immvpS6yT +GytrVe9AoNTkE5WV66Df5YeczJMQOUL8OtjjUmP4z8wgOs70y/etW+vTH9zb2qyxUCKxL BEEapfrgmdKUDxA+zQkFh2RoEOcUm4E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-IHTBsiIEPnyyAbiv00K3AQ-1; Tue, 01 Dec 2020 11:59:39 -0500 X-MC-Unique: IHTBsiIEPnyyAbiv00K3AQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB0609A223; Tue, 1 Dec 2020 16:59:37 +0000 (UTC) Received: from liberator.sandeen.net (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D8C919C44; Tue, 1 Dec 2020 16:59:36 +0000 (UTC) Subject: [PATCH 2/2] statx: move STATX_ATTR_DAX attribute handling to filesystems To: torvalds@linux-foundation.org, Miklos Szeredi , Ira Weiny , David Howells Cc: linux-fsdevel@vger.kernel.org, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, xfs , linux-ext4@vger.kernel.org, Xiaoli Feng References: From: Eric Sandeen Message-ID: <05a0f4fd-7f62-8fbc-378d-886ccd5b3f11@redhat.com> Date: Tue, 1 Dec 2020 10:59:36 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org It's a bit odd to set STATX_ATTR_DAX into the statx attributes in the VFS; while the VFS can detect the current DAX state, it is the filesystem which actually sets S_DAX on the inode, and the filesystem is the place that knows whether DAX is something that the "filesystem actually supports" [1] so that the statx attributes_mask can be properly set. So, move STATX_ATTR_DAX attribute setting to the individual dax-capable filesystems, and update the attributes_mask there as well. [1] 3209f68b3ca4 statx: Include a mask for stx_attributes in struct statx Signed-off-by: Eric Sandeen Reviewed-by: David Howells --- fs/ext2/inode.c | 6 +++++- fs/ext4/inode.c | 5 ++++- fs/stat.c | 3 --- fs/xfs/xfs_iops.c | 5 ++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 11c5c6fe75bb..3550783a6ea0 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1653,11 +1653,15 @@ int ext2_getattr(const struct path *path, struct kstat *stat, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & EXT2_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; + if (IS_DAX(inode)) + stat->attributes |= STATX_ATTR_DAX; + stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP); + STATX_ATTR_NODUMP | + STATX_ATTR_DAX); generic_fillattr(inode, stat); return 0; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0d8385aea898..848a0f2b154e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5550,13 +5550,16 @@ int ext4_getattr(const struct path *path, struct kstat *stat, stat->attributes |= STATX_ATTR_NODUMP; if (flags & EXT4_VERITY_FL) stat->attributes |= STATX_ATTR_VERITY; + if (IS_DAX(inode)) + stat->attributes |= STATX_ATTR_DAX; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | STATX_ATTR_NODUMP | - STATX_ATTR_VERITY); + STATX_ATTR_VERITY | + STATX_ATTR_DAX); generic_fillattr(inode, stat); return 0; diff --git a/fs/stat.c b/fs/stat.c index dacecdda2e79..5bd90949c69b 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -80,9 +80,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, if (IS_AUTOMOUNT(inode)) stat->attributes |= STATX_ATTR_AUTOMOUNT; - if (IS_DAX(inode)) - stat->attributes |= STATX_ATTR_DAX; - if (inode->i_op->getattr) return inode->i_op->getattr(path, stat, request_mask, query_flags); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 1414ab79eacf..56deda7042fd 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -575,10 +575,13 @@ xfs_vn_getattr( stat->attributes |= STATX_ATTR_APPEND; if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP) stat->attributes |= STATX_ATTR_NODUMP; + if (IS_DAX(inode)) + stat->attributes |= STATX_ATTR_DAX; stat->attributes_mask |= (STATX_ATTR_IMMUTABLE | STATX_ATTR_APPEND | - STATX_ATTR_NODUMP); + STATX_ATTR_NODUMP | + STATX_ATTR_DAX); switch (inode->i_mode & S_IFMT) { case S_IFBLK: