Skip to content

Commit

Permalink
drbd: Convert timers to use timer_setup()
Browse files Browse the repository at this point in the history
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: drbd-dev@lists.linbit.com
Signed-off-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Kees Cook committed Nov 6, 2017
1 parent c6f1504 commit 2bccef3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions drivers/block/drbd/drbd_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -1551,8 +1551,8 @@ extern int w_restart_disk_io(struct drbd_work *, int);
extern int w_send_out_of_sync(struct drbd_work *, int);
extern int w_start_resync(struct drbd_work *, int);

extern void resync_timer_fn(unsigned long data);
extern void start_resync_timer_fn(unsigned long data);
extern void resync_timer_fn(struct timer_list *t);
extern void start_resync_timer_fn(struct timer_list *t);

extern void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req);

Expand Down
18 changes: 7 additions & 11 deletions drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
static DEFINE_MUTEX(drbd_main_mutex);
static int drbd_open(struct block_device *bdev, fmode_t mode);
static void drbd_release(struct gendisk *gd, fmode_t mode);
static void md_sync_timer_fn(unsigned long data);
static void md_sync_timer_fn(struct timer_list *t);
static int w_bitmap_io(struct drbd_work *w, int unused);

MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, "
Expand Down Expand Up @@ -2023,14 +2023,10 @@ void drbd_init_set_defaults(struct drbd_device *device)
device->unplug_work.cb = w_send_write_hint;
device->bm_io_work.w.cb = w_bitmap_io;

setup_timer(&device->resync_timer, resync_timer_fn,
(unsigned long)device);
setup_timer(&device->md_sync_timer, md_sync_timer_fn,
(unsigned long)device);
setup_timer(&device->start_resync_timer, start_resync_timer_fn,
(unsigned long)device);
setup_timer(&device->request_timer, request_timer_fn,
(unsigned long)device);
timer_setup(&device->resync_timer, resync_timer_fn, 0);
timer_setup(&device->md_sync_timer, md_sync_timer_fn, 0);
timer_setup(&device->start_resync_timer, start_resync_timer_fn, 0);
timer_setup(&device->request_timer, request_timer_fn, 0);

init_waitqueue_head(&device->misc_wait);
init_waitqueue_head(&device->state_wait);
Expand Down Expand Up @@ -3721,9 +3717,9 @@ int drbd_md_test_flag(struct drbd_backing_dev *bdev, int flag)
return (bdev->md.flags & flag) != 0;
}

static void md_sync_timer_fn(unsigned long data)
static void md_sync_timer_fn(struct timer_list *t)
{
struct drbd_device *device = (struct drbd_device *) data;
struct drbd_device *device = from_timer(device, t, md_sync_timer);
drbd_device_post_work(device, MD_SYNC);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -5056,7 +5056,7 @@ static int drbd_disconnected(struct drbd_peer_device *peer_device)
wake_up(&device->misc_wait);

del_timer_sync(&device->resync_timer);
resync_timer_fn((unsigned long)device);
resync_timer_fn(&device->resync_timer);

/* wait for all w_e_end_data_req, w_e_end_rsdata_req, w_send_barrier,
* w_make_resync_request etc. which may still be on the worker queue
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/drbd/drbd_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,9 +1714,9 @@ static bool net_timeout_reached(struct drbd_request *net_req,
* to expire twice (worst case) to become effective. Good enough.
*/

void request_timer_fn(unsigned long data)
void request_timer_fn(struct timer_list *t)
{
struct drbd_device *device = (struct drbd_device *) data;
struct drbd_device *device = from_timer(device, t, request_timer);
struct drbd_connection *connection = first_peer_device(device)->connection;
struct drbd_request *req_read, *req_write, *req_peer; /* oldest request */
struct net_conf *nc;
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_req.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ extern int __req_mod(struct drbd_request *req, enum drbd_req_event what,
struct bio_and_error *m);
extern void complete_master_bio(struct drbd_device *device,
struct bio_and_error *m);
extern void request_timer_fn(unsigned long data);
extern void request_timer_fn(struct timer_list *t);
extern void tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
extern void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what);
extern void tl_abort_disk_io(struct drbd_device *device);
Expand Down
8 changes: 4 additions & 4 deletions drivers/block/drbd/drbd_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ int w_resync_timer(struct drbd_work *w, int cancel)
return 0;
}

void resync_timer_fn(unsigned long data)
void resync_timer_fn(struct timer_list *t)
{
struct drbd_device *device = (struct drbd_device *) data;
struct drbd_device *device = from_timer(device, t, resync_timer);

drbd_queue_work_if_unqueued(
&first_peer_device(device)->connection->sender_work,
Expand Down Expand Up @@ -1705,9 +1705,9 @@ void drbd_rs_controller_reset(struct drbd_device *device)
rcu_read_unlock();
}

void start_resync_timer_fn(unsigned long data)
void start_resync_timer_fn(struct timer_list *t)
{
struct drbd_device *device = (struct drbd_device *) data;
struct drbd_device *device = from_timer(device, t, start_resync_timer);
drbd_device_post_work(device, RS_START);
}

Expand Down

0 comments on commit 2bccef3

Please sign in to comment.