Received: by 10.223.176.5 with SMTP id f5csp162402wra; Tue, 30 Jan 2018 09:32:20 -0800 (PST) X-Google-Smtp-Source: AH8x227ml6a6X8nlVToDFU+bUBO8C9SXWRg1E9faXLJcz0R0nlC/fhrIR1IH3TLnvKEPvGShJhXQ X-Received: by 2002:a17:902:20e8:: with SMTP id v37-v6mr25683390plg.66.1517333540100; Tue, 30 Jan 2018 09:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517333540; cv=none; d=google.com; s=arc-20160816; b=OF7aDnc9czt9hgEQJmcZrVFbFqn2+yvnJNMUEDUQgidNqQhx+cuQAyJQQ7MeACI9wq CZSDi1+oJaU4h1PIKxVEz95gm8qtFAZYYMBKfFqt4ifx9IzgclUJxZ1vxl7vw/6buV/U vg6gAZFTi+TTsu8xoJxy6/ZsGMuvw4oQx4QTlSpLJRQ862rstU6g8GxzjQuAE6qPtokU ZOCXl+4POJrNkGkDhzJATNh227t+EVh7HqE558FFDus3upwzg1EE0sOri1xVJueMKfMI 0CirnCUZJd8/BcMGQKt/+66W0ADrSxV964Pi4/ESyz8bz02+HlOj4EDTKAye8o2R2KE8 E2jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=QbPRq4RBf92BtG/PdfxTGmNUl001WKiqJQvfuGTKSZc=; b=DfnBECFdPC0HmvgPTLEz9X+2bUilSweLQybQ4m12W5BARSV+1sAEELPgVfbNKoUytk TvJmJingE2zJy7y7bWEca31ml395q56prNg3+rYp2pqQms7nNHu61tfUpndnpdcDF+DW C273lgPuEn2kvg7Sy/cFEkuSE9dKYIoFPbXGxMT/w2bqB39fr4mAsnAhVobMUbGiLrEO zJBBcs/zqmYMsP7d8mq9jIsNe5JL9yPYR/mMCF/eYyV9OuweyWpFbHgnLdhFei5S+hVC Nz+85EaRTaObYUstY9tlZNby0DB9h/xCCazu0TaHbS+KNcZEgf9Pydvd59RnU+/L+6r2 eByg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tZ04SJdZ; 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 r39-v6si1092650pld.39.2018.01.30.09.32.05; Tue, 30 Jan 2018 09:32:20 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tZ04SJdZ; 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 S1753403AbeA3QhA (ORCPT + 99 others); Tue, 30 Jan 2018 11:37:00 -0500 Received: from mail-io0-f178.google.com ([209.85.223.178]:43670 "EHLO mail-io0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753379AbeA3Qg6 (ORCPT ); Tue, 30 Jan 2018 11:36:58 -0500 Received: by mail-io0-f178.google.com with SMTP id 72so12078251iom.10; Tue, 30 Jan 2018 08:36:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=QbPRq4RBf92BtG/PdfxTGmNUl001WKiqJQvfuGTKSZc=; b=tZ04SJdZ6JqoSh9RKUYtxAEAYNzLnKknROXwU6D7+L4JPWAfZ8EHzsvtUf1kXdeZqJ wOl0b7eyaXIXV8kVdNuPc7x47Uhz3PdlXoOJ+h2PAktdid8Zf84CQ2gBAKeEz/Zmthq1 H3/Qiysc/YKd7iV/NQ8a7sVZ/756uUD9XKqX2haCrbETxkX4UOGCl2ipyBhW+tITui9k ZCUEfVLGJnyKe+U7VGtUra7PHdzB+A5/r9qe0kbHqaPBvldNP93Ky25nSOD5ksD2AMZv ALOlfqLlr4F9uNG5AKkPFngTqibusRBQxWvr8utImtXRXoUO932wKp/CwnQXEPh+Kdnc Ydyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=QbPRq4RBf92BtG/PdfxTGmNUl001WKiqJQvfuGTKSZc=; b=oBKFO87wyLWUt0W0blLe63GPnjISBMnZZ8mssBhG3ZsmeiFRuYoVUrZGT4n5TePykX oTDWdG07yBM8nxz0FHieye2+VPo8k4SWqKpB4RIi0j8swN2qakGS4t8P/7Kh4fReK8AT 6Z8oN+2k+jF9aMaXqIxZVl5qsx7URlCyfmpGP0A9uiZL1nbK8aFs9l+2GFGh3GZvwT4P Q0iL/6UukupUx5Go9Um1+SgKULYjAvZ5hfgmzllY1FWLNAIWZUEhhAusvGlNTFo3WlRH kGpmwqD3t4KJNRAhuq9mopwXrQQlHG2LNMzKjfYysj852QDyCUGbMXwtqm3FViqZDM4+ NUOw== X-Gm-Message-State: AKwxytcdnd1YbBOmGXmSS3fKN9yQGJPdQtmEEKQ//4q/bSD8b0tO2B69 v2c88us52KpkvWxt/Bt8zJUfiPprM4InkbcbWNMNWeKG X-Received: by 10.107.132.3 with SMTP id g3mr30426898iod.46.1517330217017; Tue, 30 Jan 2018 08:36:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.59.196 with HTTP; Tue, 30 Jan 2018 08:36:56 -0800 (PST) In-Reply-To: <1517313948.3658.8.camel@redhat.com> References: <1517228795.5965.24.camel@redhat.com> <1517313948.3658.8.camel@redhat.com> From: Linus Torvalds Date: Tue, 30 Jan 2018 08:36:56 -0800 X-Google-Sender-Auth: H5rEy-tTCWqbSozBsrbAF76MP1w Message-ID: Subject: Re: [GIT PULL] inode->i_version rework for v4.16 To: Jeff Layton Cc: open list , "" , Al Viro , xfs , "open list:NFS, SUNRPC, AND..." , linux-btrfs , linux-integrity , Andrew Morton , "linux-ext4@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 30, 2018 at 4:05 AM, Jeff Layton wrote: > > My intent here was to have this handle wraparound using the same sort of > method that the time_before/time_after macros do. Obviously, I didn't > document that well. Oh, the intent was clear. The implementation was wrong. Note that "time_before()" returns a _boolean_. So yes, the time comparison functions do a 64-bit subtraction, exactly like yours do. BUT THEY DO NOT RETURN THAT DIFFERENCE. They test the sign in 64 bits and return that boolean single-bit value. > I want to make sure I understand what's actually broken here thoug. Is > it only broken when the two values are more than 2**63 apart, or is > there something else more fundamentally wrong here? There's something fundamentally wrong. The _intent_ is to allow numbers up to 2**63 apart, but if somebody does that int cmp = inode_cmp_iversion(inode, old); if (cmp < 0 ... then it actually only ever tests numbers 2**31 apart, because the high 32 bits will have been thrown away when the 64-bit difference is cast to "int". And what used to be a sign bit (in 64 bits) no longer exists, and the above tests the *new* sign bit that is bit #31, not #63. So you are a factor of four billion off. And while 2**63 is a big number and perfectly ok for a filesystem event difference, a difference of 2**31 is a "this can actually happen". Yes, even 2**31 is still a big difference, and it will take a very unusual situation, and quite a long time to trigger: something that does a thousand filesystem ops per second will not see the problem for 24 days. So you'll never see it in a test. But 24 days happens in real life.. That's why you need to do the comparison against zero inside the actual helper functions like the time comparisons do. Because if you return the 64-bit difference, it will be trivially lost, and the code will _look_ right, but not work right. The fact that you didn't even seem to see the problem in my example calling sequence just proves that point. Linus