Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp520653lqg; Fri, 1 Mar 2024 12:07:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVnB9drf3nhc+h5IU9QLDaSp/54Jt0m21l7OUVIghA4ODtSbmW3zrFo2hEfCl5kSLgVYgjEmYRFMLBPmHX4uU/x7J4dTFCQybyF2x1VBQ== X-Google-Smtp-Source: AGHT+IGxedExrm9Hov+G8HrOG9sxOhYso6Qzkciplg77/UxTMB/6kt75RbfvboZmjy+q4Ed2cf2B X-Received: by 2002:a17:902:ab96:b0:1dc:abeb:22fe with SMTP id f22-20020a170902ab9600b001dcabeb22femr2315601plr.65.1709323673055; Fri, 01 Mar 2024 12:07:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709323673; cv=pass; d=google.com; s=arc-20160816; b=srWOV/0kebHWnovZQjjM050SGSG1AfJqdzdO0SRT4uagPstu73kTOHGefG6qbmRI+Q lVhR7vA0Wy5M4oTYeauUXPUijEJeIaV8cTtCSQWfKBBE6yYIBl+5+Cda760JnFDCQ8dn h/Xoix7DI1XOE8G1FrCsYmdNQngcqx26PG374Evof5qvIhD6riEvUKyZTddTgbl9QvIa vCu3wqvhFEJjDyIQZqyaui5/tRs22ybKKy1Wli2pKkM/9Or0C1OSNz28GT1rjpC1r2iI BPhQ0mD7xPKt+s1Z1iD2WxHdwaEI7kwLHR1vxUeokUdFxAGUneHNi4ASs6gch3pTkfxn VeUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=KVORUB8MfdgpvFduZPozM66OeXPUqmhrFFOZyuRPc9k=; fh=5tMfbpRQnLy0yRnT9uUsTcCBVP0N63CI2Z3z1/k8g1M=; b=H3W96Oz8OodvegOjeZ0M+fresMgS4gpcLm79M8f328oyLIz0aPMeWhb1oVwe5xnUZU iak5dwlKlese72je0apTy2e0ltwsgjno3ypz4pJZxh7CmcLNBUbZn1wrQuu9EhkHI4Mh yGzyrKzCU9g28xSD/gScESTUNwNwKQiDyzCdZZU96QiH+/b0qUZr+lmwkf2B698KZYzA mB+5NynOOTb8OghYypzbKRhg7VqZfTBvmVxr3zcrkT1iL/WAMzqnAAEvqLmLatYA8g34 mxJ9C2MwnbpYo4Cj6AVAr3UZTlrSjBMmtR9vZZdaEy0RjIrP/nkq7DHxSUXcV9/d3Mm1 aE4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iNE8hwhO; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-89022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l6-20020a170903120600b001dc7a686ed4si4256643plh.230.2024.03.01.12.07.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 12:07:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iNE8hwhO; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-89022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 145E0B26AD1 for ; Fri, 1 Mar 2024 19:30:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BA723B289; Fri, 1 Mar 2024 19:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iNE8hwhO" Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66FA03A1B0 for ; Fri, 1 Mar 2024 19:30:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709321419; cv=none; b=TYR6uHtNjO/8hNJOPtLZnKUrhmCKrrC1f9djEVMG+JduMKheYdYNKmPObfQVofE9YBWZjuiDt5P2xvQvU+ZkjJ7lPuD0QfC29kjHCG4/P31P5s/OlCf3xXrzKZuSVDnYZOK6aqkdx0QO3YmIdAiitkrcB7Dcg79XMoFFTJ0aj0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709321419; c=relaxed/simple; bh=fC8yO5GWYw+06lbv+gmvQc70RO0jzfxz/BUuBmtcRTc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FuvVmuxsm7WjXNpRfV+4E1YlybRWsZh7J/rlFA7SBtPxvPec8t8qlrP8JpUvWluYGvc936XG4eeUMyz5Ff5P3epZvowDKiN2Vp50BNN/Zh7OXc90aY/mXWBJ54v9t3QsLeILCU5kpM0bllBJ3r24jbBRNSwpPVmTxyYEHWWR/P8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iNE8hwhO; arc=none smtp.client-ip=95.215.58.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Fri, 1 Mar 2024 14:30:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709321415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KVORUB8MfdgpvFduZPozM66OeXPUqmhrFFOZyuRPc9k=; b=iNE8hwhOIYqwMWCsgj7YwWxI+o4wpI/RWuHzWRfRtHlhGO6nngoPvBnN710qq8ORRCLgsN jHacogkkt5a2w6i/CCMc3asHARnnbCbMObcUFMzv1iQFYu0SuSoNWZ4uajtB4+lGHM+fGu Kv47NrxHkfnRRUF6w3nRh/CVYXuaAw4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Brian Foster Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, djwong@kernel.org Subject: Re: [PATCH 01/21] bcachefs: KEY_TYPE_accounting Message-ID: References: <20240225023826.2413565-1-kent.overstreet@linux.dev> <20240225023826.2413565-2-kent.overstreet@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Fri, Mar 01, 2024 at 10:03:06AM -0500, Brian Foster wrote: > On Thu, Feb 29, 2024 at 04:24:37PM -0500, Kent Overstreet wrote: > > On Thu, Feb 29, 2024 at 01:43:15PM -0500, Brian Foster wrote: > > > Hmm.. I think the connection I missed on first look is basically > > > disk_accounting_key_to_bpos(). I think what is confusing is that calling > > > this a key makes me think of bkey, which I understand to contain a bpos, > > > so then overlaying it with a bpos didn't really make a lot of sense to > > > me conceptually. > > > > > > So when I look at disk_accounting_key_to_bpos(), I see we are actually > > > using the bpos _pad field, and this structure basically _is_ the bpos > > > for a disk accounting btree bkey. So that kind of makes me wonder why > > > this isn't called something like disk_accounting_pos instead of _key, > > > but maybe that is wrong for other reasons. > > > > hmm, I didn't consider calling it disk_accounting_pos. I'll let that > > roll around in my brain. > > > > 'key' is more standard terminology to me outside bcachefs, but 'pos' > > does make more sense within bcachefs. > > > > Ok, so I'm not totally crazy at least. :) > > Note again that wasn't an explicit suggestion, just that it seems more > logical to me based on my current understanding. I'm just trying to put > down my initial thoughts/confusions in hopes that at least some of this > triggers ideas for improvements... I liked it because it makes the relationship between disk_accounting_pos and bpos more explicit - they're both the same kind of thing. > > > Either way, what I'm trying to get at is that I think this documentation > > > would be better if it explained conceptually how disk_accounting_key > > > relates to bkey/bpos, and why it exists separately from bkey vs. other > > > key types, rather than (or at least before) getting into the lower level > > > side effects of a union with bpos. > > > > Well, that gets into some fun territory - ideally bpos would not be a > > fixed thing that every btree was forced to use, we'd be able to define > > different types per btree. > > > > Ok, but this starts to sound orthogonal to the accounting bits. Since I > don't really grok why this is called a key, here's how I would add to > the existing documentation: > > "Here, the key has considerably more structure than a typical key > (bpos); an accounting key is 'struct disk_accounting_key', which is a > union of bpos. We do this because disk_account_key actually is bpos for > the related bkey that ends up in the accounting btree. > > This btree uses nontraditional bpos semantics because accounting btree > keys are indexed differently structures..?>. Yadda yadda.. > > Unlike with other key types, ... I'm just going to go with my latest revision for now, I think it's a reasonable balance between terse and explanatory: * More specifically: a key is just a muliword integer (where word endianness * matches native byte order), so we're treating bpos as an opaque 20 byte * integer and mapping bch_accounting_pos to that.