Skip to content

Commit cc4d585

Browse files
committed
btrfs: add allocator_hint for no allocation preferred
This is useful where you want to prevent new allocations of chunks on a disk which is going to be removed from the pool anyways, e.g. due to bad blocks or because it's slow. Signed-off-by: Kai Krakow <kai@kaishome.de>
1 parent 5d28743 commit cc4d585

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

fs/btrfs/volumes.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static const char alloc_hint_map[BTRFS_DEV_ALLOCATION_MASK_COUNT] = {
195195
[BTRFS_DEV_ALLOCATION_PREFERRED_DATA] = 0,
196196
[BTRFS_DEV_ALLOCATION_PREFERRED_METADATA] = 1,
197197
[BTRFS_DEV_ALLOCATION_METADATA_ONLY] = 2,
198+
[BTRFS_DEV_ALLOCATION_PREFERRED_NONE] = 99,
198199
/* the other values are set to 0 */
199200
};
200201
#endif
@@ -5362,7 +5363,10 @@ static int gather_device_info(struct btrfs_fs_devices *fs_devices,
53625363
* sort also by hint (metadata hint
53635364
* higher priority)
53645365
*/
5365-
devices_info[ndevs].alloc_hint = alloc_hint_map[hint];
5366+
if (hint == BTRFS_DEV_ALLOCATION_PREFERRED_NONE)
5367+
devices_info[ndevs].alloc_hint = -alloc_hint_map[hint];
5368+
else
5369+
devices_info[ndevs].alloc_hint = alloc_hint_map[hint];
53665370
}
53675371
#endif
53685372

include/uapi/linux/btrfs_tree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ struct btrfs_node {
591591
#define BTRFS_DEV_ALLOCATION_METADATA_ONLY (2ULL)
592592
/* only data chunk allowed */
593593
#define BTRFS_DEV_ALLOCATION_DATA_ONLY (3ULL)
594+
/* avoid chunk allocation if possible */
595+
#define BTRFS_DEV_ALLOCATION_PREFERRED_NONE (4ULL)
594596
/* 5..7 are unused values */
595597

596598
#endif

0 commit comments

Comments
 (0)