Skip to contentSkip to conversation

xfs: start gc on zonegc_low_space attribute updates

PATCH Superseded Hans Holmberg 4 participants 7 messages Mar 20 – Mar 25 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: start gc on zonegc_low_space attribute updates

Start gc if the agressiveness of zone garbage collection is changed by the user (if the file system is not read only).

Without this change, the new setting will not be taken into account until the gc thread is woken up by e.g. a write.

---

 fs/xfs/xfs_sysfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/xfs/xfs_sysfs.c +7 -1
index 6c7909838234..ac1329944049 100644
@@ -14,6 +14,7 @@
 #include "xfs_log_priv.h"
 #include "xfs_mount.h"
 #include "xfs_zones.h"
+#include "xfs_zone_alloc.h"
 
 struct xfs_sysfs_attr {
 	struct attribute attr;
@@ -724,6 +725,7 @@ zonegc_low_space_store(
 	const char		*buf,
 	size_t			count)
 {
+	struct xfs_mount	*mp = zoned_to_mp(kobj);
 	int			ret;
 	unsigned int		val;
 
@@ -734,7 +736,11 @@ zonegc_low_space_store(
 	if (val > 100)
 		return -EINVAL;
 
-	zoned_to_mp(kobj)->m_zonegc_low_space = val;
+	if (mp->m_zonegc_low_space != val) {
+		mp->m_zonegc_low_space = val;
+		if (!xfs_is_readonly(mp))
+			xfs_zone_gc_start(mp);
+	}
 
 	return count;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Hans Holmberg

Start gc if the agressiveness of zone garbage collection is changed by the user (if the file system is not read only).

Without this change, the new setting will not be taken into account until the gc thread is woken up by e.g. a write.

This sounds like a bug fix, so

Cc <[email protected]> # v6.15
Fixes 845abeb1f06a8a ("xfs: add tunable threshold parameter for triggering zone GC")

The zonegc start makes sense to me

--D

Quoted 42 lines

---

 fs/xfs/xfs_sysfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/xfs/xfs_sysfs.c +7 -1
index 6c7909838234..ac1329944049 100644
@@ -14,6 +14,7 @@
 #include "xfs_log_priv.h"
 #include "xfs_mount.h"
 #include "xfs_zones.h"
+#include "xfs_zone_alloc.h"
 
 struct xfs_sysfs_attr {
 	struct attribute attr;
@@ -724,6 +725,7 @@ zonegc_low_space_store(
 	const char		*buf,
 	size_t			count)
 {
+	struct xfs_mount	*mp = zoned_to_mp(kobj);
 	int			ret;
 	unsigned int		val;
 
@@ -734,7 +736,11 @@ zonegc_low_space_store(
 	if (val > 100)
 		return -EINVAL;
 
-	zoned_to_mp(kobj)->m_zonegc_low_space = val;
+	if (mp->m_zonegc_low_space != val) {
+		mp->m_zonegc_low_space = val;
+		if (!xfs_is_readonly(mp))
+			xfs_zone_gc_start(mp);
+	}
 
 	return count;
 }
Signature · 1 line
2.34.1
#2 lore raw
Quoted 9 lines · Darrick J. Wong
Quoted 7 lines · Hans Holmberg

Start gc if the agressiveness of zone garbage collection is changed by the user (if the file system is not read only).

Without this change, the new setting will not be taken into account until the gc thread is woken up by e.g. a write.

Quoted 7 lines

This sounds like a bug fix, so

Cc <[email protected]> # v6.15
Fixes 845abeb1f06a8a ("xfs: add tunable threshold parameter for triggering zone GC")

The zonegc start makes sense to me

Yeah, this is really a bug fix, thanks for the fixes tag!

Quoted 46 lines

--D

Quoted 42 lines

---

 fs/xfs/xfs_sysfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/xfs/xfs_sysfs.c +7 -1
index 6c7909838234..ac1329944049 100644
@@ -14,6 +14,7 @@
 #include "xfs_log_priv.h"
 #include "xfs_mount.h"
 #include "xfs_zones.h"
+#include "xfs_zone_alloc.h"
 
 struct xfs_sysfs_attr {
 	struct attribute attr;
@@ -724,6 +725,7 @@ zonegc_low_space_store(
 	const char		*buf,
 	size_t			count)
 {
+	struct xfs_mount	*mp = zoned_to_mp(kobj);
 	int			ret;
 	unsigned int		val;
 
@@ -734,7 +736,11 @@ zonegc_low_space_store(
 	if (val > 100)
 		return -EINVAL;
 
-	zoned_to_mp(kobj)->m_zonegc_low_space = val;
+	if (mp->m_zonegc_low_space != val) {
+		mp->m_zonegc_low_space = val;
+		if (!xfs_is_readonly(mp))
+			xfs_zone_gc_start(mp);
+	}
 
 	return count;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#3 lore raw
In reply to Hans Holmberg
Quoted 7 lines · Hans Holmberg

Start gc if the agressiveness of zone garbage collection is changed by the user (if the file system is not read only).

Without this change, the new setting will not be taken into account until the gc thread is woken up by e.g. a write.

And I agree with Darrick: a fixes tag and cc stable would be nice.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#4 lore raw
In reply to Hans Holmberg

fs/xfs/xfs_sysfs.c zonegc_low_space_store( · line 742

Quoted 3 lines
fs/xfs/xfs_sysfs.c +3 -0
+		mp->m_zonegc_low_space = val;
+		if (!xfs_is_readonly(mp))
+			xfs_zone_gc_start(mp);

Do we need to take s_umount here to prevent races with remount? (Not that it has any major effect, but we might as well get it tight).

Otherwise looks good. Do we want a test to ensure this takes effect? And one that it doesn't do anything stupid on a hard read-only file system?

#5 lore raw
Quoted 7 lines · Christoph Hellwig

fs/xfs/xfs_sysfs.c zonegc_low_space_store( · line 742

Quoted 3 lines
fs/xfs/xfs_sysfs.c +3 -0
+		mp->m_zonegc_low_space = val;
+		if (!xfs_is_readonly(mp))
+			xfs_zone_gc_start(mp);

Do we need to take s_umount here to prevent races with remount? (Not that it has any major effect, but we might as well get it tight).

Yeah, I think we might as well.

Quoted 5 lines

Otherwise looks good. Do we want a test to ensure this takes effect? And one that it doesn't do anything stupid on a hard read-only file system?

Yep, I can add add a test that checks that:

1) No gc is performed if the value is set 100 on a half-full RO scratch fs with partially used zones
2) When the file system is remounted RW, gc does its thing.

Do do this, I'll need to add a dependency to mountstats in xfstests though (checking gc status and rt available blocks), but that should be fine?

#6 lore raw
Quoted 10 lines · Hans Holmberg
Quoted 4 lines

Otherwise looks good. Do we want a test to ensure this takes effect? And one that it doesn't do anything stupid on a hard read-only file system?

Yep, I can add add a test that checks that:

1) No gc is performed if the value is set 100 on a half-full RO scratch fs with partially used zones
2) When the file system is remounted RW, gc does its thing.

Sounds great!

Quoted 3 lines

Do do this, I'll need to add a dependency to mountstats in xfstests though (checking gc status and rt available blocks), but that should be fine?

Yeah, we depend on all kinds of procfs files, and mountstats have been around from the start of the zoned allocator.