Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5719423pxj; Wed, 23 Jun 2021 07:36:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/Ooy/bK0Ri8u3bkLxEhOQjQuNwaugFyraZnrAa1BFv2A7BMLnPc2sOnhNIRrGcaKvmz83 X-Received: by 2002:a17:906:d1d1:: with SMTP id bs17mr352420ejb.492.1624458970398; Wed, 23 Jun 2021 07:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624458970; cv=none; d=google.com; s=arc-20160816; b=N+sZ1PrPDKgmLSyTd6rfcA35JtzUWIude4Lb+8CK9xgOlb74eqjJbUnq9//UrEF4f4 K4ubGWB9UkMlUxeBcANVk2msqxoAlBLEUcL9uKEFdFdkHOT38p7MbOjVQmfOaiSiXqqz KGR0PderWOacfIwEPwmhzW7Mbkd8v+9gY7eiEndGGNbKBG1NyiIvH/ZtFidrxsjyg2Pz eTMZL8sPxP4CkpsJhNfM1TS3ED2clMInlAIWs8f71CLNzu6rMXhlYIhznuMGHcpQ0Bk3 w2621tHxpPfRzzahdBpne7ilcKs0QCf0+CvtJcP8kT0JjNssCfC1T0JdPMY9DeqcE+X9 ye3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :date:cc:to:from:subject:message-id; bh=t9ttJ2ZrLwy0q/QbIgPH6+Htg9t3ZYSa1V/VtaQWwd8=; b=EBAWlFZBzVCeafvHCqxECavyatu4Z9CTLEqPEJB2ULnPb7CsdaQwg8cr8XQnANzWe5 z4crBSFmup5pHkmmeuyz9juvHF8NKrBI8KRM3C30R3GpGUuZ2/p8zeJYNgBaS1qbi8te Q4jffbjEy5CMi0QJ5o4Zhfjn4MIVtDgwISYjL4IDbb5QR/O/3wIShCOruGcHJ3g8yXLd h52SlYpVA/xMBvGF/KMgs702mgfh0ywNj7aUHXIaSd4N2oYuNrgdvyPh2JjmMd0//ac4 Xknq/2zN7P95yThZqohSIJxSZLgLiZs3Srp7c36SeuhoLLET7ye0wYRQq86xyVoRnxhT j1xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si17225941ejf.428.2021.06.23.07.35.47; Wed, 23 Jun 2021 07:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231293AbhFWOgl (ORCPT + 99 others); Wed, 23 Jun 2021 10:36:41 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:37589 "EHLO mail-wr1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbhFWOgg (ORCPT ); Wed, 23 Jun 2021 10:36:36 -0400 Received: by mail-wr1-f44.google.com with SMTP id i94so2921762wri.4; Wed, 23 Jun 2021 07:34:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version; bh=t9ttJ2ZrLwy0q/QbIgPH6+Htg9t3ZYSa1V/VtaQWwd8=; b=aFhZJbnL3wOBwTJ62+5IgFAc0xIUXsKnBpkRp7h9v07l2BTCH8WqhsqAW068OwHSha VvgHKSJN6+hchxWp6y/D9eXHPb/AEds9ebsQPpqxbO/2VTPRKt4dHv7pFUtMkAUdrqoA YyWDdbiH06jU+7cHJUkxFnquJhDlfQ3Hv2KKS/rSw1XZjvDwJJVDVSBozmn9rix1Dcd3 tIl7aotMuRLtCRJiV57oYvSFgm9zlgE96WLmBXaVQOp5zsHLfze6j/ulfcaqX6/tsQpg KAyIjRRMNLf5+d4n3VPZ3I3peyJkC7tSHCMhu5YybriUdq4edBSOrvyb5Do2YchPz1Oj A0eQ== X-Gm-Message-State: AOAM530kACEFnO74Mfq6xHtidhrYF8Ir2AL6D8ggUOvX4XOa0tpzgbSJ WO3N0p5kVLCFf6wCNOMTRe8= X-Received: by 2002:a5d:69c3:: with SMTP id s3mr352230wrw.235.1624458857074; Wed, 23 Jun 2021 07:34:17 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id p15sm105021wmq.43.2021.06.23.07.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 07:34:16 -0700 (PDT) Message-ID: <930262b2c8cfcdad9d5987956e47ffb467407a41.camel@debian.org> Subject: Re: [PATCH v3 1/6] block: add disk sequence number From: Luca Boccassi To: Hannes Reinecke , Lennart Poettering , Matteo Croce Cc: Christoph Hellwig , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe , Linux Kernel Mailing List , Alexander Viro , Damien Le Moal , Tejun Heo , Javier Gonz??lez , Niklas Cassel , Johannes Thumshirn , Matthew Wilcox , JeffleXu Date: Wed, 23 Jun 2021 15:34:14 +0100 In-Reply-To: References: <20210623105858.6978-1-mcroce@linux.microsoft.com> <20210623105858.6978-2-mcroce@linux.microsoft.com> <3be63d9f-d8eb-7657-86dc-8d57187e5940@suse.de> <1b55bc67b75e5cf982c0c1e8f45096f2eb6e8590.camel@debian.org> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-o7/lWMrV0LFXxCA7rbiC" User-Agent: Evolution 3.30.5-1.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-o7/lWMrV0LFXxCA7rbiC Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2021-06-23 at 16:21 +0200, Hannes Reinecke wrote: > On 6/23/21 4:07 PM, Luca Boccassi wrote: > > On Wed, 2021-06-23 at 16:01 +0200, Hannes Reinecke wrote: > > > On 6/23/21 3:51 PM, Lennart Poettering wrote: > > > > On Mi, 23.06.21 15:10, Matteo Croce (mcroce@linux.microsoft.com) wr= ote: > > > >=20 > > > > > On Wed, Jun 23, 2021 at 1:49 PM Christoph Hellwig wrote: > > > > > > On Wed, Jun 23, 2021 at 12:58:53PM +0200, Matteo Croce wrote: > > > > > > > +void inc_diskseq(struct gendisk *disk) > > > > > > > +{ > > > > > > > + static atomic64_t diskseq; > > > > > >=20 > > > > > > Please don't hide file scope variables in functions. > > > > > >=20 > > > > >=20 > > > > > I just didn't want to clobber that file namespace, as that is the= only > > > > > point where it's used. > > > > >=20 > > > > > > Can you explain a little more why we need a global sequence cou= nt vs > > > > > > a per-disk one here? > > > > >=20 > > > > > The point of the whole series is to have an unique sequence numbe= r for > > > > > all the disks. > > > > > Events can arrive to the userspace delayed or out-of-order, so th= is > > > > > helps to correlate events to the disk. > > > > > It might seem strange, but there isn't a way to do this yet, so I= come > > > > > up with a global, monotonically incrementing number. > > > >=20 > > > > To extend on this and given an example why the *global* sequence nu= mber > > > > matters: > > > >=20 > > > > Consider you plug in a USB storage key, and it gets named > > > > /dev/sda. You unplug it, the kernel structures for that device all > > > > disappear. Then you plug in a different USB storage key, and since > > > > it's the only one it will too be called /dev/sda. > > > >=20 > > > > With the global sequence number we can still distinguish these two > > > > devices even though otherwise they can look pretty much identical. = If > > > > we had per-device counters then this would fall flat because the > > > > counter would be flushed out when the device disappears and when a = device > > > > reappears under the same generic name we couldn't assign it a > > > > different sequence number than before. > > > >=20 > > > > Thus: a global instead of local sequence number counter is absolute= ly > > > > *key* for the problem this is supposed to solve > > > >=20 > > > Well ... except that you'll need to keep track of the numbers (otherw= ise > > > you wouldn't know if the numbers changed, right?). > > > And if you keep track of the numbers you probably will have to implem= ent > > > an uevent listener to get the events in time. > > > But if you have an uevent listener you will also get the add/remove > > > events for these devices. > > > And if you get add and remove events you can as well implement sequen= ce > > > numbers in your application, seeing that you have all information > > > allowing you to do so. > > > So why burden the kernel with it? > > >=20 > > > Cheers, > > >=20 > > > Hannes > >=20 > > Hi, > >=20 > > We need this so that we can reliably correlate events to instances of a > > device. Events alone cannot solve this problem, because events _are_ > > the problem. > >=20 > In which sense? > Yes, events can be delayed (if you list to uevents), but if you listen= =20 > to kernel events there shouldn't be a delay, right? >=20 > Cheers, >=20 > Hannes Hi, Userspace programs don't have exclusive usage rights on loopdev, so you can't reliably know if an uevent correlates to the loop0 you just added, or to the loop0 someone else added some time earlier. This series lets us do just that, reliably, without races, and fix long- standing bugs. Please see Lennart's reply, it has much more details. Thanks! --=20 Kind regards, Luca Boccassi --=-o7/lWMrV0LFXxCA7rbiC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEErCSqx93EIPGOymuRKGv37813JB4FAmDTRmYACgkQKGv37813 JB6ENhAA0QXt64CgCUDkJjsx0CBs9KoUiwIaFjycEUhpwNGOwOhWqobaw7vrzdf9 ddXH0JKTvtqVmO/EIHAW1xa+L4IAzlZYvGeSC5K9PFM9SGwPM45q/R7Zb6gliASx j+uM234I01ZfwMQuogSL4VabUAweIdDZWfWABBno2FlHCzwZx3afAXBIOTaq0E41 K7tbmEVgVlBID7ragZYTPkQOvEUCKdMnRqUr3q6qA8OELHiqgYXbopMhUZrt9col mwt7yh8LXysjBWDKArw+pzpsWT4E4q+/cY9rdK9znXkWlhlFXBcSamPnwWWjKxuI GIRgb7PaOKKnAduFVrvr/tvWEx4WAy9OOylKG20lO7dTJ/HONHOfezMRkiqHbLtQ dleWMKyuUkNtql2vyt9s+Zo8ndORslIDjnOpTflDhsUPPRVwuGf8S3EjCLfS30mt n0mlC9bASBruslhrXviVbJMcFGyuMpE9jXqNgkvr/uhfhp47ze9ia0eHYxG0V1uV oKYWrvYhMM9c1IdoMcIBPScvT5MDRXV7QWNeIoUqYa3EBVjnfZ96CKMjYUsjSvRl ixF6eBvIlVBvs82r0/Hs3ef0qRZ0lysSWn/MYzV5pMXvvmGqAuzSH3UbJ4CuGoIv 2/L2dMrnDIZMcX4qRpq1k4QYiwcA/nCIUX2k6qlrbfe+TLcAhaw= =aprY -----END PGP SIGNATURE----- --=-o7/lWMrV0LFXxCA7rbiC--