Skip to content

Commit 181ea4e

Browse files
yhrcmaiolino
authored andcommitted
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. Cc: stable@vger.kernel.org # v6.15 Fixes: 845abeb ("xfs: add tunable threshold parameter for triggering zone GC") Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 8166876 commit 181ea4e

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

fs/xfs/xfs_sysfs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "xfs_log_priv.h"
1515
#include "xfs_mount.h"
1616
#include "xfs_zones.h"
17+
#include "xfs_zone_alloc.h"
1718

1819
struct xfs_sysfs_attr {
1920
struct attribute attr;
@@ -724,6 +725,7 @@ zonegc_low_space_store(
724725
const char *buf,
725726
size_t count)
726727
{
728+
struct xfs_mount *mp = zoned_to_mp(kobj);
727729
int ret;
728730
unsigned int val;
729731

@@ -734,7 +736,10 @@ zonegc_low_space_store(
734736
if (val > 100)
735737
return -EINVAL;
736738

737-
zoned_to_mp(kobj)->m_zonegc_low_space = val;
739+
if (mp->m_zonegc_low_space != val) {
740+
mp->m_zonegc_low_space = val;
741+
xfs_zone_gc_wakeup(mp);
742+
}
738743

739744
return count;
740745
}

fs/xfs/xfs_zone_alloc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ int xfs_mount_zones(struct xfs_mount *mp);
5151
void xfs_unmount_zones(struct xfs_mount *mp);
5252
void xfs_zone_gc_start(struct xfs_mount *mp);
5353
void xfs_zone_gc_stop(struct xfs_mount *mp);
54+
void xfs_zone_gc_wakeup(struct xfs_mount *mp);
5455
#else
5556
static inline int xfs_mount_zones(struct xfs_mount *mp)
5657
{
@@ -65,6 +66,9 @@ static inline void xfs_zone_gc_start(struct xfs_mount *mp)
6566
static inline void xfs_zone_gc_stop(struct xfs_mount *mp)
6667
{
6768
}
69+
static inline void xfs_zone_gc_wakeup(struct xfs_mount *mp)
70+
{
71+
}
6872
#endif /* CONFIG_XFS_RT */
6973

7074
#endif /* _XFS_ZONE_ALLOC_H */

fs/xfs/xfs_zone_gc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,23 @@ xfs_zone_gc_stop(
11711171
kthread_park(mp->m_zone_info->zi_gc_thread);
11721172
}
11731173

1174+
void
1175+
xfs_zone_gc_wakeup(
1176+
struct xfs_mount *mp)
1177+
{
1178+
struct super_block *sb = mp->m_super;
1179+
1180+
/*
1181+
* If we are unmounting the file system we must not try to
1182+
* wake gc as m_zone_info might have been freed already.
1183+
*/
1184+
if (down_read_trylock(&sb->s_umount)) {
1185+
if (!xfs_is_readonly(mp))
1186+
wake_up_process(mp->m_zone_info->zi_gc_thread);
1187+
up_read(&sb->s_umount);
1188+
}
1189+
}
1190+
11741191
int
11751192
xfs_zone_gc_mount(
11761193
struct xfs_mount *mp)

0 commit comments

Comments
 (0)