Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp617858rdg; Thu, 10 Aug 2023 13:37:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHq8+EiXi9R6lfwkHe4DsPTxtoofuiHNmh6K5iV1tlCwp1qjvDmZfrn5TpNy3lsfjYFGbn/ X-Received: by 2002:a05:6a21:7802:b0:137:30db:bc35 with SMTP id be2-20020a056a21780200b0013730dbbc35mr86609pzc.27.1691699876990; Thu, 10 Aug 2023 13:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691699876; cv=none; d=google.com; s=arc-20160816; b=EQV1Tys8hdTZwBsMxr42F5KcAGmSsCr6fNUKv1MQVDsd1yJ5twjEZ/vJwOMvESYHjN 6Dzd/ygy3bcKTEVYT+pOC6SRjUNZxRXGW0qLjG+bpvcuUllP1fntsCcmmf+wJpFdKgwt Okeg20DIQO0CiYbSTZouMOYagccX5fQvU5IwJqMNgkQHQmHmChwWX/WTS21O2TCyspsG Dd26GNLMyrDauDT34NbRGvXazOABX1P/gXiUnCTmqcGSL4p4r1zz0mzhveJ0wKRDGE4W fArdrs+vaEnNcLfjdJavLDCv4BGw7kp0HOsmItOmaw+3ps+4R5BA+2wNrdPq8FD86fCF G5og== 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:date:dkim-signature :dkim-signature; bh=CZ25GytU7V9PgZNVJFOgesoNXDMmwuqCEuLI9Og+gD0=; fh=CYmeu5OZX+cgKCcsoPKTcYGAAkXeQEmidvQK5OpFj1A=; b=hRSQ0up02LuKjSeCyr2JRF0SuKehdcqkE0DYsUcEI6SjyvFfrs/AfU2gvYwKAOAGpr 2aYl6Ec0jWgVTB1lTRhBO5DwxX7U7X0YahMA0IY/XXj/th04DeJE1k7drSIegncq873s R6RBmB6FLmLiiVQXHjrGvZ62EPQ5z+MnEt8aJokv4PNSLkclHKX54cBwhEM4XiZaWchX Om3pb5FQVf4QyN2kpDeceWl+RnrlShueoEqSk57sg/BzCWrD0D6+UPB98DhH0xeuEroC pYNycFRhJ9DpaHi9neMDLfai7SqCmCce6cbExZ1aY5hbKEG2yYdXkExBj9zG8B/JMi3J jJQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="3K6fTy/+"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a056a00194900b006873f40fc77si2196358pfk.103.2023.08.10.13.37.45; Thu, 10 Aug 2023 13:37:56 -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=@suse.cz header.s=susede2_rsa header.b="3K6fTy/+"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235472AbjHJRwJ (ORCPT + 99 others); Thu, 10 Aug 2023 13:52:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233922AbjHJRwI (ORCPT ); Thu, 10 Aug 2023 13:52:08 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A63F103; Thu, 10 Aug 2023 10:52:07 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1B0C221868; Thu, 10 Aug 2023 17:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691689926; h=from:from:reply-to: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=CZ25GytU7V9PgZNVJFOgesoNXDMmwuqCEuLI9Og+gD0=; b=3K6fTy/+6iG/SrmpmBGEQBykxWplX1/caGh8yDZmqsCxPfXZ9Dzvo6bt2J7mj7ror0D9II /NtQ/NPTpXumjtVhH/ByfA07nTaNLtK4Y/+GgVdSMC8G8KNerhGUZIPSBrnv4bSbBSj15D lhlXfYsgJcLvgApKx5zsAZfWC+eCxqE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691689926; h=from:from:reply-to: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=CZ25GytU7V9PgZNVJFOgesoNXDMmwuqCEuLI9Og+gD0=; b=KrZiBwadLWs7KzP/JdR/tDkEM8FIxIo7xZll2oJfT8DKJV8u+KbFPTz+K4Aob7QhULMBau /xPSqNaLaEb1tzDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 03E5C138E2; Thu, 10 Aug 2023 17:52:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7pHnAMYj1WSgWgAAMHmgww (envelope-from ); Thu, 10 Aug 2023 17:52:06 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 83BE3A076F; Thu, 10 Aug 2023 19:52:05 +0200 (CEST) Date: Thu, 10 Aug 2023 19:52:05 +0200 From: Jan Kara To: Kent Overstreet Cc: Linus Torvalds , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, djwong@kernel.org, dchinner@redhat.com, sandeen@redhat.com, willy@infradead.org, josef@toxicpanda.com, tytso@mit.edu, bfoster@redhat.com, jack@suse.cz, andreas.gruenbacher@gmail.com, brauner@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, dhowells@redhat.com, snitzer@kernel.org, axboe@kernel.dk Subject: Re: [GIT PULL] bcachefs Message-ID: <20230810175205.gtlkydeis37xdxuk@quack3> References: <20230626214656.hcp4puionmtoloat@moria.home.lan> <20230706155602.mnhsylo3pnief2of@moria.home.lan> <20230712025459.dbzcjtkb4zem4pdn@moria.home.lan> <20230810155453.6xz2k7f632jypqyz@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230810155453.6xz2k7f632jypqyz@moria.home.lan> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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 Thu 10-08-23 11:54:53, Kent Overstreet wrote: > > And there clearly is something very strange going on with superblock > > handling > > This deserves an explanation because sget() is a bit nutty. > > The way sget() is conventionally used for block device filesystems, the > block device open _isn't actually exclusive_ - sure, FMODE_EXCL is used, > but the holder is the fs type pointer, so it won't exclude with other > opens of the same fs type. > > That means the only protection from multiple opens scribbling over each > other is sget() itself - but if the bdev handle ever outlives the > superblock we're completely screwed; that's a silent data corruption bug > that we can't easily catch, and if the filesystem teardown path has any > asynchronous stuff going on (and of course it does) that's not a hard > mistake to make. I've observed at least one bug that looked suspiciously > like that, but I don't think I quite pinned it down at the time. This is just being changed - check Christian's VFS tree. There are patches that make sget() use superblock pointer as a bdev holder so the reuse you're speaking about isn't a problem anymore. > It also forces the caller to separate opening of the block devices from > the rest of filesystem initialization, which is a bit less than ideal. > > Anyways, bcachefs just wants to be able to do real exclusive opens of > the block devices, and we do all filesystem bringup with a single > bch2_fs_open() call. I think this could be made to work with the way > sget() wants to work, but it'd require reworking the locking in > sget() - it does everything, including the test() and set() calls, under > a single spinlock. Yeah. Maybe the current upstream changes aren't enough to make your life easier for bcachefs, btrfs does its special thing as well after all because mount also involves multiple devices for it. I just wanted to mention that the exclusive bdev open thing is changing. Honza -- Jan Kara SUSE Labs, CR