Skip to content

Commit 696fcd5

Browse files
clemep-siosneilbrown
authored andcommitted
md: expose max value of behind writes counter
Keep track of the maximum number of concurrent write-behind requests for an md array and exposed this number in sysfs at md/bitmap/max_backlog_used Writing any value to this file will clear it. This allows userspace to be involved in tuning bitmap/backlog. Signed-off-by: Paul Clements <paul.clements@steeleye.com> Signed-off-by: NeilBrown <neilb@suse.de>
1 parent ee8b81b commit 696fcd5

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎drivers/md/bitmap.c‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,9 +1292,14 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
12921292
if (!bitmap) return 0;
12931293

12941294
if (behind) {
1295+
int bw;
12951296
atomic_inc(&bitmap->behind_writes);
1297+
bw = atomic_read(&bitmap->behind_writes);
1298+
if (bw > bitmap->behind_writes_used)
1299+
bitmap->behind_writes_used = bw;
1300+
12961301
PRINTK(KERN_DEBUG "inc write-behind count %d/%d\n",
1297-
atomic_read(&bitmap->behind_writes), bitmap->max_write_behind);
1302+
bw, bitmap->max_write_behind);
12981303
}
12991304

13001305
while (sectors) {
@@ -2006,13 +2011,35 @@ static ssize_t can_clear_store(mddev_t *mddev, const char *buf, size_t len)
20062011
static struct md_sysfs_entry bitmap_can_clear =
20072012
__ATTR(can_clear, S_IRUGO|S_IWUSR, can_clear_show, can_clear_store);
20082013

2014+
static ssize_t
2015+
behind_writes_used_show(mddev_t *mddev, char *page)
2016+
{
2017+
if (mddev->bitmap == NULL)
2018+
return sprintf(page, "0\n");
2019+
return sprintf(page, "%lu\n",
2020+
mddev->bitmap->behind_writes_used);
2021+
}
2022+
2023+
static ssize_t
2024+
behind_writes_used_reset(mddev_t *mddev, const char *buf, size_t len)
2025+
{
2026+
if (mddev->bitmap)
2027+
mddev->bitmap->behind_writes_used = 0;
2028+
return len;
2029+
}
2030+
2031+
static struct md_sysfs_entry max_backlog_used =
2032+
__ATTR(max_backlog_used, S_IRUGO | S_IWUSR,
2033+
behind_writes_used_show, behind_writes_used_reset);
2034+
20092035
static struct attribute *md_bitmap_attrs[] = {
20102036
&bitmap_location.attr,
20112037
&bitmap_timeout.attr,
20122038
&bitmap_backlog.attr,
20132039
&bitmap_chunksize.attr,
20142040
&bitmap_metadata.attr,
20152041
&bitmap_can_clear.attr,
2042+
&max_backlog_used.attr,
20162043
NULL
20172044
};
20182045
struct attribute_group md_bitmap_group = {

‎drivers/md/bitmap.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ struct bitmap {
227227
int allclean;
228228

229229
atomic_t behind_writes;
230+
unsigned long behind_writes_used; /* highest actual value at runtime */
230231

231232
/*
232233
* the bitmap daemon - periodically wakes up and sweeps the bitmap

0 commit comments

Comments
 (0)