Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5e49c78
btrfs: add flags to give an hint to the chunk allocator
kreijack Oct 24, 2021
160344a
btrfs: export dev_item.type in /sys/fs/btrfs/<uuid>/devinfo/<devid>/type
kreijack Oct 24, 2021
29637f2
btrfs: change the DEV_ITEM 'type' field via sysfs
kreijack Oct 24, 2021
970b99e
btrfs: add allocator_hint mode
kreijack Oct 24, 2021
1c1f2e2
btrfs: add allocator_hint for no allocation preferred
kakra Jun 27, 2024
82553ef
btrfs: add allocator_hint to disable allocation completely
kakra Dec 5, 2024
10248db
btrfs: simplify output formatting in btrfs_read_policy_show
asj Jan 1, 2025
4a49a27
btrfs: initialize fs_devices->fs_info earlier
asj Jan 1, 2025
ccb2922
btrfs: add btrfs_read_policy_to_enum helper and refactor read policy …
asj Jan 1, 2025
cf73e90
btrfs: add tracking of read blocks for read policy
asj Jan 1, 2025
7070070
btrfs: introduce CONFIG_BTRFS_EXPERIMENTAL from 6.13
kakra Sep 16, 2024
3efa6c7
btrfs: handle value associated with read policy parameter
asj Jan 1, 2025
6f1b9b1
btrfs: introduce RAID1 round-robin read balancing
kakra May 2, 2025
6fcee9b
btrfs: add RAID1 preferred read device
asj Jan 1, 2025
b627950
btrfs: expose experimental mode in module information
asj Jan 1, 2025
108c5e8
btrfs: enable read policy configuration via modprobe parameter
asj Jan 1, 2025
b2c5980
btrfs: modload to print read policy status
asj Jan 1, 2025
65b747f
btrfs: use the path with the lowest latency for RAID1 reads
asj Oct 11, 2024
a6dfeed
btrfs: move latency-based selection into helper
kakra Apr 9, 2025
c9b6612
btrfs: fix btrfs_read_rr to use the actual number of stripes
kakra Apr 9, 2025
5aa9fb5
btrfs: create a helper instead of open coding device latency calculation
kakra Apr 15, 2025
a451102
btrfs: add filtering by latency to btrfs_read_rr
kakra Apr 14, 2025
9e88f8e
btrfs: add hybrid latency-rr read policy
kakra Apr 18, 2025
eee7666
btrfs: add devinfo read stats to sysfs
kakra Apr 16, 2025
7437625
btrfs: add last IO age to sysfs read_stats
kakra Apr 16, 2025
7c776c2
btrfs: probe read latency if device is 1000 IOs behind its siblings
kakra Apr 16, 2025
fbeb5da
btrfs: allow a short burst of IO for probing read latency
kakra Apr 17, 2025
919eaf1
btrfs: use checkpoint latency instead of cumulative latency
kakra Apr 20, 2025
6f8dc12
btrfs: stat latency checkpoints to get more insight
kakra Apr 20, 2025
18c0ef0
btrfs: rename thresholds to better match with the checkpoint logic
kakra Apr 20, 2025
f4f2455
btrfs: add a stripe ignored counter
kakra Apr 20, 2025
db46d71
btrfs: tune age and burst for latency checkpoint
kakra Apr 21, 2025
504aea7
btrfs: add in-flight queue read policy
kakra Apr 25, 2025
e905c0c
btrfs: guard access to bdev in latency stats and inflight calculation
kakra Apr 27, 2025
740955e
btrfs: reduce atomic reads where possible in btrfs_device_read_latency
kakra May 1, 2025
abf6174
TEST: btrfs: btrfs_backref_resched.patch
fdmanana Jun 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
btrfs: use checkpoint latency instead of cumulative latency
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
kakra committed May 2, 2025
commit 919eaf1aedd76b258e3d40c72e8633d4563151f2
33 changes: 21 additions & 12 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6013,17 +6013,21 @@ static int btrfs_read_preferred(struct btrfs_chunk_map *map, int first,
* Compute the average latency of the device by dividing total latency by
* number of IOs.
*/
#define BTRFS_MAX_AGE_FOR_VALID_LATENCY 1000
#define BTRFS_MAX_AGE_FOR_VALID_LATENCY 10000
static u64 btrfs_device_read_latency(struct btrfs_device *device)
{
u64 read_wait = part_stat_read(device->bdev, nsecs[READ]);
u64 last_nsecs_read = (u64)atomic64_read(&device->last_nsecs_read);
unsigned long read_ios = part_stat_read(device->bdev, ios[READ]);
unsigned long last_ios_read = (unsigned long)atomic64_read(&device->last_ios_read);
u64 last_io_age = (u64)atomic64_read(&device->last_io_age);
u64 avg_wait = 0;
s64 delta_read_wait = read_wait - last_nsecs_read;
s64 delta_read_ios = read_ios - last_ios_read;

if (last_io_age >= 0 && last_io_age < BTRFS_MAX_AGE_FOR_VALID_LATENCY
&& read_wait && read_ios && read_wait >= read_ios)
avg_wait = div_u64(read_wait, read_ios);
&& delta_read_wait > 0 && delta_read_ios > 0 && delta_read_wait >= delta_read_ios)
avg_wait = div_u64(delta_read_wait, delta_read_ios);

return avg_wait;
}
Expand Down Expand Up @@ -6174,7 +6178,7 @@ static int btrfs_read_fastest_rr(struct btrfs_fs_info *fs_info,
}
#endif

