From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 86B1181AC8 for ; Tue, 24 Jun 2025 00:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750725226; cv=none; b=ZC9OgV95EUpkbo9FjAi2NREMZa0Tn8/zfFWt29H4Wye43XT0WsWoLpAMmw9Pr45Jt29sdbEkwaswHzdjKokvG7h6JdrysH24tiefBTNPtFzgYn8RHFq8bVd1SKwPXavNYo9ZpTwQy3Fqy3Y6ctJKy3Qf26xWvaCqt4GF/NDuShQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750725226; c=relaxed/simple; bh=StuSd1FIsn1fBr6nGm8S1WHL7svukOv5nRI1JPBPgNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p9o/e4jS7Lqy05EFFf6Vu08cB4I+7pvNk+5/onfX2fdjosZHR5vuUKX2V3nioz/q7h7xSaE8x39y85R0u2VxwqwyRJPHwWGy/lKwRgkZftXmBKVHe8q7ldu6hp3N/yy4M3CklOr4hXBUC1hCsdeCNZosjNFvvXC391JFKA6Bm9k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=gaiVJhhm; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=OOj1zIRQ; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="gaiVJhhm"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="OOj1zIRQ" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E6B8C1F454; Tue, 24 Jun 2025 00:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1750725209; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNNvWJ5heX9tb68PxZg7w36Ewu7DHrqFm1m676mhZz4=; b=gaiVJhhm4ijn3zDRUok3kwJCUn/pl4CBmxihnEVYulCXBi2zFcBdix0EYjLjNmEot4Dya0 YdBes6R8J57o1/EIps1gDrvuCfWEL0hBYe12l/hyv73XDaHqTSlLGB4Y1xbBWP1b7Pt+S8 AtWqmOSUakuOL0CZ7t3RUTuQgOOGADk= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=OOj1zIRQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1750725208; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNNvWJ5heX9tb68PxZg7w36Ewu7DHrqFm1m676mhZz4=; b=OOj1zIRQKD8oMUJcs0AhkL2D1bg83hJ81/cNVlHq/jtfGplwkyrGKIVnED65Lf8i+s+bmj 8uVOzOTVS1QjAcLVB2KRvCNZeccMw7qB66thkaHkzMSIM5VFAYZX1kwe9YtHLDOM/QsNBn iYzVfVGv07FhrRoUtpI4msqRcFGT+J8= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ABFA513485; Tue, 24 Jun 2025 00:33:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aLhuG1fyWWiCCAAAD6G6ig (envelope-from ); Tue, 24 Jun 2025 00:33:27 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: Christoph Hellwig , Johannes Thumshirn Subject: [PATCH v5 7/8] btrfs: use the super_block as holder when mounting file systems Date: Tue, 24 Jun 2025 10:02:44 +0930 Message-ID: <4345c4ee5f775ac96e05a4cb343db7ae75d9524f.1750724841.git.wqu@suse.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:dkim,suse.com:mid,suse.com:email]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: E6B8C1F454 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -3.01 From: Christoph Hellwig The file system type is not a very useful holder as it doesn't allow us to go back to the actual file system instance. Pass the super_block instead which is useful when passed back to the file system driver. This matches what is done for all other block device based file systems, and allows us to remove btrfs_fs_info::bdev_holder completely. Signed-off-by: Christoph Hellwig Signed-off-by: Johannes Thumshirn Signed-off-by: Qu Wenruo --- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/fs.h | 2 -- fs/btrfs/super.c | 3 +-- fs/btrfs/volumes.c | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 6576867cc1e9..c23847de4e99 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -250,7 +250,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, } bdev_file = bdev_file_open_by_path(device_path, BLK_OPEN_WRITE, - fs_info->bdev_holder, NULL); + fs_info->sb, NULL); if (IS_ERR(bdev_file)) { btrfs_err(fs_info, "target device %s is invalid!", device_path); return PTR_ERR(bdev_file); diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h index b239e4b8421c..d90304d4e32c 100644 --- a/fs/btrfs/fs.h +++ b/fs/btrfs/fs.h @@ -715,8 +715,6 @@ struct btrfs_fs_info { u32 data_chunk_allocations; u32 metadata_ratio; - void *bdev_holder; - /* Private scrub information */ struct mutex scrub_lock; atomic_t scrubs_running; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index b430631da647..5a07330fb3a6 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1920,7 +1920,7 @@ static int btrfs_get_tree_super(struct fs_context *fc) mutex_lock(&uuid_mutex); btrfs_fs_devices_dec_holding(fs_devices); - ret = btrfs_open_devices(fs_devices, mode, &btrfs_fs_type); + ret = btrfs_open_devices(fs_devices, mode, sb); mutex_unlock(&uuid_mutex); if (ret < 0) { deactivate_locked_super(sb); @@ -1933,7 +1933,6 @@ static int btrfs_get_tree_super(struct fs_context *fc) bdev = fs_devices->latest_dev->bdev; snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev); shrinker_debugfs_rename(sb->s_shrink, "sb-btrfs:%s", sb->s_id); - btrfs_sb(sb)->bdev_holder = &btrfs_fs_type; ret = btrfs_fill_super(sb, fs_devices); if (ret) { deactivate_locked_super(sb); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f02551f65366..8c91511ed433 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2706,7 +2706,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path return -EROFS; bdev_file = bdev_file_open_by_path(device_path, BLK_OPEN_WRITE, - fs_info->bdev_holder, NULL); + fs_info->sb, NULL); if (IS_ERR(bdev_file)) return PTR_ERR(bdev_file); @@ -7175,7 +7175,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info, if (IS_ERR(fs_devices)) return fs_devices; - ret = open_fs_devices(fs_devices, BLK_OPEN_READ, fs_info->bdev_holder); + ret = open_fs_devices(fs_devices, BLK_OPEN_READ, fs_info->sb); if (ret) { free_fs_devices(fs_devices); return ERR_PTR(ret); -- 2.49.0