Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3662536rwb; Tue, 16 Aug 2022 06:58:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7O3RVtCJM03AstbJuPeOC1XsWA0ZZ2zpkiITKb7FThjT2bISDf5uF6OgnxlozrjUKXvQkb X-Received: by 2002:a05:6402:3326:b0:43d:4448:437c with SMTP id e38-20020a056402332600b0043d4448437cmr19269393eda.394.1660658289497; Tue, 16 Aug 2022 06:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660658289; cv=none; d=google.com; s=arc-20160816; b=V/gbXkCsrL5Syx12IN/C8MnbtuOAA5eScQ9U/GgraOZhbytsxyJxTrQkU2p4Wg5Ijl twc0tv4F48CJEVVql1eYgXFJ1+PaoQ2rXmYlpYOw6kk388wVdoCvLUijg9wseDPbWCIf lJkCrdvxka1luc2wShwWRNWAzlJWLtnMGRJyLitMV+V4mKjNBCxiG6R1PDUq09gNqEUc B94s4EeTHS4OsSE+Ut9XyXIAFW0uq0Pe236MWB3hVku9MfnE/w9f62GuqO1BOKjDMa6h Hze6inEGonS2HVZlY0jMO6oOZQW82fPaBuT9UIeSR6Xk5+CFkyfEPZw45/3Z8MzdCXID qWHQ== 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:dkim-signature; bh=s9pW+j45CT3GBoi08C3tTLrCY/sEoytbxhI4uW5L5MU=; b=g6hVSzV33lr0ieNeFQNUYk5BKhIMnxdHedAASzzxKlfyejDKT5KggUvN5zx4ytNZZb LMXbbRi3X8KNa+IRZXktBU8+c2Vx6K258r66gj97ARe3nN1VXfzvg8+45JI1EsTRrHKM 8ZZKtn1SSZz00MPEo/i9unMeQwsaumrw07YjDHI61r1OinVNVqzNsXZMMoKlFA16aoEc z/DG58l9dRZE6+MGa/NLhcg58fluMMiGFt6+t3LhQltirjQ675Q9Zp6IUNs7YbquA2No mOY6NHZHYmIh2bl8iItnq3XimiWPa/6jJPSLlAu3MQtOw8/kZWVclXZ/GLSXoY31HYMi qEZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LAQ0fA7R; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a170906794800b00738545f4076si5352408ejo.286.2022.08.16.06.57.43; Tue, 16 Aug 2022 06:58:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LAQ0fA7R; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbiHPNoa (ORCPT + 99 others); Tue, 16 Aug 2022 09:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiHPNo3 (ORCPT ); Tue, 16 Aug 2022 09:44:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C99BC50731; Tue, 16 Aug 2022 06:44:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E5EA2B81A03; Tue, 16 Aug 2022 13:44:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1687C433D7; Tue, 16 Aug 2022 13:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660657464; bh=P+jgybUCHwny7uFjy5DzH0ceYlTrA2QBZL0r4X5dIxA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LAQ0fA7RhR1F5Ln+Yvo8ZxbMb1h6UWnDApx5yM9v8zfHgdmor3AvV9DiNzxLZB1Gc MLP4+bVHo2bl8KnFh9CRq88wTM+BBgI5M0eyTfR8xi9MDMxUlm2+vK99y4ihJ/DjJw lF0iSIvDsaRELWWrn+yvrLKIrGv9S6RLioa63kQbtXvcgAuvHs5A00mJpAXocjwWXm +5un06pZh/TjrBL6LPwkSjRmx0aJY51G+kWA/3o8olOJJ8aYJENbBxxRLufOgj7Y5W RAnxo0AEjjtCuUib8deJYB9dtbTZh7W2V86IAzNjbsO58hqO3yEFukfplnVUMt/YxM qmGF98JiYFNCg== Date: Tue, 16 Aug 2022 15:44:19 +0200 From: Christian Brauner To: Jeff Layton Cc: viro@zeniv.linux.org.uk, dhowells@redhat.com, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, Jeff Layton Subject: Re: [PATCH 1/4] vfs: report change attribute in statx for IS_I_VERSION inodes Message-ID: <20220816134419.xra4krb3jwlm4npk@wittgenstein> References: <20220816132759.43248-1-jlayton@kernel.org> <20220816132759.43248-2-jlayton@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220816132759.43248-2-jlayton@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Aug 16, 2022 at 09:27:56AM -0400, Jeff Layton wrote: > From: Jeff Layton > > Claim one of the spare fields in struct statx to hold a 64-bit change > attribute. When statx requests this attribute, do an > inode_query_iversion and fill the result in the field. > > Also update the test-statx.c program to display the change attribute and > the mountid as well. > > Signed-off-by: Jeff Layton > --- > fs/stat.c | 7 +++++++ > include/linux/stat.h | 1 + > include/uapi/linux/stat.h | 3 ++- > samples/vfs/test-statx.c | 8 ++++++-- > 4 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/fs/stat.c b/fs/stat.c > index 9ced8860e0f3..7c3d063c31ba 100644 > --- a/fs/stat.c > +++ b/fs/stat.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -118,6 +119,11 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, > stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT | > STATX_ATTR_DAX); > > + if ((request_mask & STATX_CHANGE_ATTR) && IS_I_VERSION(inode)) { > + stat->result_mask |= STATX_CHANGE_ATTR; > + stat->change_attr = inode_query_iversion(inode); > + } > + > mnt_userns = mnt_user_ns(path->mnt); > if (inode->i_op->getattr) > return inode->i_op->getattr(mnt_userns, path, stat, > @@ -611,6 +617,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) > tmp.stx_dev_major = MAJOR(stat->dev); > tmp.stx_dev_minor = MINOR(stat->dev); > tmp.stx_mnt_id = stat->mnt_id; > + tmp.stx_change_attr = stat->change_attr; > > return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; > } > diff --git a/include/linux/stat.h b/include/linux/stat.h > index 7df06931f25d..7b444c2ad0ad 100644 > --- a/include/linux/stat.h > +++ b/include/linux/stat.h > @@ -50,6 +50,7 @@ struct kstat { > struct timespec64 btime; /* File creation time */ > u64 blocks; > u64 mnt_id; > + u64 change_attr; > }; > > #endif > diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h > index 1500a0f58041..fd839ec76aa4 100644 > --- a/include/uapi/linux/stat.h > +++ b/include/uapi/linux/stat.h > @@ -124,7 +124,7 @@ struct statx { > __u32 stx_dev_minor; > /* 0x90 */ > __u64 stx_mnt_id; > - __u64 __spare2; > + __u64 stx_change_attr; /* Inode change attribute */ > /* 0xa0 */ > __u64 __spare3[12]; /* Spare space for future expansion */ > /* 0x100 */ > @@ -152,6 +152,7 @@ struct statx { > #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ > #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ > #define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */ > +#define STATX_CHANGE_ATTR 0x00002000U /* Want/got stx_change_attr */ I'm a bit worried that STATX_CHANGE_ATTR isn't a good name for the flag and field. Or I fail to understand what exact information this will expose and how userspace will consume it. To me the naming gives the impression that some set of generic attributes have changed but given that statx is about querying file attributes this becomes confusing. Wouldn't it make more sense this time to expose it as what it is and call this STATX_INO_VERSION and __u64 stx_ino_version?