From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56C101C7017 for ; Mon, 7 Jul 2025 23:02:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751929377; cv=none; b=ueLeImIu7zFe0S0vyITVQhy0RYIzbm5AzouiXkK/5VfWL45llE9MwyVOaf+ngbNfeM3vgksZjO5ErT+TCsu9hY7T1PjkLzHCmAAfrNmXE3XlRAWCziLEIeCBqQGTT4wZQZQQqZjH1F2RAWdZ6Z5wfhy6PXqoK6nMdGowO9AnS+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751929377; c=relaxed/simple; bh=venDfP4EzG2xqmDXVnH3VRXG5eR6DtQAF3gSkZjRBT0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IhG4+hcsJ2jd1wKTAwar0X2CsIuhGEax+QGPggXXPCyjqqXloIEl/737cYbyXe4+X9S6QOp7rpbmvxaxhpbvrH7AoTflHEobMLBWoSHsnkYhI/ddpkLPtHZvWirZ/MrXWgEEOKsfWldUUKDFt6Vyjph+cK3Cht7JVArYvGxt50w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com; spf=pass smtp.mailfrom=fromorbit.com; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b=MxCRig41; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b="MxCRig41" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-235ef62066eso58843595ad.3 for ; Mon, 07 Jul 2025 16:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1751929376; x=1752534176; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=c4pktmlF1vRQduNDQ1SA6N8TiSZQUsg3NAWNf5AHgsY=; b=MxCRig41TeJCa4KM/L6Xz2oFlIdtYCjD3OA6mnEuD5bDPv/IMBE3qkHV8dh3fNz2zk +8loAAi1XyTJh0utYOcYgRaPp6Lq9hHmdj1Ml2Iu1VWbIuVtW+rYgGEvQLUUH2zHU1Bc FZFzWHl0hOzYJ/Keixpf2MV4V2SL1nPOCuJnE6VhX9VZNqH3dwv7PIZHOv1xX1hyYwxH LuBdFhXco5s+r5zoeaU2mPc4AhjyZrrDkFwXmJlzQcwOSx61JiROY3+fI1WVGUXPWPXS m5rRjeSsQGE6irXyLOZyZvEteCvQepQG7+HADZUSi6OO6h2KgCkFfEmgY8SBNPNM7N8R 3REg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751929376; x=1752534176; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c4pktmlF1vRQduNDQ1SA6N8TiSZQUsg3NAWNf5AHgsY=; b=M//SEhAZ86Y63byTHzBVACdTCRUYKF86NpRm911ZeOhVS9BxcbwGWWCh9B9guzjBvT SRUcItZighVwdz9c/rCyV8acboc/0NyVEVQJHQW/L+60f6qcnA7pR6yxmCu+uXu1xFFM De+j2nB1qJ7KNt522kaS06PKJOpYbtt3rUX0G2SXL64YnPVXxktY6PNORPINSKg+sGAV kkk2/rep4E0VnrKuPnHSPhKfahfRclniDtlSsQ3fWiXVsHfFpyUxvdKYhQ1RCdyfd36P EUd7rydxBK9WqYItoMPiOQbzOmWzd4cwimHjvvLr9DPImFkhsAYfWVgW10Q9Z55c7l5b ss9w== X-Gm-Message-State: AOJu0YxXM/ABV61IM1tqh81uCO4TCWf6/KPW4F6kjXovxofiHsQMH7HE ioGVdWY1iCQoo0Wy/rndWSRUQe438rtq4yDm9nIY0yfbqbm6/lbEy9SqWNMXcyvCH7M= X-Gm-Gg: ASbGnctTxR43q6Oa2wa/k44Fd+mef3vR8jWGMWJeMLBrnaE4eIMBsQA57+2EuB7Qf19 0B6vR0weubR3HWgbd6VOrvivqZsWA64DI5sBZKfdjfbYrAoFBh/q2ruGjcT3mHAElObvK8ZVb3+ qd+2iflpBI8JTmNhEnmD0VPYTl94R/g6EQc3bWOPvTRswn+m4O/3NkShKf9ZUSTnZHBM4N+Iusx fF77C6Ux+QXpbphIKXB2rfOZzPEeuFuWzYwMTUHOTpNZx2yLc4M4zUuDA33mVCRqQem1xxrjHMn NSd2+Y0cP33xXmlk5ip8pIXFBHXrDjM1dUhbl8LxdPRqaDjZDISBUCuHmWe/IqJ01Lwpv9tD7WO +XSqU09H8w3Hxr6V8DSxh9vEVJAin7n6+R8Am7zhU0/h5zArh X-Google-Smtp-Source: AGHT+IEmTi6zrkNyOcS4BN99ZoRqMQGa5CBIfG1MgDs1BPtD4rrI5GMD5dIJM6aSPlLP7bK+loeCfw== X-Received: by 2002:a17:902:ce10:b0:234:8ec1:4ad3 with SMTP id d9443c01a7336-23dd1d5cc19mr6352555ad.40.1751929375710; Mon, 07 Jul 2025 16:02:55 -0700 (PDT) Received: from dread.disaster.area (pa49-180-184-88.pa.nsw.optusnet.com.au. [49.180.184.88]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23c8431a1f0sm102785765ad.32.2025.07.07.16.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jul 2025 16:02:55 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.98.2) (envelope-from ) id 1uYurM-00000008CeO-1qLV; Tue, 08 Jul 2025 09:02:52 +1000 Date: Tue, 8 Jul 2025 09:02:52 +1000 From: Dave Chinner To: Qu Wenruo Cc: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, ntfs3@lists.linux.dev, linux-xfs@vger.kernel.org Subject: Re: [PATCH v4 1/6] fs: enhance and rename shutdown() callback to remove_bdev() Message-ID: References: Precedence: bulk X-Mailing-List: linux-btrfs@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: On Fri, Jul 04, 2025 at 10:12:29AM +0930, Qu Wenruo wrote: > Currently all the filesystems implementing the > super_opearations::shutdown() callback can not afford losing a device. > > Thus fs_bdev_mark_dead() will just call the shutdown() callback for the > involved filesystem. > > But it will no longer be the case, with multi-device filesystems like > btrfs and bcachefs the filesystem can handle certain device loss without > shutting down the whole filesystem. > > To allow those multi-device filesystems to be integrated to use > fs_holder_ops: > > - Replace super_opearation::shutdown() with > super_opearations::remove_bdev() > To better describe when the callback is called. This conflates cause with action. The shutdown callout is an action that the filesystem must execute, whilst "remove bdev" is a cause notification that might require an action to be take. Yes, the cause could be someone doing hot-unplug of the block device, but it could also be something going wrong in software layers below the filesystem. e.g. dm-thinp having an unrecoverable corruption or ENOSPC errors. We already have a "cause" notification: blk_holder_ops->mark_dead(). The generic fs action that is taken by this notification is fs_bdev_mark_dead(). That action is to invalidate caches and shut down the filesystem. btrfs needs to do something different to a blk_holder_ops->mark_dead notification. i.e. it needs an action that is different to fs_bdev_mark_dead(). Indeed, this is how bcachefs already handles "single device died" events for multi-device filesystems - see bch2_fs_bdev_mark_dead(). Hence Btrfs should be doing the same thing as bcachefs. The bdev_handle_ops structure exists precisly because it allows the filesystem to handle block device events in the exact manner they require.... > - Add a new @bdev parameter to remove_bdev() callback > To allow the fs to determine which device is missing, and do the > proper handling when needed. > > For the existing shutdown callback users, the change is minimal. Except for the change in API semantics. ->shutdown is an external shutdown trigger for the filesystem, not a generic "block device removed" notification. Hooking blk_holder_ops->mark_dead means that btrfs can also provide a ->shutdown implementation for when something external other than a block device removal needs to shut down the filesystem.... -Dave. -- Dave Chinner david@fromorbit.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C1A9C83030 for ; Mon, 7 Jul 2025 23:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version:References: Message-ID:To:Date:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=M+QyBDE8+wesjS51bVD7FTBpR/Cm79PXw4/qA9Howgc=; b=lASRrTl3WvsTOi4FS84VoQc8qS d5HV/pn3Wtda6D0JsD8MEOxgxLs4GZfqwrGeU7qh6z8p8ZANGAbp9lDtZK+0/u7FQehejOu+bcJKU BIM+54i5pABGZu2G/Mbn9PxiW1iRSOHX38ypxZ77mXk7o4Y1iZpeXD2/n9bzOsSVwW6I=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1uYvIn-0000WM-Bt; Mon, 07 Jul 2025 23:31:13 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uYvIm-0000WG-Eq for linux-f2fs-devel@lists.sourceforge.net; Mon, 07 Jul 2025 23:31:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=c4pktmlF1vRQduNDQ1SA6N8TiSZQUsg3NAWNf5AHgsY=; b=bX9urX19tzmPN/o9M1pp4EQbsM 1XaMo9EqCBeoFUcaH9wd0JtqZ2lSNLPo1i7kSO5O3PsIsjHcLqYrtionU6eVcSlzSLdla5tlKvR6C k4je11WQFoEUMEyRpe8MwdUeHiGJUDprt3YER2xRe+ZdumUmryCJs9CNXHuIln/bGxE4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=c4pktmlF1vRQduNDQ1SA6N8TiSZQUsg3NAWNf5AHgsY=; b=CFfYoc30pKBqot2KTfEyuJerVX JFvVmIRdep9HM/4QQiuOmq6FinYuhAd6fXk2uEvxNhhbDU+qDXWxy45q4q3WSNWjvKoHrtHDlHGPM o032TA74XDsQqT9+CrjYN43Ckw306bBDVwnNVjSDwMJhU01eJABx6tN7lTi3mjGUXcHY=; Received: from mail-qv1-f49.google.com ([209.85.219.49]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1uYvIi-0001Rm-76 for linux-f2fs-devel@lists.sourceforge.net; Mon, 07 Jul 2025 23:31:12 +0000 Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-700fee04941so36839626d6.1 for ; Mon, 07 Jul 2025 16:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1751931057; x=1752535857; darn=lists.sourceforge.net; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=c4pktmlF1vRQduNDQ1SA6N8TiSZQUsg3NAWNf5AHgsY=; b=2vZXUNqhwa7NOazbH9xnK135aA9mSXC3zBUYVi0RrSpnH1nLdlMtzMCJbbwn246LjY FmMSVQVonMtaj2DcMof/doNeI87K5fj5nSPrIrmOe6G+z5SHnc9cUOetKMVmtt7fAYFL CcBYWa/qkZSVzQmUbYi+lyF+0LUwGREll2kY0h3uHk8mXqZmGp2pKSqEsxq80ZIalv79 ycAGIy9xVYR82cnDBfw0k0W/t/mK1jzrdH/UGhcwao8QMn21SM0f6onq8ti8TtVxSfyq ZmvcqGucPIDTzoPUr2XigH+P3SIorW7v+naAROZiW6q+r6Y9AKX8QNS/zErQpmNUkFMm oLsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751931057; x=1752535857; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c4pktmlF1vRQduNDQ1SA6N8TiSZQUsg3NAWNf5AHgsY=; b=scmBL+A685wkzoiJrFPg17nCPi8hXpTyIE6ka72I9bPynsaYsz/QTRz4RFTyR8qUqi KNvuPvFAA0ALS3aoHFgLzIOE6BeheiukKgDBUn/hLbYrmP6PrUyJ37lHhMZUiPI2Qv0c mRoC4YPz0aHXrTDs0alVBUnUCPp2ONj4q/FoIQYV0eCKH1pxtrjz22a/33QJeDznrXMc t2B8HI6u12Z6glOFcfmm43tF5Uf/KFixKvfYckPrg8+kQKdDJfrgdNGMf6f8TyAOhd65 gyzd4hU+nAJjiHZ4RFkwvnWPhbIGv9vXCj2eeYkSpBRRBHhYLuPmr2AuC3LKusbZKGFf QmAQ== X-Forwarded-Encrypted: i=1; AJvYcCU+hj+Hs4awXT9C9CIssnbBU5UyjwneiMyC0cJ1+KaPsaoGcOVTvoCndUeejS/Mx01Ulh2CH3Wk3IHZx4shmCBu@lists.sourceforge.net X-Gm-Message-State: AOJu0YynPdGJE86goZw97pC+meC4vCvfZ9Ge2kBZNOGPSccUea3baTO8 Xn1rbZAFLy4b6AgQnnRx8Jaya0T40CUfQ5zYzlNVHS6vqeo5DArn1+LgaHXWfyxp6hWAlEBCm8W I9RLg X-Gm-Gg: ASbGncu7z+0FbdxGQbGFRXSdJDkoEdHi1eyD5wFRX2MLmtRBgNgkxGkbpTC8+LWm6UJ vhjKv3E0Gn7PU9yeMZ177XZ1wM+zbm/OvOXSv9AEwmrZVF1xICuKN6VlMzyeylDVNirYZoB/wLN +wFK+OsK0YA+tNx9ZzuhkBa4L23lwgPr4g/c9W8POXi07SCvDS1J4Fn7l4wMN5CuWmXkqhxrGgM P1QugrS/F7I1gCKdj5Lp+S2KxapapbA/Ac6954UpkUMnsFGZz6zBNDCbG1xwN9rwXIivCE/4Vnk jgbTW3WV8xhI5ZI0yoCbEB6vCpppsE0PwBPscb8AIoHFebooWyibNfreuEwUuUCM6iDPfRNg8Hx Aonslxw6oKnkzM2nFabJJwp8NKcML2JLkvOJRcQ== X-Google-Smtp-Source: AGHT+IEmTi6zrkNyOcS4BN99ZoRqMQGa5CBIfG1MgDs1BPtD4rrI5GMD5dIJM6aSPlLP7bK+loeCfw== X-Received: by 2002:a17:902:ce10:b0:234:8ec1:4ad3 with SMTP id d9443c01a7336-23dd1d5cc19mr6352555ad.40.1751929375710; Mon, 07 Jul 2025 16:02:55 -0700 (PDT) Received: from dread.disaster.area (pa49-180-184-88.pa.nsw.optusnet.com.au. [49.180.184.88]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23c8431a1f0sm102785765ad.32.2025.07.07.16.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jul 2025 16:02:55 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.98.2) (envelope-from ) id 1uYurM-00000008CeO-1qLV; Tue, 08 Jul 2025 09:02:52 +1000 Date: Tue, 8 Jul 2025 09:02:52 +1000 To: Qu Wenruo Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1uYvIi-0001Rm-76 Subject: Re: [f2fs-dev] [PATCH v4 1/6] fs: enhance and rename shutdown() callback to remove_bdev() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Dave Chinner via Linux-f2fs-devel Reply-To: Dave Chinner Cc: brauner@kernel.org, ntfs3@lists.linux.dev, jack@suse.cz, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Fri, Jul 04, 2025 at 10:12:29AM +0930, Qu Wenruo wrote: > Currently all the filesystems implementing the > super_opearations::shutdown() callback can not afford losing a device. > > Thus fs_bdev_mark_dead() will just call the shutdown() callback for the > involved filesystem. > > But it will no longer be the case, with multi-device filesystems like > btrfs and bcachefs the filesystem can handle certain device loss without > shutting down the whole filesystem. > > To allow those multi-device filesystems to be integrated to use > fs_holder_ops: > > - Replace super_opearation::shutdown() with > super_opearations::remove_bdev() > To better describe when the callback is called. This conflates cause with action. The shutdown callout is an action that the filesystem must execute, whilst "remove bdev" is a cause notification that might require an action to be take. Yes, the cause could be someone doing hot-unplug of the block device, but it could also be something going wrong in software layers below the filesystem. e.g. dm-thinp having an unrecoverable corruption or ENOSPC errors. We already have a "cause" notification: blk_holder_ops->mark_dead(). The generic fs action that is taken by this notification is fs_bdev_mark_dead(). That action is to invalidate caches and shut down the filesystem. btrfs needs to do something different to a blk_holder_ops->mark_dead notification. i.e. it needs an action that is different to fs_bdev_mark_dead(). Indeed, this is how bcachefs already handles "single device died" events for multi-device filesystems - see bch2_fs_bdev_mark_dead(). Hence Btrfs should be doing the same thing as bcachefs. The bdev_handle_ops structure exists precisly because it allows the filesystem to handle block device events in the exact manner they require.... > - Add a new @bdev parameter to remove_bdev() callback > To allow the fs to determine which device is missing, and do the > proper handling when needed. > > For the existing shutdown callback users, the change is minimal. Except for the change in API semantics. ->shutdown is an external shutdown trigger for the filesystem, not a generic "block device removed" notification. Hooking blk_holder_ops->mark_dead means that btrfs can also provide a ->shutdown implementation for when something external other than a block device removal needs to shut down the filesystem.... -Dave. -- Dave Chinner david@fromorbit.com _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel