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 EA593C3DA7A for ; Tue, 20 Dec 2022 19:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234243AbiLTTz2 (ORCPT ); Tue, 20 Dec 2022 14:55:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234162AbiLTTzB (ORCPT ); Tue, 20 Dec 2022 14:55:01 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D46161EC55; Tue, 20 Dec 2022 11:53:53 -0800 (PST) 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-out2.suse.de (Postfix) with ESMTPS id 6CD44764EF; Tue, 20 Dec 2022 19:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1671566032; h=from:from:reply-to: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=jP7cOlzdQLz38OgaGOcsb9anR7C9s6SwVuf2yXeXxt0=; b=GsEjVPTajiJGYzjwxs+kmWycYcr0taR2CcWe87UUxU9FuQiNsC9JDgmMmcMSjJT5VwbWPl 1loLd4Yda1SbKhpI29Uxv31dihbg/t3NyVlJAG3jjXgEkbgPopjDGHfAtBb6OPVBK4CpQJ NPeOZQvaAOksWNOFga7HgYs06hsBHlM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1671566032; h=from:from:reply-to: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=jP7cOlzdQLz38OgaGOcsb9anR7C9s6SwVuf2yXeXxt0=; b=Vn5a1KAYIMs3+PjcDp5Y4caiTrJMsXNc4MgiK0o50MRUCcTV6yUE6WPv+OnF9S9VBEt83F Nh0QeNHj60udVlBQ== 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 2961213254; Tue, 20 Dec 2022 19:53:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yUY3CdASomN7SAAAMHmgww (envelope-from ); Tue, 20 Dec 2022 19:53:52 +0000 Date: Tue, 20 Dec 2022 20:53:06 +0100 From: David Sterba To: wqu@suse.com Cc: Chung-Chiang Cheng , Chung-Chiang Cheng , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@cccheng.net, Johnny Chang Subject: Re: [PATCH] btrfs: refuse to remount read-write with unsupported compat-ro features Message-ID: <20221220195306.GU10499@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <20221201160724.2593341-1-cccheng@synology.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 06, 2022 at 11:14:56AM +0000, Filipe Manana wrote: > On Tue, Dec 6, 2022 at 2:42 AM Chung-Chiang Cheng wrote: > > > > On Mon, Dec 5, 2022 at 6:45 PM Filipe Manana wrote: > > > > > > Wasn't this already done by the following commit? > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=81d5d61454c365718655cfc87d8200c84e25d596 > > > > > > Thanks. > > > > > > > Wow. I did not notice this commit doing the same job by Qu. But I have > > tested the latest linux-6.1 rc-7, and it's still able to mount a unsupported > > comat-ro btrfs as read-write via remount. > > > > It's caused by the follow-up commit d7f67ac9a928 ("btrfs: relax > > block-group-tree feature dependency checks"). This commit checks read- > > only with the current superblock, which will always pass in the situation > > remounting from read-only to read-write. It seems `btrfs_check_features()` > > cannot cover this scenario. > > > > if (compat_ro_unsupp && !sb_rdonly(sb)) { > > ^^^^^^^^^^^^^^ > > Yep, that's a bug. > btrfs_check_features() is called before the read only flag is updated > in the super block. > > So the condition should be: > > if (compat_ro_unsupp && sb_rdonly(sb) && we_want_to_transition_to_rw) > > We need to pass the flags passed to btrfs_remount() to > btrfs_check_features() for that "we_want_to_transition_to_rw" check. > > That seems to be what needs to be fixed. Qu, can you please have a look, it's caused by commit 81d5d61454c365718655cfc87d8200c84e25d596 that's also in stable kernels so this should be fixed quickly.