2022-11-19 02:21:11 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
#include "bcachefs.h"
|
|
|
|
#include "nocow_locking.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
void __bch2_bucket_nocow_lock(struct bucket_nocow_lock_table *t,
|
2022-11-27 01:09:59 +03:00
|
|
|
two_state_lock_t *l, int flags)
|
2022-11-19 02:21:11 +03:00
|
|
|
{
|
|
|
|
struct bch_fs *c = container_of(t, struct bch_fs, nocow_locks);
|
|
|
|
u64 start_time = local_clock();
|
|
|
|
|
2022-11-27 01:09:59 +03:00
|
|
|
__bch2_two_state_lock(l, flags & BUCKET_NOCOW_LOCK_UPDATE);
|
2022-11-19 02:21:11 +03:00
|
|
|
bch2_time_stats_update(&c->times[BCH_TIME_nocow_lock_contended], start_time);
|
|
|
|
}
|