From patchwork Thu Jun 21 16:04:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139551 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2261876lji; Thu, 21 Jun 2018 09:05:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ7r6q2NYGK1ncync9vzl+rhsJqlenJuLvbUSRtRGm3KwCQ2nZOS5fPUj6/4mx7vfW28sWv X-Received: by 2002:a17:902:b7c8:: with SMTP id v8-v6mr1845093plz.188.1529597103968; Thu, 21 Jun 2018 09:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529597103; cv=none; d=google.com; s=arc-20160816; b=pDeNTE9kCAFUMJujLb/AdxyMDMDhRmRXh7uiLXLbsq+6GKQNQWt7YugKpp1/IQhQWB GuY0x7JIKsOGDIm/DS5pElwz6Ul4vnp5bvV2aIcvumvbfv99F7JszLbk4BGBdxkRx832 qp3ErQmMphI/Vbb8MuIrKuBDZRKLc7QBoqYl+nIXqTRzWr6m3rifRtRB0JMAXg9RfVH+ G8qnEr+9HRnINHfPBB/jIqA9M4KU+NPxwuVdJyclQtyi8ua25GNXCpcw5rw3wIMB+oCO eg21OY/oJkQufzGmdc9Dqn4yUvKOoigA+O/0p3MniF/UMWbnrEy1vtFu7NvgZAtCRvgi N0Ag== 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=QPJiM4U7xTIltroIL+ihlstkImVO5ShF1c/ChMWYHds=; b=bLtRFY29cdk/0yvrav1k7VO+AKRhaYPuKO8PX2A01RSeHJSOGXEoGCQyLFHlH39b5X HGnSTTvlW0TdGdhDVo1DqJdBCzW3M9uYtEehBvMNO2SP/LOq5hhsk/5c2GoEPlBRHGmY uRK5g7rPSmauDwlh0Lev09FIRaNux32ycqmx9Ilm1Gqq0tDtbfDA0Kc5644u5hclQhk9 fLyKiUFYffEMKz2RF2C4R2X3LeVAbEq1Co5K8WQY877V7ilv0kjvsljmkJ0V31/gLlwY 2viW9DTskyW/MniV/kzqiusAyvo1xKlViy+3tuoie4H83Xl9xcDIRzYRMPTE0nOAGY9S XbgA== 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 v14-v6si4192556pgq.146.2018.06.21.09.05.03; Thu, 21 Jun 2018 09:05:03 -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 S933477AbeFUQFA (ORCPT + 30 others); Thu, 21 Jun 2018 12:05:00 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:38809 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932858AbeFUQE7 (ORCPT ); Thu, 21 Jun 2018 12:04:59 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MbXro-1foesu1O3o-00IjFn; Thu, 21 Jun 2018 18:04:24 +0200 From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba Cc: Arnd Bergmann , Qu Wenruo , Nikolay Borisov , Anand Jain , Liu Bo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Date: Thu, 21 Jun 2018 18:04:05 +0200 Message-Id: <20180621160420.139575-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:fV6nzSuXSRbmacKeU+QH9t5xFaNCdZYxLn9F9oVABGxTE+izuNW 8gdw1Xc6BOpBOWu1ZeyRtERsIBESn2V5hUo/QwTPUZ2UCnWKc2Mkdgcc+kWmQCbgwtxghxh 4L6CBP1mVMMHpA0t+gZiJ33n9r41XD8rjUG9PKcEM+POGPxxQAojFMm7CcUvugHQnLedjkv dwvGMes4GzJaJSRAJb5dQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Twf5/40fyYI=:NQyrRvnIhPbbwckkUsApMO vok43N4yeGu6LMjLSXxmg3dik3gbj/cSlP3PYqryHXAcSm6eSC7gifJnplG6UYvE5c5nawr6K QR1hxyE6dt4xNQLuPHhtJggeu9tydafvQazA34aBMT6KaNQV/1Cq+to4L5aKA1U4QYZcXNNJc Xtjax6AmPUpP90UVL9XyTU/Hnahndzl2QdAJCYyA6aSNOFXq0lIxWLmNQ6I/xXrkfYYko6kiZ 9Yk040fgFIaL2trIveIgssPPsmTjKqLiYzfyQ2t3gbuNYA8msTI9vu+BNRL+CYD4I5xD6gRyP sZFJ5mNe1VAvZjxfY976PfR0Ur6CZAwXt1AgP5tzOI4lZcLWs+pqFOKeTJFnPsGTUKEPyLQnD X61LztHvoeRjWbrFd9UrEyWJLuCbpPnoBCiVtvBGTdmUISpVMOa2S2fav/O3UNvhO7Ea/5xFy PavgPabk4mxSOiN3v1ThIPSO9nOTzpWXY7j8VRX6jlAAUlpjxITvBo8rfCEhPVs3yPWMG5YyV KOtucRMQgtabqg2IZcod0/zbOGwNzugnQljv3S12qY3BTjxLW7JTTICSE3CXLKWrs1Lx08X5A ebHVKfWrvu3GYgmsR48/i9UwiuTmHpajl8zC9xaKlLefaD9u7ZXx+pMJZC8NNKkaseNln79x2 9sefOGfVjUNb6dMxc+0+O4Ips0Rn5AnIW8FJzzKQEgaGpQ8MKSagMsFTAYrBogp5YDJg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The transaction times were changed to ktime_get_real_seconds to avoid the y2038 overflow, but they still have a minor problem when they go backwards or jump due to settimeofday() or leap seconds. This changes the transaction handling to instead use ktime_get_seconds(), which returns a CLOCK_MONOTONIC timestamp that has neither of those problems. Signed-off-by: Arnd Bergmann --- v2: Rebased on top of an earlier patch by Allen Pais, which also obsoleted the original patch 2/3 --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/transaction.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 Reviewed-by: Nikolay Borisov diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index f3224e23d5fa..bf0717f2824d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1819,7 +1819,7 @@ static int transaction_kthread(void *arg) goto sleep; } - now = ktime_get_real_seconds(); + now = ktime_get_seconds(); if (cur->state < TRANS_STATE_BLOCKED && !test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) && (now < cur->start_time || diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 56c8bab0b816..ebe50dfb8947 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -241,7 +241,7 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info, refcount_set(&cur_trans->use_count, 2); atomic_set(&cur_trans->pending_ordered, 0); cur_trans->flags = 0; - cur_trans->start_time = ktime_get_real_seconds(); + cur_trans->start_time = ktime_get_seconds(); memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs)); From patchwork Thu Jun 21 16:04:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139552 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2262475lji; Thu, 21 Jun 2018 09:05:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLDQfTqzZozbJvKwAlCLaIPslw1oFalJy+6Yap3ORQK5fyzbLTi0DizYpzfDyEf8E1hVlSu X-Received: by 2002:a63:770b:: with SMTP id s11-v6mr23445765pgc.339.1529597133853; Thu, 21 Jun 2018 09:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529597133; cv=none; d=google.com; s=arc-20160816; b=LfIxyFdbF8+rDtF580K56nujsrV58s+BH5F55+cDSqd0hH/T/Rk2sTFoxex0CMm5gI Z5swehEwkMRAlOfboDSBapwbMKpneKvxtAT798Mu9lpOP0zYrXdJ6tOHxZGVhmmPEeA7 xAKqqXkqjv0rfaozbA3tvKqjqJUGp4RntQyGHaRxUNBqYCLFEEshplnLpqE+K7VUxaj8 UIJiFw1fYe+UTk8ffk7XA5xkwXLPdNUSrRusuo3HcgSaiTrcYRi898A3ESb2aTr+xS4x a403v4vfX1Tvguaeq8Dyyrz+p6KMvl9toPAQ0TqGWX3hYvZZVDK+axI+IclkKCw/GtEm +7sg== 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=K9yw+P6xznraqQdANKlus01owcZ0qv/vOz0v79Ank7U=; b=BwZmha1G0NeErWNUFbaIjhQnpNC1oD5Hr7HSY/WK0+RtSQobBNVGNtiRFA/PhMso+e nFtRbAIiiWHDjpXhaAhem/PuKhXPSD8iwS0CECPhohppzkyqVP2AudMzofZxeDlsaPbl 4NeY5oej1dO9prkCV9ynn/g69OowBvDTSZIxcbRXf6rll7UGUGuDwXeTUv3A/LKa4xkn kvtpHF+cf9/yhvXjj6OborX+F9VPFUGSezyl1znX5s20T3q9vurdqiqoBmMU5mWt8kUM TrX2kVRsWnKM5dMDYGkchMDun8WUIed8ki+ZIIXN701c4LcRQoyx+1zVSc2MjWp0Zr5T +Nyg== 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 v14-v6si4192556pgq.146.2018.06.21.09.05.33; Thu, 21 Jun 2018 09:05:33 -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 S933546AbeFUQFb (ORCPT + 30 others); Thu, 21 Jun 2018 12:05:31 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:39873 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932858AbeFUQFa (ORCPT ); Thu, 21 Jun 2018 12:05:30 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0LisgQ-1g3Qoi3fvq-00dHDB; Thu, 21 Jun 2018 18:04:39 +0200 From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba Cc: Arnd Bergmann , Omar Sandoval , Nikolay Borisov , Liu Bo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime Date: Thu, 21 Jun 2018 18:04:06 +0200 Message-Id: <20180621160420.139575-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180621160420.139575-1-arnd@arndb.de> References: <20180621160420.139575-1-arnd@arndb.de> X-Provags-ID: V03:K1:RPgmPI+oan5jG1gT9SLeDop9/LIgYHtQ9KYDsB1h1xaXWr8yp+c UaRWIZaiAUYks/IzZQ2BElAmtovyESS51Ui70vyZCk2MC90+TyieZm0kumPseEBiTeedEnq wknVgZsp2V5jeKukODUKXU2SVLiikKPrzO2sbeLyrrM1PU7CgR2RWvoqLXGNsaxQYSzaepE x+KjxBB10jNtnjVctOeHA== X-UI-Out-Filterresults: notjunk:1; V01:K0:HvGdXofP5Ik=:qas8yQWowTx6fRhINj6fcy 1wY9ruIx828wnFAslGJDAv3EwKQe896Xee1ekIr5dGISdxVQQ02ztrV1f/Xdq2JWyfNjRI41K 3qVaIPwd9dMgA0XEPTNtKC7xGwoc/Jfkq4xjAZDEsxDVvVYhzZcnBcdXhaQC9R9ZA0N0Elh0Q reTl7f/BbQ+HCcApZQ4pwIwrAM4HWEXtjSuiFHIuLetR+KOcHgSoQ4AyosrRqBFqWQLJafIbt Gps7utt86fuUqkaT1ki4NUqKv9yCNwLCgExyJ7MApczXxhvxzEVnmbpNvB/ck7rWo3xFAwRhK N8AAUWdAnLiOb0XuVsnp/uNTpMJp8GcezbeGHLLkHPiD2WWcSG6iFzXSQ1fAUArjkdpjWVUDG pqwFIDDtLhuLSCifANN7WC3cRLQSQbCScNK00FqnVy7bdGeEEIifISMh7DxNJwilf0UgvbBJc 3tWDDd+94RjXJQh68W4EXp7CYE4djY4N8pnd4qhqAlM2ago/R4b8LcISuj5ibuW3ksIYo8oY1 9C9mb/rbBYUmByi/fglY3vnXLIA8+AgRjVG8i5ZQiA58nJzyuVHj9ms9XfmxHFmYavyBt9IDN OG12DLifaYNmZdCKcQtkA+faWOhKiU3/yP99bRQufTAK7WSIUhq5MiJxY3P3piVTrgpJB22mr CtSI+j3Jv7zRM9FR1akCV3CsUoD4NsIPWodVWMsrC8NvReoICkXhZcJptP16M/4mMC2k= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While the regular inode timestamps all use timespec64 now, the i_otime field is btrfs specific and still needs to be converted to correctly represent times beyond 2038. Signed-off-by: Arnd Bergmann --- v2: no changes --- fs/btrfs/btrfs_inode.h | 2 +- fs/btrfs/inode.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.9.0 Reviewed-by: Nikolay Borisov diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 7e075343daa5..1343ac57b438 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -178,7 +178,7 @@ struct btrfs_inode { struct btrfs_delayed_node *delayed_node; /* File creation time. */ - struct timespec i_otime; + struct timespec64 i_otime; /* Hook into fs_info->delayed_iputs */ struct list_head delayed_iput; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e9482f0db9d0..22dcc8afd38f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5745,7 +5745,7 @@ static struct inode *new_simple_dir(struct super_block *s, inode->i_mtime = current_time(inode); inode->i_atime = inode->i_mtime; inode->i_ctime = inode->i_mtime; - BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime); + BTRFS_I(inode)->i_otime = inode->i_mtime; return inode; } @@ -6349,7 +6349,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, inode->i_mtime = current_time(inode); inode->i_atime = inode->i_mtime; inode->i_ctime = inode->i_mtime; - BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime); + BTRFS_I(inode)->i_otime = inode->i_mtime; inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], struct btrfs_inode_item);