Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1355891rdb; Mon, 19 Feb 2024 12:36:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwHGuKhDFhPQNxYyutaSlrolsNcmFm1YRuUSHUWbfC8/MzruaQQR4NFEorBb6xXUFaOvGnxvh2oh302I8ZTro6eFQ63GIrvQU/bB/f9w== X-Google-Smtp-Source: AGHT+IHahGQ2UytqK6FcsrpiPLt5wZBmjF2DApwLZHoGa+Jf06l6+qpmt/jjb9wyLhN92fa8NaSi X-Received: by 2002:a05:6a00:13a3:b0:6e0:51e3:909d with SMTP id t35-20020a056a0013a300b006e051e3909dmr18208444pfg.17.1708375009452; Mon, 19 Feb 2024 12:36:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708375009; cv=pass; d=google.com; s=arc-20160816; b=O/o7F5JBUlYLg48ubf4/3FlmrjiP6nnsIpq0xGY7i2IFVomXIWC1OIC6/eMlyuyYVP 6qIKHC7Co9kAkPhPUHlCuYNDDGPvBNhU0fIy5nmUk+wFVW311Gemee9GbRVdH8jEEI0h NY9DZ0/NEX9JxGKUdwlCmADInqm9mK2J8QpexPhAJkjacVxJ0nLe3uWBLKMDBzzEmLAv KH3ySDDBlVuG4jZOBkPNI2dbIOWFHrHmUTBr49qyBGNxBcNTEePQwvz1kkExiSxcXiGO OfkfKcC9l5W1kizwycTTibhHaZ2q4b6m5LBFFWwQJhQM1nkCABP1GXJRCaI9psfVkcJb x1Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :reply-to:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=IaiaYYyRrIaayqv/xsgvuF0xUZS0lMy4+lcMvWeNzEk=; fh=jEG0Z7RwbAVihsb98oXIN6cGxrokEmbopp/4Ze0YXDI=; b=Vrtk5d/Fo7l05QifghqDt8GQsl5r9h6tGfwb1zQCOSSUwt9b+Ua1CeexzTXiC7N6CL DTnytjXxFrD9Y8g43KiaanK4XfhkODgZcFqOf2sOXIctwS6iFfcuu5tjBbeHu6p5CESK 4+onS7iOOW4vLesH+6/ZIQjOVSdm0r/ME+8whuKqUPdfPrEXQCdVYUEiDW8VZXYAT7B6 WeovJnTI4mK3ys109hGduQ7G6H00zAft0z1RBXcKKq5sO2gSkQcNUOTY8UoFJZ+qo55s U/3cdeLkTt7gSTnffRHH1vNSQ9YEKht5ugEQ5Etek0cMfhMp4yxRS1xOMlhODczEahwe EA0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=kX1OCIx5; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=sY665t8f; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-71958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71958-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s23-20020a056a00179700b006e44b41a6c2si3184882pfg.149.2024.02.19.12.36.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 12:36:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=kX1OCIx5; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=sY665t8f; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-71958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71958-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E5139B21AD1 for ; Mon, 19 Feb 2024 20:24:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50E8D53E39; Mon, 19 Feb 2024 20:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="kX1OCIx5"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="o6ZRAM16"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="sY665t8f"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="deH1j0Ln" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 8795E535C6; Mon, 19 Feb 2024 20:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708374212; cv=none; b=XO2VdfNLe1vru1ylcGo3qiSCDrYYYbuTiSo9KF+RkbO3roM/LPbhdL5edRg6HLanK3A3I+MsOAkCH7YNi6DfE4uezFuBefVCuJ1W+Rh0lWzRaS3e3+YPCjbSf4EkUIOWKlFe3asLcF+bA9nnPzId5P6E4Io78MIqpQtbVUK6h24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708374212; c=relaxed/simple; bh=uZaCMC5IWWkK0wjuMtfXpecMc77gSRyuDuSAVtOMOsc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ODUyZ8MyCBUn+Vi+66+n8PJfcAt6UIELPlzE+c+S0pm7s8xMbdYpiFgIV+bNMPsbhbSYw+4eOiBRYH++b/HVza/lVnHSFbj6qOhFzW4t9lAbXZXlr/tt/rlskCBJrpkThZXtOGt7BzixQQuBT2hTbu9ggZCWnxZjRt4uLVez5pE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=kX1OCIx5; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=o6ZRAM16; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=sY665t8f; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=deH1j0Ln; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (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-out1.suse.de (Postfix) with ESMTPS id A48CD22109; Mon, 19 Feb 2024 20:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708374208; 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=IaiaYYyRrIaayqv/xsgvuF0xUZS0lMy4+lcMvWeNzEk=; b=kX1OCIx5L7FrOS4ttnrl+jwssJS9IshxqPo2u/zBth9Ueiil1mMczdT2j4TjuOHfcY1BPP 1Mq3OydsFBmLiSk81VNUukc+72GUNlViR5cSC3BaA9Ysr82UqsBEIUa+MN29wDcIPAzBjZ zbFYcNvE+zrC+0PEZS9A3tIrSYa8g9k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708374208; 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=IaiaYYyRrIaayqv/xsgvuF0xUZS0lMy4+lcMvWeNzEk=; b=o6ZRAM16QjPGOjR0eNezYoLiPPvKB4ucceCvDTdKM7GFXJOGOALsp8PENO/GIPSfdS8+Dv nStz0Nr/jBeYhgDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708374207; 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=IaiaYYyRrIaayqv/xsgvuF0xUZS0lMy4+lcMvWeNzEk=; b=sY665t8fRME6ZA8d7ypbzSkc9RXAlouAKJ0Fa3jy/CaZQsecK8e9jZydeDe1luNsjdGqgZ c2f/5qnCM+aOdg8yE9s9c6mAkXKOHYtvyJPbS/VK9lI96mBu0NZHW1QTwAeulRGhCPsc6B HSpea3XM9O0s5Lr7/WSauql7xBOu7zg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708374207; 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=IaiaYYyRrIaayqv/xsgvuF0xUZS0lMy4+lcMvWeNzEk=; b=deH1j0LnkaQV7CHUI8lLF2NeXthu0pOZRSzbSPhXHLMKZBjb0GgX5TZd8hbFK+JQhn5LJE H9tNz6NrZQjxzvBA== Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 9148C13585; Mon, 19 Feb 2024 20:23:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 7sVLI7+402VHXQAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 20:23:27 +0000 Date: Mon, 19 Feb 2024 21:22:47 +0100 From: David Sterba To: Johannes Thumshirn Cc: Chris Mason , Josef Bacik , David Sterba , Christoph Hellwig , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] btrfs: always open the device read-only in btrfs_scan_one_device Message-ID: <20240219202247.GB355@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <20240214-hch-device-open-v1-0-b153428b4f72@wdc.com> <20240214-hch-device-open-v1-1-b153428b4f72@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20240214-hch-device-open-v1-1-b153428b4f72@wdc.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -1.01 X-Spamd-Result: default: False [-1.01 / 50.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.30)[dsterba@suse.cz]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; DBL_BLOCKED_OPENRESOLVER(0.00)[lst.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.01)[50.61%] X-Spam-Flag: NO On Wed, Feb 14, 2024 at 08:42:12AM -0800, Johannes Thumshirn wrote: > From: Christoph Hellwig > > btrfs_scan_one_device opens the block device only to read the super > block. Instead of passing a blk_mode_t argument to sometimes open > it for writing, just hard code BLK_OPEN_READ as it will never write > to the device or hand the block_device out to someone else. Opening for write was not meant to be for writing but also to exclude other attempted writes. That it's always for read seems OK, this has changed at some point and is explained in btrfs_scan_one_device(): 1356 /* 1357 * Avoid an exclusive open here, as the systemd-udev may initiate the 1358 * device scan which may race with the user's mount or mkfs command, 1359 * resulting in failure. 1360 * Since the device scan is solely for reading purposes, there is no 1361 * need for an exclusive open. Additionally, the devices are read again 1362 * during the mount process. It is ok to get some inconsistent 1363 * values temporarily, as the device paths of the fsid are the only 1364 * required information for assembling the volume. 1365 */ 1366 bdev_handle = bdev_open_by_path(path, flags, NULL, NULL);