aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-08-03 13:30:47 -0400
committerTejun Heo <tj@kernel.org>2012-08-13 19:27:37 -0400
commit41f63c5359d14ca995172b8f6eaffd93f60fec54 (patch)
treed3d93dfd25d2e29e8abeae934835f2266b018cb7 /fs/afs
parent8376fe22c7e79c7e90857d39f82aeae6cad6c4b8 (diff)
workqueue: use mod_delayed_work() instead of cancel + queue
Convert delayed_work users doing cancel_delayed_work() followed by queue_delayed_work() to mod_delayed_work(). Most conversions are straight-forward. Ones worth mentioning are, * drivers/edac/edac_mc.c: edac_mc_workq_setup() converted to always use mod_delayed_work() and cancel loop in edac_mc_reset_delay_period() is dropped. * drivers/platform/x86/thinkpad_acpi.c: No need to remember whether watchdog is active or not. @fan_watchdog_active and related code dropped. * drivers/power/charger-manager.c: Seemingly a lot of delayed_work_pending() abuse going on here. [delayed_]work_pending() are unsynchronized and racy when used like this. I converted one instance in fullbatt_handler(). Please conver the rest so that it invokes workqueue APIs for the intended target state rather than trying to game work item pending state transitions. e.g. if timer should be modified - call mod_delayed_work(), canceled - call cancel_delayed_work[_sync](). * drivers/thermal/thermal_sys.c: thermal_zone_device_set_polling() simplified. Note that round_jiffies() calls in this function are meaningless. round_jiffies() work on absolute jiffies not delta delay used by delayed_work. v2: Tomi pointed out that __cancel_delayed_work() users can't be safely converted to mod_delayed_work(). They could be calling it from irq context and if that happens while delayed_work_timer_fn() is running, it could deadlock. __cancel_delayed_work() users are dropped. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Acked-by: David Howells <dhowells@redhat.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Doug Thompson <dougthompson@xmission.com> Cc: David Airlie <airlied@linux.ie> Cc: Roland Dreier <roland@kernel.org> Cc: "John W. Linville" <linville@tuxdriver.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Len Brown <len.brown@intel.com> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Johannes Berg <johannes@sipsolutions.net>
Diffstat (limited to 'fs/afs')
-rw-r--r--fs/afs/callback.c4
-rw-r--r--fs/afs/server.c10
-rw-r--r--fs/afs/vlocation.c14
3 files changed, 6 insertions, 22 deletions
diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index 587ef5123cd8..7ef637d7f3a5 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -351,9 +351,7 @@ void afs_dispatch_give_up_callbacks(struct work_struct *work)
351 */ 351 */
352void afs_flush_callback_breaks(struct afs_server *server) 352void afs_flush_callback_breaks(struct afs_server *server)
353{ 353{
354 cancel_delayed_work(&server->cb_break_work); 354 mod_delayed_work(afs_callback_update_worker, &server->cb_break_work, 0);
355 queue_delayed_work(afs_callback_update_worker,
356 &server->cb_break_work, 0);
357} 355}
358 356
359#if 0 357#if 0
diff --git a/fs/afs/server.c b/fs/afs/server.c
index d59b7516e943..f342acf3547d 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -285,12 +285,7 @@ static void afs_reap_server(struct work_struct *work)
285 expiry = server->time_of_death + afs_server_timeout; 285 expiry = server->time_of_death + afs_server_timeout;
286 if (expiry > now) { 286 if (expiry > now) {
287 delay = (expiry - now) * HZ; 287 delay = (expiry - now) * HZ;
288 if (!queue_delayed_work(afs_wq, &afs_server_reaper, 288 mod_delayed_work(afs_wq, &afs_server_reaper, delay);
289 delay)) {
290 cancel_delayed_work(&afs_server_reaper);
291 queue_delayed_work(afs_wq, &afs_server_reaper,
292 delay);
293 }
294 break; 289 break;
295 } 290 }
296 291
@@ -323,6 +318,5 @@ static void afs_reap_server(struct work_struct *work)
323void __exit afs_purge_servers(void) 318void __exit afs_purge_servers(void)
324{ 319{
325 afs_server_timeout = 0; 320 afs_server_timeout = 0;
326 cancel_delayed_work(&afs_server_reaper); 321 mod_delayed_work(afs_wq, &afs_server_reaper, 0);
327 queue_delayed_work(afs_wq, &afs_server_reaper, 0);
328} 322}
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 431984d2e372..57bcb1596530 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -561,12 +561,7 @@ static void afs_vlocation_reaper(struct work_struct *work)
561 if (expiry > now) { 561 if (expiry > now) {
562 delay = (expiry - now) * HZ; 562 delay = (expiry - now) * HZ;
563 _debug("delay %lu", delay); 563 _debug("delay %lu", delay);
564 if (!queue_delayed_work(afs_wq, &afs_vlocation_reap, 564 mod_delayed_work(afs_wq, &afs_vlocation_reap, delay);
565 delay)) {
566 cancel_delayed_work(&afs_vlocation_reap);
567 queue_delayed_work(afs_wq, &afs_vlocation_reap,
568 delay);
569 }
570 break; 565 break;
571 } 566 }
572 567
@@ -614,13 +609,10 @@ void afs_vlocation_purge(void)
614 spin_lock(&afs_vlocation_updates_lock); 609 spin_lock(&afs_vlocation_updates_lock);
615 list_del_init(&afs_vlocation_updates); 610 list_del_init(&afs_vlocation_updates);
616 spin_unlock(&afs_vlocation_updates_lock); 611 spin_unlock(&afs_vlocation_updates_lock);
617 cancel_delayed_work(&afs_vlocation_update); 612 mod_delayed_work(afs_vlocation_update_worker, &afs_vlocation_update, 0);
618 queue_delayed_work(afs_vlocation_update_worker,
619 &afs_vlocation_update, 0);
620 destroy_workqueue(afs_vlocation_update_worker); 613 destroy_workqueue(afs_vlocation_update_worker);
621 614
622 cancel_delayed_work(&afs_vlocation_reap); 615 mod_delayed_work(afs_wq, &afs_vlocation_reap, 0);
623 queue_delayed_work(afs_wq, &afs_vlocation_reap, 0);
624} 616}
625 617
626/* 618/*