From patchwork Wed Jun 20 15:32:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139357 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp933415lji; Wed, 20 Jun 2018 08:34:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLDMyHYc6hxPd6DfWmP8QrlsiHzd9hrGJ+bMhP1im++2ZEf41GNUNC76fUIBj89J4mLS6V/ X-Received: by 2002:a65:52cd:: with SMTP id z13-v6mr8199824pgp.357.1529508858198; Wed, 20 Jun 2018 08:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508858; cv=none; d=google.com; s=arc-20160816; b=IsKw6+z5kxqvFUzrmeBUrXArWTFIcaNZpE2k2KaooX/VtxoN7WatIGFdh5BnWPyqLc 9Ni5ydwJKggdw9MYjwsgv5RKt3Bu8CHf/jO7G1NcWK1tRUzrg/3MGAJ2obaMEL1jfuMH Cb5qZXxz3WSa6YpY0Wrf1hwbuZmZPMccsKyaqO41d8B178ROU5cK0LWLCIp6a87TDvNN KjYLTogbPK0YQJU/HavjIXJ2cvMLxzaSm/hBe2rcZQKO4cUYZ/GHfetsY6fdEqxHxO0t f3m+c+dBXzPgwBZpNkHzf6lBIAcmNbL/OA0uf1ypbnqeVR/UEiG+1blnWpT8CNYATch/ HIUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NGbRtGhS2om3utDVWsvHCCeO4+r1sh53+w5XOZasTvg=; b=BDAUcxDwtuzv6OaBwpEYz76wSgwm+VHH9lFnjbd/rRmyMv+CDPUKBYBKld+aPA/9KL Z/DjT3lxz6z0EaBeq1ELz+/ClmkeclChicDQdUPZwvDH8By+pDYalNE7X9u1cyOGRuUq tkcgIwMS4vAGuSY9sU7xb0LLyC89+RZYolRlrB/v2FRf9GyPuXGK/VSxKNzxMM9O+b1i Lo9ovNsd+dK+hqyOT3LGvLPYxcpQ14yeWDKk/K/FTwDp5b9VPxsTdzs+4YCvfaf4aXjv BTkec15iSuk2XzMvue6RtS0hEV0Bad4lxNf3aXr4RNr6nYZ7a7GHT840CGLKkVAAUDEn mLIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si2551378pfl.87.2018.06.20.08.34.17; Wed, 20 Jun 2018 08:34:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754236AbeFTPeO (ORCPT + 30 others); Wed, 20 Jun 2018 11:34:14 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:51825 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753938AbeFTPeM (ORCPT ); Wed, 20 Jun 2018 11:34:12 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LscDB-1gBm9K477x-012Gb0; Wed, 20 Jun 2018 17:33:24 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , stable@vger.kernel.org, Tyson Nottingham , Riccardo Schirone , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] ext4: sysfs: print ext4_super_block fields as little-endian Date: Wed, 20 Jun 2018 17:32:58 +0200 Message-Id: <20180620153322.54221-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:VkaJ/Z/IFyPmmUhGam8Uo0ZjIddzhfasuzSoRXgb5ck7jeePMGP cPe0Cer7D4lQe0ATfH2R+BlufNPhJYBHWT5rJ2ssZNspITM7/Mo3mGmQzzDwaF/FuVKGMDO 2wX5LkUhd4mBEzKGir+hm5M9XnnOaJVLEglf24SOtC8+L/DaRR9wok5sSDx4Vd6pJUIFpZ5 g5oR50P2YDIcMExtXAniw== X-UI-Out-Filterresults: notjunk:1; V01:K0:3djHRb4JBDA=:TaGLgNG07MzmDY/TEQwZ7D YkOiSeaGOyno27Vfc03eESxrIIzO1TrCLdHcAJK1KEBPhk644SYDG/kKlVkwl0ABOCi8fdKO8 R0V1+KA+vHrMhylHKECjwXO8FE+dfXS1XVzZDEgYZOJAV2+wG6m9McdYUNl1Yo8nLu0mIt46s UnQzBXZ2Oe8/e1xuMaGm2pbHT02iXoa3qVu/18VNrJf7nSGEt+3QzGd8c+Y/FnAUmOT/UYin/ iB7t9G2X9LNIypCmXBkf3VeZBOjaZtx9Uzg6uquVTir1p57jHauCKgTLY5DJkgtLer0Z9u12A +ODeP/zSGM09s8OlObMqKhhgWVrfA2DtU0F6vky8+1nF38siHpJd+umpmF63vRY1MiXyl82Vj 50Ks9stakws3h+cGCDwZeRKjpMkGJHSKWAfFigVVkDz8f+QE3kKBjHZSFkK0rNP75vheHEsJ0 d+nG1Hf0Ln/+U4A1FqBJCsixu3q5LCVWQRR39v359cRwxYX72JcAVnL6A8hDvuNU8P2kzGuot 3wsHT92WG57ACUdN/Og8dAnZDvV9OzT1yO4dm930SfEEEUg1k9j0anQzfwd2vWIBiNxplFWHi F6UQNz9ywICkKKrYtP6tzo6nMuTug6bC/R3t/6aCz4EQ7H1Qo9qJufzxohF8f8/ADbpgoNy+g VLshcMlPQ5X6J4HoKMPGbwkMGQf/f5becrT8UH809bq3DdvzXXuIB2tE4kRpyPOHSqKQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While working on extended rand for last_error/first_error timestamps, I noticed that the endianess is wrong, we access the little-endian fields in struct ext4_super_block as native-endian when we print them. This adds a special case in ext4_attr_show() and ext4_attr_store() to byteswap the superblock fields if needed. In older kernels, this code was part of super.c, it got moved to sysfs.c in linux-4.4. Cc: stable@vger.kernel.org Fixes: 52c198c6820f ("ext4: add sysfs entry showing whether the fs contains errors") Signed-off-by: Arnd Bergmann --- fs/ext4/sysfs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index f34da0bb8f17..b970a200f20c 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -274,8 +274,12 @@ static ssize_t ext4_attr_show(struct kobject *kobj, case attr_pointer_ui: if (!ptr) return 0; - return snprintf(buf, PAGE_SIZE, "%u\n", - *((unsigned int *) ptr)); + if (a->attr_ptr == ptr_ext4_super_block_offset) + return snprintf(buf, PAGE_SIZE, "%u\n", + le32_to_cpup(ptr)); + else + return snprintf(buf, PAGE_SIZE, "%u\n", + *((unsigned int *) ptr)); case attr_pointer_atomic: if (!ptr) return 0; @@ -308,7 +312,10 @@ static ssize_t ext4_attr_store(struct kobject *kobj, ret = kstrtoul(skip_spaces(buf), 0, &t); if (ret) return ret; - *((unsigned int *) ptr) = t; + if (a->attr_ptr == ptr_ext4_super_block_offset) + *((__le32 *) ptr) = cpu_to_le32(t); + else + *((unsigned int *) ptr) = t; return len; case attr_inode_readahead: return inode_readahead_blks_store(sbi, buf, len); From patchwork Wed Jun 20 15:32:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139356 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp932929lji; Wed, 20 Jun 2018 08:33:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJESpguAnf0RWXIZqM3lDAbl0i1PXl/D1+qT5ZLB/wERX2ImkggNmjKESFt7oxJdM22jHfo X-Received: by 2002:a62:48cd:: with SMTP id q74-v6mr22849006pfi.153.1529508829852; Wed, 20 Jun 2018 08:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508829; cv=none; d=google.com; s=arc-20160816; b=preouOQTMAdRg5Yr8myy7SYQ05XbSvSVmHyQR/LlR5Tt6VIrAbA56LvyEjEI/0OuMH 6l0QXH/2kA2uLM0PVbqvpmA0cg5ybCZpqtRQ3Xo4xNuhcD1CTEIn9VuLI23INQ7njaWo tBAxr3p3kzP1rx1IdP6Efq+HsDWQkolt7XguqTyHclNwbp4irnKzFfGUDDPgmf6nsIgE bRx7SpcvygIEAzTCzpYwZ3UQQJVxDkl788O8a27kD2xOQ42hHpII2L+/KxUgux0yf5HK TOCDKhHU3JgbrufKdG44C8SYdxzJr9SdWIk5Eu9SSnT+j0L1kvHd48KuwiwPgbF/XMJi EeUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=nj53NiKPU/9401Q646lOwB1zB0PZJxm2Md+37Qzpj3o=; b=FepLouFqHuEfpbWHwezYZNl5Hjy5mnTgjmYtl7OyCL0pVHmMd+MDLiAE4qqysfuvG5 BYBbA1yf2uC/ybvqfMSbCBG0htAYgK9Q1GTT2V2MU8gKnHB5cCY0B8Djfkdacz5uTT+J CcHqyRx7GNqSt/JIjLA7mgQaFyf3we2KBNeCBQ7kodOiNvidkko9WqNeEOe0ctadlK7D 9IfvA6QxCiqEAeSHpE80A7/pVBN+aiNGgVLr57CtShQqT5eSV9P2QDBDs0wUFC5HkQAS PmfW7twcqAkKf7qQd1m2vevJ70oPewWr7ekavdJ/bUYDoKIlywP091a3imRIQijnT0ym WIRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si2551378pfl.87.2018.06.20.08.33.49; Wed, 20 Jun 2018 08:33:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbeFTPdq (ORCPT + 30 others); Wed, 20 Jun 2018 11:33:46 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:32781 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753938AbeFTPdo (ORCPT ); Wed, 20 Jun 2018 11:33:44 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0M1vbP-1gK3bv2iPT-00tyr6; Wed, 20 Jun 2018 17:33:36 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] ext4: use 64-bit timestamps for mmp_time Date: Wed, 20 Jun 2018 17:32:59 +0200 Message-Id: <20180620153322.54221-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180620153322.54221-1-arnd@arndb.de> References: <20180620153322.54221-1-arnd@arndb.de> X-Provags-ID: V03:K1:7+eRQPh3uEgClCrJVyNQwckvPa3aPLK9+P5+XJvIvWw0DTq8vLY wo24erLuYLCFw1Ea5seDddn5qqWUgOkAp51H2uNGVIxmEPfq6WUdf2g+Lrx+5oyG62ZFY0J KLwu8FdgnGbHY2xiJeWSkFZlk08yDrI2+8tcXKdmCfQmshb5NYApITAcuCwGN8peoBB932Z PZMbGZS9CEcPYb31jnCPw== X-UI-Out-Filterresults: notjunk:1; V01:K0:itZ639F3zPo=:wFONAgh62chH71J8a74KAY +rbOocw/NVovMksxN6AfARGXAGT7KdqqdQeFZKx4FF921tZSph6NvmUt9eWe8qs3hbqukHrO/ 2ICwY1CbGQyM+6pfsN6FwU4mps86uRqzAC2y/MwWifxDqIF2Sdmei/cfYlJULstddsulJTmUl +aq+2QIWMbwGScxIUIaABYU0DEAxx0KzfnZQsGtmgR0njYooM3quhsig8bl1yxBpXyiinyHFp Hrvhc1NTrfiW/S2EcP9F+Dfp/IuFe1g7AEJ7IsYMtaQMJDaYTdxxnQG5H49TU5chZ8C+QUXqG wnc0HrkylGw4bm9olDFRTB8sep4MlTgrO5hgKGYEthg81tsriFHgh1RkXJpkgY7iwg5N/+y0B zyTPI8pojhaixcYafPLebUkec3FvMQ/pswEfuzHgaLKU1cduYoLJz90+HXoNdesDI6aWAZiD6 1Pb4GEZdk815VpuPD8ASEYbLvzOp3B+fBNe8VivMF1c06/7zIw1PuSVn59nM9iyRqLyLlUtN/ uXNdn11sZ0e1cYaKvImtTwN5YHJmy8Lvkfk6zrXHjHXt5vij51WRtOlNuo20hqyZZAV2i/tnC DXNE57JF3N75UBqbJ0kA90KEI80HeN1TEjjmRRaVOQoHRvPNFK3P2d+GfOu8boJz62WGZtysC 8HylXRAJ+avqkPNYToyndzs4XrzTk2R30PQWbnNUniiR+3+EvodeOqUMqZeo9P+kTEKk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mmp_time field is 64 bits wide, which is good, but calling get_seconds() results in a 32-bit value on 32-bit architectures. Using ktime_get_real_seconds() instead returns 64 bits everywhere. Signed-off-by: Arnd Bergmann --- fs/ext4/mmp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.9.0 Reviewed-by: Andreas Dilger Reviewed-by: Jan Kara diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 27b9a76a0dfa..39da4eb48361 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -147,7 +147,7 @@ static int kmmpd(void *data) mmp_block = le64_to_cpu(es->s_mmp_block); mmp = (struct mmp_struct *)(bh->b_data); - mmp->mmp_time = cpu_to_le64(get_seconds()); + mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds()); /* * Start with the higher mmp_check_interval and reduce it if * the MMP block is being updated on time. @@ -165,7 +165,7 @@ static int kmmpd(void *data) seq = 1; mmp->mmp_seq = cpu_to_le32(seq); - mmp->mmp_time = cpu_to_le64(get_seconds()); + mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds()); last_update_time = jiffies; retval = write_mmp_block(sb, bh); @@ -244,7 +244,7 @@ static int kmmpd(void *data) * Unmount seems to be clean. */ mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN); - mmp->mmp_time = cpu_to_le64(get_seconds()); + mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds()); retval = write_mmp_block(sb, bh); From patchwork Wed Jun 20 15:33:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139359 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp933853lji; Wed, 20 Jun 2018 08:34:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJLuXYyuylTzS0w4T7pGQdCvHXTdXRECvmLy+zwyfmTHY7jknEVAoLG0K2EjdZpc4mGu4ZY X-Received: by 2002:a63:8c4f:: with SMTP id q15-v6mr19652012pgn.236.1529508886907; Wed, 20 Jun 2018 08:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508886; cv=none; d=google.com; s=arc-20160816; b=kUdBW09Kd+0ZlvMFsm9b1+5oIF5KaH99DbRUiHqh/T3ud1JfRjDkl8s+2O/Ki5PIS7 SmQXfu4JD77yneeeaQzUQNpAs0Mm+3VXZLGoQR8zvKuL7GunNixdkI6AKyAmpVsUkN3D BLXI+TkaYtdpnCbIZ/Jre3Sz6O4wCRqVlpXk0qcl3UFaLTEr3d2F9f7fwHlAbSVGN51v ofdoDidMRYoJQwpv8lN5WZbNIG9dVQ2rRMPZW8HX0WzqPFK/5N7IA+jIpWYhOlRc54+q gs2u/NCkfy9ZsqDRx1ismyRv69Qq3efK+nSskAX/+oeGkc1xN3GCsNhcRsKpLrIPJPCi ldng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=3Htz+CMutx07wIVPTQLshfUxgUrJaZtTfeW23HF3XbI=; b=St9CjZl1r5iaknsr3mCxND9nLqUoPChHg2qhNM2GiqPJlgNlfDp1kW2kYLxrpBa22K 9dVZXAwypdlbp7DxmzhfbI2ImUbQTQC9qgzGvHOVwhdB60cm7r/KSVTJXXiYq2Qd5gCH IIxzvQCXdpn/kWvaogkKef1CyQkHhUlRPEYb6PBXt2W4g0BKz/z6e+WNn9ZZ+G7SXq5E f33LYBzJN0EO2ISXljTcgxDHCgJHCluU/cPr2UYRwsjZDquMKcztMj50fhrNL5n+GKXp U4FkC1rWmr+HyHrI+Hwc98rEUoIUw8fVE8tYj/IqTlldccLT5rPEqN2RqNEGNt+n0GwM Ib6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si2748244pla.418.2018.06.20.08.34.46; Wed, 20 Jun 2018 08:34:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754358AbeFTPeo (ORCPT + 30 others); Wed, 20 Jun 2018 11:34:44 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:44891 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754297AbeFTPem (ORCPT ); Wed, 20 Jun 2018 11:34:42 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LfbNC-1fxnnW2sKQ-00pOJ3; Wed, 20 Jun 2018 17:33:52 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , Jan Kara , Tahsin Erdogan , Miao Xie , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] ext4: use ktime_get_real_seconds for i_dtime Date: Wed, 20 Jun 2018 17:33:00 +0200 Message-Id: <20180620153322.54221-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180620153322.54221-1-arnd@arndb.de> References: <20180620153322.54221-1-arnd@arndb.de> X-Provags-ID: V03:K1:77Ay0kvre9eEXCP+7Do73N197ZmQxp5tyy1w2ShvryDjGW1P4ch qaJlRiiAdnYXZlKeR1LgS8cGfEM1E9RM2fDvIq0xasKmeimbIB9rzstYuoTOLeHj++Uw+7T 3hFwXrhTVF35vaTkO38GzWnKZstwH2ukIIlWG9zcZbYHAye1xEPwYx7AYP6QkuACwsnR15m +BCN6jFfXo3hlxvvLU5ZA== X-UI-Out-Filterresults: notjunk:1; V01:K0:btxtYbaX/6A=:bCChF3C9ZVKhZE2XXftEkB Fi4hlG8aVieyETiVBXUvLVkL5iyp78KSXQyaWbwuQVtzXrHlWrCRrlm2YJAInyZ/6wKLWZQsk ws6hdaF9R3wa17wN+bMqSQ+rh66cXh4VklJbXqcK8Z/qC+rQcwW2SC1oSlkFxWoO719EGO1PI P8F0sINc7MQXPpDgJn7MH0Nif8TE2DK3tm8H2Xl10QULk0hlwpf24bigw9WS8MLLU5BnJuldf 5LGT48+8N3priqHIQHwmtVcrhfJa560jFNBpzW2FrN5gNx4pd0yRQppZkOTf1glmMCLGVyB6n V1dkTMS2x95hrdUPHq55hGCwuG5LvfH5l034wgFdM6DcMHEGvYZEsDFznQuKEp3Dn6a/fRpDY 8qSsVsAAEVesTCD/fTaDMKZ827xKHfE6QFfsnUKtkEbx4WNE5gxRNQ3lIQ3u6JmNYMBMvYSTU TCdNhP6cAyOx4qSpTaNt9LW9WjoDR9dScm7Nx2IMbfqDCGDfDvQcICu5cfb5aHlh+/mLC0A/g TLugKh0z11nqubHdF8+UvUzkektyO0xfQuX0H6zH0Bm1xMao9NcZ0Jwq6yHjfNyYLq3guPob/ meRjplQwRUloTBzmvEEXfmwpVOPM4KDC1zdwYEpXFMPJoXwmnCJuCmNSBnZrmO7hmsv3QzyZO 4oJdxRH/Jma2tNBCNTW2Y9D8TKsLlLbzgcLLJjFhWOFEKgzmbRtEnwLg6tuVf/gapM6g= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We only care about the low 32-bit for i_dtime as explained in commit b5f515735bea ("ext4: avoid Y2038 overflow in recently_deleted()"), so the use of get_seconds() is correct here, but that function is getting removed in the process of the y2038 fixes, so let's use the modern ktime_get_real_seconds() here. Signed-off-by: Arnd Bergmann --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 Reviewed-by: Andreas Dilger diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2ea07efbe016..600e2063d1df 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -317,7 +317,7 @@ void ext4_evict_inode(struct inode *inode) * (Well, we could do this if we need to, but heck - it works) */ ext4_orphan_del(handle, inode); - EXT4_I(inode)->i_dtime = get_seconds(); + EXT4_I(inode)->i_dtime = ktime_get_real_seconds(); /* * One subtle ordering requirement: if anything has gone wrong From patchwork Wed Jun 20 15:33:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139358 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp933691lji; Wed, 20 Jun 2018 08:34:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJR5hnB+B41CkeVlxOPwW4olphV30ZvLEtmXoEZbtoJBezRE1mwrkvuLKcXc33CqU2WSSfL X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr11919365plo.91.1529508876747; Wed, 20 Jun 2018 08:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508876; cv=none; d=google.com; s=arc-20160816; b=tKt1+TyLT4ksHGkmSiFRuco8+HB3YAv/Pin5kxpagXsKp3YW2+Tc6n0VWp1G781vlf ltaGX63LCOWgr3WC4S2pfzG1ilZ5m8Mf9rFvNj34qdcyT+jVbk44RAyNaPoWCDnpKGzY Fyae6bai4bulu6gwJrIunU66MPZWbFiagjE+2401ymNJot+ubNX7F2yRyHLUgEsTA6Vc MXkahl0/mmNAQ9DEosPYcF7t7W44B7YuxBBwOGEhNTIPlqTEHV1GbhzlOjbxQzgNBKFh +nroMSHLlTRGnkpj8LRlwmlErX1rylhxshwm5eVbTxyosgEYLX8d2qSQ6TFNxoqEvPbD yk6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uB6lNjGieMhYjgw09suz8qc5mZQ4skR2q91ONxdZCjs=; b=nEc8p6fPs3qZw6DaT/D0u3AAIW3feADNflBC7psmHREIdbLQezuDVXYngWS0KQ1vVY sE8lUwMJfILFtuDuhzpDWZ6+Q3oaJwUgMiSWJ5dwpvwmjwZIY+ppXpBx59kXv469bTQy M6XR0a0/netQW8OCA4bDqx00CgbOymSZ7iyRWxmKNxh47Fl/76W8e23wL6TyZR6/wGAt vSQJIV36/i5Wtv7iMv2qHzXrxQpntbKb1pnwZ4NK23AwG73MwhjxrmryN0XUKAAcMeZj XOFhJSJOqlEPApiu624drNbaBz5rFnDsp964e/9ES7ToWjUZ+ZMg+1C006sRGeebH/WM rV6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si2748244pla.418.2018.06.20.08.34.36; Wed, 20 Jun 2018 08:34:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754280AbeFTPee (ORCPT + 30 others); Wed, 20 Jun 2018 11:34:34 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:41555 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754243AbeFTPeb (ORCPT ); Wed, 20 Jun 2018 11:34:31 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MOXED-1fbQHW3kUn-005r4c; Wed, 20 Jun 2018 17:34:20 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , Ross Zwisler , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] ext4: use timespec64 for all inode times Date: Wed, 20 Jun 2018 17:33:01 +0200 Message-Id: <20180620153322.54221-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180620153322.54221-1-arnd@arndb.de> References: <20180620153322.54221-1-arnd@arndb.de> X-Provags-ID: V03:K1:OxfsEwd2qoEFU1YiFJomABpL6ZKFyn6XFKTmU1bZQlLXyf/3lVk UpGhjkg6CSa/q1vxQR9zq8/6TVZVcJPeTTRh0L0E7bLnnqCPsTaxisnSTQK+L82IrxQzMOi 88/wwsC3qYe18JC2JehKlWxWmUkcIn9hPqCBJxB9gKHnzb3KUS/fKhga5Hrnf6yWCo7UcNm 2gfiYGILzG7umwVw+ihPQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:h6bulAq365Q=:eBQxlXffo/nv9AGeA2/Jn7 ul4792VEyBkvEfoY4ZWdDCg7tJsZZ8CMRvq1B0kdpBzmFlnUu8oUft/qbvJ0pJRon4EJGtE3r mpzWI6+GsBHqtlNBUlHXJs1BfqPsvP5uSMYTw0x031qu83ERWexKa9iEioolcGYFodYg2ZCbI EbvANqpxx389zlNTLBuuxcsjADmKTrwob+OxVH8S5pqcPvu94Zw2rtP9e6AV/fcxl7Q1FQArq 3QgWdJQeqnrAQsGShOvmA/mKrSir1UaDIEhG5fhd5O64CY+oGRI9FijN9mfUF9b7kYMwPVKc7 Yco8cDJY2lnPkIFzj6O9H4pshNywRxywdcJfM8eC4OYxhUlECjzDhYiMgZhXTq1cSSZSsmV92 INOoiYI1VbYKkPrtG46J8Fh0cnTIRPM0MCEsZMTJXfBMqleH80MTbHJJjxsmwxHX8LRBovym2 q3f0fJBX8UbQHnI2IZ8nGegd/ufJGecWZlEnLcgU4KhWCY/IPBwSkGrMZOjGJdVxn7Fhnly2Q EJiC2CzhfegvHu2Iolgu59EmorIaoCcpngJ9GPIfc3bHbZFOynYfRIQK9kbhaVJUKSJBTJrxv VVhlEpwfPECwdQbqS1MX4uUfXhrm22ifAPYCbOAhuU8ExsYmUZ1U4He+TYA0NmcEC8t1Ci/KE NL0gWlOk4I2WWqBq7qxbGR1cnHKU6wLSt5h2bx73l0Im2A0YLkltDSPR1WRHidDwpPNk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is the last missing piece for the inode times on 32-bit systems: now that VFS interfaces use timespec64, we just need to stop truncating the tv_sec values for y2038 compatibililty. Signed-off-by: Arnd Bergmann --- fs/ext4/ext4.h | 18 +++++++----------- fs/ext4/ialloc.c | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) -- 2.9.0 Reviewed-by: Andreas Dilger diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 0b127853c584..6b4f4369a08c 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -789,17 +789,16 @@ struct move_extent { * affected filesystem before 2242. */ -static inline __le32 ext4_encode_extra_time(struct timespec *time) +static inline __le32 ext4_encode_extra_time(struct timespec64 *time) { u32 extra = sizeof(time->tv_sec) > 4 ? ((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 0; return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS)); } -static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) +static inline void ext4_decode_extra_time(struct timespec64 *time, __le32 extra) { - if (unlikely(sizeof(time->tv_sec) > 4 && - (extra & cpu_to_le32(EXT4_EPOCH_MASK)))) { + if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK))) { #if 1 /* Handle legacy encoding of pre-1970 dates with epoch @@ -821,9 +820,8 @@ static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) do { \ (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\ - struct timespec ts = timespec64_to_timespec((inode)->xtime); \ (raw_inode)->xtime ## _extra = \ - ext4_encode_extra_time(&ts); \ + ext4_encode_extra_time(&(inode)->xtime); \ } \ } while (0) @@ -840,10 +838,8 @@ do { \ do { \ (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \ if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) { \ - struct timespec ts = timespec64_to_timespec((inode)->xtime); \ - ext4_decode_extra_time(&ts, \ + ext4_decode_extra_time(&(inode)->xtime, \ raw_inode->xtime ## _extra); \ - (inode)->xtime = timespec_to_timespec64(ts); \ } \ else \ (inode)->xtime.tv_nsec = 0; \ @@ -993,9 +989,9 @@ struct ext4_inode_info { /* * File creation time. Its function is same as that of - * struct timespec i_{a,c,m}time in the generic inode. + * struct timespec64 i_{a,c,m}time in the generic inode. */ - struct timespec i_crtime; + struct timespec64 i_crtime; /* mballoc */ struct list_head i_prealloc_list; diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index f525f909b559..8c00c871f5dc 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1073,7 +1073,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, /* This is the optimal IO size (for stat), not the fs block size */ inode->i_blocks = 0; inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); - ei->i_crtime = timespec64_to_timespec(inode->i_mtime); + ei->i_crtime = inode->i_mtime; memset(ei->i_data, 0, sizeof(ei->i_data)); ei->i_dir_start_lookup = 0; From patchwork Wed Jun 20 15:33:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139360 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp933879lji; Wed, 20 Jun 2018 08:34:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJAI2cm3qats/V0FCzQWfJCpp5II0Yh/+AxVbqiskhrvS3VMOjU6ZvaQSzfQTMDf8BjBMTD X-Received: by 2002:a62:4f4f:: with SMTP id d76-v6mr23171033pfb.188.1529508888496; Wed, 20 Jun 2018 08:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508888; cv=none; d=google.com; s=arc-20160816; b=i/+OOGvS7jjQ3RaCJQj6ssDpO8AtJeF2Xbpt0go5yKumpruLScTQ9VTBT4R5uz5jaq AgnaKcumZ1D25ww/XO0RYY2Jc06USCb7g9bAtRMrpmbjRf/k0U+n3pQgdESXinWFHR0f tx6IIm40KsrGY+Awcnd4ceF94wH+TIFlOd5mLaWWnoK8A6Nxg9NcOhyZhWt/P/VHghIb g/38XEWqaD/H0m6kaeZuiJgWzj5775ilSiYmwVzmniuUUox5S/9Kt64ZOK2nQTIIpuPu lzl3iUbE9mvM4f26QjPaoiUWptZreXsjdRrzMby6edrGuOJJvDN7zTVo4hiVy+bXoJJr +PUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=xudS0gtv5coRD6osH1l4kcftmP3nykaK1XmQYkesLtE=; b=nrtoqKqvyRZaFOiXuvrrXEueOeuePcHqQaIJxZ3/GXgsBFjGAFGC3pNIJO2+C4GNf2 qOqjAJ9GBtfQdwX+2qAa1W9TIwHDKrEh+8I6/9WzTrLClAL4WRMrrPf2poVxBrs14yUz L4IL6fMIMl8TByYWFjh3yBA3Z9hEoFYyF1HJADXOFPeOdkobhSDEkg/3/Rls6z+US7ur jPiN/0AVeX321BSaRCzWE/ZAiQbzmxYBp2YV/GGI4xvU9LdqV7s3fB0uVnTgsR6eDjGd tUW4/URgWjk3hA3/Wd2VUbEXvEYO19tU0v+TzGUqolqwCyaoQ/otH+Qx5GOi74Far3RY pMrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si2748244pla.418.2018.06.20.08.34.48; Wed, 20 Jun 2018 08:34:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754382AbeFTPeq (ORCPT + 30 others); Wed, 20 Jun 2018 11:34:46 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:51519 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754335AbeFTPeo (ORCPT ); Wed, 20 Jun 2018 11:34:44 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lj9jT-1g3dAS0Q0d-00dXvs; Wed, 20 Jun 2018 17:34:27 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] jbd2: replace current_kernel_time64 with ktime equivalent Date: Wed, 20 Jun 2018 17:33:02 +0200 Message-Id: <20180620153322.54221-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180620153322.54221-1-arnd@arndb.de> References: <20180620153322.54221-1-arnd@arndb.de> X-Provags-ID: V03:K1:XB5O87moimnOK3P1rqIZynulXeYHVuVcxg64p/U2NlN+GmgBkoY TCFvu8hRg9UWSg2wkde0gQ+dWGdUtr5rnK7BdNJ36bBDvg4fdUui7HuPA6ZBoSpHKV5J8+S G8Toirw7QhINkYpvFawbcLb8WPhq2XMk/HXvq9kTKN4dNc9OQZk1GIYw0MY0U4a61PGElbv Fak9GQlMOlngjlz88BfhQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:JQ8pSVmYQzY=:N7amg/iW1b8mUo9Srs39/M cI6sGpvuFHlDX3kVz5tvgF5YBOSc14BW+2vKHDQCKAV1SW22h7haZwHAli+gq0NqZsK9jaa2W BDNTphg7bmHAWRcUdETQyNXjlWrwtO75rzPMelD+H7oe6jjYYtu2SB6OtD1aREQ76+1A8z//a gg0ut8DHXNK3+K6WYN3JEJNn2yac3aZ9JpsCpbrW3oQ3zpR/bXIqL8edui6Q0z81Ocf9IJs33 aZgE+5MBFixWOhBmbRZaU0sY29TcFd3Rc7tLxQxOf9WxmYBDmLdMUW3xSZcLAPQ411ouywD1L TL2yJ2ia8iWggLRnFaN8XvVVnoy1Piw2XrkC5e4j4bWmm/Tbfq9QvhgJvc+OrtmVV0BFTO5xY 9QJ6yqEZS97tdjEUMSLhoFn+twzRatzMp5lWN3cUdzBOQiuoatH4qzTO6lvTdUIb9IWL7HHVs gWwnN40Z7XyctS0eVv9J0TmnEqpt/Nvfkyt0pOLG6QVIfWTciK2utHB3+nwOTli9l9x8zOSCH wryUAkYCWPBxKqT3XVeM0On7eDTSR2gZTlw8JqowTnbk38HYbLYkYEVWb3anbRRSP7ASlZxiM eSCEj9NohomPsAeYCN5K5ujMZCU1Z8id/WwYgQ/ymN4VkkPteXWF7MU+sET5W/xHvOBGSaDLY z73TR2F+AWY5iyHLgXnGrjGYsTmXE8/wVfCK+SRAEJv2yUbHaAioQmLNU6V01LzlOc2g= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org jbd2 is one of the few callers of current_kernel_time64(), which is a wrapper around ktime_get_coarse_real_ts64(). This calls the latter directly for consistency with the rest of the kernel that is moving to the ktime_get_ family of time accessors. Signed-off-by: Arnd Bergmann --- fs/jbd2/commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.9.0 Reviewed-by: Andreas Dilger Reviewed-by: Jan Kara diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 8de0e7723316..150cc030b4d7 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -121,7 +121,7 @@ static int journal_submit_commit_record(journal_t *journal, struct commit_header *tmp; struct buffer_head *bh; int ret; - struct timespec64 now = current_kernel_time64(); + struct timespec64 now; *cbh = NULL; @@ -134,6 +134,7 @@ static int journal_submit_commit_record(journal_t *journal, return 1; tmp = (struct commit_header *)bh->b_data; + ktime_get_coarse_real_ts64(&now); tmp->h_commit_sec = cpu_to_be64(now.tv_sec); tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec); From patchwork Wed Jun 20 15:33:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139361 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp934629lji; Wed, 20 Jun 2018 08:35:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLheodKXcosskTsUI1lg+APFsoBJZSEA+BuZ7dbAHkmRABOw4hmGFe/NiHBiXSSv8Dp2W7n X-Received: by 2002:a65:50cb:: with SMTP id s11-v6mr18799663pgp.384.1529508934625; Wed, 20 Jun 2018 08:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508934; cv=none; d=google.com; s=arc-20160816; b=oKzWAJv4lboIpReKebCOKjGHoC+z1oSy7BhFYoyx6wUart3rRv0GUpmuO77+EA3ilj rq7/reXcEUZmhcCQHz4YhPgeucVGAgMZ+ATMAe81cJuL+nXXfpGI1TKY/PDMbLbBDsHW yda1pwucwidxJnhJe54A6106cWD420n8Y7XdUYApxskmGHIYVaQecLRSifUpj0kd6vwM j2+a3Lug3/yR9QseMlK8dksJoOaiRq9vM79GNyO6Hu3TRYVWHEBS8roJJCTUqbvjPkvO /Ydnq/aObogkJjhkKdQmv9+nhkGIA3126GbzlLWdGJ3LdDDBKXJGr/IoRJihzDMNDQbS fKqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=6GJnWQgjko/7JI0PIPmeJaYkGysB3pUGUsYnLa0TURM=; b=pL1EOA0/KkbW0K/CNxgqD2DBxrX6WLoaTm34KL3x9OhA9fW6YyvajrbwAfNXv/ujd4 3OpkYemfbfnyt3sPjiFDPx6lUNiZmTeceVB2iYhgaTf14CzkVoLj27zIHyfZFFEqmRct OU8qENj7D4VnDHAYqfhgue0l4at0P0FN5/NglqSH5VdyFxCcdw7TphMHX8re8j7iM8Wt yoLbMOtMJBvsc7xobmiTRFceKbZ1sbfdZtL4UyT/3BmUlmgTIqZngF7JEMQswpWQJ9bm sZB8iFQ7SuclqIvV2J7991ojY5RKdhHy8h4mmo2ip4WDMDCNfFJUbhPJAOy0eSfHT+6g XsHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12-v6si2184306pgt.384.2018.06.20.08.35.34; Wed, 20 Jun 2018 08:35:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754502AbeFTPfc (ORCPT + 30 others); Wed, 20 Jun 2018 11:35:32 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:46201 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754462AbeFTPfa (ORCPT ); Wed, 20 Jun 2018 11:35:30 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MYoWQ-1fiC4n0suA-00VOY9; Wed, 20 Jun 2018 17:34:51 +0200 From: Arnd Bergmann To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: y2038@lists.linaro.org, linux-ext4@vger.kernel.org, Arnd Bergmann , Tahsin Erdogan , Jan Kara , Deepa Dinamani , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] [RFC] ext4: super: extend timestamps to 40 bits Date: Wed, 20 Jun 2018 17:33:03 +0200 Message-Id: <20180620153322.54221-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180620153322.54221-1-arnd@arndb.de> References: <20180620153322.54221-1-arnd@arndb.de> X-Provags-ID: V03:K1:XtKspeFT7x7rqK6YhiM5QuWh6Y9c96IItHuvkk1J5e1dlf4fGHM xH4zVyqQ/VbiYjJtVMDA8nbPFfgBLv2V+8fUVQMNYGBB174zMArAmkoztKQI9ggnQlnZBYn cW/ORo91VSfMEBoSh6eWBxSZWNM6BwWtoTLSEYRvNAvMZlbikzGGy/roEQxaqNjHRTbtN01 QXyOyAY1nwKfLqL43wycA== X-UI-Out-Filterresults: notjunk:1; V01:K0:fgCosSI6eXY=:/tNLqpwNlUPmCa8llAFTR2 jBwCkn8aeWkgFs6x2grdymCIrE5YEXw5XyiYuFYfJQWtXLL4dQG4qdSJAx9Pgd4swQ7Uzp/yJ +Z0xQLBNbbxAHtfLtN0SfjzW+wgmIQl2cg27xiG2WqaNJBo/+jG5L+FZYWUhApQ8Pp8XyV1Y7 IsAxE+pmOR01CL7MhdK1jX2MlykcNyVPYho5um5bF22OKrY/+MEX3idgsxflxp9JIeUk4p/fa 8Mh6AvzYaR3F1Q9HQY5iKUQKWqT3uAHTC4x1SSscRwfvzDerF6S2qzdhcoGcwaimNtkx+Maqz XcUE6k5gLg9ImcpUV5qqywQHyBGubO0NVpMcsMdJd+3HT94WiZW5ldliOXXYj8xvbhuxLdshu zbWaTd2PIktJAdE1Rl8R/h/7kWp3zzXpH+G0l78SxSLb/GDI6Zr5yU9BjYVgNTl7EWlBSIbGh zE4bSKYhlxC/DM8wcjfn5m02WmhMhcPwkkYaXT/1unbfSIIsHt43haUO3/REoKj6Eh20+9TJ0 H2ZBkccBG79v9bQQ4W61XKjxg3gzfI/ljzS8olcBJcmCNEE3pY/mJh0kKQbBx4vb4UFm9qSj1 tVba+hwRM7sZN0vLVGVGmqZoIEEl9AxfC4/wKb+VW4bEhaMewlY7zNgWdVe+n98yKNBHV9baM 3ZxPGga4pkYIKbHPPSqm+cAV5aKg5o4ier/RB8AhzeDe/PXbhhcuLCvY/3AW2JuCwXTE= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The inode timestamps use 34 bits in ext4, but the various timestamps in the superblock are limited to 32 bits. If every user accesses these as 'unsigned', then this is good until year 2106, but it seems better to extend this a bit further in the process of removing the deprecated get_seconds() function. This adds another byte for each timestamp in the superblock, making them long enough to store timestamps beyond what is in the inodes, which seems good enough here (in ocfs2, they are already 64-bit wide, which is appropriate for a new layout). I did not modify e2fsprogs, which obviously needs the same change to actually interpret future timestamps correctly. Signed-off-by: Arnd Bergmann --- fs/ext4/ext4.h | 9 ++++++++- fs/ext4/super.c | 35 ++++++++++++++++++++++++++--------- fs/ext4/sysfs.c | 18 ++++++++++++++++-- 3 files changed, 50 insertions(+), 12 deletions(-) -- 2.9.0 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 6b4f4369a08c..cac1464383e4 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1294,7 +1294,14 @@ struct ext4_super_block { __le32 s_lpf_ino; /* Location of the lost+found inode */ __le32 s_prj_quota_inum; /* inode for tracking project quota */ __le32 s_checksum_seed; /* crc32c(uuid) if csum_seed set */ - __le32 s_reserved[98]; /* Padding to the end of the block */ + __u8 s_wtime_hi; + __u8 s_mtime_hi; + __u8 s_mkfs_time_hi; + __u8 s_lastcheck_hi; + __u8 s_first_error_time_hi; + __u8 s_last_error_time_hi; + __u8 s_pad[2]; + __le32 s_reserved[96]; /* Padding to the end of the block */ __le32 s_checksum; /* crc32c(superblock) */ }; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 0c4c2201b3aa..2063d4e5ed08 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -312,6 +312,20 @@ void ext4_itable_unused_set(struct super_block *sb, bg->bg_itable_unused_hi = cpu_to_le16(count >> 16); } +static void ext4_update_tstamp(__le32 *lo, __u8 *hi) +{ + time64_t now = ktime_get_real_seconds(); + + now = clamp_val(now, 0, 0xffffffffffull); + + *lo = cpu_to_le32(lower_32_bits(now)); + *hi = upper_32_bits(now); +} + +static time64_t ext4_get_tstamp(__le32 *lo, __u8 *hi) +{ + return ((time64_t)(*hi) << 32) + le32_to_cpu(*lo); +} static void __save_error_info(struct super_block *sb, const char *func, unsigned int line) @@ -322,11 +336,12 @@ static void __save_error_info(struct super_block *sb, const char *func, if (bdev_read_only(sb->s_bdev)) return; es->s_state |= cpu_to_le16(EXT4_ERROR_FS); - es->s_last_error_time = cpu_to_le32(get_seconds()); + ext4_update_tstamp(&es->s_last_error_time, &es->s_last_error_time_hi); strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func)); es->s_last_error_line = cpu_to_le32(line); if (!es->s_first_error_time) { es->s_first_error_time = es->s_last_error_time; + es->s_first_error_time_hi = es->s_last_error_time_hi; strncpy(es->s_first_error_func, func, sizeof(es->s_first_error_func)); es->s_first_error_line = cpu_to_le32(line); @@ -2163,8 +2178,8 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, "warning: maximal mount count reached, " "running e2fsck is recommended"); else if (le32_to_cpu(es->s_checkinterval) && - (le32_to_cpu(es->s_lastcheck) + - le32_to_cpu(es->s_checkinterval) <= get_seconds())) + (ext4_get_tstamp(&es->s_lastcheck, &es->s_lastcheck_hi) + + le32_to_cpu(es->s_checkinterval) <= ktime_get_real_seconds())) ext4_msg(sb, KERN_WARNING, "warning: checktime reached, " "running e2fsck is recommended"); @@ -2173,7 +2188,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); le16_add_cpu(&es->s_mnt_count, 1); - es->s_mtime = cpu_to_le32(get_seconds()); + ext4_update_tstamp(&es->s_mtime, &es->s_mtime_hi); ext4_update_dynamic_rev(sb); if (sbi->s_journal) ext4_set_feature_journal_needs_recovery(sb); @@ -2839,8 +2854,9 @@ static void print_daily_error_info(struct timer_list *t) ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u", le32_to_cpu(es->s_error_count)); if (es->s_first_error_time) { - printk(KERN_NOTICE "EXT4-fs (%s): initial error at time %u: %.*s:%d", - sb->s_id, le32_to_cpu(es->s_first_error_time), + printk(KERN_NOTICE "EXT4-fs (%s): initial error at time %llu: %.*s:%d", + sb->s_id, + ext4_get_tstamp(&es->s_first_error_time, &es->s_first_error_time_hi), (int) sizeof(es->s_first_error_func), es->s_first_error_func, le32_to_cpu(es->s_first_error_line)); @@ -2853,8 +2869,9 @@ static void print_daily_error_info(struct timer_list *t) printk(KERN_CONT "\n"); } if (es->s_last_error_time) { - printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d", - sb->s_id, le32_to_cpu(es->s_last_error_time), + printk(KERN_NOTICE "EXT4-fs (%s): last error at time %llu: %.*s:%d", + sb->s_id, + ext4_get_tstamp(&es->s_last_error_time, &es->s_last_error_time_hi), (int) sizeof(es->s_last_error_func), es->s_last_error_func, le32_to_cpu(es->s_last_error_line)); @@ -4747,7 +4764,7 @@ static int ext4_commit_super(struct super_block *sb, int sync) * to complain and force a full file system check. */ if (!(sb->s_flags & SB_RDONLY)) - es->s_wtime = cpu_to_le32(get_seconds()); + ext4_update_tstamp(&es->s_wtime, &es->s_wtime_hi); if (sb->s_bdev->bd_part) es->s_kbytes_written = cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index b970a200f20c..fe58aa905cbe 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -25,6 +25,8 @@ typedef enum { attr_reserved_clusters, attr_inode_readahead, attr_trigger_test_error, + attr_first_error_time, + attr_last_error_time, attr_feature, attr_pointer_ui, attr_pointer_atomic, @@ -182,8 +184,8 @@ EXT4_RW_ATTR_SBI_UI(warning_ratelimit_burst, s_warning_ratelimit_state.burst); EXT4_RW_ATTR_SBI_UI(msg_ratelimit_interval_ms, s_msg_ratelimit_state.interval); EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst); EXT4_RO_ATTR_ES_UI(errors_count, s_error_count); -EXT4_RO_ATTR_ES_UI(first_error_time, s_first_error_time); -EXT4_RO_ATTR_ES_UI(last_error_time, s_last_error_time); +EXT4_ATTR(first_error_time, 0444, first_error_time); +EXT4_ATTR(last_error_time, 0444, last_error_time); static unsigned int old_bump_val = 128; EXT4_ATTR_PTR(max_writeback_mb_bump, 0444, pointer_ui, &old_bump_val); @@ -249,6 +251,12 @@ static void *calc_ptr(struct ext4_attr *a, struct ext4_sb_info *sbi) return NULL; } +static ssize_t print_time(char *buf, __le32 lo, __u8 hi) +{ + return snprintf(buf, PAGE_SIZE, "%lld", + ((time64_t)hi << 32) + le32_to_cpu(lo)); +} + static ssize_t ext4_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -287,6 +295,12 @@ static ssize_t ext4_attr_show(struct kobject *kobj, atomic_read((atomic_t *) ptr)); case attr_feature: return snprintf(buf, PAGE_SIZE, "supported\n"); + case attr_first_error_time: + return print_time(buf, sbi->s_es->s_first_error_time, + sbi->s_es->s_first_error_time_hi); + case attr_last_error_time: + return print_time(buf, sbi->s_es->s_last_error_time, + sbi->s_es->s_last_error_time_hi); } return 0;