Unverified Commit f6f5059a authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files
parents 844b9b09 74ca7f7e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -69,6 +69,14 @@ static int nothing_to_commit(struct ubifs_info *c)
	if (c->zroot.znode && ubifs_zn_dirty(c->zroot.znode))
		return 0;

	/*
	 * Increasing @c->dirty_pn_cnt/@c->dirty_nn_cnt and marking
	 * nnodes/pnodes as dirty in run_gc() could race with following
	 * checking, which leads inconsistent states between @c->nroot
	 * and @c->dirty_pn_cnt/@c->dirty_nn_cnt, holding @c->lp_mutex
	 * to avoid that.
	 */
	mutex_lock(&c->lp_mutex);
	/*
	 * Even though the TNC is clean, the LPT tree may have dirty nodes. For
	 * example, this may happen if the budgeting subsystem invoked GC to
@@ -76,12 +84,15 @@ static int nothing_to_commit(struct ubifs_info *c)
	 * free space. In this case GC would just change the lprops of this
	 * LEB (by turning all space into free space) and unmap it.
	 */
	if (c->nroot && test_bit(DIRTY_CNODE, &c->nroot->flags))
	if (c->nroot && test_bit(DIRTY_CNODE, &c->nroot->flags)) {
		mutex_unlock(&c->lp_mutex);
		return 0;
	}

	ubifs_assert(c, atomic_long_read(&c->dirty_zn_cnt) == 0);
	ubifs_assert(c, c->dirty_pn_cnt == 0);
	ubifs_assert(c, c->dirty_nn_cnt == 0);
	mutex_unlock(&c->lp_mutex);

	return 1;
}