lkml.org 
[lkml]   [2021]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC 2/6] btrfs: Store the last device I/O offset
Date
From: Michal Rostecki <mrostecki@suse.com>

Add an atomic field which stores the physical offset of the last I/O
operation scheduled to the device. This information is going to be used
to measure the locality of I/O requests.

Signed-off-by: Michal Rostecki <mrostecki@suse.com>
---
fs/btrfs/volumes.c | 4 ++++
fs/btrfs/volumes.h | 1 +
2 files changed, 5 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index d4f452dcce95..292175206873 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -444,6 +444,7 @@ static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info)
kfree(dev);
return ERR_PTR(-ENOMEM);
}
+ atomic_set(&dev->last_offset, 0);

return dev;
}
@@ -6368,11 +6369,13 @@ static void submit_stripe_bio(struct btrfs_bio *bbio, struct bio *bio,
u64 physical, struct btrfs_device *dev)
{
struct btrfs_fs_info *fs_info = bbio->fs_info;
+ u64 length;

bio->bi_private = bbio;
btrfs_io_bio(bio)->device = dev;
bio->bi_end_io = btrfs_end_bio;
bio->bi_iter.bi_sector = physical >> 9;
+ length = bio->bi_iter.bi_size;
btrfs_debug_in_rcu(fs_info,
"btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u",
bio_op(bio), bio->bi_opf, bio->bi_iter.bi_sector,
@@ -6382,6 +6385,7 @@ static void submit_stripe_bio(struct btrfs_bio *bbio, struct bio *bio,

btrfs_bio_counter_inc_noblocked(fs_info);
percpu_counter_inc(&dev->inflight);
+ atomic_set(&dev->last_offset, physical + length);

btrfsic_submit_bio(bio);
}
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 938c5292250c..6e544317a377 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -146,6 +146,7 @@ struct btrfs_device {

/* I/O stats for raid1 mirror selection */
struct percpu_counter inflight;
+ atomic_t last_offset;
};

/*
--
2.30.0
\
 
 \ /
  Last update: 2021-02-10 00:40    [W:0.246 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site