MCPcopy Create free account
hub / github.com/ceph/ceph / Lock

Function Lock

src/libcephsqlite.cc:272–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270#define getdata(vfs) (*((cephsqlite_appdata*)((vfs)->pAppData)))
271
272static int Lock(sqlite3_file *file, int ilock)
273{
274 auto f = (cephsqlite_file*)file;
275 auto start = ceph::coarse_mono_clock::now();
276 df(5) << std::hex << ilock << dendl;
277
278 auto& lock = f->lock;
279 ceph_assert(!f->io.rs->is_locked() || lock > SQLITE_LOCK_NONE);
280 ceph_assert(lock <= ilock);
281 if (!f->io.rs->is_locked() && ilock > SQLITE_LOCK_NONE) {
282 if (int rc = f->io.rs->lock(0); rc < 0) {
283 df(5) << "failed: " << rc << dendl;
284 if (rc == -EBLOCKLISTED) {
285 getdata(f->vfs).maybe_reconnect(f->io.cluster);
286 }
287 return SQLITE_IOERR;
288 }
289 }
290
291 lock = ilock;
292 auto end = ceph::coarse_mono_clock::now();
293 getdata(f->vfs).logger->tinc(P_OPF_LOCK, end-start);
294 return SQLITE_OK;
295}
296
297static int Unlock(sqlite3_file *file, int ilock)
298{

Callers

nothing calls this directly

Calls 5

maybe_reconnectMethod · 0.80
nowFunction · 0.50
is_lockedMethod · 0.45
lockMethod · 0.45
tincMethod · 0.45

Tested by

no test coverage detected