Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp888053pxb; Tue, 9 Feb 2021 15:40:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJMpWc6+gOV8Ef4aoIUDujkLa5qN1RUmW6cygquhldURv7qNvZtb6Ysi3UzjGWaC8vPjKI X-Received: by 2002:a17:906:5d15:: with SMTP id g21mr113635ejt.373.1612914006606; Tue, 09 Feb 2021 15:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612914006; cv=none; d=google.com; s=arc-20160816; b=Zfi5UcU++XIz1U8yutBuXdFXA0ge2fqI55qxgsqH/0UJ4DfebdH7tHZOsqo1lx6CYg /nQevdu5rDFSLYiRhXc/7+ytk8DEtBpwRCZNvFiNFbkTojUyJf7z02Orbe0zw/x6oUOq uqWGfwMl21UAzdNlTvybeNt6IpLkkplgX5dQsi0GrVRDnJPYS+B/SB4q+IhSuJcvEH+f +CwFP8YL6ogpVsKdesh9y+7sk8mCyi92xkF+IU7ovUd4mtMj8UwAuayG5eatFdbc0wvR zwadCTs1AKSr6vonqBN1KXvGIVDBgoRg25POe0GkWIPCuqdbRCRrFFtH1k5ZiFo0bwg+ TyLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6x3qWIHo5GAirAO5PKB3edXrJzac7FmvhXNFBGyW0BI=; b=v0P/htKPwBGxkeng3phxcXuwDyFcF6IPTRKZ5DSz3hzxGgmU5YzQFVB+Udzs5So0DC +qQ9tS0Xme0H5mfzYessUJqRakUZPH4Pti0cL0j5HB0QTNNDx8XSPfhgbmsE9kb/SO9e gVS/xnXLzivmGWhDoPtGPvOpv5uEaO1fc6504WjOimC3WwHcAapO2BQrbnUAi7vO7Ndx AIOdYNiAEBiXpHeDQ5oob5apqW6FZ2DjPKNONmsJP7jbIK/9B/h05ckEEwkzEhA7KbBe g1EGCRrk1571jHV3ZkgziOBeNk7tg5znEdQCdpPZ3bGsfswqhgsPokWvUz4lbhAKwQX4 25nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si177143edv.245.2021.02.09.15.39.42; Tue, 09 Feb 2021 15:40:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234207AbhBIXiZ (ORCPT + 99 others); Tue, 9 Feb 2021 18:38:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:38608 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbhBIUdz (ORCPT ); Tue, 9 Feb 2021 15:33:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 98BBDB109; Tue, 9 Feb 2021 20:31:21 +0000 (UTC) From: Michal Rostecki To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM), linux-kernel@vger.kernel.org (open list) Cc: Michal Rostecki Subject: [PATCH RFC 2/6] btrfs: Store the last device I/O offset Date: Tue, 9 Feb 2021 21:30:36 +0100 Message-Id: <20210209203041.21493-3-mrostecki@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210209203041.21493-1-mrostecki@suse.de> References: <20210209203041.21493-1-mrostecki@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Rostecki 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 --- 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