Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-5.12-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fix from David Sterba:
"One more patch that we'd like to get to 5.12 before release.

It's changing where and how the superblock is stored in the zoned
mode. It is an on-disk format change but so far there are no
implications for users as the proper mkfs support hasn't been merged
and is waiting for the kernel side to settle.

Until now, the superblocks were derived from the zone index, but zone
size can differ per device. This is changed to be based on fixed
offset values, to make it independent of the device zone size.

The work on that got a bit delayed, we discussed the exact locations
to support potential device sizes and usecases. (Partially delayed
also due to my vacation.) Having that in the same release where the
zoned mode is declared usable is highly desired, there are userspace
projects that need to be updated to recognize the feature. Pushing
that to the next release would make things harder to test"

* tag 'for-5.12-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: zoned: move superblock logging zone location

+42 -11
+42 -11
fs/btrfs/zoned.c
··· 21 21 /* Pseudo write pointer value for conventional zone */ 22 22 #define WP_CONVENTIONAL ((u64)-2) 23 23 24 + /* 25 + * Location of the first zone of superblock logging zone pairs. 26 + * 27 + * - primary superblock: 0B (zone 0) 28 + * - first copy: 512G (zone starting at that offset) 29 + * - second copy: 4T (zone starting at that offset) 30 + */ 31 + #define BTRFS_SB_LOG_PRIMARY_OFFSET (0ULL) 32 + #define BTRFS_SB_LOG_FIRST_OFFSET (512ULL * SZ_1G) 33 + #define BTRFS_SB_LOG_SECOND_OFFSET (4096ULL * SZ_1G) 34 + 35 + #define BTRFS_SB_LOG_FIRST_SHIFT const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET) 36 + #define BTRFS_SB_LOG_SECOND_SHIFT const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET) 37 + 24 38 /* Number of superblock log zones */ 25 39 #define BTRFS_NR_SB_LOG_ZONES 2 40 + 41 + /* 42 + * Maximum supported zone size. Currently, SMR disks have a zone size of 43 + * 256MiB, and we are expecting ZNS drives to be in the 1-4GiB range. We do not 44 + * expect the zone size to become larger than 8GiB in the near future. 45 + */ 46 + #define BTRFS_MAX_ZONE_SIZE SZ_8G 26 47 27 48 static int copy_zone_info_cb(struct blk_zone *zone, unsigned int idx, void *data) 28 49 { ··· 132 111 } 133 112 134 113 /* 135 - * The following zones are reserved as the circular buffer on ZONED btrfs. 136 - * - The primary superblock: zones 0 and 1 137 - * - The first copy: zones 16 and 17 138 - * - The second copy: zones 1024 or zone at 256GB which is minimum, and 139 - * the following one 114 + * Get the first zone number of the superblock mirror 140 115 */ 141 116 static inline u32 sb_zone_number(int shift, int mirror) 142 117 { 143 - ASSERT(mirror < BTRFS_SUPER_MIRROR_MAX); 118 + u64 zone; 144 119 120 + ASSERT(mirror < BTRFS_SUPER_MIRROR_MAX); 145 121 switch (mirror) { 146 - case 0: return 0; 147 - case 1: return 16; 148 - case 2: return min_t(u64, btrfs_sb_offset(mirror) >> shift, 1024); 122 + case 0: zone = 0; break; 123 + case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break; 124 + case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break; 149 125 } 150 126 151 - return 0; 127 + ASSERT(zone <= U32_MAX); 128 + 129 + return (u32)zone; 152 130 } 153 131 154 132 /* ··· 320 300 zone_sectors = bdev_zone_sectors(bdev); 321 301 } 322 302 323 - nr_sectors = bdev_nr_sectors(bdev); 324 303 /* Check if it's power of 2 (see is_power_of_2) */ 325 304 ASSERT(zone_sectors != 0 && (zone_sectors & (zone_sectors - 1)) == 0); 326 305 zone_info->zone_size = zone_sectors << SECTOR_SHIFT; 306 + 307 + /* We reject devices with a zone size larger than 8GB */ 308 + if (zone_info->zone_size > BTRFS_MAX_ZONE_SIZE) { 309 + btrfs_err_in_rcu(fs_info, 310 + "zoned: %s: zone size %llu larger than supported maximum %llu", 311 + rcu_str_deref(device->name), 312 + zone_info->zone_size, BTRFS_MAX_ZONE_SIZE); 313 + ret = -EINVAL; 314 + goto out; 315 + } 316 + 317 + nr_sectors = bdev_nr_sectors(bdev); 327 318 zone_info->zone_size_shift = ilog2(zone_info->zone_size); 328 319 zone_info->max_zone_append_size = 329 320 (u64)queue_max_zone_append_sectors(queue) << SECTOR_SHIFT;