Skip to contentSkip to conversation

fs/btrfs/tree-log.c:3318:1-7: preceding lock on line 3156 (fwd)

PATCH New Julia Lawall 1 participant 1 message Jan 30, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 14817/14851 fs/btrfs/tree-log.c:3318:1-7: preceding lock on line 3156 (fwd)

It's complaining about the goto on line 3167, which is missing a mutex_unlock.

julia

---------- Forwarded message ----------
Date: Sat, 30 Jan 2021 16:55:27 +0800
From: kernel test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: lkp(a)intel.com, Julia Lawall <[email protected]>
Subject: [kdave-btrfs-devel:for-next-20210129 14817/14851]

    fs/btrfs/tree-log.c:3318:1-7: preceding lock on line 3156

CC: kbuild-all(a)lists.01.org
TO: Naohiro Aota <[email protected]>
CC: David Sterba <[email protected]>
CC: Josef Bacik <[email protected]>
CC: Johannes Thumshirn <[email protected]>

tree:   https://github.com/kdave/btrfs-devel.git for-next-20210129
head:   6e043613b2c4377ce095ea826160d42031156d35
commit: 122cfba0d2eb42d0a31161cf2139be0ead18afb7 [14817/14851] btrfs: reorder log node allocation

:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
config: powerpc64-randconfig-c003-20210129 (attached as .config)
compiler: powerpc64le-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

"coccinelle warnings: (new ones prefixed by >>)"

Quoted 1 line
Quoted 1 line

fs/btrfs/tree-log.c:3318:1-7: preceding lock on line 3156

vim +3318 fs/btrfs/tree-log.c

