Skip to contentSkip to conversation

jbd2: Convert timers to use timer_setup()

PATCH Applied Kees Cook 3 participants 3 messages Oct 5, 2017 – Oct 18, 2017 Journalling layer for block devices (JBD2)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 jbd2: Convert timers to use timer_setup()

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 "Theodore Ts'o" <[email protected]>
Cc Jan Kara <[email protected]>
Cc Thomas Gleixner <[email protected]>

---
This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone.

---
 fs/jbd2/journal.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/jbd2/journal.c +4 -5
index 7d5ef3bf3f3e..d2a85c9720e9 100644
@@ -165,11 +165,11 @@ static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
  * Helper function used to manage commit timeouts
  */
 
-static void commit_timeout(unsigned long __data)
+static void commit_timeout(struct timer_list *t)
 {
-	struct task_struct * p = (struct task_struct *) __data;
+	journal_t *journal = from_timer(journal, t, j_commit_timer);
 
-	wake_up_process(p);
+	wake_up_process(journal->j_task);
 }
 
 /*
@@ -197,8 +197,7 @@ static int kjournald2(void *arg)
 	 * Set up an interval timer which can be used to trigger a commit wakeup
 	 * after the commit interval expires
 	 */
-	setup_timer(&journal->j_commit_timer, commit_timeout,
-			(unsigned long)current);
+	timer_setup(&journal->j_commit_timer, commit_timeout, 0);
 
 	set_freezable();
 
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Kees Cook

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 "Theodore Ts'o" <[email protected]>
Cc Jan Kara <[email protected]>
Cc Thomas Gleixner <[email protected]>

The patch looks good to me. You can add:

Honza

Quoted 45 lines

---
This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone.

---
 fs/jbd2/journal.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/jbd2/journal.c +4 -5
index 7d5ef3bf3f3e..d2a85c9720e9 100644
@@ -165,11 +165,11 @@ static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
  * Helper function used to manage commit timeouts
  */
 
-static void commit_timeout(unsigned long __data)
+static void commit_timeout(struct timer_list *t)
 {
-	struct task_struct * p = (struct task_struct *) __data;
+	journal_t *journal = from_timer(journal, t, j_commit_timer);
 
-	wake_up_process(p);
+	wake_up_process(journal->j_task);
 }
 
 /*
@@ -197,8 +197,7 @@ static int kjournald2(void *arg)
 	 * Set up an interval timer which can be used to trigger a commit wakeup
 	 * after the commit interval expires
 	 */
-	setup_timer(&journal->j_commit_timer, commit_timeout,
-			(unsigned long)current);
+	timer_setup(&journal->j_commit_timer, commit_timeout, 0);
 
 	set_freezable();
 
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
Quoted 11 lines · Jan Kara
Quoted 9 lines · Kees Cook

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 "Theodore Ts'o" <[email protected]>
Cc Jan Kara <[email protected]>
Cc Thomas Gleixner <[email protected]>
Quoted 3 lines

The patch looks good to me. You can add:

Applied, thanks.

- Ted