linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Rostecki <mrostecki@suse.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM),
	linux-kernel@vger.kernel.org (open list)
Cc: Michal Rostecki <mrostecki@suse.com>
Subject: [PATCH RFC 2/6] btrfs: Store the last device I/O offset
Date: Tue,  9 Feb 2021 21:30:36 +0100	[thread overview]
Message-ID: <20210209203041.21493-3-mrostecki@suse.de> (raw)
In-Reply-To: <20210209203041.21493-1-mrostecki@suse.de>

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


  parent reply	other threads:[~2021-02-09 21:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 20:30 [PATCH RFC 0/6] Add roundrobin raid1 read policy Michal Rostecki
2021-02-09 20:30 ` [PATCH RFC 1/6] btrfs: Add inflight BIO request counter Michal Rostecki
2021-02-09 20:30 ` Michal Rostecki [this message]
2021-02-09 20:30 ` [PATCH RFC 3/6] btrfs: Add stripe_physical function Michal Rostecki
2021-02-09 20:30 ` [PATCH RFC 4/6] btrfs: Check if the filesystem is has mixed type of devices Michal Rostecki
2021-02-10  4:08   ` Michał Mirosław
2021-02-10 12:50     ` Michal Rostecki
2021-02-12 18:26     ` Michal Rostecki
2021-02-12 23:36       ` Michał Mirosław
2021-02-15 14:40         ` Michal Rostecki
2021-02-10 10:09   ` Filipe Manana
2021-02-10 12:55     ` Michal Rostecki
2021-02-09 20:30 ` [PATCH RFC 5/6] btrfs: sysfs: Add directory for read policies Michal Rostecki
2021-02-13 10:19   ` Greg KH
2021-02-15 14:35     ` Michal Rostecki
2021-02-15 14:59       ` Greg KH
2021-02-09 20:30 ` [PATCH RFC 6/6] btrfs: Add roundrobin raid1 read policy Michal Rostecki
2021-02-10  4:24   ` Michał Mirosław
2021-02-10 12:29     ` Michal Rostecki
2021-02-10 12:58       ` Michał Mirosław
2021-02-10 19:23         ` Michal Rostecki
2021-02-11  2:27           ` Michał Mirosław
2021-02-11 12:35             ` Michal Rostecki
2021-02-10  8:20   ` Anand Jain
2021-02-11 15:55     ` Michal Rostecki
2021-02-12 17:12       ` Michal Rostecki
2021-02-10  6:52 ` [PATCH RFC 0/6] " Anand Jain
2021-02-10 12:18   ` Michal Rostecki
2021-02-10 14:00     ` Michal Rostecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210209203041.21493-3-mrostecki@suse.de \
    --to=mrostecki@suse.de \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrostecki@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).