Re: [PATCH v10 12/41] btrfs: implement zoned chunk allocator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index db884b96a5ea..7831cf6c6da4 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1416,6 +1416,21 @@ static bool contains_pending_extent(struct btrfs_device *device, u64 *start,
  	return false;
  }
+static inline u64 dev_extent_search_start_zoned(struct btrfs_device *device,
+						u64 start)
+{
+	u64 tmp;
+
+	if (device->zone_info->zone_size > SZ_1M)
+		tmp = device->zone_info->zone_size;
+	else
+		tmp = SZ_1M;
+	if (start < tmp)
+		start = tmp;
+
+	return btrfs_align_offset_to_zone(device, start);
+}
+
  static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)
  {
  	switch (device->fs_devices->chunk_alloc_policy) {
@@ -1426,11 +1441,57 @@ static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)
  		 * make sure to start at an offset of at least 1MB.
  		 */
  		return max_t(u64, start, SZ_1M);
+	case BTRFS_CHUNK_ALLOC_ZONED:
+		return dev_extent_search_start_zoned(device, start);
  	default:
  		BUG();
  	}
  }

@@ -165,4 +190,13 @@ static inline bool btrfs_check_super_location(struct btrfs_device *device,
  	       !btrfs_dev_is_sequential(device, pos);
  }
+static inline u64 btrfs_align_offset_to_zone(struct btrfs_device *device,
+					     u64 pos)
+{
+	if (!device->zone_info)
+		return pos;
+
+	return ALIGN(pos, device->zone_info->zone_size);
+}
+
  #endif


 Small functions (such as above) can be opened coded to make the
 reviewing easier. The btrfs_align_offset_to_zone() and
 dev_extent_search_start_zoned() can be open coded and merged into
 the parent function dev_extent_search_start() as below...

dev_extent_search_start()
::
	case BTRFS_CHUNK_ALLOC_ZONED:
		start = max_t(u64, start,
			      max_t(u64, device->zone_info->zone_size, SZ_1M));

         return ALIGN(start, device->zone_info->zone_size);

 As of now we don't allow mix of zoned with regular device in a
 btrfs (those are verified during mount and device add/replace).
 So we don't have to check for the same again in
 btrfs_align_offset_to_zone().

Thanks.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux