From patchwork Fri Aug 5 18:35:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 595805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4AADC25B0F for ; Fri, 5 Aug 2022 18:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241482AbiHESfw (ORCPT ); Fri, 5 Aug 2022 14:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241438AbiHESfu (ORCPT ); Fri, 5 Aug 2022 14:35:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE396765E; Fri, 5 Aug 2022 11:35:49 -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 93E28B829F2; Fri, 5 Aug 2022 18:35:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58042C433C1; Fri, 5 Aug 2022 18:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659724547; bh=rTxZdWYcyUDsw35HfXDcwe1teGLqBNlOzMdnw0TScoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X0JzmwCxMunXMqz2W2d286b6qohBaha2Iuo9HihcbgTlmjZgdBgFgvrU7GOCyGDjP 6P7uNyz2m2QFpvrRIrn92mlo03Ua/yjJeCMnxBmnVKRUc/Z3sG/Wx9fJqx+eyYQRnf p6UGCCMEk/jy5Oy0O2Mvi8S+j12UyEQ05flmSDk8FyAdOkKgPMACPKQuvqkvOpIvF7 LBfmXYcwBsbZ/EP9Eewexcu1Ic1lPOUGiIEO3y6pL42atW1aKWUSdBVDDWNnkb469O PfCldYXv0zezlS7DiJ31tAEAsCSEXTUlAgd8D66fbAnKQWmPtSBRhJo2hv9LdHMrcW itIW3V6IPHqDQ== From: Jeff Layton To: 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, Jeff Layton Subject: [RFC PATCH 1/4] vfs: report change attribute in statx for IS_I_VERSION inodes Date: Fri, 5 Aug 2022 14:35:40 -0400 Message-Id: <20220805183543.274352-2-jlayton@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805183543.274352-1-jlayton@kernel.org> References: <20220805183543.274352-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 fetch the change attribute 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 | 4 +++- 4 files changed, 13 insertions(+), 2 deletions(-) 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 #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_CHGATTR) && IS_I_VERSION(inode)) { + stat->result_mask |= STATX_CHGATTR; + stat->chgattr = 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_chgattr = stat->chgattr; 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; }; #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 */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ 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 = 0, atflag = AT_SYMLINK_NOFOLLOW; - unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; + unsigned int mask = STATX_BASIC_STATS | STATX_BTIME | STATX_CHGATTR; for (argv++; *argv; argv++) { if (strcmp(*argv, "-F") == 0) { From patchwork Fri Aug 5 18:35:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 595532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63BADC25B0E for ; Fri, 5 Aug 2022 18:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241466AbiHESfv (ORCPT ); Fri, 5 Aug 2022 14:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241368AbiHESfu (ORCPT ); Fri, 5 Aug 2022 14:35:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A128125CB; Fri, 5 Aug 2022 11:35:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 23761619B9; Fri, 5 Aug 2022 18:35:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 944AFC433B5; Fri, 5 Aug 2022 18:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659724548; bh=CXhOaBQbPFYiQTY/SMRa/9kU9DcUByI7xcnrlvCh3Z0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hbv0DjQP9ER5DxNx6k3QSNQvAG1dC0pXEiWkUZpPHqewQW1+ykAp5DIo5PYWHqz7l J3WJSgD6wA6Hh1Rui3FzLzKLmJHX5NIpkZNHV63mpySM/GSq4+LqUa9mQnqCrgcSdB tF7SWLckJxh095ZF8IieD9k/PFUH9DbBNBs6eJ2baWF1WRkt/Xo6CsAJMsJtB4NIC1 H1diaZcDxasE5uYBfRy+p5Y7yffr01EkymCvqHk/Ej2RgJbuBzFbB/Ohbq15jkSmS/ OqLk/42/XDXkBldd+XiWLiMb+TYpf9V4z3PHB/l0kq/fTpUqc+RWLroQmjlcwA5f8u Dl5Qh/hixeiTQ== From: Jeff Layton To: 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 Subject: [RFC PATCH 2/4] nfs: report the change attribute if requested Date: Fri, 5 Aug 2022 14:35:41 -0400 Message-Id: <20220805183543.274352-3-jlayton@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805183543.274352-1-jlayton@kernel.org> References: <20220805183543.274352-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Allow NFS to report the i_version in statx. Since the cost to fetch it is relatively cheap, do it unconditionally and just set the flag if it looks like it's valid. Signed-off-by: Jeff Layton --- fs/nfs/inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index b4e46b0ffa2d..8e0e7ecf6429 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -829,6 +829,8 @@ static u32 nfs_get_valid_attrmask(struct inode *inode) reply_mask |= STATX_UID | STATX_GID; if (!(cache_validity & NFS_INO_INVALID_BLOCKS)) reply_mask |= STATX_BLOCKS; + if (!(cache_validity & NFS_INO_INVALID_CHANGE)) + reply_mask |= STATX_CHGATTR; return reply_mask; } @@ -914,6 +916,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, generic_fillattr(&init_user_ns, inode, stat); stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); + stat->chgattr = inode_peek_iversion_raw(inode); if (S_ISDIR(inode->i_mode)) stat->blksize = NFS_SERVER(inode)->dtsize; out: From patchwork Fri Aug 5 18:35:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 595531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A551C25B0E for ; Fri, 5 Aug 2022 18:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241493AbiHESgD (ORCPT ); Fri, 5 Aug 2022 14:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241484AbiHESfx (ORCPT ); Fri, 5 Aug 2022 14:35:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D5A76350; Fri, 5 Aug 2022 11:35:52 -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 DF232B829E9; Fri, 5 Aug 2022 18:35:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD426C433D6; Fri, 5 Aug 2022 18:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659724549; bh=IMTrWJWnieceGbG5NqZtFEctzXK036a+Q7hbE1yr5UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgn7hhdvDfOpGmH2MNlYJDkipS/1LtOgwvgrmyZIfwFOY21hGb2rYGFHPzuFfKaYS +iHiQLsxliCX1g6VjMXydeMi5QYvLQJZ/Ycr89q4t/rpGmlo1ZBMsoYCu7mApT4C8y vJMpCd1vtxt4rx+N527SMhS8kHBDbiaOWCVablIXKbN7L7iXZfmb9LWX13XRhTzs4R OV0iOFGYLYBLGUNON95UGqw5J7VXNW440ygYcXyMY161/2G68hP2osUusyqcCieKFt 72GE+18HXyp/533ALd6KWJXgtmd4/Qqo3J1zir2MXfAJxqIJs2WVpk2H2sj7ry/SF9 JGlt+2/zLFEcw== From: Jeff Layton To: 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 Subject: [RFC PATCH 3/4] afs: fill out change attribute in statx replies Date: Fri, 5 Aug 2022 14:35:42 -0400 Message-Id: <20220805183543.274352-4-jlayton@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805183543.274352-1-jlayton@kernel.org> References: <20220805183543.274352-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Always copy the change attribute in a statx reply, and set the STATX_CHGATTR bit unconditionally. Signed-off-by: Jeff Layton --- fs/afs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 64dab70d4a4f..dffd6edd6628 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -760,6 +760,8 @@ int afs_getattr(struct user_namespace *mnt_userns, const struct path *path, do { read_seqbegin_or_lock(&vnode->cb_lock, &seq); generic_fillattr(&init_user_ns, inode, stat); + stat->chgattr = inode_peek_iversion_raw(inode); + stat->result_mask |= STATX_CHGATTR; if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) && stat->nlink > 0) stat->nlink -= 1; From patchwork Fri Aug 5 18:35:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 595804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CAB7C25B07 for ; Fri, 5 Aug 2022 18:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241519AbiHESgH (ORCPT ); Fri, 5 Aug 2022 14:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238385AbiHESfy (ORCPT ); Fri, 5 Aug 2022 14:35:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77369DFE2; Fri, 5 Aug 2022 11:35:53 -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 28C2EB80D83; Fri, 5 Aug 2022 18:35:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5675C433D7; Fri, 5 Aug 2022 18:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659724550; bh=EQv+UvsRrAxVqCjRTPFq4HNln4t/Rpaq3UXlIzOheYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FC6xPAsfpgcjFytX4DmHj01ESIMdhFh7ovpKkoggYZ9EpfrYbn1X/E2JTI7yulhK/ 4/ULxbe2w2QSI32YMFAKYSFzte0w1qId2bfa4WWSWVBzRVJv3YlIGy62ihTO4cRLgF 2z3un+siyUbZVmTGCU9+GWfJYBDnaHodnaTDgBcmnlLlslUB7DFB8YDivMsfKB2GG5 s51GWHlxMxI90kl9c9rZTo2qJmIGYCmWgXkH7DdI4l8ZKauM7cyNAnn+5Ie0TKLR4/ +hU43YIkqc4ljEG3uuoPtDMLFNwZWO2WFcj0KgJ39ZdxpGzng9RpBIFk2YBT6Yt5TV F8YHIVWRPTSag== From: Jeff Layton To: 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 Subject: [RFC PATCH 4/4] ceph: fill in the change attribute in statx requests Date: Fri, 5 Aug 2022 14:35:43 -0400 Message-Id: <20220805183543.274352-5-jlayton@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805183543.274352-1-jlayton@kernel.org> References: <20220805183543.274352-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org When statx requests the change attribute, request the full gamut of caps (similarly to how ctime is handled). When the change attribute seems to be valid, return it in the chgattr field. Signed-off-by: Jeff Layton Reviewed-by: Xiubo Li --- fs/ceph/inode.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 56c53ab3618e..fb2ed85f9083 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2408,10 +2408,10 @@ static int statx_to_caps(u32 want, umode_t mode) { int mask = 0; - if (want & (STATX_MODE|STATX_UID|STATX_GID|STATX_CTIME|STATX_BTIME)) + if (want & (STATX_MODE|STATX_UID|STATX_GID|STATX_CTIME|STATX_BTIME|STATX_CHGATTR)) mask |= CEPH_CAP_AUTH_SHARED; - if (want & (STATX_NLINK|STATX_CTIME)) { + if (want & (STATX_NLINK|STATX_CTIME|STATX_CHGATTR)) { /* * The link count for directories depends on inode->i_subdirs, * and that is only updated when Fs caps are held. @@ -2422,11 +2422,10 @@ static int statx_to_caps(u32 want, umode_t mode) mask |= CEPH_CAP_LINK_SHARED; } - if (want & (STATX_ATIME|STATX_MTIME|STATX_CTIME|STATX_SIZE| - STATX_BLOCKS)) + if (want & (STATX_ATIME|STATX_MTIME|STATX_CTIME|STATX_SIZE| STATX_BLOCKS|STATX_CHGATTR)) mask |= CEPH_CAP_FILE_SHARED; - if (want & (STATX_CTIME)) + if (want & (STATX_CTIME|STATX_CHGATTR)) mask |= CEPH_CAP_XATTR_SHARED; return mask; @@ -2468,6 +2467,11 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path, valid_mask |= STATX_BTIME; } + if (request_mask & STATX_CHGATTR) { + stat->chgattr = inode_peek_iversion_raw(inode); + valid_mask |= STATX_CHGATTR; + } + if (ceph_snap(inode) == CEPH_NOSNAP) stat->dev = inode->i_sb->s_dev; else