From patchwork Wed Jul 11 09:14:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 942376 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41QYLr17LfzB4MT for ; Wed, 11 Jul 2018 19:15:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732522AbeGKJSR (ORCPT ); Wed, 11 Jul 2018 05:18:17 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:49143 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbeGKJSO (ORCPT ); Wed, 11 Jul 2018 05:18:14 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M0Qv7-1fvOTt2wnN-00ubJL; Wed, 11 Jul 2018 11:14:48 +0200 From: Arnd Bergmann To: adilger.kernel@dilger.ca Cc: arnd@arndb.de, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, sirmy15@gmail.com, stable@vger.kernel.org, tgnottingham@gmail.com, tytso@mit.edu, y2038@lists.linaro.org Subject: [PATCH v2 1/6] ext4: sysfs: print ext4_super_block fields as little-endian Date: Wed, 11 Jul 2018 11:14:09 +0200 Message-Id: <20180711091414.1494843-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:k96ja8uKs2cKCxeGGBOC7DdqQntq9kxxFt1GvibNWAjl6FnyhOc oGHbX9U/lTfzNyLSYeEqIh8QMmHpWFCDN0fMQod7i990D13JxOiVNwE09hYFzGLsF9Sej8a amVEi7x1dqyLMdUtaRmea0LhEkI/q88GpUwpIlIvICnvTd6Skkf1BJwhz70QyjJZ1YdmYdv z65cQ82y5Ltecb5vKHzhA== X-UI-Out-Filterresults: notjunk:1; V01:K0:XB78hOjXeho=:VUFx62ifQMg9bF/Ofbfhut OS3T9wkUGtA3dTe65iJ3NRV9He4Z6QJb+u4uYT/tGBtshquIjKGXQbaZQjUKVz2wUXdFNR8L/ 0sNOA5nE8UNybHFG+U7svmR3SaPYNoyNYoS4X4QbJTN1YB9E2DpQpafEWaZlBnvjRjMF4V607 UsQuozQcnT3qTHJWAK74bf+2TBZYjudvwKs+091+36bebY+dG3mflqUue1dVrtm/hK5RWYAQJ 4Vry5oNXC0Ir+DekBxHvzWZFX1ozOxABKUKw6T6p6vWO3nHj4yKgtTpRgJjxPR2o1iQFKE4+S rjUnkp7kDDrH7ypPZOEhoohy6Rrydg21t5YMGaea64u3Ic6cOKCWnBY49Iu0DHENoIUU371Gz nm5b/y+E0r3WP47H/FlKG31YkwZFzzCHDR8wsWXHd6973rWgJ7eOaNtae8pKZlRmcv3BbFB/M 4DSlChT/z3R/qjdqdLhveO6F8UuBZRsBxqMuDuz0aeE5hlvJaMmFPIgVRtjA1To+Y3Z972fw5 UNgkHJM4h98ksf4sfT1j34ugITRrmifc0bsMeIhAyAhKfYoJgHKJaLEjuln+L6zP5RsW1zqJe cEGbwoPveN4YX6I8J3SQXurVZj3WnkvOYeAZ0BpwAnNPzChLOF+7wKR68OpeRAUTRlwqN3/Pt sYGFJCmfwvWkhzuCayQOur+XqnuCk4LBrlHz5jQm4zNkX7kzlyG/Yl+MAAJc/yVeSn04= Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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") Reviewed-by: Andreas Dilger Signed-off-by: Arnd Bergmann --- fs/ext4/sysfs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 Jul 11 09:14:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 942379 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41QYM6229lz9s0n for ; Wed, 11 Jul 2018 19:15:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732407AbeGKJSN (ORCPT ); Wed, 11 Jul 2018 05:18:13 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:34731 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeGKJSN (ORCPT ); Wed, 11 Jul 2018 05:18:13 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MHpFN-1fe09c0kQ9-003b7L; Wed, 11 Jul 2018 11:14:49 +0200 From: Arnd Bergmann To: adilger.kernel@dilger.ca Cc: arnd@arndb.de, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, sirmy15@gmail.com, stable@vger.kernel.org, tgnottingham@gmail.com, tytso@mit.edu, y2038@lists.linaro.org Subject: [PATCH v2 2/6] ext4: use 64-bit timestamps for mmp_time Date: Wed, 11 Jul 2018 11:14:10 +0200 Message-Id: <20180711091414.1494843-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180711091414.1494843-1-arnd@arndb.de> References: <20180711091414.1494843-1-arnd@arndb.de> X-Provags-ID: V03:K1:9KIdbbQHbE6BmsF9QS6CE0VZGaLOATdivJmOebBq+U+ibEFUsDJ Is1BBABZEJivi6E85kYeXu43lgaCw21XcC2NMi5/FdBXwmx7GJEnEnjTOXTRByt9wxear5s S7Zg/wb972C3ezH6dFdR3UgL/gdK7rJJqxR0h9ctk4z6yMQm2jgTxM60iDvF9g2Ahj/pbQU tFQ+tb+ZBVJjLl4lmYPag== X-UI-Out-Filterresults: notjunk:1; V01:K0:bq64pgaBvEc=:uAfBXobQm2ytQkwu68BoFG QZ3nPwDTMoco9xYM7diFqXMlR0NnVfv+5QVSJjlDhrt6Pr0wAzpdAvlwnYmReyMaHj/txRCXK pZwMD4/YnYaklMv3eci9bxOgV6IKXMa/ZuJgADCmxc8NHpMqCPFsmIR0lQ/OpRckDVtbxWxd7 4BAXQCmsgJR/vwc+iTRJ4JzY4Y2F+7hqPQMXu2ud6x/iSbWrGrenLD0ldhLIx/BR+UoaHTTqA DynC8/JjT8G4hfhLafCwIwNwznnOEq59g8HOzovA1Cjpu/Bkl/l6NK5k2EIjuzqSBD3w/nYoS Xs+EvEfJ6hQxDnT8Hoy4VmLEHacntS2H1ohPv8kjd/kOq9y4wLVXC77b9X+CZUC4cOO0dtFy1 H8/3ecXG70s/snYXdTT7etChOxTiK8qYqZ408beGQGau0VsM6eFqRV+U2RQsIcmysgduqqcgv Q2Y/SsLp7VFq/2f3np6OM6fWoDqZmHCdQW4lamFsqh7h1TmKZnDaYtWJ+5aHID8Gi4zTa1k30 J0uSF/nhEDPYOhtThMuRrS97kWAKNaS0F3bCj4MhNzOTVJUbX2Ywe+DWsly4mcpY1iphz9Gl+ dXT6HizkhrPQIcvkrqCTMzcwdLwGS3eY5YzU/Xin5ehI1uwfGqSgdW+epp/BmmSpDpD6pwuYZ 2w36o4+s195WI3Su2mh35Y3uTaQLJpCGofDxfBhlAcUL8KFg7cGqJD3mxEWwH5B3O5XA= Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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. Reviewed-by: Andreas Dilger Reviewed-by: Jan Kara Signed-off-by: Arnd Bergmann --- fs/ext4/mmp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 Jul 11 09:14:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 942374 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41QYLW03QmzB4MS for ; Wed, 11 Jul 2018 19:14:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732508AbeGKJSQ (ORCPT ); Wed, 11 Jul 2018 05:18:16 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:48621 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732366AbeGKJSO (ORCPT ); Wed, 11 Jul 2018 05:18:14 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MeBaA-1fRZZv2gqk-00PvCC; Wed, 11 Jul 2018 11:14:49 +0200 From: Arnd Bergmann To: adilger.kernel@dilger.ca Cc: arnd@arndb.de, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, sirmy15@gmail.com, stable@vger.kernel.org, tgnottingham@gmail.com, tytso@mit.edu, y2038@lists.linaro.org Subject: [PATCH v2 3/6] ext4: use ktime_get_real_seconds for i_dtime Date: Wed, 11 Jul 2018 11:14:11 +0200 Message-Id: <20180711091414.1494843-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180711091414.1494843-1-arnd@arndb.de> References: <20180711091414.1494843-1-arnd@arndb.de> X-Provags-ID: V03:K1:aLZZDLe4yh9mM/SxxZyq83TZgByo8/3I999hKbspb10a+AXFU3A vKFh9z44EXJwcmC7zLSDiyqiBL67c9CZ7SqDIAG5nbOwcjS0fqtEFsdJmn5ck5ssz40FPEd EmZv4J4TZ4LiTuW9RudvUaclouFuj5C7q4HjqodyZt5+JFDbkJV7Yp0I/HpOgOROrSx2zP7 9HgMNbB9sIF5HfrjX0VXQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:pLJ0P+786jA=:Nz5demrXIadNQ/i7ERRua8 KKWf+iPFJHwtQH5E4HrAJ078q2cfj4rtDTk2TJGTr3raClkDqz5YVs+3zMhKWsAR2Mixql3Os 8rvY6RX9yV8vrrUqKnYBNZkDrt34L7UAMPotPdAyv49ky9zn9PbdGIGIF6KuAxIEeO50PeHlX 8yGyi0sn3OhRxoUzHJWCkIQlaNCBbLnDlmSCGUrOCYqz6L6TESyHBX9K/fUDtGm7gTKNteh8y F4jRiwv6jzH0/nameYSOEk6RXo2L42DQosx5SHPVestayI1Jq9LFr/0zi7L6by4UyziAKxNMy T7mPCMBhTvEZdTbwvJ5uor7SRs4G+nIprLSDwhWKzNnwhsxUQFQEqAORCRET06QhmhEYiZkri CeVeN4YMkccPQEkY4WvOfFpdv1C6y2DQ7fPBgE6tvouQHWlzyIDD5gd+RehB9NQ2ArDLggnfF 8pHgvhnhwydjzpw0toB6F1ACpya8femVj6gMeqxIYD4+QdxBzeYHuYJqRU1UPpau3mMvF0gMA hUsNcz7hLmGmrGMuiCtMF6Hem4FLPSstfGMKC0N9fHf11Ug2Adg0g4sozSWvTG+UZhspUCuml MdkkAj7FyL6S0PgKh93/FwKd11BSNFteTX4Z2NdBgszcWu9p7CEa1KemNp5HxgtciG9j4JuPv xW8LfLvOu2xYSF8q3G6/2OoBmUVCBx4qjoCy1RbmFB/s27jZOSLmKZilfkNInY/C4lDY= Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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. Reviewed-by: Andreas Dilger Signed-off-by: Arnd Bergmann --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 74982a9566a9..3b54227cf2b1 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 = (__u32)ktime_get_real_seconds(); /* * One subtle ordering requirement: if anything has gone wrong From patchwork Wed Jul 11 09:14:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 942377 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41QYLt50psz9s0n for ; Wed, 11 Jul 2018 19:15:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732513AbeGKJSR (ORCPT ); Wed, 11 Jul 2018 05:18:17 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:59793 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeGKJSP (ORCPT ); Wed, 11 Jul 2018 05:18:15 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M8iRY-1fn6qE0aZY-00C9q6; Wed, 11 Jul 2018 11:14:50 +0200 From: Arnd Bergmann To: adilger.kernel@dilger.ca Cc: arnd@arndb.de, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, sirmy15@gmail.com, stable@vger.kernel.org, tgnottingham@gmail.com, tytso@mit.edu, y2038@lists.linaro.org Subject: [PATCH v2 4/6] ext4: use timespec64 for all inode times Date: Wed, 11 Jul 2018 11:14:12 +0200 Message-Id: <20180711091414.1494843-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180711091414.1494843-1-arnd@arndb.de> References: <20180711091414.1494843-1-arnd@arndb.de> X-Provags-ID: V03:K1:btygqJY5XDy41W3h5gSj0JmWcqxhEd25Q38kiD0YBSTilUYitYq /EnuPJjMSqpEx98oUYKuOzgt2pvmFCDHM6wVD0XyV7bjaAlP4vGVqMwqwfrMp9gTkHDxzGN 0COqNN+PY3FTCbmlpDvCwWdvlusZ2Fxrj5vlvGPb0TkFdkJhQqVzOKhFdoeUdzvxnCwcuLv HjYPGXFwWPJ14psvLL7zQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:+nsWJ4ZGs08=:GzMwSZOYFjGKKTG3q/atyy e5I0mCzh/UYJua4yYZRIoMiPZFSDJlyOCMn+vfkW1UTqVkG7tye+XazCE+Y1dDzqC/CqHAYoD ebbYYmCSSqts+1Scyndu57IFKk5cF9GjBS7yiTtK7yWzE3dYjBevZ8yTfNXdhhrIqTTatDqxg YXI2oDAXFyNcWmpz8KMYHJ4KA4fBrCC//AS+EKGcRK4rU5AaAzdGipwh6EuovXU7onh02Bmhc JulK7zvFXRhtO9CK52vDKLOiqBq3dY/BbvZojIy7/kJADevFNJkIBlMFktEdjSzB/WQMOT94p PUi9jI7Pa5Q2JiN4+kydnCOa1yJM1aQn3fQJmWmbuxLXmIAUL0hhCPf2e3cuyaE3Yk/26NpZb XXoqmuVCvs+wPzWCrzUuZrZQhasRYvZ/OLd1xV24YQZdeW+2kQYN8FBvfjxq3f6eqBRfti9ZO bzmK1dwUKNKPl6hCh2Ps8BbcFI4WGmzQ7SpS1ctyJ89lv+pNCaUpw2XdpG6/GRZGqPasE05GD KwnBrsmXPGuIC4QmhCdsJdA35Tbc1Dz1P8IljqVwvoemOOcCA0p28Mi3ffBadADDGbSDy0V3L uU5Of2UuIlSEQ6R9EZ5iMqVLuG6Y0ETlZBeiXWXHTCCYlCmplNJ2FLemRt12C7k4K597jIDTB 93UebVOvzlNwxRmdVXkArkbxJTxFa3rWrKpO84OR0Qe9akoHs7A613wgc++8RqGOf99M= Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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. Reviewed-by: Andreas Dilger Signed-off-by: Arnd Bergmann --- fs/ext4/ext4.h | 22 +++++++++------------- fs/ext4/ialloc.c | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index d79d1a54a27e..f71ccafe8f9f 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; + u32 extra =((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK; 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 fb83750c1a14..18c37c43751c 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1083,7 +1083,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 Jul 11 09:14:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 942375 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41QYLp27yMz9s0n for ; Wed, 11 Jul 2018 19:15:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732528AbeGKJSR (ORCPT ); Wed, 11 Jul 2018 05:18:17 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:36257 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732496AbeGKJSQ (ORCPT ); Wed, 11 Jul 2018 05:18:16 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MI6MY-1fep6K2TB0-003s6C; Wed, 11 Jul 2018 11:14:50 +0200 From: Arnd Bergmann To: adilger.kernel@dilger.ca Cc: arnd@arndb.de, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, sirmy15@gmail.com, stable@vger.kernel.org, tgnottingham@gmail.com, tytso@mit.edu, y2038@lists.linaro.org Subject: [PATCH v2 5/6] jbd2: replace current_kernel_time64 with ktime equivalent Date: Wed, 11 Jul 2018 11:14:13 +0200 Message-Id: <20180711091414.1494843-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180711091414.1494843-1-arnd@arndb.de> References: <20180711091414.1494843-1-arnd@arndb.de> X-Provags-ID: V03:K1:cVp0WYR2ZFIdEgbp9PF+Qdqd0SUXDYog7yfsgNUFUmd9mj8u2Cs aGL4HqKtEcPQgTMkfDdVWDNaD4AN2C9Ymm4GdkWPO+05GTFnwidcyCfW3cL3vP8JMO9A4wC cZgpBTsvRsolEphYT0vewKYZMOCzAXOp+ymz019x+Eb5h8cNXy48NcABJtAgyOA2efmRYu4 qmuQZU4q5Y/nqvJFhGaag== X-UI-Out-Filterresults: notjunk:1; V01:K0:d3MQqQdD6FA=:YokxPCv4m6sBog4Pxap2mi IcNPusw86p7AQW0af+5kMQeBMMbLFNvCWWbOjhoxWOQYcO0vl0I/UKc36+NeBvF7bQX75evS/ iUfPkB9HzlKooY8Ln6mENqcLcIhmgPcaxbL2Muuj80Y/ap5EMrcbOZ1weRnPkIXp4MtbGmT98 vBTlxgQlTfIZMbYM86s0YE92TTmrGANq/Ot7y3k0b8QmfGRzidu5wd2CcyL3WUU5sulqR0aaV tF5lyz4H30vRD5Ldf4+HAbZLPSlUAMchrda3kXsTgnhFND0W1KkhGcn0sMThZrDzRlyKQHLSo QO4tOqLq/SI1ENwwNbclLboGiJawK8ERW9uv7q3zo55d+ZFbR0S40aXspMV2nib3sryTxJivG NtLp97AyOLBgVbCSXe0kPuEMaRwGnQgs042wCAbCGls7JegV+M67hlPWEM5+Iz5BlW0NOAZBz WlOPH48mwCYBvaqfxOB0+XZKhfALtzAedh6RLzGY4AnBvav7bmi+Wt2SOMaqwg2gzf/EwoxZA GGbl63vopkyxCjXpFE+ttCp8yrx9Ee91lgWP0URGHRrPgWm1DrdG5lF66a28vU2K6p8ejz/p5 WufSe6JlWsMb6tQb/JTdOk+NCEt04fCfRWHHFl4WnoYLAcku+GWo3/AWdGZp+t/THS4hxiKTt CQpQmvrzrAkw8U0wh3iJPZaMQUDtBw0hUcjLS4eOle+5r5zduu/ZQKIrf0Wj/jmTzTAc= Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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. Reviewed-by: Andreas Dilger Reviewed-by: Jan Kara Signed-off-by: Arnd Bergmann --- fs/jbd2/commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 Jul 11 09:14:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 942378 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41QYM268gXzB4MR for ; Wed, 11 Jul 2018 19:15:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbeGKJSj (ORCPT ); Wed, 11 Jul 2018 05:18:39 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:46595 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732495AbeGKJSQ (ORCPT ); Wed, 11 Jul 2018 05:18:16 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LbItu-1gNoR70C1y-00kwA0; Wed, 11 Jul 2018 11:14:51 +0200 From: Arnd Bergmann To: adilger.kernel@dilger.ca Cc: arnd@arndb.de, jack@suse.cz, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, sirmy15@gmail.com, stable@vger.kernel.org, tgnottingham@gmail.com, tytso@mit.edu, y2038@lists.linaro.org Subject: [PATCH v2 6/6] ext4: super: extend timestamps to 40 bits Date: Wed, 11 Jul 2018 11:14:14 +0200 Message-Id: <20180711091414.1494843-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180711091414.1494843-1-arnd@arndb.de> References: <20180711091414.1494843-1-arnd@arndb.de> X-Provags-ID: V03:K1:20Wchcr3kLso94smYgixxLckDSeH2idv+oOepEOCqYyI9iQpkjn BebCENWmuw08kHSrBOPapDRRdQm7QaV4umeaJuTFUHpQgawkRENkPQx32hocvtHokSrjuwG 8Zd+yF5ElZkjR2TXQcK+2kmPAVigtIwz+afz/l+vIBDd/D3QCP+m8HnwMENbHWG+U6upfxU Zq8Rmuqc80A7hBai6VYbg== X-UI-Out-Filterresults: notjunk:1; V01:K0:uI8gAj6IHnI=:POsO6RWEndsVb7ad646Y/l Zk+E57bZ0mM0Ef4O4qGAqbn/8D2abArfwO5CZuhdiHBhpQD2vGcXljHrNnGiqhpX9qkWCSVyM iG78YN5oh2vP6KBjeAOnoJaD/cxuAjWGvrDhwxlXgUKrbowbPMaWa+FXG8oE/GZERBxbT5sdE H5xxuaz0ptMcC318hZhIraVNIjaijHL5tIkynx404F16SLRFoXB9bh/5UHnMSpagktE4HMJxc nuJdVjUujCCvhJbdQz0sPzRLuNN5fKKvMVh8TqDHzdLO5ipU9Rql1cn7tNYos73y06jQmrTSL ZWLlE4W14TAK9vi/9uLIQWCA6aiGiiPpky+EyZeyTqiLgo9vGxkqZBYe6cqeEL0j0dwjdniG2 AWhJ813YR/3KUzH+SPuU3Qj/1OWSzP6RMEHnLXf6HD6b4+BOs+4TxjmcEsqVIEfyE8q/0qlRf Z/cXQSKZyeXIP3xwPeD1IydUaDgDKhc/0WzXVplsY5BrqdDrZcmAcr0j9nHXNHsEmjDCvj8PY YH5MUYC/aZ4Bti731DsQiTJNNEWoeTfnVKWGuBEWl9gMIUiLACLMHM08Lew1Z0dUOFFivMkZj xtSHbqXK0y4JSdJDJRmI0SoKfwiMCHmPP8otxVjQT9iLTcwkqp86olTvSYyKevTjsAoPyIOnI fMPntocDStNdyaPqdTZPpPicmAXbnNLU9l863iLAicqGGSuGNgDYHmCvi6Ia58YSTy9o= Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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 --- v2: drop 'RFC' from subject minor changes as suggested by Andreas Dilger --- fs/ext4/ext4.h | 9 ++++++++- fs/ext4/super.c | 39 ++++++++++++++++++++++++++++++--------- fs/ext4/sysfs.c | 19 +++++++++++++++++-- 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index f71ccafe8f9f..3ee9f198c698 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1295,7 +1295,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 86e3d13787e6..aaf29e3981db 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -313,6 +313,24 @@ 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, (1ull << 40) - 1); + + *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); +} +#define ext4_update_tstamp(es, tstamp) \ + __ext4_update_tstamp(&(es)->tstamp, &(es)->tstamp ## _hi) +#define ext4_get_tstamp(es, tstamp) \ + __ext4_get_tstamp(&(es)->tstamp, &(es)->tstamp ## _hi) static void __save_error_info(struct super_block *sb, const char *func, unsigned int line) @@ -323,11 +341,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); 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); @@ -2175,8 +2194,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) + + le32_to_cpu(es->s_checkinterval) <= ktime_get_real_seconds())) ext4_msg(sb, KERN_WARNING, "warning: checktime reached, " "running e2fsck is recommended"); @@ -2185,7 +2204,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); ext4_update_dynamic_rev(sb); if (sbi->s_journal) ext4_set_feature_journal_needs_recovery(sb); @@ -2876,8 +2895,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), (int) sizeof(es->s_first_error_func), es->s_first_error_func, le32_to_cpu(es->s_first_error_line)); @@ -2890,8 +2910,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), (int) sizeof(es->s_last_error_func), es->s_last_error_func, le32_to_cpu(es->s_last_error_line)); @@ -4822,7 +4843,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); 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..e60cc5e89023 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,15 @@ static void *calc_ptr(struct ext4_attr *a, struct ext4_sb_info *sbi) return NULL; } +static ssize_t __print_tstamp(char *buf, __le32 lo, __u8 hi) +{ + return snprintf(buf, PAGE_SIZE, "%lld", + ((time64_t)hi << 32) + le32_to_cpu(lo)); +} + +#define print_tstamp(buf, es, tstamp) \ + __print_tstamp(buf, (es)->tstamp, (es)->tstamp ## _hi) + static ssize_t ext4_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -287,6 +298,10 @@ 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_tstamp(buf, sbi->s_es, s_first_error_time); + case attr_last_error_time: + return print_tstamp(buf, sbi->s_es, s_last_error_time); } return 0;