Skip to content

Commit 0ad53ee

Browse files
htejuntorvalds
authored andcommitted
afs: add afs_wq and use it instead of the system workqueue
flush_scheduled_work() is going away. afs needs to make sure all the works it has queued have finished before being unloaded and there can be arbitrary number of pending works. Add afs_wq and use it as the flush domain instead of the system workqueue. Also, convert cancel_delayed_work() + flush_scheduled_work() to cancel_delayed_work_sync() in afs_mntpt_kill_timer(). Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: David Howells <dhowells@redhat.com> Cc: linux-afs@lists.infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e1fcc7e commit 0ad53ee

7 files changed

Lines changed: 38 additions & 28 deletions

File tree

‎fs/afs/cmservice.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int afs_deliver_cb_callback(struct afs_call *call, struct sk_buff *skb,
289289
call->server = server;
290290

291291
INIT_WORK(&call->work, SRXAFSCB_CallBack);
292-
schedule_work(&call->work);
292+
queue_work(afs_wq, &call->work);
293293
return 0;
294294
}
295295

@@ -336,7 +336,7 @@ static int afs_deliver_cb_init_call_back_state(struct afs_call *call,
336336
call->server = server;
337337

338338
INIT_WORK(&call->work, SRXAFSCB_InitCallBackState);
339-
schedule_work(&call->work);
339+
queue_work(afs_wq, &call->work);
340340
return 0;
341341
}
342342

@@ -367,7 +367,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call,
367367
call->server = server;
368368

369369
INIT_WORK(&call->work, SRXAFSCB_InitCallBackState);
370-
schedule_work(&call->work);
370+
queue_work(afs_wq, &call->work);
371371
return 0;
372372
}
373373

@@ -400,7 +400,7 @@ static int afs_deliver_cb_probe(struct afs_call *call, struct sk_buff *skb,
400400
call->state = AFS_CALL_REPLYING;
401401

402402
INIT_WORK(&call->work, SRXAFSCB_Probe);
403-
schedule_work(&call->work);
403+
queue_work(afs_wq, &call->work);
404404
return 0;
405405
}
406406

@@ -496,7 +496,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call, struct sk_buff *skb,
496496
call->state = AFS_CALL_REPLYING;
497497

498498
INIT_WORK(&call->work, SRXAFSCB_ProbeUuid);
499-
schedule_work(&call->work);
499+
queue_work(afs_wq, &call->work);
500500
return 0;
501501
}
502502

@@ -580,6 +580,6 @@ static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call,
580580
call->state = AFS_CALL_REPLYING;
581581

582582
INIT_WORK(&call->work, SRXAFSCB_TellMeAboutYourself);
583-
schedule_work(&call->work);
583+
queue_work(afs_wq, &call->work);
584584
return 0;
585585
}

‎fs/afs/internal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ extern int afs_drop_inode(struct inode *);
577577
/*
578578
* main.c
579579
*/
580+
extern struct workqueue_struct *afs_wq;
580581
extern struct afs_uuid afs_uuid;
581582

582583
/*

‎fs/afs/main.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module_param(rootcell, charp, 0);
3030
MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
3131

3232
struct afs_uuid afs_uuid;
33+
struct workqueue_struct *afs_wq;
3334

3435
/*
3536
* get a client UUID
@@ -87,10 +88,16 @@ static int __init afs_init(void)
8788
if (ret < 0)
8889
return ret;
8990

91+
/* create workqueue */
92+
ret = -ENOMEM;
93+
afs_wq = alloc_workqueue("afs", 0, 0);
94+
if (!afs_wq)
95+
return ret;
96+
9097
/* register the /proc stuff */
9198
ret = afs_proc_init();
9299
if (ret < 0)
93-
return ret;
100+
goto error_proc;
94101

95102
#ifdef CONFIG_AFS_FSCACHE
96103
/* we want to be able to cache */
@@ -140,6 +147,8 @@ static int __init afs_init(void)
140147
error_cache:
141148
#endif
142149
afs_proc_cleanup();
150+
error_proc:
151+
destroy_workqueue(afs_wq);
143152
rcu_barrier();
144153
printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
145154
return ret;
@@ -163,7 +172,7 @@ static void __exit afs_exit(void)
163172
afs_purge_servers();
164173
afs_callback_update_kill();
165174
afs_vlocation_purge();
166-
flush_scheduled_work();
175+
destroy_workqueue(afs_wq);
167176
afs_cell_purge();
168177
#ifdef CONFIG_AFS_FSCACHE
169178
fscache_unregister_netfs(&afs_cache_netfs);

‎fs/afs/mntpt.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
268268
path_put(&nd->path);
269269
nd->path.mnt = newmnt;
270270
nd->path.dentry = dget(newmnt->mnt_root);
271-
schedule_delayed_work(&afs_mntpt_expiry_timer,
272-
afs_mntpt_expiry_timeout * HZ);
271+
queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
272+
afs_mntpt_expiry_timeout * HZ);
273273
break;
274274
case -EBUSY:
275275
/* someone else made a mount here whilst we were busy */
@@ -295,8 +295,8 @@ static void afs_mntpt_expiry_timed_out(struct work_struct *work)
295295

