Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp656055rwi; Wed, 2 Nov 2022 16:49:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5tHA6DAWTC2fUlLwueXVGqJ5ZKfXP+OV0Zf8AuzjZJmA5OR5jcRCCbn7ui9yc9X9xMitOe X-Received: by 2002:a50:d602:0:b0:463:a83b:6f89 with SMTP id x2-20020a50d602000000b00463a83b6f89mr12465017edi.366.1667432979143; Wed, 02 Nov 2022 16:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667432979; cv=none; d=google.com; s=arc-20160816; b=QWROyrkhRYjYh+31/kMcg5tyG+nIgVz8zspNN4OeJmGC/j/NwDFqWHpjCeoTk05sQg Hdc4MA9YKkl0g736U67Rq289DQuNSyOQBdAwhGKGFw6Al6OJWjw2bLpuqZgASZdGdTCC dc5natUR1M/FRzhLSXMUuai9IELBbA7zlp4kr+fUH4B58oi4zg1H8CcZBHm8afN/VDJZ o4GDnu5WVWlxO4AqQzn0SFkiqszdKZVA484irZUbxYmCSg38fac5ssheQ0CDNrGoUsjj 5J8yOu0SXCizbor/kMbPZbmmeskQgN6eYUjWIjs6JSSVoZ4F+nESkKs7PdzyCCqRn1GJ lMcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:date:message-id:subject:mime-version:from :dkim-signature; bh=rJxlbqXdP+CrIusjDzh/oVjx3yFbw3NsPbbPFnIK7Ko=; b=DL1+5VrNlkQeFCY8kI1zZTP7Xeo6BMtwL+VPAuSa1XhNTCpJB/imHzEHocbq34pXCI Q+YxN6YMzZZhR4ByR0y2gbhLyM+2SKYJJCha84lyF/8IJ2OAsypWdEvI5xVpHZ6A5I1G Fjh+4XpOumLRSc0FvSYsURV758t+NVx1j7CvH2nkIwoE0QJ8zJm2Da3X/hOjqIajPLku P2paH82KYSLGmqZFCK9p6YMOIfY2mZoR+g69Fj11954uZAeMgAhgeR+0sQ5Z8HuahR9X 18BHFvxMlvfPGJMQInc34v8XaQgXGOzMNluELxS86oROsqMpGC5i6X2qhCciEhQN87lV d6Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dilger-ca.20210112.gappssmtp.com header.s=20210112 header.b=BZJwKaY9; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020a1709061ed600b0078df1c345dcsi14573298ejj.535.2022.11.02.16.49.09; Wed, 02 Nov 2022 16:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@dilger-ca.20210112.gappssmtp.com header.s=20210112 header.b=BZJwKaY9; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbiKBXog (ORCPT + 99 others); Wed, 2 Nov 2022 19:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbiKBXoW (ORCPT ); Wed, 2 Nov 2022 19:44:22 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2F0313E9A for ; Wed, 2 Nov 2022 16:41:10 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so225870pjl.3 for ; Wed, 02 Nov 2022 16:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dilger-ca.20210112.gappssmtp.com; s=20210112; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=rJxlbqXdP+CrIusjDzh/oVjx3yFbw3NsPbbPFnIK7Ko=; b=BZJwKaY9UrF9O4vqb/ByVAl+NkWMYB6PeluEkmiNNV2Wt4iddeihODNKbdbLENc/D1 40MDp6Fnmch/3D7uG4npogA1/WY0qP7pkZC0uACG+E6WaMdFwYdwLpOytp+qYg27sWT5 5egSvbFegciebOLrsdmHiKpGQLejJy3zoePNAPFERNpa91FhGNYeTOiJ6j6G7ZKk9MzE piXKolijv/JpZTm8pY5FCzq2ariNahdLgzl2Jb2Q94s+cTNYx3XkAOcyvP1WCNHlrQn3 lxZ/QS+rnY3tgsJVcdwoo2pJIplAuclsLumBCnwck1+TiVAqaGWTyhRQJzzmRM6+1DSd PNvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rJxlbqXdP+CrIusjDzh/oVjx3yFbw3NsPbbPFnIK7Ko=; b=7XB+eu08rPMbQmSIaUeI8QLBf5JlG8T3LYe7feWd3+v1Bq6tn3ZayHEtLsvkQXU+bE 5GUqR6obpfRe4EvwkYJktZHuU+rDN6IwexHm+q1CWaS5F6qrSO9oaohNOIe/HSGoPVyT jifQUzTHdfOo3XsDgE1nAOC1n2inAS3hEdYzyTuUmVJJJOqHpc5Z4HFiMpdY+4m7M2yq bZRcm3viJW5RCPbWE98rWWkYHyJp6gRvTVoA3KziftCSIdM61AxWXxB1V8sRlerdBsTZ 9TwFSaqIlKneNSpSlL0YO7lxnND3lgNViFi/l3q5+Ej6wESu62U+lg7XE6RSnr/trKR5 uuQQ== X-Gm-Message-State: ACrzQf2cqOq2pCiZ6v1yW+ZAuYav+NAZXgWMmsx+a5JxqMtFJDuI1/DZ TqGN3Z81qvfBi7yC3YL9SugVGYbrV3+eIQ== X-Received: by 2002:a17:90b:33d0:b0:213:137b:1343 with SMTP id lk16-20020a17090b33d000b00213137b1343mr28374828pjb.128.1667432469961; Wed, 02 Nov 2022 16:41:09 -0700 (PDT) Received: from cabot.adilger.int (S01061cabc081bf83.cg.shawcable.net. [70.77.221.9]) by smtp.gmail.com with ESMTPSA id n16-20020a635910000000b0046f6d7dcd1dsm8083291pgb.25.2022.11.02.16.41.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2022 16:41:09 -0700 (PDT) From: Andreas Dilger Content-Type: multipart/signed; boundary="Apple-Mail=_17EEC37C-A0E2-44C3-AAA9-050078F7CDDA"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: periodic lifetime_write_kbytes updates? Message-Id: <92BC4EEA-69A6-4AE0-ABA8-304E9DE2D4A9@dilger.ca> Date: Wed, 2 Nov 2022 17:41:07 -0600 To: linux-ext4@vger.kernel.org X-Mailer: Apple Mail (2.3273) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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-ext4@vger.kernel.org --Apple-Mail=_17EEC37C-A0E2-44C3-AAA9-050078F7CDDA Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii I was looking at the /sys/fs/ext4/*/lifetime_write_kbytes counters on my home server and wondering about how accurate they are. That is most interesting in the case of flash devices, to get a good idea of the lifetime writes vs. actual rated drive writes per day. It looks like s_kbytes_written is only updated on clean unmount via ext4_commit_super->ext4_update_super() and in a few error handling codepaths. This means any in-memory updates are typically lost if the server crashes or loses power (which is typical for long-running servers, rather than a clean shutdown). It would be useful to periodically update the superblock with the current value, maybe once an hour if the value has changed more than some small margin (to take into account the *previous* update). The superblock used to be written frequently via ->write_super(), but this has not been the case since commit v3.5-rc5-19-g4d47603d9703. Any thoughts/objections to a periodic task calling ext4_update_super() every hour if there have been any noticeable writes since the last time it was called? This could potentially be more clever so that it only writes if the disk is not asleep, and do the writes the next time it wakes, but I'm not sure how easy/hard that is to detect at the filesystem level. Cheers, Andreas PS: there is *also* a function resize.c::ext4_update_super() for added confusion, but that does something completely different... --Apple-Mail=_17EEC37C-A0E2-44C3-AAA9-050078F7CDDA Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIzBAEBCAAdFiEEDb73u6ZejP5ZMprvcqXauRfMH+AFAmNjABMACgkQcqXauRfM H+BkbRAAuif5gEFSb4hycovccbB+JKCr6tVBj/w+b4MVFnMKx6NKXtyU83qaDCFC HNQY0U9BYd+Z6FPT3nU/Zud8XRvMybFACBky4rfKyMyEG0GWQ2yaLV1ObLfR83I0 JLVBPIzz+F54sEhQiPhFuny8wqh4x+HOUrKpmz8sqh1J7V4zFD2CUcoHslLTP9zZ L0ycn9nqi3JkelEQkh+tA6vfiZ4JGw2hICQwO7iY/pPAtplFK5jKO1U9DrquIfuG NFtP7r5jRxzpWSSL8Xx223BjXU3PnZ08+hF3PBWqhn0cXIaxDivfUYeHkVX6lGY8 6X3kWtndq2wOAVm0qw2/OFxA1FQ4xJotWkqfxYHRpyXpwp89K99fOo7ME5rvQJdK pRRtLnAsJ/dG5eMDUB1uSD6TJa3QDK6WeiUPs1qF1cLbs4EZALJtkL0lZ90bqdnJ h44QfyvDPCVFs2cZQlcYbF8T1oLParZ0QvRKfpkrjkfvVqhiYSYLiiiSQZveestY fkdMJpV7polzbwkYwfsw3EPrryBmLWHa8TtpRFxEhLNVzz3bKjRWg3IVdhLAv0Br po36Np8++bQHtLIPTzKmx/u+D1QoeVzKkKemyG4OM7D7KlXr2T9c/a/3WbYabG5Y /6C6JNpbLOdyqUVRaJLooJkuXyGg5UvEx/s5rcq7dOSxA9Loxk0= =Jnm9 -----END PGP SIGNATURE----- --Apple-Mail=_17EEC37C-A0E2-44C3-AAA9-050078F7CDDA--