backref.c (98cc42227a1b9b0fb6e89729d08f87f9356bb846) backref.c (9665ebd5dba6a2c36cf67827ab074680c4fc2197)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2011 STRATO. All rights reserved.
4 */
5
6#include <linux/mm.h>
7#include <linux/rbtree.h>
8#include <trace/events/btrfs.h>

--- 1190 unchanged lines hidden (view full) ---

1199 if (!trans) {
1200 path->search_commit_root = 1;
1201 path->skip_locking = 1;
1202 }
1203
1204 if (time_seq == BTRFS_SEQ_LAST)
1205 path->skip_locking = 1;
1206
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2011 STRATO. All rights reserved.
4 */
5
6#include <linux/mm.h>
7#include <linux/rbtree.h>
8#include <trace/events/btrfs.h>

--- 1190 unchanged lines hidden (view full) ---

1199 if (!trans) {
1200 path->search_commit_root = 1;
1201 path->skip_locking = 1;
1202 }
1203
1204 if (time_seq == BTRFS_SEQ_LAST)
1205 path->skip_locking = 1;
1206
1207 /*
1208 * grab both a lock on the path and a lock on the delayed ref head.
1209 * We need both to get a consistent picture of how the refs look
1210 * at a specified point in time
1211 */
1212again:
1213 head = NULL;
1214
1215 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1216 if (ret < 0)
1217 goto out;
1218 BUG_ON(ret == 0);
1219
1220#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1221 if (trans && likely(trans->type != __TRANS_DUMMY) &&
1222 time_seq != BTRFS_SEQ_LAST) {
1223#else
1224 if (trans && time_seq != BTRFS_SEQ_LAST) {
1225#endif
1226 /*
1207again:
1208 head = NULL;
1209
1210 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1211 if (ret < 0)
1212 goto out;
1213 BUG_ON(ret == 0);
1214
1215#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1216 if (trans && likely(trans->type != __TRANS_DUMMY) &&
1217 time_seq != BTRFS_SEQ_LAST) {
1218#else
1219 if (trans && time_seq != BTRFS_SEQ_LAST) {
1220#endif
1221 /*
1227 * look if there are updates for this ref queued and lock the
1228 * head
1222 * We have a specific time_seq we care about and trans which
1223 * means we have the path lock, we need to grab the ref head and
1224 * lock it so we have a consistent view of the refs at the given
1225 * time.
1229 */
1230 delayed_refs = &trans->transaction->delayed_refs;
1231 spin_lock(&delayed_refs->lock);
1232 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
1233 if (head) {
1234 if (!mutex_trylock(&head->mutex)) {
1235 refcount_inc(&head->refs);
1236 spin_unlock(&delayed_refs->lock);

--- 1889 unchanged lines hidden ---
1226 */
1227 delayed_refs = &trans->transaction->delayed_refs;
1228 spin_lock(&delayed_refs->lock);
1229 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
1230 if (head) {
1231 if (!mutex_trylock(&head->mutex)) {
1232 refcount_inc(&head->refs);
1233 spin_unlock(&delayed_refs->lock);

--- 1889 unchanged lines hidden ---