Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4560023rwb; Mon, 8 Aug 2022 03:19:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR7fn9WAxmAYZqygq7Z8nHcOPSv8gnBEbpHtHzlJMmILafirK9nblhXzF8NaMeXiQsDBQ5tE X-Received: by 2002:a05:6a00:4095:b0:52d:ee31:ec37 with SMTP id bw21-20020a056a00409500b0052dee31ec37mr18078330pfb.63.1659953950279; Mon, 08 Aug 2022 03:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659953950; cv=none; d=google.com; s=arc-20160816; b=vc9ZAq8NyWASVVleH8IZ+abC8eDMC7anJL5Q+HTETnlh1G8Dy9AhVlS3wCUyUSghh+ 2Dh+40L16vI3IMXzW0pUhaPqhc2sC7CW0sXU2p6Qd17ZaN4pGHXuKwI8pjLe+vsSjBsK pTk/COl9V/dv4Y3dSIYqT31QDvaRed1lHWxqMww6k4SndwGJFjNFRObH7/oyEee7dtKL VUZxj92SDirZduvbwRXJby4MjWgIF3ZhBwvPF9vcjHykGhdThE7z9o6Y2iG7OQV/gQ1k 4GCwuwsWzFI1tvXYrmxrgVJNB7VApi2DzytxTx9776IOtl2V1pQMZn/wxN8lbpaQDgQ7 7XRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=zqurIDtZF1/93y9MigrIYfLu8FPjkuLZb7fciV6Hnuw=; b=Qbfi8RRA1OGzS36pwKOA4zGQs/QT1nrF9hl14Gms9dI7mVlQqy8y7R67bPIFRu9yLK f6Wi+FEtRUBIalZNxVBOji3w6/COHvL5U96Di4kaMi1BurlM2/7ev6rDtOW8SQLB+kVQ g8L/4MN9TJ0X/SdNJn/RfR2XgEp0vzMbHicEXE2KKedQpScXDUpMZW6zZBBjXsRF+hyn Vc9DK43dqmaoV7xidqlnZ/QDyz35uMGedRCdNuCb0GZqnocXfQWnuzbYj8GdkE8N01DP Z5S4+mu/fNUwT9wO1wcMOcrP3Sw6wUOCAd8ybXM0cA3+ttPb4f5tTMesgnQyM7Cfvo/c xmNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bayUb3SX; 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 l4-20020a17090aec0400b001f51f0d3737si10476477pjy.132.2022.08.08.03.18.36; Mon, 08 Aug 2022 03:19:10 -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=bayUb3SX; 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 S235395AbiHHKSW (ORCPT + 99 others); Mon, 8 Aug 2022 06:18:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234440AbiHHKSV (ORCPT ); Mon, 8 Aug 2022 06:18:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71D2FDF85; Mon, 8 Aug 2022 03:18:20 -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 22EC6B80E38; Mon, 8 Aug 2022 10:18:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0127C43470; Mon, 8 Aug 2022 10:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659953897; bh=NeqZRYiD9+QFszEb0HDM46ke3bHl/YmdCD/826WagaA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=bayUb3SXYtM1CEKJnQhutAqSXWfGamnU+2f3VI6Lu7xB7XXv8f7UDn0kdPabDRRnH sH2CBxWVzae7kpqcOnMWmok3cVAkIiYwaHOPbtMrEB5AK9NmRqKP4M6V0ZX5t9z0CQ HU/dC+XuBtCdaW+yaO2wCP6HuVq6y8Pby2f5MwEfsVPr85C1cyYQ0tBtBGqKOrjvEU joiWmLrIJNsOly31/qgnmGlLhk/8vgbKji02eOMH7ZFq1D9i/PTWVylQCshOi97owx B1/jHVHhVbdmSgV+VUGzRWQXWkopnzqMl71JkcNdWi45wJ0l0xaJklGNFSiH0jF8BO Bag/xMSkTZcBA== Message-ID: Subject: Re: [RFC PATCH 1/4] vfs: report change attribute in statx for IS_I_VERSION inodes From: Jeff Layton To: Xiubo Li , linux-fsdevel@vger.kernel.org Cc: dhowells@redhat.com, lczerner@redhat.com, bxue@redhat.com, ceph-devel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org Date: Mon, 08 Aug 2022 06:18:15 -0400 In-Reply-To: <8a87ee82-fa04-6b99-8716-9acf24446c5a@redhat.com> References: <20220805183543.274352-1-jlayton@kernel.org> <20220805183543.274352-2-jlayton@kernel.org> <8a87ee82-fa04-6b99-8716-9acf24446c5a@redhat.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.3 (3.44.3-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-7.7 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 Mon, 2022-08-08 at 10:09 +0800, Xiubo Li wrote: > On 8/6/22 2:35 AM, Jeff Layton wrote: > > From: Jeff Layton > >=20 > > 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. > >=20 > > Also update the test-statx.c program to fetch the change attribute as > > well. > >=20 > > 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 | 4 +++- > > 4 files changed, 13 insertions(+), 2 deletions(-) > >=20 > > diff --git a/fs/stat.c b/fs/stat.c > > index 9ced8860e0f3..976e0a59ab23 100644 > > --- a/fs/stat.c > > +++ b/fs/stat.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > =20 > > #include > > #include > > @@ -118,6 +119,11 @@ int vfs_getattr_nosec(const struct path *path, str= uct kstat *stat, > > stat->attributes_mask |=3D (STATX_ATTR_AUTOMOUNT | > > STATX_ATTR_DAX); > > =20 > > + if ((request_mask & STATX_CHGATTR) && IS_I_VERSION(inode)) { > > + stat->result_mask |=3D STATX_CHGATTR; > > + stat->chgattr =3D inode_query_iversion(inode); > > + } > > + > > mnt_userns =3D 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 __u= ser *buffer) > > tmp.stx_dev_major =3D MAJOR(stat->dev); > > tmp.stx_dev_minor =3D MINOR(stat->dev); > > tmp.stx_mnt_id =3D stat->mnt_id; > > + tmp.stx_chgattr =3D stat->chgattr; > > =20 > > return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; > > } > > diff --git a/include/linux/stat.h b/include/linux/stat.h > > index 7df06931f25d..4a17887472f6 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 chgattr; > > }; > > =20 > > #endif > > diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h > > index 1500a0f58041..b45243a0fbc5 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_chgattr; /* 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_CHGATTR 0x00002000U /* Want/git stx_chgattr */ >=20 > s/git/get/ ? >=20 Muscle-memory typo. Fixed in my tree. > > =20 > > #define STATX__RESERVED 0x80000000U /* Reserved for future struct st= atx expansion */ > > =20 > > diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c > > index 49c7a46cee07..767208d2f564 100644 > > --- a/samples/vfs/test-statx.c > > +++ b/samples/vfs/test-statx.c > > @@ -109,6 +109,8 @@ static void dump_statx(struct statx *stx) > > printf(" Inode: %-11llu", (unsigned long long) stx->stx_ino); > > if (stx->stx_mask & STATX_NLINK) > > printf(" Links: %-5u", stx->stx_nlink); > > + if (stx->stx_mask & STATX_CHGATTR) > > + printf(" Change Attr: 0x%llx", stx->stx_chgattr); > > if (stx->stx_mask & STATX_TYPE) { > > switch (stx->stx_mode & S_IFMT) { > > case S_IFBLK: > > @@ -218,7 +220,7 @@ int main(int argc, char **argv) > > struct statx stx; > > int ret, raw =3D 0, atflag =3D AT_SYMLINK_NOFOLLOW; > > =20 > > - unsigned int mask =3D STATX_BASIC_STATS | STATX_BTIME; > > + unsigned int mask =3D STATX_BASIC_STATS | STATX_BTIME | STATX_CHGATTR= ; > > =20 > > for (argv++; *argv; argv++) { > > if (strcmp(*argv, "-F") =3D=3D 0) { >=20 Thanks, --=20 Jeff Layton