8b050d350c7846 Miao Xie       2014-02-20  3039
e02119d5a7b439 Chris Mason    2008-09-05  3040  /*
e02119d5a7b439 Chris Mason    2008-09-05  3041   * btrfs_sync_log does sends a given tree log down to the disk and
e02119d5a7b439 Chris Mason    2008-09-05  3042   * updates the super blocks to record it.  When this call is done,
12fcfd22fe5bf4 Chris Mason    2009-03-24  3043   * you know that any inodes previously logged are safely on disk only
12fcfd22fe5bf4 Chris Mason    2009-03-24  3044   * if it returns 0.
12fcfd22fe5bf4 Chris Mason    2009-03-24  3045   *
12fcfd22fe5bf4 Chris Mason    2009-03-24  3046   * Any other return value means you need to call btrfs_commit_transaction.
12fcfd22fe5bf4 Chris Mason    2009-03-24  3047   * Some of the edge cases for fsyncing directories that have had unlinks
12fcfd22fe5bf4 Chris Mason    2009-03-24  3048   * or renames done in the past mean that sometimes the only safe
12fcfd22fe5bf4 Chris Mason    2009-03-24  3049   * fsync is to commit the whole FS.  When btrfs_sync_log returns -EAGAIN,
12fcfd22fe5bf4 Chris Mason    2009-03-24  3050   * that has happened.
e02119d5a7b439 Chris Mason    2008-09-05  3051   */
e02119d5a7b439 Chris Mason    2008-09-05  3052  int btrfs_sync_log(struct btrfs_trans_handle *trans,
8b050d350c7846 Miao Xie       2014-02-20  3053  		   struct btrfs_root *root, struct btrfs_log_ctx *ctx)
e02119d5a7b439 Chris Mason    2008-09-05  3054  {
7237f1833601dc Yan Zheng      2009-01-21  3055  	int index1;
7237f1833601dc Yan Zheng      2009-01-21  3056  	int index2;
8cef4e160d7492 Yan, Zheng     2009-11-12  3057  	int mark;
e02119d5a7b439 Chris Mason    2008-09-05  3058  	int ret;
0b246afa62b0cf Jeff Mahoney   2016-06-22  3059  	struct btrfs_fs_info *fs_info = root->fs_info;
e02119d5a7b439 Chris Mason    2008-09-05  3060  	struct btrfs_root *log = root->log_root;
0b246afa62b0cf Jeff Mahoney   2016-06-22  3061  	struct btrfs_root *log_root_tree = fs_info->log_root_tree;
4203e968947071 Josef Bacik    2019-09-30  3062  	struct btrfs_root_item new_root_item;
bb14a59b619d3a Miao Xie       2014-02-20  3063  	int log_transid = 0;
8b050d350c7846 Miao Xie       2014-02-20  3064  	struct btrfs_log_ctx root_log_ctx;
c6adc9cc082e3c Miao Xie       2013-05-28  3065  	struct blk_plug plug;
47876f7ceffa0e Filipe Manana  2020-11-25  3066  	u64 log_root_start;
47876f7ceffa0e Filipe Manana  2020-11-25  3067  	u64 log_root_level;
e02119d5a7b439 Chris Mason    2008-09-05  3068
7237f1833601dc Yan Zheng      2009-01-21  3069  	mutex_lock(&root->log_mutex);
d1433debe7f434 Miao Xie       2014-02-20  3070  	log_transid = ctx->log_transid;
d1433debe7f434 Miao Xie       2014-02-20  3071  	if (root->log_transid_committed >= log_transid) {
d1433debe7f434 Miao Xie       2014-02-20  3072  		mutex_unlock(&root->log_mutex);
d1433debe7f434 Miao Xie       2014-02-20  3073  		return ctx->log_ret;
d1433debe7f434 Miao Xie       2014-02-20  3074  	}
d1433debe7f434 Miao Xie       2014-02-20  3075
d1433debe7f434 Miao Xie       2014-02-20  3076  	index1 = log_transid % 2;
7237f1833601dc Yan Zheng      2009-01-21  3077  	if (atomic_read(&root->log_commit[index1])) {
60d53eb3107c8e Zhaolei        2015-08-17  3078  		wait_log_commit(root, log_transid);
7237f1833601dc Yan Zheng      2009-01-21  3079  		mutex_unlock(&root->log_mutex);
8b050d350c7846 Miao Xie       2014-02-20  3080  		return ctx->log_ret;
e02119d5a7b439 Chris Mason    2008-09-05  3081  	}
d1433debe7f434 Miao Xie       2014-02-20  3082  	ASSERT(log_transid == root->log_transid);
7237f1833601dc Yan Zheng      2009-01-21  3083  	atomic_set(&root->log_commit[index1], 1);
7237f1833601dc Yan Zheng      2009-01-21  3084
7237f1833601dc Yan Zheng      2009-01-21  3085  	/* wait for previous tree log sync to complete */
7237f1833601dc Yan Zheng      2009-01-21  3086  	if (atomic_read(&root->log_commit[(index1 + 1) % 2]))
60d53eb3107c8e Zhaolei        2015-08-17  3087  		wait_log_commit(root, log_transid - 1);
48cab2e0714913 Miao Xie       2014-02-20  3088
86df7eb921a009 Yan, Zheng     2009-10-14  3089  	while (1) {
2ecb79239bcd04 Miao Xie       2012-09-06  3090  		int batch = atomic_read(&root->log_batch);
cd354ad613a393 Chris Mason    2011-10-20  3091  		/* when we're on an ssd, just kick the log commit out */
0b246afa62b0cf Jeff Mahoney   2016-06-22  3092  		if (!btrfs_test_opt(fs_info, SSD) &&
27cdeb7096b86f Miao Xie       2014-04-02  3093  		    test_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state)) {
7237f1833601dc Yan Zheng      2009-01-21  3094  			mutex_unlock(&root->log_mutex);
e02119d5a7b439 Chris Mason    2008-09-05  3095  			schedule_timeout_uninterruptible(1);
7237f1833601dc Yan Zheng      2009-01-21  3096  			mutex_lock(&root->log_mutex);
86df7eb921a009 Yan, Zheng     2009-10-14  3097  		}
60d53eb3107c8e Zhaolei        2015-08-17  3098  		wait_for_writer(root);
2ecb79239bcd04 Miao Xie       2012-09-06  3099  		if (batch == atomic_read(&root->log_batch))
e02119d5a7b439 Chris Mason    2008-09-05  3100  			break;
e02119d5a7b439 Chris Mason    2008-09-05  3101  	}
e02119d5a7b439 Chris Mason    2008-09-05  3102
12fcfd22fe5bf4 Chris Mason    2009-03-24  3103  	/* bail out if we need to do a full commit */
4884b8e8ebf54e David Sterba   2019-03-20  3104  	if (btrfs_need_log_full_commit(trans)) {
12fcfd22fe5bf4 Chris Mason    2009-03-24  3105  		ret = -EAGAIN;
12fcfd22fe5bf4 Chris Mason    2009-03-24  3106  		mutex_unlock(&root->log_mutex);
12fcfd22fe5bf4 Chris Mason    2009-03-24  3107  		goto out;
12fcfd22fe5bf4 Chris Mason    2009-03-24  3108  	}
12fcfd22fe5bf4 Chris Mason    2009-03-24  3109
8cef4e160d7492 Yan, Zheng     2009-11-12  3110  	if (log_transid % 2 == 0)
8cef4e160d7492 Yan, Zheng     2009-11-12  3111  		mark = EXTENT_DIRTY;
8cef4e160d7492 Yan, Zheng     2009-11-12  3112  	else
8cef4e160d7492 Yan, Zheng     2009-11-12  3113  		mark = EXTENT_NEW;
8cef4e160d7492 Yan, Zheng     2009-11-12  3114
690587d109ffe1 Chris Mason    2009-10-13  3115  	/* we start IO on  all the marked extents here, but we don't actually
690587d109ffe1 Chris Mason    2009-10-13  3116  	 * wait for them until later.
690587d109ffe1 Chris Mason    2009-10-13  3117  	 */
c6adc9cc082e3c Miao Xie       2013-05-28  3118  	blk_start_plug(&plug);
2ff7e61e0d30ff Jeff Mahoney   2016-06-22  3119  	ret = btrfs_write_marked_extents(fs_info, &log->dirty_log_pages, mark);
79787eaab46121 Jeff Mahoney   2012-03-12  3120  	if (ret) {
c6adc9cc082e3c Miao Xie       2013-05-28  3121  		blk_finish_plug(&plug);
66642832f06a43 Jeff Mahoney   2016-06-10  3122  		btrfs_abort_transaction(trans, ret);
907877664e2d85 David Sterba   2019-03-20  3123  		btrfs_set_log_full_commit(trans);
79787eaab46121 Jeff Mahoney   2012-03-12  3124  		mutex_unlock(&root->log_mutex);
79787eaab46121 Jeff Mahoney   2012-03-12  3125  		goto out;
79787eaab46121 Jeff Mahoney   2012-03-12  3126  	}
7237f1833601dc Yan Zheng      2009-01-21  3127
4203e968947071 Josef Bacik    2019-09-30  3128  	/*
4203e968947071 Josef Bacik    2019-09-30  3129  	 * We _must_ update under the root->log_mutex in order to make sure we
4203e968947071 Josef Bacik    2019-09-30  3130  	 * have a consistent view of the log root we are trying to commit at
4203e968947071 Josef Bacik    2019-09-30  3131  	 * this moment.
4203e968947071 Josef Bacik    2019-09-30  3132  	 *
4203e968947071 Josef Bacik    2019-09-30  3133  	 * We _must_ copy this into a local copy, because we are not holding the
4203e968947071 Josef Bacik    2019-09-30  3134  	 * log_root_tree->log_mutex yet.  This is important because when we
4203e968947071 Josef Bacik    2019-09-30  3135  	 * commit the log_root_tree we must have a consistent view of the
4203e968947071 Josef Bacik    2019-09-30  3136  	 * log_root_tree when we update the super block to point at the
4203e968947071 Josef Bacik    2019-09-30  3137  	 * log_root_tree bytenr.  If we update the log_root_tree here we'll race
4203e968947071 Josef Bacik    2019-09-30  3138  	 * with the commit and possibly point at the new block which we may not
4203e968947071 Josef Bacik    2019-09-30  3139  	 * have written out.
4203e968947071 Josef Bacik    2019-09-30  3140  	 */
5d4f98a28c7d33 Yan Zheng      2009-06-10  3141  	btrfs_set_root_node(&log->root_item, log->node);
4203e968947071 Josef Bacik    2019-09-30  3142  	memcpy(&new_root_item, &log->root_item, sizeof(new_root_item));
7237f1833601dc Yan Zheng      2009-01-21  3143
7237f1833601dc Yan Zheng      2009-01-21  3144  	root->log_transid++;
7237f1833601dc Yan Zheng      2009-01-21  3145  	log->log_transid = root->log_transid;
ff782e0a131c7f Josef Bacik    2009-10-08  3146  	root->log_start_pid = 0;
7237f1833601dc Yan Zheng      2009-01-21  3147  	/*
8cef4e160d7492 Yan, Zheng     2009-11-12  3148  	 * IO has been started, blocks of the log tree have WRITTEN flag set
8cef4e160d7492 Yan, Zheng     2009-11-12  3149  	 * in their headers. new modifications of the log will be written to
8cef4e160d7492 Yan, Zheng     2009-11-12  3150  	 * new positions. so it's safe to allow log writers to go in.
7237f1833601dc Yan Zheng      2009-01-21  3151  	 */
7237f1833601dc Yan Zheng      2009-01-21  3152  	mutex_unlock(&root->log_mutex);
7237f1833601dc Yan Zheng      2009-01-21  3153
28a235931b56d4 Filipe Manana  2016-08-23  3154  	btrfs_init_log_ctx(&root_log_ctx, NULL);
d1433debe7f434 Miao Xie       2014-02-20  3155
7237f1833601dc Yan Zheng      2009-01-21 @3156  	mutex_lock(&log_root_tree->log_mutex);
d1433debe7f434 Miao Xie       2014-02-20  3157
d1433debe7f434 Miao Xie       2014-02-20  3158  	index2 = log_root_tree->log_transid % 2;
d1433debe7f434 Miao Xie       2014-02-20  3159  	list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]);
d1433debe7f434 Miao Xie       2014-02-20  3160  	root_log_ctx.log_transid = log_root_tree->log_transid;
d1433debe7f434 Miao Xie       2014-02-20  3161
122cfba0d2eb42 Naohiro Aota   2021-01-26  3162  	mutex_lock(&fs_info->tree_log_mutex);
122cfba0d2eb42 Naohiro Aota   2021-01-26  3163  	if (!log_root_tree->node) {
122cfba0d2eb42 Naohiro Aota   2021-01-26  3164  		ret = btrfs_alloc_log_tree_node(trans, log_root_tree);
122cfba0d2eb42 Naohiro Aota   2021-01-26  3165  		if (ret) {
122cfba0d2eb42 Naohiro Aota   2021-01-26  3166  			mutex_unlock(&fs_info->tree_log_mutex);
122cfba0d2eb42 Naohiro Aota   2021-01-26  3167  			goto out;
122cfba0d2eb42 Naohiro Aota   2021-01-26  3168  		}
122cfba0d2eb42 Naohiro Aota   2021-01-26  3169  	}
122cfba0d2eb42 Naohiro Aota   2021-01-26  3170  	mutex_unlock(&fs_info->tree_log_mutex);
122cfba0d2eb42 Naohiro Aota   2021-01-26  3171
4203e968947071 Josef Bacik    2019-09-30  3172  	/*
4203e968947071 Josef Bacik    2019-09-30  3173  	 * Now we are safe to update the log_root_tree because we're under the
4203e968947071 Josef Bacik    2019-09-30  3174  	 * log_mutex, and we're a current writer so we're holding the commit
4203e968947071 Josef Bacik    2019-09-30  3175  	 * open until we drop the log_mutex.
4203e968947071 Josef Bacik    2019-09-30  3176  	 */
4203e968947071 Josef Bacik    2019-09-30  3177  	ret = update_log_root(trans, log, &new_root_item);
4a500fd178c89b Yan, Zheng     2010-05-16  3178  	if (ret) {
d1433debe7f434 Miao Xie       2014-02-20  3179  		if (!list_empty(&root_log_ctx.list))
d1433debe7f434 Miao Xie       2014-02-20  3180  			list_del_init(&root_log_ctx.list);
d1433debe7f434 Miao Xie       2014-02-20  3181
c6adc9cc082e3c Miao Xie       2013-05-28  3182  		blk_finish_plug(&plug);
907877664e2d85 David Sterba   2019-03-20  3183  		btrfs_set_log_full_commit(trans);
995946dd296177 Miao Xie       2014-04-02  3184
79787eaab46121 Jeff Mahoney   2012-03-12  3185  		if (ret != -ENOSPC) {
66642832f06a43 Jeff Mahoney   2016-06-10  3186  			btrfs_abort_transaction(trans, ret);
79787eaab46121 Jeff Mahoney   2012-03-12  3187  			mutex_unlock(&log_root_tree->log_mutex);
79787eaab46121 Jeff Mahoney   2012-03-12  3188  			goto out;
79787eaab46121 Jeff Mahoney   2012-03-12  3189  		}
bf89d38febaadd Jeff Mahoney   2016-09-09  3190  		btrfs_wait_tree_log_extents(log, mark);
4a500fd178c89b Yan, Zheng     2010-05-16  3191  		mutex_unlock(&log_root_tree->log_mutex);
4a500fd178c89b Yan, Zheng     2010-05-16  3192  		ret = -EAGAIN;
4a500fd178c89b Yan, Zheng     2010-05-16  3193  		goto out;
4a500fd178c89b Yan, Zheng     2010-05-16  3194  	}
4a500fd178c89b Yan, Zheng     2010-05-16  3195
d1433debe7f434 Miao Xie       2014-02-20  3196  	if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) {
3da5ab56482f32 Forrest Liu    2015-01-30  3197  		blk_finish_plug(&plug);
cbd60aa7cd17d8 Chris Mason    2016-09-06  3198  		list_del_init(&root_log_ctx.list);
d1433debe7f434 Miao Xie       2014-02-20  3199  		mutex_unlock(&log_root_tree->log_mutex);
d1433debe7f434 Miao Xie       2014-02-20  3200  		ret = root_log_ctx.log_ret;
d1433debe7f434 Miao Xie       2014-02-20  3201  		goto out;
d1433debe7f434 Miao Xie       2014-02-20  3202  	}
8b050d350c7846 Miao Xie       2014-02-20  3203
d1433debe7f434 Miao Xie       2014-02-20  3204  	index2 = root_log_ctx.log_transid % 2;
7237f1833601dc Yan Zheng      2009-01-21  3205  	if (atomic_read(&log_root_tree->log_commit[index2])) {
c6adc9cc082e3c Miao Xie       2013-05-28  3206  		blk_finish_plug(&plug);
bf89d38febaadd Jeff Mahoney   2016-09-09  3207  		ret = btrfs_wait_tree_log_extents(log, mark);
60d53eb3107c8e Zhaolei        2015-08-17  3208  		wait_log_commit(log_root_tree,
d1433debe7f434 Miao Xie       2014-02-20  3209  				root_log_ctx.log_transid);
7237f1833601dc Yan Zheng      2009-01-21  3210  		mutex_unlock(&log_root_tree->log_mutex);
5ab5e44a36164f Filipe Manana  2014-11-13  3211  		if (!ret)
8b050d350c7846 Miao Xie       2014-02-20  3212  			ret = root_log_ctx.log_ret;
7237f1833601dc Yan Zheng      2009-01-21  3213  		goto out;
7237f1833601dc Yan Zheng      2009-01-21  3214  	}
d1433debe7f434 Miao Xie       2014-02-20  3215  	ASSERT(root_log_ctx.log_transid == log_root_tree->log_transid);
7237f1833601dc Yan Zheng      2009-01-21  3216  	atomic_set(&log_root_tree->log_commit[index2], 1);
7237f1833601dc Yan Zheng      2009-01-21  3217
12fcfd22fe5bf4 Chris Mason    2009-03-24  3218  	if (atomic_read(&log_root_tree->log_commit[(index2 + 1) % 2])) {
60d53eb3107c8e Zhaolei        2015-08-17  3219  		wait_log_commit(log_root_tree,
d1433debe7f434 Miao Xie       2014-02-20  3220  				root_log_ctx.log_transid - 1);
12fcfd22fe5bf4 Chris Mason    2009-03-24  3221  	}
7237f1833601dc Yan Zheng      2009-01-21  3222
12fcfd22fe5bf4 Chris Mason    2009-03-24  3223  	/*
12fcfd22fe5bf4 Chris Mason    2009-03-24  3224  	 * now that we've moved on to the tree of log tree roots,
12fcfd22fe5bf4 Chris Mason    2009-03-24  3225  	 * check the full commit flag again
12fcfd22fe5bf4 Chris Mason    2009-03-24  3226  	 */
4884b8e8ebf54e David Sterba   2019-03-20  3227  	if (btrfs_need_log_full_commit(trans)) {
c6adc9cc082e3c Miao Xie       2013-05-28  3228  		blk_finish_plug(&plug);
bf89d38febaadd Jeff Mahoney   2016-09-09  3229  		btrfs_wait_tree_log_extents(log, mark);
12fcfd22fe5bf4 Chris Mason    2009-03-24  3230  		mutex_unlock(&log_root_tree->log_mutex);
12fcfd22fe5bf4 Chris Mason    2009-03-24  3231  		ret = -EAGAIN;
12fcfd22fe5bf4 Chris Mason    2009-03-24  3232  		goto out_wake_log_root;
12fcfd22fe5bf4 Chris Mason    2009-03-24  3233  	}
7237f1833601dc Yan Zheng      2009-01-21  3234
2ff7e61e0d30ff Jeff Mahoney   2016-06-22  3235  	ret = btrfs_write_marked_extents(fs_info,
8cef4e160d7492 Yan, Zheng     2009-11-12  3236  					 &log_root_tree->dirty_log_pages,
8cef4e160d7492 Yan, Zheng     2009-11-12  3237  					 EXTENT_DIRTY | EXTENT_NEW);
c6adc9cc082e3c Miao Xie       2013-05-28  3238  	blk_finish_plug(&plug);
79787eaab46121 Jeff Mahoney   2012-03-12  3239  	if (ret) {
907877664e2d85 David Sterba   2019-03-20  3240  		btrfs_set_log_full_commit(trans);
66642832f06a43 Jeff Mahoney   2016-06-10  3241  		btrfs_abort_transaction(trans, ret);
79787eaab46121 Jeff Mahoney   2012-03-12  3242  		mutex_unlock(&log_root_tree->log_mutex);
79787eaab46121 Jeff Mahoney   2012-03-12  3243  		goto out_wake_log_root;
79787eaab46121 Jeff Mahoney   2012-03-12  3244  	}
bf89d38febaadd Jeff Mahoney   2016-09-09  3245  	ret = btrfs_wait_tree_log_extents(log, mark);
5ab5e44a36164f Filipe Manana  2014-11-13  3246  	if (!ret)
bf89d38febaadd Jeff Mahoney   2016-09-09  3247  		ret = btrfs_wait_tree_log_extents(log_root_tree,
c6adc9cc082e3c Miao Xie       2013-05-28  3248  						  EXTENT_NEW | EXTENT_DIRTY);
5ab5e44a36164f Filipe Manana  2014-11-13  3249  	if (ret) {
907877664e2d85 David Sterba   2019-03-20  3250  		btrfs_set_log_full_commit(trans);
5ab5e44a36164f Filipe Manana  2014-11-13  3251  		mutex_unlock(&log_root_tree->log_mutex);
5ab5e44a36164f Filipe Manana  2014-11-13  3252  		goto out_wake_log_root;
5ab5e44a36164f Filipe Manana  2014-11-13  3253  	}
e02119d5a7b439 Chris Mason    2008-09-05  3254
47876f7ceffa0e Filipe Manana  2020-11-25  3255  	log_root_start = log_root_tree->node->start;
47876f7ceffa0e Filipe Manana  2020-11-25  3256  	log_root_level = btrfs_header_level(log_root_tree->node);
7237f1833601dc Yan Zheng      2009-01-21  3257  	log_root_tree->log_transid++;
7237f1833601dc Yan Zheng      2009-01-21  3258  	mutex_unlock(&log_root_tree->log_mutex);
7237f1833601dc Yan Zheng      2009-01-21  3259
7237f1833601dc Yan Zheng      2009-01-21  3260  	/*
47876f7ceffa0e Filipe Manana  2020-11-25  3261  	 * Here we are guaranteed that nobody is going to write the superblock
47876f7ceffa0e Filipe Manana  2020-11-25  3262  	 * for the current transaction before us and that neither we do write
47876f7ceffa0e Filipe Manana  2020-11-25  3263  	 * our superblock before the previous transaction finishes its commit
47876f7ceffa0e Filipe Manana  2020-11-25  3264  	 * and writes its superblock, because:
47876f7ceffa0e Filipe Manana  2020-11-25  3265  	 *
47876f7ceffa0e Filipe Manana  2020-11-25  3266  	 * 1) We are holding a handle on the current transaction, so no body
47876f7ceffa0e Filipe Manana  2020-11-25  3267  	 *    can commit it until we release the handle;
47876f7ceffa0e Filipe Manana  2020-11-25  3268  	 *
47876f7ceffa0e Filipe Manana  2020-11-25  3269  	 * 2) Before writing our superblock we acquire the tree_log_mutex, so
47876f7ceffa0e Filipe Manana  2020-11-25  3270  	 *    if the previous transaction is still committing, and hasn't yet
47876f7ceffa0e Filipe Manana  2020-11-25  3271  	 *    written its superblock, we wait for it to do it, because a
47876f7ceffa0e Filipe Manana  2020-11-25  3272  	 *    transaction commit acquires the tree_log_mutex when the commit
47876f7ceffa0e Filipe Manana  2020-11-25  3273  	 *    begins and releases it only after writing its superblock.
7237f1833601dc Yan Zheng      2009-01-21  3274  	 */
47876f7ceffa0e Filipe Manana  2020-11-25  3275  	mutex_lock(&fs_info->tree_log_mutex);
47876f7ceffa0e Filipe Manana  2020-11-25  3276  	btrfs_set_super_log_root(fs_info->super_for_commit, log_root_start);
47876f7ceffa0e Filipe Manana  2020-11-25  3277  	btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level);
eece6a9cf69140 David Sterba   2017-02-10  3278  	ret = write_all_supers(fs_info, 1);
47876f7ceffa0e Filipe Manana  2020-11-25  3279  	mutex_unlock(&fs_info->tree_log_mutex);
5af3e8cce8b7ba Stefan Behrens 2012-08-01  3280  	if (ret) {
907877664e2d85 David Sterba   2019-03-20  3281  		btrfs_set_log_full_commit(trans);
66642832f06a43 Jeff Mahoney   2016-06-10  3282  		btrfs_abort_transaction(trans, ret);
5af3e8cce8b7ba Stefan Behrens 2012-08-01  3283  		goto out_wake_log_root;
5af3e8cce8b7ba Stefan Behrens 2012-08-01  3284  	}
7237f1833601dc Yan Zheng      2009-01-21  3285
257c62e1bce03e Chris Mason    2009-10-13  3286  	mutex_lock(&root->log_mutex);
257c62e1bce03e Chris Mason    2009-10-13  3287  	if (root->last_log_commit < log_transid)
257c62e1bce03e Chris Mason    2009-10-13  3288  		root->last_log_commit = log_transid;
257c62e1bce03e Chris Mason    2009-10-13  3289  	mutex_unlock(&root->log_mutex);
257c62e1bce03e Chris Mason    2009-10-13  3290
12fcfd22fe5bf4 Chris Mason    2009-03-24  3291  out_wake_log_root:
570dd45042a7c8 Chris Mason    2016-10-27  3292  	mutex_lock(&log_root_tree->log_mutex);
8b050d350c7846 Miao Xie       2014-02-20  3293  	btrfs_remove_all_log_ctxs(log_root_tree, index2, ret);
8b050d350c7846 Miao Xie       2014-02-20  3294
d1433debe7f434 Miao Xie       2014-02-20  3295  	log_root_tree->log_transid_committed++;
7237f1833601dc Yan Zheng      2009-01-21  3296  	atomic_set(&log_root_tree->log_commit[index2], 0);
d1433debe7f434 Miao Xie       2014-02-20  3297  	mutex_unlock(&log_root_tree->log_mutex);
d1433debe7f434 Miao Xie       2014-02-20  3298
33a9eca7e4a4c2 David Sterba   2015-10-10  3299  	/*
093258e6ebaf17 David Sterba   2018-02-26  3300  	 * The barrier before waitqueue_active (in cond_wake_up) is needed so
093258e6ebaf17 David Sterba   2018-02-26  3301  	 * all the updates above are seen by the woken threads. It might not be
093258e6ebaf17 David Sterba   2018-02-26  3302  	 * necessary, but proving that seems to be hard.
33a9eca7e4a4c2 David Sterba   2015-10-10  3303  	 */
093258e6ebaf17 David Sterba   2018-02-26  3304  	cond_wake_up(&log_root_tree->log_commit_wait[index2]);
e02119d5a7b439 Chris Mason    2008-09-05  3305  out:
d1433debe7f434 Miao Xie       2014-02-20  3306  	mutex_lock(&root->log_mutex);
570dd45042a7c8 Chris Mason    2016-10-27  3307  	btrfs_remove_all_log_ctxs(root, index1, ret);
d1433debe7f434 Miao Xie       2014-02-20  3308  	root->log_transid_committed++;
7237f1833601dc Yan Zheng      2009-01-21  3309  	atomic_set(&root->log_commit[index1], 0);
d1433debe7f434 Miao Xie       2014-02-20  3310  	mutex_unlock(&root->log_mutex);
8b050d350c7846 Miao Xie       2014-02-20  3311
33a9eca7e4a4c2 David Sterba   2015-10-10  3312  	/*
093258e6ebaf17 David Sterba   2018-02-26  3313  	 * The barrier before waitqueue_active (in cond_wake_up) is needed so
093258e6ebaf17 David Sterba   2018-02-26  3314  	 * all the updates above are seen by the woken threads. It might not be
093258e6ebaf17 David Sterba   2018-02-26  3315  	 * necessary, but proving that seems to be hard.
33a9eca7e4a4c2 David Sterba   2015-10-10  3316  	 */
093258e6ebaf17 David Sterba   2018-02-26  3317  	cond_wake_up(&root->log_commit_wait[index1]);
b31eabd86eb68d Chris Mason    2011-01-31 @3318  	return ret;
e02119d5a7b439 Chris Mason    2008-09-05  3319  }
e02119d5a7b439 Chris Mason    2008-09-05  3320

:::::: The code at line 3318 was first introduced by commit
:::::: b31eabd86eb68d3c217e6821078249bc045e698a Btrfs: catch errors from btrfs_sync_log

:::::: TO: Chris Mason <[email protected]>
:::::: CC: Chris Mason <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org