Skip to content

Commit b3a3b02

Browse files
naotakdave
authored andcommitted
btrfs: zoned: drop optimization of zone finish
We have an optimization in do_zone_finish() to send REQ_OP_ZONE_FINISH only when necessary, i.e. we don't send REQ_OP_ZONE_FINISH when we assume we wrote fully into the zone. The assumption is determined by "alloc_offset == capacity". This condition won't work if the last ordered extent is canceled due to some errors. In that case, we consider the zone is deactivated without sending the finish command while it's still active. This inconstancy results in activating another block group while we cannot really activate the underlying zone, which causes the active zone exceeds errors like below. BTRFS error (device nvme3n2): allocation failed flags 1, wanted 520192 tree-log 0, relocation: 0 nvme3n2: I/O Cmd(0x7d) @ LBA 160432128, 127 blocks, I/O Error (sct 0x1 / sc 0xbd) MORE DNR active zones exceeded error, dev nvme3n2, sector 0 op 0xd:(ZONE_APPEND) flags 0x4800 phys_seg 1 prio class 0 nvme3n2: I/O Cmd(0x7d) @ LBA 160432128, 127 blocks, I/O Error (sct 0x1 / sc 0xbd) MORE DNR active zones exceeded error, dev nvme3n2, sector 0 op 0xd:(ZONE_APPEND) flags 0x4800 phys_seg 1 prio class 0 Fix the issue by removing the optimization for now. Fixes: 8376d9e ("btrfs: zoned: finish superblock zone once no space left for new SB") Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 2963457 commit b3a3b02

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

fs/btrfs/zoned.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,6 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
18891889
{
18901890
struct btrfs_fs_info *fs_info = block_group->fs_info;
18911891
struct map_lookup *map;
1892-
bool need_zone_finish;
18931892
int ret = 0;
18941893
int i;
18951894

@@ -1946,12 +1945,6 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
19461945
}
19471946
}
19481947

1949-
/*
1950-
* The block group is not fully allocated, so not fully written yet. We
1951-
* need to send ZONE_FINISH command to free up an active zone.
1952-
*/
1953-
need_zone_finish = !btrfs_zoned_bg_is_full(block_group);
1954-
19551948
block_group->zone_is_active = 0;
19561949
block_group->alloc_offset = block_group->zone_capacity;
19571950
block_group->free_space_ctl->free_space = 0;
@@ -1967,15 +1960,13 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
19671960
if (device->zone_info->max_active_zones == 0)
19681961
continue;
19691962

1970-
if (need_zone_finish) {
1971-
ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH,
1972-
physical >> SECTOR_SHIFT,
1973-
device->zone_info->zone_size >> SECTOR_SHIFT,
1974-
GFP_NOFS);
1963+
ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH,
1964+
physical >> SECTOR_SHIFT,
1965+
device->zone_info->zone_size >> SECTOR_SHIFT,
1966+
GFP_NOFS);
19751967

1976-
if (ret)
1977-
return ret;
1978-
}
1968+
if (ret)
1969+
return ret;
19791970

19801971
btrfs_dev_clear_active_zone(device, physical);
19811972
}

0 commit comments

Comments
 (0)