Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31971582rwd; Fri, 7 Jul 2023 07:03:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHL/gIKtJfeBqFuxBMuZZK6iTHk6cEXuXKjDWpldvMHMf/zv7S0YQTnSte3o0+yFY0P3Rz+ X-Received: by 2002:a05:6830:114:b0:6b8:c0e0:3ee5 with SMTP id i20-20020a056830011400b006b8c0e03ee5mr4775069otp.36.1688738628886; Fri, 07 Jul 2023 07:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688738628; cv=none; d=google.com; s=arc-20160816; b=QuONKv1oHWolYVOTXLLtn7pxUVI1yOrRdn3vRIitT9e2q1rts4D30NWikBu2WyM6Xt SplzXP2+Dqs9x8SmJDy60mv7kHeJ5i0tk5gI0oHY0gtuY4O/6IHQ02L6k+46dp5RD+Z5 pkFdlA1s+B4hvuwNztCLOPQi8/hMxP+zR5/b5uFgim/k7UKU8mUOggeUo1xrSDanLWVB xQgspTEOKc1wx18gdrk8cBN91rd71NC9JCD2vazdcV0VlyVK676Rr8dU4s9qEBH1JXGQ X1WYel8mhRSqRUbCoth99Py6VXBz9knFZO2hXeYYSCEc2zAAx+cA5c8n70VIZ+d7Nc4W tVrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=PYGaz3tsGre2YQId5W/WNn6D8n5IoYheTvK03OWWAb4=; fh=nOQMCgOm5fY/SJ0VU5FLn5r/uJMZL7cidaW6OPFR9jE=; b=DD51cl8HkPjVQIkyleThrN5QEgcOa7MS+Dt3Oo6omluRHVm1DuTLNAfw+3LsVk0+6z n9Ra/YQ1V0Mb2tcjE1iDimdUdcHmgaZbhK3ZHnXjFN22jFo0bNfZRCLuCchNDewvMtwH O2cR8nGDUwnkELtm1/EUvbHGoo33w2qQf3A2m6ktt10UWTEbb9QzIUjYYYuFQn0CJm4y 27l7cU6xrCgzfd+PwCT0wp+9WbAGVfx6CZZeZMnGt4coiTBpq/NsociuuK/DZLVzkI23 GRTxxOsO9IBOqgZDymf/5PPrdPJz8nGBwTxYzoNOrofUCO1KjqnIqOUfi6P93lLQ/a6d Frmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=DHtVLxlo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x19-20020a9d4593000000b006b58899aa09si1691542ote.45.2023.07.07.07.03.35; Fri, 07 Jul 2023 07:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=DHtVLxlo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbjGGNxD (ORCPT + 99 others); Fri, 7 Jul 2023 09:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjGGNwu (ORCPT ); Fri, 7 Jul 2023 09:52:50 -0400 Received: from out-57.mta1.migadu.com (out-57.mta1.migadu.com [IPv6:2001:41d0:203:375::39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F000E1FE6 for ; Fri, 7 Jul 2023 06:52:47 -0700 (PDT) Date: Fri, 7 Jul 2023 09:52:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688737966; 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=PYGaz3tsGre2YQId5W/WNn6D8n5IoYheTvK03OWWAb4=; b=DHtVLxloStQhHAezJb+IjS7xDwKmA6M79VjaLK/v0EmuiMqELhkInyNsdiePvEFvZbrWR4 322F1wIxRK8y02XP3I4on4OAx6rZevrokOo47VMDjdGLOG1uhCEiBE/GNaG2BeowhTv4Ko cFYfKOUnvgBQNhR9e5Q/YwJttgeuGq4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Jan Kara Cc: "Darrick J. Wong" , Josef Bacik , torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, dchinner@redhat.com, sandeen@redhat.com, willy@infradead.org, tytso@mit.edu, bfoster@redhat.com, andreas.gruenbacher@gmail.com, brauner@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, dhowells@redhat.com Subject: Re: [GIT PULL] bcachefs Message-ID: <20230707135240.6asq2nzxnec6gjo6@moria.home.lan> References: <20230626214656.hcp4puionmtoloat@moria.home.lan> <20230706155602.mnhsylo3pnief2of@moria.home.lan> <20230706164055.GA2306489@perftesting> <20230706173819.36c67pf42ba4gmv4@moria.home.lan> <20230706211914.GB11476@frogsfrogsfrogs> <20230706224314.u5zbeld23uqur2ct@moria.home.lan> <20230707131306.2wdgtuafc3unjetu@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230707131306.2wdgtuafc3unjetu@quack3> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 07, 2023 at 03:13:06PM +0200, Jan Kara wrote: > On Thu 06-07-23 18:43:14, Kent Overstreet wrote: > > On Thu, Jul 06, 2023 at 02:19:14PM -0700, Darrick J. Wong wrote: > > > /me shrugs, been on vacation and in hospitals for the last month or so. > > > > > > > bcachefs doesn't use sget() for mutual exclusion because a) sget() > > > > is insane, what we really want is the _block device_ to be opened > > > > exclusively (which we do), and we have our own block device opening > > > > path - which we need to, as we're a multi device filesystem. > > > > > > ...and isn't jan kara already messing with this anyway? > > > > The blkdev_get_handle() patchset? I like that, but I don't think that's > > related - if there's something more related to sget() I haven't seen it > > yet > > There's a series on top of that that also modifies how sget() works [1]. > Christian wants that bit to be merged separately from the bdev handle stuff > and Christoph chimed in with some other related cleanups so he'll now take > care of that change. > > Anyhow we should have sget() that does not exclusively claim the bdev > unless it needs to create a new superblock soon. Thanks for the link sget() felt a bit odd in bcachefs because we have our own bch2_fs_open() path that, completely separately from the VFS opens a list of block devices and returns a fully constructed filesystem handle. We need this because it's also used in userspace, where we don't have the VFS and it wouldn't make much sense to lift sget(), for e.g. fsck and other tools. IOW, we really do need to own the whole codepath that opens the actual block devices; our block device open path does things like parse the opts struct to decide whether to open the block device in write mode or exclusive mode... So the way around this in bcachefs is we call sget() twice - first in "find an existing sb but don't create one" mode, then if that fails we call bch2_fs_open() and call sget() again in "create a super_block and attach it to this bch_fs" - a bit awkward but it works. Not sure if this has come up in other filesystems, but here's the relevant bcachefs code: https://evilpiepirate.org/git/bcachefs.git/tree/fs/bcachefs/fs.c#n1756