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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A78FC433F5 for ; Mon, 18 Apr 2022 15:49:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345950AbiDRPwH (ORCPT ); Mon, 18 Apr 2022 11:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345903AbiDRPvu (ORCPT ); Mon, 18 Apr 2022 11:51:50 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC8C12759 for ; Mon, 18 Apr 2022 08:30:59 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id o18so10253548qtk.7 for ; Mon, 18 Apr 2022 08:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hxMpVA+vY3er/hLF7xfbfNHgtcZ8KeWqt4rWVE6pHlU=; b=r5Cg80JFVujoiSWJc87j7ZfJ5XvMet94oEVliiapS8rgEMkHoJObwQhuuHGqbCa7O7 +5K5XOh8KFLDFov1wgkBqeIqlIahu7cq4limW4EpVbmUapbeV20VWFLx6SwVVBnkofEU CoTDv5hPtZFX9SWzyn/SqBRvOUFlrdtovbc1Y8Zo02214Mem1wFVrxZL9hR71LQRXNku mVz6UZiWTis8bs9d7zFNHGp6BzL5RBYmWA9oe5YLYjtzMGPQLludt+PJuauyP5ahB4oO cT7M/jOdUykpjqNySCQM7615S+OpFnw0ytafVf4Q+MuG1p4jnBPfFoGgCbGY9sazOsDn A88Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hxMpVA+vY3er/hLF7xfbfNHgtcZ8KeWqt4rWVE6pHlU=; b=eS7FBOwKdHXxtXgvRtuTS6U7aJE6Gx0eM+gyK5XIuN672GGE+P/8pEs0geldhaUD/L JbMHIZRxTy6j66YUqvc5QwJirRtFpONneQeK0dnEdb9WtzgdhT6IaTbSo6SHi2hgyMTF Z0KGoR+2rUXQCW+7oPsi9BQgrKiQoy2J/IQefcagefzcXu1+xh+hjMA9MMUczxoNAfdA N8x/SSLvWYt1JLDkKyoRbtjyWtneGYSmTatdBqb+Xb4e9+z9644DuZ8uYbujmaEQi3I1 liQeagEfGbhWPX2cRM+CdqmHSZ428x8302ZcfC7i9wJjE0UqUcGD3oPpx1qWOGnvsJvV beUg== X-Gm-Message-State: AOAM531MyEZJhEcvpW7Vn8fzrJa6zoJpSMLE9+nihIfK507A+gtjggqh DUvJ1dQK/g8pKZ9Y7BwdtXVJMU5b5fHMAQ== X-Google-Smtp-Source: ABdhPJwOCwfap+ZJ1bZkFuB+0A9a/fRkm4kb/FrPK8r7uSRr4T1MUvoSCIfe3RX1pVDnI39E/5siXw== X-Received: by 2002:ac8:7e8a:0:b0:2f1:ebd6:b28b with SMTP id w10-20020ac87e8a000000b002f1ebd6b28bmr7532218qtj.286.1650295858062; Mon, 18 Apr 2022 08:30:58 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id n8-20020ac85a08000000b002f1fc230725sm2483362qta.31.2022.04.18.08.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 08:30:57 -0700 (PDT) Date: Mon, 18 Apr 2022 11:30:55 -0400 From: Josef Bacik To: Qu Wenruo Cc: linux-btrfs@vger.kernel.org Subject: Re: [PATCH] btrfs-progs: do not allow setting seed flag on fs with dirty log Message-ID: References: <4022d9f87067124c26bb83d4bba1970c954cdf50.1650022504.git.wqu@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4022d9f87067124c26bb83d4bba1970c954cdf50.1650022504.git.wqu@suse.com> Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Fri, Apr 15, 2022 at 07:37:43PM +0800, Qu Wenruo wrote: > [BUG] > The following sequence operation can lead to a seed fs rejected by > kernel: > > # Generate a fs with dirty log > mkfs.btrfs -f $file > mount $dev $mnt > xfs_io -f -c "pwrite 0 16k" -c fsync $mnt/file > cp $file $file.backup > umount $mnt > mv $file.backup $file > > # now $file has dirty log, set seed flag on it > btrfstune -S1 $file > > # mount will fail > mount $file $mnt > > The mount failure with the following dmesg: > > [ 980.363667] loop0: detected capacity change from 0 to 262144 > [ 980.371177] BTRFS info (device loop0): flagging fs with big metadata feature > [ 980.372229] BTRFS info (device loop0): using free space tree > [ 980.372639] BTRFS info (device loop0): has skinny extents > [ 980.375075] BTRFS info (device loop0): start tree-log replay > [ 980.375513] BTRFS warning (device loop0): log replay required on RO media > [ 980.381652] BTRFS error (device loop0): open_ctree failed > > [CAUSE] > Although btrfs will replay its dirty log even with RO mount, but kernel > will treat seed device as RO device, and dirty log can not be replayed > on RO device. > > This rejection is already the better end, just imagine if we don't treat > seed device as RO, and replayed the dirty log. > The filesystem relying on the seed device will be completely screwed up. > > [FIX] > Just add extra check on log tree in btrfstune to reject setting seed > flag on filesystems with dirty log. > > Signed-off-by: Qu Wenruo Can we get a progs test for this as well? Reviewed-by: Josef Bacik Thanks, Josef