From patchwork Tue Apr 2 22:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13614672 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 0C05315ECC2 for ; Tue, 2 Apr 2024 22:08:10 +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=1712095692; cv=none; b=bZgyFDFkn+RHFLv4Hush8O/zDljBBIZqAAP8Js3SpJlDjE64VCTTUeGD9fqL3vOBjjyId6dtd2DcnDUxZZKjJ7c96XncDKD35cOdDFRWUTGaACxiGFvac27YbCytqWFMxODaxKK+ZY6bpiybSEA1U0X+sUi1cfG0MmXUpcUxblQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095692; c=relaxed/simple; bh=5RjL8I2QRD7HhDPJwAHsBSEXx1BXdgcSyL4p55lIUcs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Crsh0ZP+AAae6jN9GmbleZ/5gqY/ivVEc/rzYQ5hSd29BcqS+5K3nf7ls9bp2SWaSmDxLXFNZpiZpUy4sEPhhmMWbQAXaESebR6jEylmR8/WqyrJlJNmDOoHrQtUjQhWjKP4/f4YJxw1x179cLjx3q/lqU1cu6B/kXmej3mefUE= 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=j0dpbK6R; 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="j0dpbK6R" 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-out2.suse.de (Postfix) with ESMTPS id 413295C3FA for ; Tue, 2 Apr 2024 22:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712095689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7eZ5svEWEtzMaa6FcvFfBpA1NZNfT9qxx6JvzO+Y9CM=; b=j0dpbK6RvzEnmnrJW/osCfoPe9+ZE059Gw3g66Vw+s3E0CvH1rCBwhgBFNXeHKbaz50ajk tXaV88PzUblDzemzJmGPHfCkb17wdwjEfPcI7fqwUSkrT8qf5pOLui6Arc+OWIfpjkXtmP /Ipilh3gxoaEeNGw6XHsKrLQf0ydDH8= Authentication-Results: smtp-out2.suse.de; none 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 4AEFE13A90 for ; Tue, 2 Apr 2024 22:08:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id AJG7A8iBDGYIdwAAn2gu4w (envelope-from ) for ; Tue, 02 Apr 2024 22:08:08 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 1/5] btrfs-progs: tune: add the missing newline for --convert-from-block-group-tree Date: Wed, 3 Apr 2024 08:37:36 +1030 Message-ID: <39cc5f46367eec2769ab2dc45c38e350001dfa0f.1712095635.git.wqu@suse.com> X-Mailer: git-send-email 2.44.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 X-Spamd-Result: default: False [1.20 / 50.00]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; BAYES_HAM(-0.00)[41.92%]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_NONE(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[linux-btrfs@vger.kernel.org]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: 1.20 X-Spam-Level: * X-Spam-Flag: NO There is a missing newline for a successful --convert-from-block-group-tree run, meanwhile --convert-to-block-group-tree has the correct newline. Signed-off-by: Qu Wenruo --- tune/convert-bgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tune/convert-bgt.c b/tune/convert-bgt.c index dd3a8c750604..1263b147241e 100644 --- a/tune/convert-bgt.c +++ b/tune/convert-bgt.c @@ -270,7 +270,7 @@ iterate_bgs: return ret; } pr_verbose(LOG_DEFAULT, - "Converted filesystem with block-group-tree to extent tree feature"); + "Converted filesystem with block-group-tree to extent tree feature\n"); return 0; error: From patchwork Tue Apr 2 22:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13614673 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 74C3015ECC5 for ; Tue, 2 Apr 2024 22:08:12 +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=1712095694; cv=none; b=X8g3T3nbx8wONMv9ZUtCyiBkEtbxGARtW9Zmkr8A9gZEr56lzTjONA5hzIw3mSzkbl5w2aek+kNkW2m9y4bCsrdqPYzE1JuYzNABwcA9j+PZk9hkks7U2FQUv7bhlfJ9lXQvMbyUrVDIJHXW3ZGSJuX4bQEbjB9nazttouS8dcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095694; c=relaxed/simple; bh=MlpIsCa5jFcKIuYVY7LL8bDrWcMJbFMIZEPxJs92X7I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PXsqGYnu9STI2pDsOxaXtQDOIRMGTYA+vNVbVgHu17YNMNrcEVketWO6OZ9Pgmh690crta5SR+xQWu39M14nmEPWQLdALZ2dbhPjdFI8GjEEeayXlairX+/6PMM2octvkl4VhD8m2b3syD/BGtDWz9UrxznXJ2dDRWUtRYtcO4M= 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=I+DBJU48; 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="I+DBJU48" 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-out2.suse.de (Postfix) with ESMTPS id A47855C3FB for ; Tue, 2 Apr 2024 22:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712095690; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KnQpUzP5gvjlC5TorASiHrgBpUrmdj1oNN2dAjhatTY=; b=I+DBJU48KAL/jihCtGekHAqrnfhu4zAqZLt/fa1MEo2xZKQ0eM26o4+FfElOZxHGMvTqVf QW3sRh+FcL5wyVWvOqFLIxUfpDCJ0PwsxSmshd/w2Qi48n17PqOj5u+YG194swx+YicSXa 6TbKq0wJ+JAt9YQqPaefOdbydB2at+8= Authentication-Results: smtp-out2.suse.de; none 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 C373A13A90 for ; Tue, 2 Apr 2024 22:08:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id 8AItIcmBDGYIdwAAn2gu4w (envelope-from ) for ; Tue, 02 Apr 2024 22:08:09 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 2/5] btrfs-progs: mkfs: use proper zoned compatible write for bgt feature Date: Wed, 3 Apr 2024 08:37:37 +1030 Message-ID: <69d093d141f7e3ad02f4353d69458805fa8883bc.1712095635.git.wqu@suse.com> X-Mailer: git-send-email 2.44.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 X-Spamd-Result: default: False [-1.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[linux-btrfs@vger.kernel.org]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -1.80 X-Spam-Level: X-Spam-Flag: NO [BUG] There is a bug report that mkfs.btrfs can not specify block-group-tree feature along with zoned devices: # mkfs.btrfs /dev/nullb0 -O block-group-tree,zoned btrfs-progs v6.7.1 See https://btrfs.readthedocs.io for more information. Resetting device zones /dev/nullb0 (40 zones) ... NOTE: several default settings have changed in version 5.15, please make sure this does not affect your deployments: - DUP for metadata (-m dup) - enabled no-holes (-O no-holes) - enabled free-space-tree (-R free-space-tree) ERROR: error during mkfs: Invalid argument [CAUSE] During mkfs, we need to write all the 7 or 8 tree blocks into the metadata zone, and since it's zoned device, we need to fulfill all the requirement for zoned writes, including: - All writes must be in sequential bytenr - Buffer must be aligned to sector size The sequential bytenr requirement is already met by the mkfs design, but the second requirement on memory alignment is never met for metadata, as we put the contents of a leaf in extent_buffer::data[], which is after a lot of small members. Thus metadata IO buffer would never be aligned to sector size (normally 4K). And we require btrfs_pwrite() and btrfs_pread() to handle the memory alignment for us. However in create_block_group_tree() we didn't use btrfs_pwrite(), but plain pwrite() call directly, which would lead to -EINVAL error due to memory alignment problem. [FIX] Just call btrfs_pwrite() instead of the plain pwrite() in create_block_group_tree(). Issue: #765 Signed-off-by: Qu Wenruo --- mkfs/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkfs/common.c b/mkfs/common.c index 5e56b33dda6d..3c48a6c120e7 100644 --- a/mkfs/common.c +++ b/mkfs/common.c @@ -249,8 +249,8 @@ static int create_block_group_tree(int fd, struct btrfs_mkfs_config *cfg, btrfs_set_header_nritems(buf, 1); csum_tree_block_size(buf, btrfs_csum_type_size(cfg->csum_type), 0, cfg->csum_type); - ret = pwrite(fd, buf->data, cfg->nodesize, - cfg->blocks[MKFS_BLOCK_GROUP_TREE]); + ret = btrfs_pwrite(fd, buf->data, cfg->nodesize, + cfg->blocks[MKFS_BLOCK_GROUP_TREE], cfg->zone_size); if (ret != cfg->nodesize) return ret < 0 ? -errno : -EIO; return 0; From patchwork Tue Apr 2 22:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13614674 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 295C215ECD2 for ; Tue, 2 Apr 2024 22:08:13 +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=1712095695; cv=none; b=IkSXqDXCiHMwsjYPBgy1VH0RSiLt82gQVL1A+KqBfpYYVhf3N1xk0kGaCuUpkYR1gGN7/cCLWcIxt2d/HHyy+k6Ik/doeHZgAPT1SuItUjafnLCRvX0/K9uaPb8zHP/z+BSO+6Y1YwiVmGh0n9Zj8DRLjhIXTPCz/g2eiq0pF/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095695; c=relaxed/simple; bh=DYnZRZur7rmeAGSOy90AIzOHK83dJ862UxZlk7swF+g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sV2NQE1G3IMjWWdMKi9IjJKP+jFl8wJsi2KDc3Zq+CrgZ2A+OUPW9XHqe0gT0dD8or789lAr9l9HTAl2yAOBKPOlZ8JvFrwfFGApCBZQFczXh2Np9lwWVyrkG/VTCWMeWjA8gs/RFDNNmJ1L3iSAXlvxBg7hTpPp9Yc8QvQrtGI= 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=mVC3Aj5y; 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="mVC3Aj5y" 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-out2.suse.de (Postfix) with ESMTPS id 3B1385C3FC for ; Tue, 2 Apr 2024 22:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712095692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M33JOYoHXp3rxcdR5EghkqmQpwg8VHsxga6OrR63qQg=; b=mVC3Aj5ySNK36uA6zreVDNtURtNvVsxwB/ABZBd0KhHnW35pWejNqwXJHrwpNUF56EJhwz hhXd/uUL2eaU8u1bXrbYoihoZy3/+YuO3onm3Oyd4XpwR2wE+hVlVxvd05GPvVWisGby7e zblCExsk540u1asfp6j1f4rtjDv4STw= Authentication-Results: smtp-out2.suse.de; none 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 488EC13A90 for ; Tue, 2 Apr 2024 22:08:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id 2Jb2OsqBDGYIdwAAn2gu4w (envelope-from ) for ; Tue, 02 Apr 2024 22:08:10 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 3/5] btrfs-progs: tune: properly open zoned devices for RW Date: Wed, 3 Apr 2024 08:37:38 +1030 Message-ID: X-Mailer: git-send-email 2.44.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 X-Spamd-Result: default: False [-1.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[linux-btrfs@vger.kernel.org]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email] X-Spam-Score: -1.80 X-Spam-Level: X-Spam-Flag: NO [BUG] There is a report that, for zoned devices btrfstune is unable to convert it to block group tree. # btrfstune /dev/nullb0 --convert-to-block-group-tree Error reading 1342193664, -1 Error reading 1342193664, -1 ERROR: cannot read chunk root ERROR: open ctree failed [CAUSE] For read-write opened zoned devices, all the read/write has to be aligned to its sector size. However btrfs stores its metadata by extent_buffer::data[], which has all the structures before it, thus never aligned to zoned device sector size. Normally we would require btrfs_pread() and btrfs_pwrite() to do the extra alignment, but during open_ctree(), we are not aware if a device is zoned or not. Thus we rely on if the fd is opened with O_DIRECT flag, if the fd has O_DIRECT, then we would temporarily set fs_info->zoned for chunk tree read. Unforunately not all open_ctree_fd() callers have the flags set properly, and btrfstune is one of the missing call site. This makes all the read not properly aligned and cause read failure. [FIX] Just manually check if the target device is a zoned one, and set O_DIRECT accordingly. Issue: #765 Signed-off-by: Qu Wenruo --- tune/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tune/main.c b/tune/main.c index 0fbf37dd4800..cfb5b5d6e323 100644 --- a/tune/main.c +++ b/tune/main.c @@ -29,6 +29,7 @@ #include "kernel-shared/transaction.h" #include "kernel-shared/volumes.h" #include "kernel-shared/free-space-tree.h" +#include "kernel-shared/zoned.h" #include "common/utils.h" #include "common/open-utils.h" #include "common/device-scan.h" @@ -194,6 +195,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) u64 super_flags = 0; int quota = 0; int fd = -1; + int oflags = O_RDWR; btrfs_config_init(); @@ -337,7 +339,9 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) } } - fd = open(device, O_RDWR); + if (zoned_model(device) == ZONED_HOST_MANAGED) + oflags |= O_DIRECT; + fd = open(device, oflags); if (fd < 0) { error("mount check: cannot open %s: %m", device); ret = 1; From patchwork Tue Apr 2 22:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13614675 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 5135715ECDB for ; Tue, 2 Apr 2024 22:08:15 +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=1712095697; cv=none; b=JXwhmlPnz7YpEviMg8ltwKp3tBuaJgA0EbTLS0f4PAYKpFo453oqtMNnju+ZXq+Atc2fAR/cxP/uR3RE075oL5S9UpDMcN6uOFNhQG5EmcLBy7Jjhd9egKbOyvAbYEukH6O51epoT74+s/zFltWOyRnxICf9StiJ83tpuMb9jRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095697; c=relaxed/simple; bh=xmktfWVx7hK3fFpN9ZfZaOWSduk9zR+6XX7ljEdNy7o=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZsV8dW2mVluLJJ9ce9DDMJKDJCAwQZXtqCY/y1+jvZd/w4iL4L/gETB3RgF5ejHxWytMlVg5ALcwV62qv/mueLvx9JUY6GSWB+TObcw0dTkhnhJvjXJO1wQtLgWgimF6Q1Yd+Mebeef0tpyW7Tn3p96QAJzuIe7+9lKG2X9AoNk= 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=F4sTxXLL; arc=none smtp.client-ip=195.135.223.130 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="F4sTxXLL" 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 B86AD34BC8 for ; Tue, 2 Apr 2024 22:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712095693; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AR0TTEjPd/C61+s6MmilNxXsq0kN/l5UkdS4mSjJKNs=; b=F4sTxXLLy6R59KGN8GpH0SQtg1Bh/plZrZuuhfzNJlOUvu2FAbc73bzu2XMy8L8WmuuIVh FoheJ4kxArQJ5B15pDodVBL6O1oB+oJVjVNt8w8cre9hMkK8aVOEpBtIur31fPVzDjeSuR mNIeevTa0aBqOPYgZZmaA0uNwSBLrS0= Authentication-Results: smtp-out1.suse.de; none 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 CB30813A90 for ; Tue, 2 Apr 2024 22:08:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id aIF0H8yBDGYIdwAAn2gu4w (envelope-from ) for ; Tue, 02 Apr 2024 22:08:12 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 4/5] btrfs-progs: tests-mkfs: add test case for zoned block group tree feature Date: Wed, 3 Apr 2024 08:37:39 +1030 Message-ID: <88966130f8833cfe8a3aa3511ced9b029b71ab75.1712095635.git.wqu@suse.com> X-Mailer: git-send-email 2.44.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 X-Spamd-Result: default: False [-1.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[linux-btrfs@vger.kernel.org]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -1.80 X-Spam-Level: X-Spam-Flag: NO Signed-off-by: Qu Wenruo --- tests/mkfs-tests/031-zoned-bgt/test.sh | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tests/mkfs-tests/031-zoned-bgt/test.sh diff --git a/tests/mkfs-tests/031-zoned-bgt/test.sh b/tests/mkfs-tests/031-zoned-bgt/test.sh new file mode 100755 index 000000000000..91c107cd5a3b --- /dev/null +++ b/tests/mkfs-tests/031-zoned-bgt/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Verify mkfs for zoned devices support block-group-tree feature + +source "$TEST_TOP/common" || exit + +setup_root_helper +prepare_test_dev + +nullb="$TEST_TOP/nullb" +# Create one 128M device with 4M zones, 32 of them +size=128 +zone=4 + +run_mayfail $SUDO_HELPER "$nullb" setup +if [ $? != 0 ]; then + _not_run "cannot setup nullb environment for zoned devices" +fi + +# Record any other pre-existing devices in case creation fails +run_check $SUDO_HELPER "$nullb" ls + +# Last line has the name of the device node path +out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "$size" -z "$zone") +if [ $? != 0 ]; then + _fail "cannot create nullb zoned device $i" +fi +dev=$(echo "$out" | tail -n 1) +name=$(basename "${dev}") + +run_check $SUDO_HELPER "$nullb" ls + +TEST_DEV="${dev}" +# Use single as it's supported on more kernels +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -m single -d single -O block-group-tree "${dev}" +run_check_mount_test_dev +run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 +run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" +run_check_umount_test_dev + +run_check $SUDO_HELPER "$nullb" rm "${name}" From patchwork Tue Apr 2 22:07:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13614676 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 E27D715ECE3 for ; Tue, 2 Apr 2024 22:08:16 +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=1712095698; cv=none; b=VxCAGO4mh6CnbMy7QSu1UDUqa6UhZ+URasEiUv/c5tNHHCGP/ewRP9X/19beIj3BRdljh9n2tTsakNncV4yQt3fUuvN9q1eMqAZTeWd9UJdtJunLToVOipbPR/4bo7HhEe2gP3x7DR/e3rbXruR5mMg9nXO7rAhwgHVA6hrPEa8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712095698; c=relaxed/simple; bh=6qFWotBaRh3xKSe+GspsQt4Z1oIVqAShKghCdIY3YGw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n0dRibJ8TblvuSnU6DUzxCGURSg5TCWlElcnXWo0oMgCVaVo/yj6u7GDxM076dkQeu47aIMV3isDQ44hMN6sgADgodamaFeaiXyJtiWqlmP0o/gZV8n+deU293W9MgnpgJf/wDYW4C9hE4rRIlJtjy40/Trf2itF+SJYSZKY0qk= 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=r0090IhT; arc=none smtp.client-ip=195.135.223.130 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="r0090IhT" 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 2C6B334BD1 for ; Tue, 2 Apr 2024 22:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712095695; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JxUTII/S0U5aofQ2nYiUooFyplSuZEkMIVtDfxuvjG8=; b=r0090IhTbHROdZfp3W5D+OMKe7SCGIn/uxNCXrl2KIJ1sGSMDABUTFH/avTKdKwdM7ILpq PEohiNzmWfcFAmaDMkmRI1CdShFHHr7kEeRF6zm2pXemyLuTk0prllJtuzk3wQDxeQCqJK iCZj859P6lRzcM16FKWEg4H1Emb+bOI= Authentication-Results: smtp-out1.suse.de; none 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 59A6513A90 for ; Tue, 2 Apr 2024 22:08:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id GL2zA86BDGYIdwAAn2gu4w (envelope-from ) for ; Tue, 02 Apr 2024 22:08:14 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 5/5] btrfs-progs: tests-misc: add a test case to check zoned bgt conversion Date: Wed, 3 Apr 2024 08:37:40 +1030 Message-ID: <7b9e0f7997c95c4870c6a0d006a84239653e12d9.1712095635.git.wqu@suse.com> X-Mailer: git-send-email 2.44.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 X-Spamd-Result: default: False [-1.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[linux-btrfs@vger.kernel.org]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -1.80 X-Spam-Level: X-Spam-Flag: NO Add a new test case to make sure: - btrfstune can convert a zoned btrfs with extent tree to bgt - btrfstune can convert a zoned btrfs with bgt back to extent tree Signed-off-by: Qu Wenruo --- .../063-btrfstune-zoned-bgt/test.sh | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tests/misc-tests/063-btrfstune-zoned-bgt/test.sh diff --git a/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh b/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh new file mode 100755 index 000000000000..dc2003cc78ab --- /dev/null +++ b/tests/misc-tests/063-btrfstune-zoned-bgt/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Verify btrfstune for zoned devices with block-group-tree conversion + +source "$TEST_TOP/common" || exit + +setup_root_helper +prepare_test_dev + +nullb="$TEST_TOP/nullb" +# Create one 128M device with 4M zones, 32 of them +size=128 +zone=4 + +run_mayfail $SUDO_HELPER "$nullb" setup +if [ $? != 0 ]; then + _not_run "cannot setup nullb environment for zoned devices" +fi + +# Record any other pre-existing devices in case creation fails +run_check $SUDO_HELPER "$nullb" ls + +# Last line has the name of the device node path +out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "$size" -z "$zone") +if [ $? != 0 ]; then + _fail "cannot create nullb zoned device $i" +fi +dev=$(echo "$out" | tail -n 1) +name=$(basename "${dev}") + +run_check $SUDO_HELPER "$nullb" ls + +TEST_DEV="${dev}" + +# Create the fs without bgt +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m single -d single -O ^block-group-tree "${dev}" +run_check_mount_test_dev +run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file1 bs=1M count=1 +run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" +run_check_umount_test_dev + +# Convert to bgt +run_check $SUDO_HELPER "$TOP/btrfstune" --convert-to-block-group-tree "${dev}" +run_check_mount_test_dev +run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file2 bs=1M count=1 +run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" +run_check_umount_test_dev + +# And convert back to old extent tree +run_check $SUDO_HELPER "$TOP/btrfstune" --convert-from-block-group-tree "${dev}" +run_check_mount_test_dev +run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file3 bs=1M count=1 +run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" +run_check_umount_test_dev + +run_check $SUDO_HELPER "$nullb" rm "${name}"