From patchwork Wed Jun 20 14:34:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139352 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp867518lji; Wed, 20 Jun 2018 07:35:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ8R7PbJ0DRzi4eXRX+Wm5pWuHuE6bcwgjkfczzumyhIfkzomrRJ0dLZuJE2F6hlhZvaP3d X-Received: by 2002:a62:90db:: with SMTP id q88-v6mr23274773pfk.186.1529505313979; Wed, 20 Jun 2018 07:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529505313; cv=none; d=google.com; s=arc-20160816; b=lfd3fYw342nKlqp6j8HM8PGJI5iHP6BJp3oDkqg5DejaD3uciLf9ldkw7gtt8xqLso /l/EdlNAf7kRJKjfdJOu9MRtRl7jV5LvR7/QrBR+09NDVKJ5QQ8KEsyYmBVsvEfYgJVr 40HquHngYKnAMXtOTj81rcYWaJJJd3dsazC9tNMA7Xbn4l3gfvcme/iHDRbWVMUbOp9V Y3zVD2kApINYai8/5YYFM36VrYWQ6NK+5HVAISZGq0l6tQfKMa18HrcH5WzIvH0t7Ux1 hB+w5cDzbZ66RLu29f+3Zqipt/NcKM0gsIxxdh+49EmsiqhRmJJKCnkG4gSXEKoCYW3s Hi5A== 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=JQ4S1UcL5ZqGuznQSNsf1lmHWyFRxdMJfUxjrpB2ZHI=; b=ub37BFPWycAJveFO8tK+RQQY2clr5Td0HEIIwcVKb4bJB95YRndDmos1+I46Z7WIvR hqZy2kjbQKx1bGbhqcqhZYCToQvxICphZZY+FMXT9kXmK2Zt4uxKJqG8NMghh/0DDOfE O1hsy3ZY+5W/23rbZHrbgflMdCMdeakKKQpZ2Y9Lg/a7Z2xCHxZke7PzSMmeCqua+Q0M R7hukbThMPKC12xzo8j8aCPbf07/ts8KMHHS+RvTdXDCS9g9w+QJ1IvkMeSobUnrUrTN jZjcTzRBRvsH57jzvLy+CYGzaxEUiQHNkkzFo3yf0S+WSzHrQyFyOBJmGzFsU23iyCq7 j1PA== 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 b2-v6si2420599plx.88.2018.06.20.07.35.13; Wed, 20 Jun 2018 07:35:13 -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 S1754153AbeFTOfL (ORCPT + 30 others); Wed, 20 Jun 2018 10:35:11 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:52403 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753202AbeFTOfK (ORCPT ); Wed, 20 Jun 2018 10:35:10 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0M3dNR-1gMn0s1RQH-00rDit; Wed, 20 Jun 2018 16:34:51 +0200 From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba Cc: y2038@lists.linaro.org, Arnd Bergmann , Qu Wenruo , Nikolay Borisov , Anand Jain , Liu Bo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] btrfs: use monotonic time for transaction handling Date: Wed, 20 Jun 2018 16:34:32 +0200 Message-Id: <20180620143448.44388-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:MtvJ2iFA9/LaYZd1ruuHDxsLXAOCr+xAiDICHrxoScZxVLigjuM sosnnngWe5MtmRv21mB1rybde/V8XsTaVO6retjpOUQisaav+U49EVeTlRuU8DCfuINulCy lCqGmA+nsE174ZEHbECaMBcs0270OuVIGuKJ7c5J6wEdW6DfXyI/v9wFE9099h4TSdveySz E8HcsaZTAndvMTwoyIx3A== X-UI-Out-Filterresults: notjunk:1; V01:K0:5HUJBgJCYTw=:/J/KS3M5coxrRiZ/V+QM41 563/SwIgYY30v+0PIYzrqyWEfykJbf9VKRgCDDMPSYE5O/+h3OIDE4+AyQMvwTnUm9YBvhEWZ Y2CrPzk4ru9z2gNLSLwwutuSugDNsZzzHrT1qUCKQtz5eNp8WaRPI4WvM7pSa65FUdUMOtUHz 6ulN4nZECmO1R+ALqcmSOd0SHZ1ogoB82uqvvLglC+LI4bn9yug3gt3kivlBxnQDCnGKgIJIL 0r17Exq3ap8c5G4rLN5Xk4mBZ4od2YSZtYFxhys5/jcNyWyqCVbgNYjyAPZnKm3YekXpI+t6Z unpndKUXl46tYeraToRV1WE/h8sqz2JIb22r1jVlkXK9V+gGz95QcmcbZ5KTFqTGyZXDtbVZx cF2xGqcpfpkjWCmmelxLhjIFWKCqMLqCHOlhBt0+5BOFJuevI534OfDc9hVFKTX1+ve/dJS4q 1c3Ikv6wFsv9FCqgLmnEWlHYUUILBF98TLHUM7eABWzPrhx+ISWzarjSj2/CgcMTtmlP3YTXJ KV37v3KlbXpEXSlh5Fr2G3g6KI/gB3OQevuxvNqTqKc4DqiPEGzEMXXqMgiXJjp68b4DOKPSw kIteuOPAo52Ax6zWWDVNtU894/Etx3lO2jFuTVS6bYTde7e2djloVZUEbAfLWhJ5Lz9MwpkA5 BlROkHkKJm60GsdirUK5HgVRMjVyy1Oi/oPLfXtw+owMpx7HPJgYbh0qLN5z/NaFLf4U= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org get_seconds() is deprecated because of the overflow of 32-bit times, and it's not the best choice for measuring time intervals because it can 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 --- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/transaction.c | 2 +- fs/btrfs/transaction.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 2.9.0 diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 205092dc9390..bf0717f2824d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1803,7 +1803,7 @@ static int transaction_kthread(void *arg) struct btrfs_trans_handle *trans; struct btrfs_transaction *cur; u64 transid; - unsigned long now; + time64_t now; unsigned long delay; bool cannot_commit; @@ -1819,7 +1819,7 @@ static int transaction_kthread(void *arg) goto sleep; } - now = get_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 ff5f6c719976..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 = get_seconds(); + cur_trans->start_time = ktime_get_seconds(); memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs)); diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 94439482a0ec..4cbb1b55387d 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -48,7 +48,7 @@ struct btrfs_transaction { int aborted; struct list_head list; struct extent_io_tree dirty_pages; - unsigned long start_time; + time64_t start_time; wait_queue_head_t writer_wait; wait_queue_head_t commit_wait; wait_queue_head_t pending_wait;