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

Method _do_filelock

src/client/Client.cc:13620–13732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13618}
13619
13620int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep,
13621 struct flock *fl, uint64_t owner, bool removing)
13622{
13623 ldout(cct, 10) << __func__ << " ino " << in->ino
13624 << (lock_type == CEPH_LOCK_FCNTL ? " fcntl" : " flock")
13625 << " type " << fl->l_type << " owner " << owner
13626 << " " << fl->l_start << "~" << fl->l_len << dendl;
13627
13628 if (in->flags & I_ERROR_FILELOCK)
13629 return -EIO;
13630
13631 int lock_cmd;
13632 if (F_RDLCK == fl->l_type)
13633 lock_cmd = CEPH_LOCK_SHARED;
13634 else if (F_WRLCK == fl->l_type)
13635 lock_cmd = CEPH_LOCK_EXCL;
13636 else if (F_UNLCK == fl->l_type)
13637 lock_cmd = CEPH_LOCK_UNLOCK;
13638 else
13639 return -EIO;
13640
13641 if (op != CEPH_MDS_OP_SETFILELOCK || lock_cmd == CEPH_LOCK_UNLOCK)
13642 sleep = 0;
13643
13644 /*
13645 * Set the most significant bit, so that MDS knows the 'owner'
13646 * is sufficient to identify the owner of lock. (old code uses
13647 * both 'owner' and 'pid')
13648 */
13649 owner |= (1ULL << 63);
13650
13651 MetaRequest *req = new MetaRequest(op);
13652 filepath path;
13653 in->make_nosnap_relative_path(path); //FIXME why not filepath(ino=in->ino) ??
13654 req->set_filepath(path);
13655 req->set_inode(in);
13656
13657 req->head.args.filelock_change.rule = lock_type;
13658 req->head.args.filelock_change.type = lock_cmd;
13659 req->head.args.filelock_change.owner = owner;
13660 req->head.args.filelock_change.pid = fl->l_pid;
13661 req->head.args.filelock_change.start = fl->l_start;
13662 req->head.args.filelock_change.length = fl->l_len;
13663 req->head.args.filelock_change.wait = sleep;
13664
13665 int ret;
13666 bufferlist bl;
13667
13668 if (sleep && switch_interrupt_cb) {
13669 // enable interrupt
13670 switch_interrupt_cb(callback_handle, req->get());
13671 ret = make_request(req, fh->actor_perms, NULL, NULL, -1, &bl);
13672 // disable interrupt
13673 switch_interrupt_cb(callback_handle, NULL);
13674 if (ret == 0 && req->aborted()) {
13675 // effect of this lock request has been revoked by the 'lock intr' request
13676 ret = req->get_abort_code();
13677 }

Callers

nothing calls this directly

Calls 11

switch_interrupt_cbFunction · 0.85
set_inodeMethod · 0.80
abortedMethod · 0.80
get_abort_codeMethod · 0.80
make_requestFunction · 0.50
decodeFunction · 0.50
set_filepathMethod · 0.45
getMethod · 0.45
cbeginMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected