@@ -301,9 +301,11 @@ static noinline_for_stack void do_trace_key_cache_fill(struct btree_trans *trans
301
301
}
302
302
303
303
static noinline int btree_key_cache_fill (struct btree_trans * trans ,
304
- struct btree_path * ck_path ,
304
+ btree_path_idx_t ck_path_idx ,
305
305
unsigned flags )
306
306
{
307
+ struct btree_path * ck_path = trans -> paths + ck_path_idx ;
308
+
307
309
if (flags & BTREE_ITER_cached_nofill ) {
308
310
ck_path -> l [0 ].b = NULL ;
309
311
return 0 ;
@@ -325,6 +327,7 @@ static noinline int btree_key_cache_fill(struct btree_trans *trans,
325
327
goto err ;
326
328
327
329
/* Recheck after btree lookup, before allocating: */
330
+ ck_path = trans -> paths + ck_path_idx ;
328
331
ret = bch2_btree_key_cache_find (c , ck_path -> btree_id , ck_path -> pos ) ? - EEXIST : 0 ;
329
332
if (unlikely (ret ))
330
333
goto out ;
@@ -344,10 +347,11 @@ static noinline int btree_key_cache_fill(struct btree_trans *trans,
344
347
}
345
348
346
349
static inline int btree_path_traverse_cached_fast (struct btree_trans * trans ,
347
- struct btree_path * path )
350
+ btree_path_idx_t path_idx )
348
351
{
349
352
struct bch_fs * c = trans -> c ;
350
353
struct bkey_cached * ck ;
354
+ struct btree_path * path = trans -> paths + path_idx ;
351
355
retry :
352
356
ck = bch2_btree_key_cache_find (c , path -> btree_id , path -> pos );
353
357
if (!ck )
@@ -373,27 +377,32 @@ static inline int btree_path_traverse_cached_fast(struct btree_trans *trans,
373
377
return 0 ;
374
378
}
375
379
376
- int bch2_btree_path_traverse_cached (struct btree_trans * trans , struct btree_path * path ,
380
+ int bch2_btree_path_traverse_cached (struct btree_trans * trans ,
381
+ btree_path_idx_t path_idx ,
377
382
unsigned flags )
378
383
{
379
- EBUG_ON (path -> level );
380
-
381
- path -> l [1 ].b = NULL ;
384
+ EBUG_ON (trans -> paths [path_idx ].level );
382
385
383
386
int ret ;
384
387
do {
385
- ret = btree_path_traverse_cached_fast (trans , path );
388
+ ret = btree_path_traverse_cached_fast (trans , path_idx );
386
389
if (unlikely (ret == - ENOENT ))
387
- ret = btree_key_cache_fill (trans , path , flags );
390
+ ret = btree_key_cache_fill (trans , path_idx , flags );
388
391
} while (ret == - EEXIST );
389
392
393
+ struct btree_path * path = trans -> paths + path_idx ;
394
+
390
395
if (unlikely (ret )) {
391
396
path -> uptodate = BTREE_ITER_NEED_TRAVERSE ;
392
397
if (!bch2_err_matches (ret , BCH_ERR_transaction_restart )) {
393
398
btree_node_unlock (trans , path , 0 );
394
399
path -> l [0 ].b = ERR_PTR (ret );
395
400
}
401
+ } else {
402
+ BUG_ON (path -> uptodate );
403
+ BUG_ON (!path -> nodes_locked );
396
404
}
405
+
397
406
return ret ;
398
407
}
399
408
0 commit comments