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));