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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 451C4C433E6 for ; Sat, 29 Aug 2020 06:40:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C3CA207BB for ; Sat, 29 Aug 2020 06:40:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hr+xuOKa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725929AbgH2Gkt (ORCPT ); Sat, 29 Aug 2020 02:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgH2Gkt (ORCPT ); Sat, 29 Aug 2020 02:40:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE917C061236; Fri, 28 Aug 2020 23:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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; bh=7l+Em9gvBvWd82kjcq938GwighvalU0zZ6jp3z8HlSI=; b=hr+xuOKarpl9EfqKCjkFM5KlYc 527XyEupWB/z+YMisYTw5goBiZWS0iGPO/sgBY+bXs1DjcGnz3T7OOlGdsI7LoNswS0GSccwNNI2G T0I5vOvoTFT/i6J3Vu1E/DnFcU47xy2gEHv4ciK1Z2m33LwjaMgahdsR3qLf2mKndFJxZYowODfPx N58VYJzgJsUfm8dIjwu5ydyrTvxqWlgCvzoAhJiYy195VsEtYuxLODFwGqvyrhT6K5LHhpSb1U+MX MA15xXjMyHhNg2neyDtZCz3p6Q6xFaBhdzmoDZu3x9mE/x0dHHkzxMBs/sYQmyuzVet4QGdezQpBf 5auA6M4g==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBuXZ-0007Vf-Rk; Sat, 29 Aug 2020 06:40:41 +0000 Date: Sat, 29 Aug 2020 07:40:41 +0100 From: Christoph Hellwig To: Andreas Dilger Cc: Christoph Hellwig , Jan Kara , linux-fsdevel , yebin , linux-block , Jens Axboe Subject: Re: [PATCH RFC 2/2] block: Do not discard buffers under a mounted filesystem Message-ID: <20200829064041.GA23205@infradead.org> References: <20200825120554.13070-1-jack@suse.cz> <20200825120554.13070-3-jack@suse.cz> <20200825121616.GA10294@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Fri, Aug 28, 2020 at 02:21:29AM -0600, Andreas Dilger wrote: > On Aug 25, 2020, at 6:16 AM, Christoph Hellwig wrote: > > > > On Tue, Aug 25, 2020 at 02:05:54PM +0200, Jan Kara wrote: > >> Discarding blocks and buffers under a mounted filesystem is hardly > >> anything admin wants to do. Usually it will confuse the filesystem and > >> sometimes the loss of buffer_head state (including b_private field) can > >> even cause crashes like: > > > > Doesn't work if the file system uses multiple devices. > > It's not _worse_ than the current situation of allowing the complete > destruction of the mounted filesystem. It doesn't fix the problem > for XFS with realtime devices, or ext4 with a separate journal device, > but it fixes the problem for a majority of users with a single device > filesystem. > > While BLKFLSBUF causing a crash is annoying, BLKDISCARD/BLKSECDISCARD > under a mounted filesystem is definitely dangerous and wrong. > > What about checking for O_EXCL on the device, indicating that it is > currently in use by some higher level? That actually seems like a much better idea.