From: Greg Farnum Date: Tue, 2 Aug 2016 02:15:51 +0000 (-0700) Subject: client: store "actor" UserPerm in Fh, use for requesting file locks and things X-Git-Tag: v11.0.1~36^2~47 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4cc7c40b832738589dac39c53747282ee7f4e4c8;p=ceph.git client: store "actor" UserPerm in Fh, use for requesting file locks and things Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index c4c7881eee2..3820093384b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7708,7 +7708,7 @@ int Client::lookup_name(Inode *ino, Inode *parent, const UserPerm& perms) } -Fh *Client::_create_fh(Inode *in, int flags, int cmode) + Fh *Client::_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms) { // yay Fh *f = new Fh; @@ -7718,6 +7718,7 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode) // inode assert(in); f->inode = in; + f->actor_perms = perms; ldout(cct, 10) << "_create_fh " << in->ino << " mode " << cmode << dendl; @@ -7826,7 +7827,7 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, // success? if (result >= 0) { if (fhp) - *fhp = _create_fh(in, flags, cmode); + *fhp = _create_fh(in, flags, cmode, perms); } else { in->put_open_ref(cmode); } @@ -9009,7 +9010,7 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep, int ret; bufferlist bl; - UserPerm perms(get_uid(), get_gid()); // FIXME + UserPerm perms(fh->actor_uid, fh->actor_gid); if (sleep && switch_interrupt_cb) { // enable interrupt switch_interrupt_cb(callback_handle, req->get()); @@ -10639,7 +10640,7 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode, /* If the caller passed a value in fhp, do the open */ if(fhp) { (*inp)->get_open_ref(cmode); - *fhp = _create_fh(inp->get(), flags, cmode); + *fhp = _create_fh(inp->get(), flags, cmode, perms); } reply_error: diff --git a/src/client/Client.h b/src/client/Client.h index cc4970f89aa..2f55fcd96c6 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -759,7 +759,7 @@ private: int _ll_put(Inode *in, int num); void _ll_drop_pins(); - Fh *_create_fh(Inode *in, int flags, int cmode); + Fh *_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms); int _release_fh(Fh *fh); void _put_fh(Fh *fh); diff --git a/src/client/Fh.h b/src/client/Fh.h index db3a28c47a8..170d0e70301 100644 --- a/src/client/Fh.h +++ b/src/client/Fh.h @@ -21,14 +21,16 @@ struct Fh { bool pos_locked; // pos is currently in use list pos_waiters; // waiters for pos + UserPerm actor_perms; // perms I opened the file with + Readahead readahead; // file lock ceph_lock_state_t *fcntl_locks; ceph_lock_state_t *flock_locks; - + Fh() : _ref(1), pos(0), mds(0), mode(0), flags(0), pos_locked(false), - readahead(), fcntl_locks(NULL), flock_locks(NULL) {} + actor_perms(), readahead(), fcntl_locks(NULL), flock_locks(NULL) {} void get() { ++_ref; } int put() { return --_ref; } };