From patchwork Tue Apr 11 14:36:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 8023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2631154vqo; Tue, 11 Apr 2023 07:47:44 -0700 (PDT) X-Google-Smtp-Source: AKy350ZtHxDM2AMYmivl0/7DFAzdhrvgcX1s+FW/N1LpBSs6f/pvF/Kw+QDn07ABDsjhqHhJdk7G X-Received: by 2002:a05:6a20:5481:b0:bf:58d1:cea0 with SMTP id i1-20020a056a20548100b000bf58d1cea0mr17372097pzk.31.1681224464637; Tue, 11 Apr 2023 07:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681224464; cv=none; d=google.com; s=arc-20160816; b=cD5hlKgt6SL8a28XUbpt7YWnYpVh2eAJRnJza17cFA1KivgrnmaN7gJWwswyPFByEZ GLB0UZC9ZAmhU7GZBKW9fzu+6V/DEqByFaCDf57Cs882w+EilRFBMlARb8Hd2WqAr56K Ra5w4W41cZwbh5DpmE4XKkDvWJ6T+cjo2DfN80VbHY7DIW8+eEfwQ4doZ4ipjboswAi7 cLYsP5QNjhQhLBkdQrv3NuWa4dkDxgq+d+BlkPo2xBDaZJdnvPRjj6kNay6VevMs85lf EyVAM2OGeAHvZmLkJvUg8XgAcWjCsG7sx6zCBBSYDVY2LIcX2kOOgu0+PFdv7OjKVGJR N0Lg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pwIqzlLgPxL9uHO3cMjsOKzk3pP9dtOVL/SY92iHXpU=; b=ytPa/Z9xNsefNN97mrMn058F9JBAdStLQmgINwavbgDbFD+9TJlE/+W+9/Zc8VXuMh 6RWs1aeVzojWSeQsaZHVFmMaOB6CxN87AG4DcQkJCF+cu7vDIebnnrQL3R66JnWR/3oa XyhbCIeidcUjg9lNU3s4x9ge0r0eZCoaOGa9KSKtwuVxDpmafFTIgq5dY3HyipK/Ud3D 0aT8PQknmJzd3Z1sRFfo+eQYu8EWk9snZtv3xosfJJ88bUy5948ZuvIaJHjC2QIU4LaR G/iPqFgUQDFsE6HqU67T7wROHMEjJ5xM6NvD/aP01hw8/dPQ9p7/8CBcoCGXS9OFahHx K2WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t4qT7x6t; 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 r11-20020a635d0b000000b0050b3083b64fsi13067195pgb.429.2023.04.11.07.47.31; Tue, 11 Apr 2023 07:47:44 -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=t4qT7x6t; 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 S230223AbjDKOhM (ORCPT + 99 others); Tue, 11 Apr 2023 10:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbjDKOhI (ORCPT ); Tue, 11 Apr 2023 10:37:08 -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 8D69246AF; Tue, 11 Apr 2023 07:37:06 -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 02937627A7; Tue, 11 Apr 2023 14:37:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41813C433D2; Tue, 11 Apr 2023 14:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681223825; bh=IRCClithvgPTE04hKaJiM2EAL0BbX3ippre0W+x0FD4=; h=From:To:Cc:Subject:Date:From; b=t4qT7x6t2LTb4FTbywjpwvf4EZgxgoZDbquly4oCmuXuqeQHVn8s3QnZNlI8SwIt+ pjjvDJdWxP73tNqCgdJkKkph2o3QfeFww7QhfVDKoKt92Cgbu3ROm7x5RtpjebsiJT TTVr2x9eaw3xhwKJuT4FJbUWsqcNUK3AVcl7oSJoyNRESlqJvFls5gMWhdOXNdU1aa y/xNNgsCceoYVMtskUS+ytTRKik/3kWiXiYxZDIjWZLGkVgvXnr6g6zhIXyb2LkX3p dPVQMmiI2WSWyRm6wI+wARvMxps10ptSmgDmffgC65ZOuOJqIqsxQmI5ED1yYIPJA/ wYw7FCMju4k6Q== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Subject: [RFC PATCH 0/3][RESEND] fs: opportunistic high-res file timestamps Date: Tue, 11 Apr 2023 10:36:59 -0400 Message-Id: <20230411143702.64495-1-jlayton@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762890851728667346?= X-GMAIL-MSGID: =?utf-8?q?1762891624468341252?= (Apologies for the resend, but I didn't send this with a wide enough distribution list originally). A few weeks ago, during one of the discussions around i_version, Dave Chinner wrote this: "You've missed the part where I suggested lifting the "nfsd sampled i_version" state into an inode state flag rather than hiding it in the i_version field. At that point, we could optimise away the secondary ctime updates just like you are proposing we do with the i_version updates. Further, we could also use that state it to decide whether we need to use high resolution timestamps when recording ctime updates - if the nfsd has not sampled the ctime/i_version, we don't need high res timestamps to be recorded for ctime...." While I don't think we can practically optimize away ctime updates like we do with i_version, I do like the idea of using this scheme to indicate when we need to use a high-res timestamp. This patchset is a first stab at a scheme to do this. It declares a new i_state flag for this purpose and adds two new vfs-layer functions to implement conditional high-res timestamp fetching. It then converts both tmpfs and xfs to use it. This seems to behave fine under xfstests, but I haven't yet done any performance testing with it. I wouldn't expect it to create huge regressions though since we're only grabbing high res timestamps after each query. I like this scheme because we can potentially convert any filesystem to use it. No special storage requirements like with i_version field. I think it'd potentially improve NFS cache coherency with a whole swath of exportable filesystems, and helps out NFSv3 too. This is really just a proof-of-concept. There are a number of things we could change: 1/ We could use the top bit in the tv_sec field as the flag. That'd give us different flags for ctime and mtime. We also wouldn't need to use a spinlock. 2/ We could probably optimize away the high-res timestamp fetch in more cases. Basically, always do a coarse-grained ts fetch and only fetch the high-res ts when the QUERIED flag is set and the existing time hasn't changed. If this approach looks reasonable, I'll plan to start working on converting more filesystems. One thing I'm not clear on is how widely available high res timestamps are. Is this something we need to gate on particular CONFIG_* options? Thoughts? Jeff Layton (3): fs: add infrastructure for opportunistic high-res ctime/mtime updates shmem: mark for high-res timestamps on next update after getattr xfs: mark the inode for high-res timestamp update in getattr fs/inode.c | 40 +++++++++++++++++++++++++++++++-- fs/stat.c | 10 +++++++++ fs/xfs/libxfs/xfs_trans_inode.c | 2 +- fs/xfs/xfs_acl.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iops.c | 15 ++++++++++--- include/linux/fs.h | 5 ++++- mm/shmem.c | 23 ++++++++++--------- 8 files changed, 80 insertions(+), 19 deletions(-)