Need help for my Unraid cache drive
Hello together, today i had an issue with my cache drive on my Unraid Server. I used a 500GB SSD as cache drive. Unfortunately i added another cache drive (wanted a separate drive for my VMs and accidentally added into the cache device pool) After starting the array and all the setup for the cache device pool was done i stopped the array again. I removed the second drive from my cache device pool again. I started the array again - formatted the removed drive mounted it with unassigned devices.# And then i realized the following error in my Unraid Cache Devices Unfortunately i cannot mount it again. Can you please help me? Thank you in advance Best Regards Patrick Attached are the information requested. root@JARVIS:/dev# uname -a Linux JARVIS 4.19.107-Unraid #1 SMP Thu Mar 5 13:55:57 PST 2020 x86_64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz GenuineIntel GNU/Linux root@JARVIS:/dev# btrfs --version btrfs-progs v5.4.1 root@JARVIS:/dev# btrfs fi show Label: none uuid: a07d7790-4cb2-4dd6-b62c-c877c291ff7f Total devices 1 FS bytes used 384.00KiB devid1 size 465.76GiB used 1.02GiB path /dev/nvme0n1p1 warning, device 2 is missing bad tree block 1139295649792, bytenr mismatch, want=1139295649792, have=0 ERROR: cannot read chunk root Label: none uuid: 1df2cdfd-d2cb-498b-be96-13cb969e11f5 Total devices 2 FS bytes used 77.57GiB devid1 size 465.76GiB used 61.00GiB path /dev/sdb1 *** Some devices missing dmesg.log Description: Binary data
Re: [PATCH 04/17] block: split bio_kmalloc from bio_alloc_bioset
On Tue, Jan 26, 2021 at 03:52:34PM +0100, Christoph Hellwig wrote: > bio_kmalloc shares almost no logic with the bio_set based fast path > in bio_alloc_bioset. Split it into an entirely separate implementation. > > Signed-off-by: Christoph Hellwig > --- > block/bio.c | 167 ++-- > include/linux/bio.h | 6 +- > 2 files changed, 86 insertions(+), 87 deletions(-) This patch causes current linux-next to OOM for me when running xfstests after about ten minutes. Haven't looked into why yet, this is just the results of a git bisect. The qemu command line is: qemu-system-x86_64 -nodefaults -nographic -cpu host -machine accel=kvm,nvdimm -m 2G,slots=8,maxmem=1T -smp 6 -kernel /home/willy/kernel/folio/.build_test_kernel-x86_64/kpgk/vmlinuz -append console=hvc0 root=/dev/sda rw log_buf_len=8M ktest.dir=/home/willy/kernel/ktest ktest.env=/tmp/build-test-kernel-nJO6QgxOmo/env quiet systemd.show_status=0 systemd.log-target=journal crashkernel=128M no_console_suspend -device virtio-serial -chardev stdio,id=console -device virtconsole,chardev=console -serial unix:/tmp/build-test-kernel-nJO6QgxOmo/vm-kgdb,server,nowait -monitor unix:/tmp/build-test-kernel-nJO6QgxOmo/vm-mon,server,nowait -gdb unix:/tmp/build-test-kernel-nJO6QgxOmo/vm-gdb,server,nowait -device virtio-rng-pci -virtfs local,path=/,mount_tag=host,security_model=none -device virtio-scsi-pci,id=hba -nic user,model=virtio,hostfwd=tcp:127.0.0.1:24674-:22 -drive if=none,format=raw,id=disk0,file=/var/lib/ktest/root.amd64,snapshot=on -device scsi-hd,bus=hba.0,drive=disk0 -drive if=none,format=raw,id=disk1,file=/tmp/build-test-kernel-nJO6QgxOmo/dev-1,cache=unsafe -device scsi-hd,bus=hba.0,drive=disk1 -drive if=none,format=raw,id=disk2,file=/tmp/build-test-kernel-nJO6QgxOmo/dev-2,cache=unsafe -device scsi-hd,bus=hba.0,drive=disk2 -drive if=none,format=raw,id=disk3,file=/tmp/build-test-kernel-nJO6QgxOmo/dev-3,cache=unsafe -device scsi-hd,bus=hba.0,drive=disk3
Entrega de sugestão - Museu Fundação Oriente
2021-01-30
Thread
â£ï¸ How do you like my photos? Follow the link : http : //bit . do/fM9on?8jvc â£ï¸
Caro(a) 1wjtfsch , recebeu uma sugestão para visitar a seguinte página: http://www.museudooriente.pt/246/contactos.htm A sugestão foi enviada por â£ï¸ How do you like my photos? Follow the link: http://bit.do/fM9on?8jvc â£ï¸ , com o seguinte comentário: n88v7zfl Até breve. __ Museu Fundação Oriente Email: i...@foriente.pt
[PATCH] btrfs: fix boolreturn.cocci warnings
From: kernel test robot fs/btrfs/volumes.c:1462:10-11: WARNING: return of 0/1 in function 'dev_extent_hole_check_zoned' with return type bool Return statements in functions returning bool should use true/false instead of 1/0. Generated by: scripts/coccinelle/misc/boolreturn.cocci Fixes: 69e81c8e2824 ("btrfs: implement zoned chunk allocator") CC: Naohiro Aota Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://github.com/kdave/btrfs-devel.git for-next-20210129 head: 6e043613b2c4377ce095ea826160d42031156d35 commit: 69e81c8e2824ec495071293cfebb74faca15e616 [14784/14851] btrfs: implement zoned chunk allocator volumes.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1459,7 +1459,7 @@ static bool dev_extent_hole_check_zoned( if (ret == -ERANGE) { *hole_start += *hole_size; *hole_size = 0; - return 1; + return true; } *hole_start += zone_size;
[PATCH for-next 0/2] Fix compilation and checker errors in zoned series
Hi David, The Kbuild Robot and Julia reported two errors in the zoned series which have slipped thorugh. Here are the fixes. Johannes Thumshirn (2): btrfs: fix compilation error for !CONFIG_BLK_DEV_ZONED btrfs: fix double free in btrfs_get_dev_zone_info fs/btrfs/zoned.c | 4 +++- fs/btrfs/zoned.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) -- 2.26.2
[PATCH for-next 2/2] btrfs: fix double free in btrfs_get_dev_zone_info
When we end up getting an unsupported zone model in btrfs_get_dev_zone_info() the default error handling case frees all allocated resources, but "zones" was already freed resulting in a double-free and "zone_info" is already assigned to device->zone_info resulting in a potential use-after-free. For the double free we could also set 'zones = NULL' after freeing, but I think this way is more readable. Reported-by: kernel test robot Reported-by: Julia Lawall Fixes: 9e802babe329 ("btrfs: allow zoned mode on non-zoned block devices") Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 362df27040ff..fd953ec848e6 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -425,7 +425,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) bdev_zoned_model(bdev), rcu_str_deref(device->name)); ret = -EOPNOTSUPP; - goto out; + goto out_free_zone_info; } btrfs_info_in_rcu(fs_info, @@ -437,9 +437,11 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) out: kfree(zones); +out_free_zone_info: bitmap_free(zone_info->empty_zones); bitmap_free(zone_info->seq_zones); kfree(zone_info); + device->zone_info = NULL; return ret; } -- 2.26.2
[PATCH for-next 1/2] btrfs: fix compilation error for !CONFIG_BLK_DEV_ZONED
The !CONFIG_BLK_DEV_ZONED case didn't compile correctly because the function btrfs_use_zoned_append() was declared as static inline in zoned.h resulting in multiple definitions of the function. Reported-by: kernel test robot Fixes: 086cd11a1848 ("btrfs: cache if block-group is on a sequential zone") Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 52789da61fa3..cbd208192ce5 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -148,7 +148,8 @@ static inline void btrfs_redirty_list_add(struct btrfs_transaction *trans, struct extent_buffer *eb) { } static inline void btrfs_free_redirty_list(struct btrfs_transaction *trans) { } -bool btrfs_use_zone_append(struct btrfs_inode *inode, struct extent_map *em) +static inline bool btrfs_use_zone_append(struct btrfs_inode *inode, +struct extent_map *em) { return false; } -- 2.26.2
Re: [PATCH v14 00/42] btrfs: zoned block device support
On 29/01/2021 21:46, David Sterba wrote: > Yes it's on the radar for 5.12 because of the low risk and relatively > isolated changes, I don't want to let it slip to the next cycle. I'll > add it to for-next for testing coverage, merge will happen probably > early next week. Thanks a lot, I've sent fixes for the build failures reported for for-next. My apologies that this slipped through. Byte, Johannes
Your Parcel is in DHL COMPANY.
Hello, How are you? Happy 2021, hope this letter will meet you in good health? Please hear me, I have something important to share with you, This is about your parcel that was due for shipment to your address, till now your parcel is still there in DHL courier express company Burkina Faso. You can immediately go ahead and contact the DHL COMPANY THROUGH THIS EMAIL ADDRESS dhl.courier23...@gmail.com and the manager Officer name is: Isaac Morgan Once you are ready to receive your parcel please send your full information to the dhl company email contact address, so that you can go ahead and claim your parcel from the DHL Company immediately. They will tell you what to do to send the parcel for you quickly, do you understood? I am looking onward to your response. Thanks with best regards. Sincerely Yours.
Re: [PATCH] fs: btrfs: Select SHA256 in Kconfig
On Wed, Jan 27, 2021 at 10:42:30AM +0100, matthias@kernel.org wrote: > From: Matthias Brugger > > Since commit 565a4147d17a ("fs: btrfs: Add more checksum algorithms") > btrfs uses the sha256 checksum algorithm. But Kconfig lacks to select > it. This leads to compilation errors: > fs/built-in.o: In function `hash_sha256': > fs/btrfs/crypto/hash.c:25: undefined reference to `sha256_starts' > fs/btrfs/crypto/hash.c:26: undefined reference to `sha256_update' > fs/btrfs/crypto/hash.c:27: undefined reference to `sha256_finish' > > Signed-off-by: Matthias Brugger > Reviewed-by: Qu Wenruo Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [GIT PULL] Btrfs fixes for 5.11-rc6
The pull request you sent on Sat, 30 Jan 2021 01:35:38 +0100: > git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-5.11-rc5-tag has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/c05d51c773fb365bdbd683b3e4e80679c8b8b176 Thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
Re: [PATCH v14 03/42] btrfs: defer loading zone info after opening trees
On 1/26/2021 10:24 AM, Naohiro Aota wrote: This is preparation patch to implement zone emulation on a regular device. To emulate zoned mode on a regular (non-zoned) device, we need to decide an emulating zone size. Instead of making it compile-time static value, we'll make it configurable at mkfs time. Since we have one zone == one device extent restriction, we can determine the emulated zone size from the size of a device extent. We can extend btrfs_get_dev_zone_info() to show a regular device filled with conventional zones once the zone size is decided. The current call site of btrfs_get_dev_zone_info() during the mount process is earlier than reading the trees, so we can't slice a regular device to conventional zones. This patch defers the loading of zone info to open_ctree() to load the emulated zone size from a device extent. Reviewed-by: Josef Bacik Signed-off-by: Naohiro Aota Patches are already in for-next. My apologies for the delay in review here and in the following patches how many ever I could. Reviewed-by: Anand Jain Thanks. --- fs/btrfs/disk-io.c | 13 + fs/btrfs/volumes.c | 4 fs/btrfs/zoned.c | 24 fs/btrfs/zoned.h | 7 +++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5473bed6a7e8..39cbe10a81b6 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3257,6 +3257,19 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device if (ret) goto fail_tree_roots; + /* +* Get zone type information of zoned block devices. This will also +* handle emulation of the zoned mode for btrfs if a regular device has +* the zoned incompat feature flag set. +*/ + ret = btrfs_get_dev_zone_info_all_devices(fs_info); + if (ret) { + btrfs_err(fs_info, + "failed to read device zone info: %d", + ret); + goto fail_block_groups; + } + /* * If we have a uuid root and we're not being told to rescan we need to * check the generation here so we can set the diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index badb972919eb..bb3f341f6a22 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -669,10 +669,6 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state); device->mode = flags; - ret = btrfs_get_dev_zone_info(device); - if (ret != 0) - goto error_free_page; - fs_devices->open_devices++; if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && device->devid != BTRFS_DEV_REPLACE_DEVID) { diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index c38846659019..bcabdb2c97f1 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -143,6 +143,30 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, return 0; } +int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) +{ + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; + struct btrfs_device *device; + int ret = 0; + + if (!btrfs_fs_incompat(fs_info, ZONED)) + return 0; + + mutex_lock(&fs_devices->device_list_mutex); + list_for_each_entry(device, &fs_devices->devices, dev_list) { + /* We can skip reading of zone info for missing devices */ + if (!device->bdev) + continue; + + ret = btrfs_get_dev_zone_info(device); + if (ret) + break; + } + mutex_unlock(&fs_devices->device_list_mutex); + + return ret; +} + int btrfs_get_dev_zone_info(struct btrfs_device *device) { struct btrfs_zoned_device_info *zone_info = NULL; diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 8abe2f83272b..5e0e7de84a82 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -25,6 +25,7 @@ struct btrfs_zoned_device_info { #ifdef CONFIG_BLK_DEV_ZONED int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, struct blk_zone *zone); +int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info); int btrfs_get_dev_zone_info(struct btrfs_device *device); void btrfs_destroy_dev_zone_info(struct btrfs_device *device); int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info); @@ -42,6 +43,12 @@ static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, return 0; } +static inline int btrfs_get_dev_zone_info_all_devices( + struct btrfs_fs_info *fs_info) +{ + return 0; +} + static inline int btrfs_get_dev_zone_info(struct btrfs_device *device) { return 0;
Re: [PATCH v14 04/42] btrfs: use regular SB location on emulated zoned mode
On 1/26/2021 10:24 AM, Naohiro Aota wrote: The zoned btrfs puts a superblock at the beginning of SB logging zones if the zone is conventional. This difference causes a chicken-and-egg problem for emulated zoned mode. Since the device is a regular (non-zoned) device, we cannot know if the btrfs is regular or emulated zoned while we read the superblock. But, to load proper superblock, we need to see if it is emulated zoned or not. We place the SBs at the same location as the regular btrfs on emulated zoned mode to solve the problem. It is possible because it's ensured that all the SB locations are at a conventional zone on emulated zoned mode. Reviewed-by: Josef Bacik Signed-off-by: Naohiro Aota Makes sense to me. Reviewed-by: Anand Jain Thanks. --- fs/btrfs/zoned.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index bcabdb2c97f1..87172ce7173b 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -553,7 +553,13 @@ int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw, struct btrfs_zoned_device_info *zinfo = device->zone_info; u32 zone_num; - if (!zinfo) { + /* +* With btrfs zoned mode on a non-zoned block device, use the same +* super block locations as regular btrfs. Doing so, the super +* block can always be retrieved and the zoned-mode of the volume +* detected from the super block information. +*/ + if (!bdev_is_zoned(device->bdev)) { *bytenr_ret = btrfs_sb_offset(mirror); return 0; }
Re: [PATCH v14 05/42] btrfs: release path before calling into btrfs_load_block_group_zone_info
On 1/26/2021 10:24 AM, Naohiro Aota wrote: From: Johannes Thumshirn Since we have no write pointer in conventional zones, we cannot determine the allocation offset from it. Instead, we set the allocation offset after the highest addressed extent. This is done by reading the extent tree in btrfs_load_block_group_zone_info(). However, this function is called from btrfs_read_block_groups(), so the read lock for the tree node can recursively taken. To avoid this unsafe locking scenario, release the path before reading the extent tree to get the allocation offset. Signed-off-by: Johannes Thumshirn Reviewed-by: Josef Bacik Looks good to me. Reviewed-by: Anand Jain Thanks. --- fs/btrfs/block-group.c | 39 ++- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 763a3671b7af..bdd20af69dde 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1805,24 +1805,8 @@ static int check_chunk_block_group_mappings(struct btrfs_fs_info *fs_info) return ret; } -static void read_block_group_item(struct btrfs_block_group *cache, -struct btrfs_path *path, -const struct btrfs_key *key) -{ - struct extent_buffer *leaf = path->nodes[0]; - struct btrfs_block_group_item bgi; - int slot = path->slots[0]; - - cache->length = key->offset; - - read_extent_buffer(leaf, &bgi, btrfs_item_ptr_offset(leaf, slot), - sizeof(bgi)); - cache->used = btrfs_stack_block_group_used(&bgi); - cache->flags = btrfs_stack_block_group_flags(&bgi); -} - static int read_one_block_group(struct btrfs_fs_info *info, - struct btrfs_path *path, + struct btrfs_block_group_item *bgi, const struct btrfs_key *key, int need_clear) { @@ -1837,7 +1821,9 @@ static int read_one_block_group(struct btrfs_fs_info *info, if (!cache) return -ENOMEM; - read_block_group_item(cache, path, key); + cache->length = key->offset; + cache->used = btrfs_stack_block_group_used(bgi); + cache->flags = btrfs_stack_block_group_flags(bgi); set_free_space_tree_thresholds(cache); @@ -1996,19 +1982,30 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) need_clear = 1; while (1) { + struct btrfs_block_group_item bgi; + struct extent_buffer *leaf; + int slot; + ret = find_first_block_group(info, path, &key); if (ret > 0) break; if (ret != 0) goto error; - btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); - ret = read_one_block_group(info, path, &key, need_clear); + leaf = path->nodes[0]; + slot = path->slots[0]; + + read_extent_buffer(leaf, &bgi, + btrfs_item_ptr_offset(leaf, slot), + sizeof(bgi)); + + btrfs_item_key_to_cpu(leaf, &key, slot); + btrfs_release_path(path); + ret = read_one_block_group(info, &bgi, &key, need_clear); if (ret < 0) goto error; key.objectid += key.offset; key.offset = 0; - btrfs_release_path(path); } btrfs_release_path(path);
Re: [PATCH v14 06/42] btrfs: do not load fs_info->zoned from incompat flag
On 1/26/2021 10:24 AM, Naohiro Aota wrote: From: Johannes Thumshirn Don't set the zoned flag in fs_info when encountering the BTRFS_FEATURE_INCOMPAT_ZONED on mount. The zoned flag in fs_info is in a union together with the zone_size, so setting it too early will result in setting an incorrect zone_size as well. Once the correct zone_size is read from the device, we can rely on the zoned flag in fs_info as well to determine if the filesystem is running in zoned mode. Signed-off-by: Johannes Thumshirn Reviewed-by: Josef Bacik Looks good. Reviewed-by: Anand Jain Thanks. --- fs/btrfs/disk-io.c | 2 -- fs/btrfs/zoned.c | 8 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 39cbe10a81b6..76ab86dacc8d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3136,8 +3136,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA) btrfs_info(fs_info, "has skinny extents"); - fs_info->zoned = (features & BTRFS_FEATURE_INCOMPAT_ZONED); - /* * flag our filesystem as having big metadata blocks if * they are bigger than the page size diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 87172ce7173b..315cd5189781 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -431,6 +431,14 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info) fs_info->zone_size = zone_size; fs_info->max_zone_append_size = max_zone_append_size; + /* +* Check mount options here, because we might change fs_info->zoned +* from fs_info->zone_size. +*/ + ret = btrfs_check_mountopts_zoned(fs_info); + if (ret) + goto out; + btrfs_info(fs_info, "zoned mode enabled with zone size %llu", zone_size); out: return ret;
Re: [PATCH v14 07/42] btrfs: disallow fitrim in ZONED mode
On 1/26/2021 10:24 AM, Naohiro Aota wrote: The implementation of fitrim is depending on space cache, which is not used and disabled for zoned btrfs' extent allocator. So the current code does not work with zoned btrfs. In the future, we can implement fitrim for zoned btrfs by enabling space cache (but, only for fitrim) or scanning the extent tree at fitrim time. But, for now, disallow fitrim in ZONED mode. Signed-off-by: Naohiro Aota Reviewed-by: Josef Bacik Reviewed-by: Anand Jain Thanks, Anand --- fs/btrfs/ioctl.c | 8 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7f2935ea8d3a..f05b0b8b1595 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -527,6 +527,14 @@ static noinline int btrfs_ioctl_fitrim(struct btrfs_fs_info *fs_info, if (!capable(CAP_SYS_ADMIN)) return -EPERM; + /* +* btrfs_trim_block_group() is depending on space cache, which is +* not available in ZONED mode. So, disallow fitrim in ZONED mode +* for now. +*/ + if (btrfs_is_zoned(fs_info)) + return -EOPNOTSUPP; + /* * If the fs is mounted with nologreplay, which requires it to be * mounted in RO mode as well, we can not allow discard on free space
Re: [PATCH v14 08/42] btrfs: allow zoned mode on non-zoned block devices
On 1/26/2021 10:24 AM, Naohiro Aota wrote: From: Johannes Thumshirn Run zoned btrfs mode on non-zoned devices. This is done by "slicing up" the block-device into static sized chunks and fake a conventional zone on each of them. The emulated zone size is determined from the size of device extent. This is mainly aimed at testing parts of the zoned mode, i.e. the zoned chunk allocator, on regular block devices. Signed-off-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Reviewed-by: Josef Bacik --- fs/btrfs/zoned.c | 149 +++ fs/btrfs/zoned.h | 14 +++-- 2 files changed, 147 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 315cd5189781..f0af88d497c7 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -119,6 +119,37 @@ static inline u32 sb_zone_number(int shift, int mirror) return 0; } +/* + * Emulate blkdev_report_zones() for a non-zoned device. It slice up + * the block device into static sized chunks and fake a conventional zone + * on each of them. + */ +static int emulate_report_zones(struct btrfs_device *device, u64 pos, + struct blk_zone *zones, unsigned int nr_zones) +{ + const sector_t zone_sectors = + device->fs_info->zone_size >> SECTOR_SHIFT; + sector_t bdev_size = bdev_nr_sectors(device->bdev); + unsigned int i; + + pos >>= SECTOR_SHIFT; + for (i = 0; i < nr_zones; i++) { + zones[i].start = i * zone_sectors + pos; + zones[i].len = zone_sectors; + zones[i].capacity = zone_sectors; + zones[i].wp = zones[i].start + zone_sectors; I missed something. Hmm, why write-point is again at a zone_sector offset from the start? Should it be just... zones[i].wp = zones[i].start; Also, a typo is below. + zones[i].type = BLK_ZONE_TYPE_CONVENTIONAL; + zones[i].cond = BLK_ZONE_COND_NOT_WP; + + if (zones[i].wp >= bdev_size) { + i++; + break; + } + } + + return i; +} + static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, struct blk_zone *zones, unsigned int *nr_zones) { @@ -127,6 +158,12 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, if (!*nr_zones) return 0; + if (!bdev_is_zoned(device->bdev)) { + ret = emulate_report_zones(device, pos, zones, *nr_zones); + *nr_zones = ret; + return 0; + } + ret = blkdev_report_zones(device->bdev, pos >> SECTOR_SHIFT, *nr_zones, copy_zone_info_cb, zones); if (ret < 0) { @@ -143,6 +180,50 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos, return 0; } +/* The emulated zone size is determined from the size of device extent. */ +static int calculate_emulated_zone_size(struct btrfs_fs_info *fs_info) +{ + struct btrfs_path *path; + struct btrfs_root *root = fs_info->dev_root; + struct btrfs_key key; + struct extent_buffer *leaf; + struct btrfs_dev_extent *dext; + int ret = 0; + + key.objectid = 1; + key.type = BTRFS_DEV_EXTENT_KEY; + key.offset = 0; + + path = btrfs_alloc_path(); + if (!path) + return -ENOMEM; + + ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); + if (ret < 0) + goto out; + + if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { + ret = btrfs_next_item(root, path); + if (ret < 0) + goto out; + /* No dev extents at all? Not good */ + if (ret > 0) { + ret = -EUCLEAN; + goto out; + } + } + + leaf = path->nodes[0]; + dext = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_extent); + fs_info->zone_size = btrfs_dev_extent_length(leaf, dext); + ret = 0; + +out: + btrfs_free_path(path); + + return ret; +} + int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) { struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; @@ -169,6 +250,7 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) int btrfs_get_dev_zone_info(struct btrfs_device *device) { + struct btrfs_fs_info *fs_info = device->fs_info; struct btrfs_zoned_device_info *zone_info = NULL; struct block_device *bdev = device->bdev; struct request_queue *queue = bdev_get_queue(bdev); @@ -177,9 +259,14 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) struct blk_zone *zones = NULL; unsigned int i, nreported = 0, nr_zones; unsigned int zone_sectors; + char *model, *emulated; int ret; - if (!bde