From: wangyugui <wangyugui@e16-tech.com>
To: linux-btrfs@vger.kernel.org
Cc: kreijack@libero.it, wangyugui <wangyugui@e16-tech.com>
Subject: [PATCH 4/4] btrfs: tier-aware free space cacl
Date: Thu, 29 Oct 2020 13:35:56 +0800 [thread overview]
Message-ID: <20201029053556.10619-5-wangyugui@e16-tech.com> (raw)
In-Reply-To: <20201029053556.10619-1-wangyugui@e16-tech.com>
Detect some case of free space 0 because of tier policy of data.
Full support is yet TODO/FIXME.
Signed-off-by: wangyugui <wangyugui@e16-tech.com>
---
fs/btrfs/super.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c8dfa89..feb1ae3 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2105,6 +2105,9 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
int num_stripes = 1;
int i = 0, nr_devices;
const struct btrfs_raid_attr *rattr;
+ /* tier-aware */
+ int nr_top_tier = 0;
+ u8 top_tier_score = 0;
/*
* We aren't under the device list lock, so this is racy-ish, but good
@@ -2176,12 +2179,27 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
devices_info[i].dev = device;
devices_info[i].max_avail = avail_space;
+ if (devices_info[i].dev->tier_score > top_tier_score) {
+ top_tier_score = devices_info[i].dev->tier_score;
+ nr_top_tier = 1;
+ }
+ else if (devices_info[i].dev->tier_score == top_tier_score) {
+ nr_top_tier++;
+ }
+
i++;
}
rcu_read_unlock();
nr_devices = i;
+ if (fs_info->data_tier_policy == OTHER_TIER_ONLY &&
+ nr_top_tier != nr_devices && nr_devices - nr_top_tier < rattr->devs_min) {
+ /* FIXME: full support of tier-aware. */
+ *free_bytes = 0;
+ return 0;
+ }
+
btrfs_descending_sort_devices(devices_info, nr_devices);
i = nr_devices - 1;
--
2.29.1
prev parent reply other threads:[~2020-10-29 7:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 5:35 [PATCH 0/4] btrfs: basic tier support wangyugui
2020-10-29 5:35 ` [PATCH 1/4] btrfs: add tier score to device wangyugui
2020-10-29 5:35 ` [PATCH 2/4] btrfs: tiering data and metadata wangyugui
2020-10-29 5:35 ` [PATCH 3/4] btrfs: tier-aware mirror path select wangyugui
2020-10-29 5:35 ` wangyugui [this message]
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=20201029053556.10619-5-wangyugui@e16-tech.com \
--to=wangyugui@e16-tech.com \
--cc=kreijack@libero.it \
--cc=linux-btrfs@vger.kernel.org \
/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