From patchwork Mon Oct 17 10:57:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 3392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1380851wrs; Mon, 17 Oct 2022 03:59:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42aRnyj0wVMFzPXrDzLLW/uDr3K4usBA0VW7Y5ggz7bXRvQ4zQHpienxjR8oYE1WDJC5G9 X-Received: by 2002:a63:ea4a:0:b0:439:4695:c0f8 with SMTP id l10-20020a63ea4a000000b004394695c0f8mr9978956pgk.440.1666004369849; Mon, 17 Oct 2022 03:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666004369; cv=none; d=google.com; s=arc-20160816; b=gXGQlqrSfRhnvgj/OByGGIbabQaBn8WB7Jds+pxOlAepMUomU+esgdlOqKpM51xTOx i64QcC9NeynDQf7KZcmpuODCK5Ls92BjeWzUf5T14Q6DUFcjMaKydB8+suwEfichpMrQ md6F4vlpbKgqZKaFMrFdl2UpvQPiCB0us+/UifYoFbzUrKzorU3hKx6xOFr/Pb/qWwin Tcm4UsI4gnXGd8igty3nLU28TNIkujYZyN4hRfLb8uOrZeaXSJWKR41Fp0ISi4++nVg4 KXYntg7q4kfxFwHLi044AFeNxTlaVqa9C8aCJagdFClEvwZY/dMT5iU8gEcPrnKQBOn6 YeWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mO+EWE9vFr8NsCwM2LXTtSR2PucxsVl8S6KFi+y7TE8=; b=JVdGmFe7iFjkEQ1YmIvtqbnpO61qO4Y+iF17l0YfmvzUzrjMmbFROdgspyYakfVt0w MGcabuuqOuMGKXjZOjTzjUrEsqIMx/JcEmEH5XgqSHkC97iCkKqFdBURJSuVkb4NalTF tA0SLOQq4k5+r9IKHQZCoReCXRAnTZda2Gxd923n3jslszQnnUIju86fm4sLaG/YTI2B siGbesq5ng3cCGUrtf4cJno3ul08C+qnUbFlLIfOA7toXRfcRM16cPM/ALUGJQdHVgOw ++Q9LwRfC2g4xy6JoCqcuVuvbX1gkHOOnwbJuQhZQ3AjBiMyeTFRNHh55z+kBJGWNrQ0 ITjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bh5nTooK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a17090a510200b00200a22064afsi16253613pjh.41.2022.10.17.03.59.17; Mon, 17 Oct 2022 03:59:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=bh5nTooK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S231159AbiJQK6Y (ORCPT + 99 others); Mon, 17 Oct 2022 06:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbiJQK5a (ORCPT ); Mon, 17 Oct 2022 06:57:30 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE0BB61B2D; Mon, 17 Oct 2022 03:57:28 -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 sin.source.kernel.org (Postfix) with ESMTPS id 945B0CE12AE; Mon, 17 Oct 2022 10:57:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8BA6C433D7; Mon, 17 Oct 2022 10:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666004244; bh=xnrewwvldKIjoeh5ebiZu+onJb8qn6gj1nIuV6NIss8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bh5nTooKpjTJrP2pLkH49auOau9LSXv/ChZHfvENHLq5PdUL9u5sbQlNrDoOn6YMZ WieShPVHZCnZcKf+VDyEgIvtuU6KAlxhaWVpT76Z9ZzS9/oxmULozBKfr6FO16xefe SaJQTNLrEXX7EVZKB+K81f0SFCkXq+N/XuctzrgSZuvqymSzlXk+I63YEe8Nhdka/j PqtAo0CWb2fIZbyv/ddnTp8GvYNSUXZGssJNU7bn9yBifArha9ZucJCQ6Nkpeyoh4C OkU27OjjcdtmBAAuKhaAopo/ZzG0deuEkPTGjhEgM+SWTLNCXxr3trSWtODFA7bBXN qDAkOQ/0TBbbw== From: Jeff Layton To: tytso@mit.edu, adilger.kernel@dilger.ca, djwong@kernel.org, david@fromorbit.com, trondmy@hammerspace.com, neilb@suse.de, viro@zeniv.linux.org.uk, zohar@linux.ibm.com, xiubli@redhat.com, chuck.lever@oracle.com, lczerner@redhat.com, jack@suse.cz, bfields@fieldses.org, brauner@kernel.org, fweimer@redhat.com Cc: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v7 5/9] ceph: report the inode version in getattr if requested Date: Mon, 17 Oct 2022 06:57:05 -0400 Message-Id: <20221017105709.10830-6-jlayton@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221017105709.10830-1-jlayton@kernel.org> References: <20221017105709.10830-1-jlayton@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746932197714680439?= X-GMAIL-MSGID: =?utf-8?q?1746932197714680439?= When getattr requests the STX_VERSION, request the full gamut of caps (similarly to how ctime is handled). When the change attribute seems to be valid, return it in the ino_version field and set the flag in the reply mask. Also, unconditionally enable STATX_ATTR_VERSION_MONOTONIC. Reviewed-by: Xiubo Li Signed-off-by: Jeff Layton --- fs/ceph/inode.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 42351d7a0dd6..bcab855bf1ae 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2415,10 +2415,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_VERSION)) mask |= CEPH_CAP_AUTH_SHARED; - if (want & (STATX_NLINK|STATX_CTIME)) { + if (want & (STATX_NLINK|STATX_CTIME|STATX_VERSION)) { /* * The link count for directories depends on inode->i_subdirs, * and that is only updated when Fs caps are held. @@ -2429,11 +2429,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_VERSION)) mask |= CEPH_CAP_FILE_SHARED; - if (want & (STATX_CTIME)) + if (want & (STATX_CTIME|STATX_VERSION)) mask |= CEPH_CAP_XATTR_SHARED; return mask; @@ -2475,6 +2474,11 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path, valid_mask |= STATX_BTIME; } + if (request_mask & STATX_VERSION) { + stat->version = inode_peek_iversion_raw(inode); + valid_mask |= STATX_VERSION; + } + if (ceph_snap(inode) == CEPH_NOSNAP) stat->dev = inode->i_sb->s_dev; else @@ -2498,6 +2502,8 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path, stat->nlink = 1 + 1 + ci->i_subdirs; } + stat->attributes_mask |= STATX_ATTR_VERSION_MONOTONIC; + stat->attributes |= STATX_ATTR_VERSION_MONOTONIC; stat->result_mask = request_mask & valid_mask; return err; }