296296
if (!list_empty(&afs_vfsmounts)) {
297297
mark_mounts_for_expiry(&afs_vfsmounts);
298-
schedule_delayed_work(&afs_mntpt_expiry_timer,
299-
afs_mntpt_expiry_timeout * HZ);
298+
queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
299+
afs_mntpt_expiry_timeout * HZ);
300300
}
301301

302302
_leave("");
@@ -310,6 +310,5 @@ void afs_mntpt_kill_timer(void)
310310
_enter("");
311311

312312
ASSERT(list_empty(&afs_vfsmounts));
313-
cancel_delayed_work(&afs_mntpt_expiry_timer);
314-
flush_scheduled_work();
313+
cancel_delayed_work_sync(&afs_mntpt_expiry_timer);
315314
}

‎fs/afs/rxrpc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static void afs_rx_interceptor(struct sock *sk, unsigned long user_call_ID,
410410
if (!call) {
411411
/* its an incoming call for our callback service */
412412
skb_queue_tail(&afs_incoming_calls, skb);
413-
schedule_work(&afs_collect_incoming_call_work);
413+
queue_work(afs_wq, &afs_collect_incoming_call_work);
414414
} else {
415415
/* route the messages directly to the appropriate call */
416416
skb_queue_tail(&call->rx_queue, skb);

‎fs/afs/server.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ void afs_put_server(struct afs_server *server)
238238
if (atomic_read(&server->usage) == 0) {
239239
list_move_tail(&server->grave, &afs_server_graveyard);
240240
server->time_of_death = get_seconds();
241-
schedule_delayed_work(&afs_server_reaper,
242-
afs_server_timeout * HZ);
241+
queue_delayed_work(afs_wq, &afs_server_reaper,
242+
afs_server_timeout * HZ);
243243
}
244244
spin_unlock(&afs_server_graveyard_lock);
245245
_leave(" [dead]");
@@ -285,10 +285,11 @@ static void afs_reap_server(struct work_struct *work)
285285
expiry = server->time_of_death + afs_server_timeout;
286286
if (expiry > now) {
287287
delay = (expiry - now) * HZ;
288-
if (!schedule_delayed_work(&afs_server_reaper, delay)) {
288+
if (!queue_delayed_work(afs_wq, &afs_server_reaper,
289+
delay)) {
289290
cancel_delayed_work(&afs_server_reaper);
290-
schedule_delayed_work(&afs_server_reaper,
291-
delay);
291+
queue_delayed_work(afs_wq, &afs_server_reaper,
292+
delay);
292293
}
293294
break;
294295
}
@@ -323,5 +324,5 @@ void __exit afs_purge_servers(void)
323324
{
324325
afs_server_timeout = 0;
325326
cancel_delayed_work(&afs_server_reaper);
326-
schedule_delayed_work(&afs_server_reaper, 0);
327+
queue_delayed_work(afs_wq, &afs_server_reaper, 0);
327328
}

‎fs/afs/vlocation.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ void afs_put_vlocation(struct afs_vlocation *vl)
507507
_debug("buried");
508508
list_move_tail(&vl->grave, &afs_vlocation_graveyard);
509509
vl->time_of_death = get_seconds();
510-
schedule_delayed_work(&afs_vlocation_reap,
511-
afs_vlocation_timeout * HZ);
510+
queue_delayed_work(afs_wq, &afs_vlocation_reap,
511+
afs_vlocation_timeout * HZ);
512512

513513
/* suspend updates on this record */
514514
if (!list_empty(&vl->update)) {
@@ -561,11 +561,11 @@ static void afs_vlocation_reaper(struct work_struct *work)
561561
if (expiry > now) {
562562
delay = (expiry - now) * HZ;
563563
_debug("delay %lu", delay);
564-
if (!schedule_delayed_work(&afs_vlocation_reap,
565-
delay)) {
564+
if (!queue_delayed_work(afs_wq, &afs_vlocation_reap,
565+
delay)) {
566566
cancel_delayed_work(&afs_vlocation_reap);
567-
schedule_delayed_work(&afs_vlocation_reap,
568-
delay);
567+
queue_delayed_work(afs_wq, &afs_vlocation_reap,
568+
delay);
569569
}
570570
break;
571571
}
@@ -620,7 +620,7 @@ void afs_vlocation_purge(void)
620620
destroy_workqueue(afs_vlocation_update_worker);
621621

622622
cancel_delayed_work(&afs_vlocation_reap);
623-
schedule_delayed_work(&afs_vlocation_reap, 0);
623+
queue_delayed_work(afs_wq, &afs_vlocation_reap, 0);
624624
}
625625

626626
/*

0 commit comments

Comments
 (0)