Skip to content

Commit fe0690f

Browse files
author
Andreas Gruenbacher
committed
gfs2: Sanitize kthread stopping
Immediately stop the logd and quotad kernel threads when a filesystem withdraw is detected: those threads aren't doing anything useful after a withdraw. (Depends on the extra logd and quotad task struct references held since commit 7a109f383fa3 ("gfs2: Fix asynchronous thread destruction").) In addition, check for kthread_should_stop() in the wait condition in gfs2_quotad() to stop immediately when kthread_stop() is called. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent e4a8b54 commit fe0690f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

fs/gfs2/log.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,11 +1298,9 @@ int gfs2_logd(void *data)
12981298
unsigned long t = 1;
12991299

13001300
while (!kthread_should_stop()) {
1301+
if (gfs2_withdrawn(sdp))
1302+
break;
13011303

1302-
if (gfs2_withdrawn(sdp)) {
1303-
msleep_interruptible(HZ);
1304-
continue;
1305-
}
13061304
/* Check for errors writing to the journal */
13071305
if (sdp->sd_log_error) {
13081306
gfs2_lm(sdp,
@@ -1311,7 +1309,7 @@ int gfs2_logd(void *data)
13111309
"prevent further damage.\n",
13121310
sdp->sd_fsname, sdp->sd_log_error);
13131311
gfs2_withdraw(sdp);
1314-
continue;
1312+
break;
13151313
}
13161314

13171315
if (gfs2_jrnl_flush_reqd(sdp) || t == 0) {
@@ -1339,6 +1337,7 @@ int gfs2_logd(void *data)
13391337
gfs2_ail_flush_reqd(sdp) ||
13401338
gfs2_jrnl_flush_reqd(sdp) ||
13411339
sdp->sd_log_error ||
1340+
gfs2_withdrawn(sdp) ||
13421341
kthread_should_stop(),
13431342
t);
13441343
}

fs/gfs2/quota.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,9 +1559,9 @@ int gfs2_quotad(void *data)
15591559
unsigned long t = 0;
15601560

15611561
while (!kthread_should_stop()) {
1562-
15631562
if (gfs2_withdrawn(sdp))
1564-
goto bypass;
1563+
break;
1564+
15651565
/* Update the master statfs file */
15661566
if (sdp->sd_statfs_force_sync) {
15671567
int error = gfs2_statfs_sync(sdp->sd_vfs, 0);
@@ -1579,11 +1579,12 @@ int gfs2_quotad(void *data)
15791579

15801580
try_to_freeze();
15811581

1582-
bypass:
15831582
t = min(quotad_timeo, statfs_timeo);
15841583

15851584
t = wait_event_interruptible_timeout(sdp->sd_quota_wait,
1586-
sdp->sd_statfs_force_sync,
1585+
sdp->sd_statfs_force_sync ||
1586+
gfs2_withdrawn(sdp) ||
1587+
kthread_should_stop(),
15871588
t);
15881589

15891590
if (sdp->sd_statfs_force_sync)

0 commit comments

Comments
 (0)