btrfs: zstd ensure reclaim timer is properly cleaned up
Subsystems (2)
PATCH 1/1 btrfs: zstd ensure reclaim timer is properly cleaned up
The timer function, zstd_reclaim_timer_fn(), reschedules itself under certain conditions. Switch to del_timer_sync() to ensure that the timer function hasn't rescheduled itself.
--- fs/btrfs/zstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/zstd.c +1 -1
@@ -195,7 +195,7 @@ static void zstd_cleanup_workspace_manager(void)struct workspace *workspace;int i; -del_timer (&wsm.timer); +del_timer_sync (&wsm.timer);for (i =0 ; i <ZSTD_BTRFS_MAX_LEVEL ; i++) {while (!list_empty (&wsm.idle_ws[i])) {
Signature · 1 line
2.17.1
Quoted 3 lines · Dennis Zhou
The timer function,
zstd_reclaim_timer_fn(), reschedules itself under certain conditions. Switch todel_timer_sync()to ensure that the timer function hasn't rescheduled itself.
According to del_timer_sync it just waits for any concurrent invocation to finish. But it's responsibility of the caller to ensure the timer cannot really be restarted. It's not obvious how zstd_cleanup_workspace_manager ensures that the timer won't be restared. Looking at the timer function for it to not restart wsm.lru_list has to be empty. And seeing that workspace->lru_list is deleted afterwards I'm not sure this invariant holds.
Quoted 20 lines
Signed-off-by Dennis Zhou <[email protected]>--- fs/btrfs/zstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/zstd.c +1
-1@@ -195,7 +195,7 @@ static void zstd_cleanup_workspace_manager(void)struct workspace *workspace;int i; -del_timer (&wsm.timer); +del_timer_sync (&wsm.timer);for (i =0 ; i <ZSTD_BTRFS_MAX_LEVEL ; i++) {while (!list_empty (&wsm.idle_ws[i])) {
Quoted 7 lines · Nikolay Borisov
Quoted 3 lines · Dennis Zhou
The timer function,
zstd_reclaim_timer_fn(), reschedules itself under certain conditions. Switch todel_timer_sync()to ensure that the timer function hasn't rescheduled itself.
Quoted 8 lines
According to
del_timer_syncit just waits for any concurrent invocation to finish. But it's responsibility of the caller to ensure the timer cannot really be restarted. It's not obvious howzstd_cleanup_workspace_managerensures that the timer won't be restared. Looking at the timer function for it to not restart wsm.lru_list has to be empty. And seeing thatworkspace->lru_listis deleted afterwards I'm not sure this invariant holds.
Hmmm, I see. I misunderstood the invariant. I'll spin v2 and handle it another way.
Thanks,
Dennis
Quoted 20 lines
Quoted 20 lines
Signed-off-by Dennis Zhou <[email protected]>--- fs/btrfs/zstd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/zstd.c +1
-1@@ -195,7 +195,7 @@ static void zstd_cleanup_workspace_manager(void)struct workspace *workspace;int i; -del_timer (&wsm.timer); +del_timer_sync (&wsm.timer);for (i =0 ; i <ZSTD_BTRFS_MAX_LEVEL ; i++) {while (!list_empty (&wsm.idle_ws[i])) {