#define BTRFS_OLD_AGE_IO_BURST 20
#define BTRFS_OLD_AGE_IO_BURST 100
static int find_live_mirror(struct btrfs_fs_info *fs_info,
struct btrfs_chunk_map *map, int first,
int dev_replace_is_ongoing)
Expand Down Expand Up @@ -6256,19 +6260,24 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,

out:
#ifdef CONFIG_BTRFS_EXPERIMENTAL
/* reset age of selected stripe */
s64 current_age, new_age;
do {
current_age = atomic64_read(&map->stripes[preferred_mirror].dev->last_io_age);
/* reset age of selected stripe */
s64 current_age;
struct btrfs_device *pref_dev = map->stripes[preferred_mirror].dev;

spin_lock(&pref_dev->latency_lock);

current_age = atomic64_read(&pref_dev->last_io_age);
if (current_age >= BTRFS_MAX_AGE_FOR_VALID_LATENCY) {
new_age = -BTRFS_OLD_AGE_IO_BURST;
atomic64_set(&pref_dev->last_io_age, -BTRFS_OLD_AGE_IO_BURST);
atomic64_set(&pref_dev->last_nsecs_read, part_stat_read(pref_dev->bdev, nsecs[READ]));
atomic64_set(&pref_dev->last_ios_read, part_stat_read(pref_dev->bdev, ios[READ]));
} else if (current_age >= 0) {
new_age = 0;
} else {
return preferred_mirror;
atomic64_set(&pref_dev->last_io_age, 0);
}
} while (unlikely(atomic64_cmpxchg(&map->stripes[preferred_mirror].dev->last_io_age, current_age, new_age) != current_age));

spin_unlock(&pref_dev->latency_lock);
} while (0);
#endif

/* we couldn't find one that doesn't fail. Just return something
Expand Down
7 changes: 7 additions & 0 deletions fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ struct btrfs_device {
#ifdef CONFIG_BTRFS_EXPERIMENTAL
/* store an age of last read access */
atomic64_t last_io_age;

/* lock while updating values */
spinlock_t latency_lock;

/* last latency values for short term latency calculation */
atomic64_t last_nsecs_read;
atomic64_t last_ios_read;
#endif
};

Expand Down