]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
md/r5cache: assign conf->log before r5l_load_log()
authorSong Liu <songliubraving@fb.com>
Wed, 14 Dec 2016 23:38:02 +0000 (15:38 -0800)
committerShaohua Li <shli@fb.com>
Thu, 5 Jan 2017 19:44:38 +0000 (11:44 -0800)
r5l_load_log() calls functions that requires a proper conf->log,
for example, r5c_is_writeback(). Therefore, we should set
conf->log before calling r5l_load_log(). If r5l_load_log() fails,
conf->log is set back to NULL.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5-cache.c

index b178a8fef26643b0c63aa3066912039f8f4ccef3..bff1b4a949e8e480659ebd05334bc2709d4eb7d8 100644 (file)
@@ -2633,14 +2633,16 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
        spin_lock_init(&log->stripe_in_journal_lock);
        atomic_set(&log->stripe_in_journal_count, 0);
 
+       rcu_assign_pointer(conf->log, log);
+
        if (r5l_load_log(log))
                goto error;
 
-       rcu_assign_pointer(conf->log, log);
        set_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
        return 0;
 
 error:
+       rcu_assign_pointer(conf->log, NULL);
        md_unregister_thread(&log->reclaim_thread);
 reclaim_thread:
        mempool_destroy(log->meta_pool);