]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add options to specify caller_{uid,gid} of MClientCaps
authorYan, Zheng <zyan@redhat.com>
Fri, 14 Aug 2015 07:04:22 +0000 (15:04 +0800)
committerSage Weil <sage@redhat.com>
Thu, 1 Oct 2015 13:41:31 +0000 (09:41 -0400)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc
src/client/Client.h
src/common/config_opts.h

index 4f49bb425ab2ba7fce715891ded9b78c53292412..1b8849ee45d4a70d6606f98049e1090346164816 100644 (file)
@@ -266,6 +266,9 @@ Client::Client(Messenger *m, MonClient *mc)
   _dir_vxattrs_name_size = _vxattrs_calcu_name_size(_dir_vxattrs);
   _file_vxattrs_name_size = _vxattrs_calcu_name_size(_file_vxattrs);
 
+  user_id = cct->_conf->client_user_id;
+  group_id = cct->_conf->client_group_id;
+
   lru.lru_set_max(cct->_conf->client_cache_size);
   lru.lru_set_midpoint(cct->_conf->client_cache_mid);
 
@@ -3021,6 +3024,11 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap,
                                   flush,
                                   cap->mseq,
                                    cap_epoch_barrier);
+  if (user_id >= 0)
+    m->caller_uid = user_id;
+  if (group_id >= 0)
+    m->caller_gid = group_id;
+
   m->head.issue_seq = cap->issue_seq;
   m->set_tid(flush_tid);
 
@@ -3291,7 +3299,12 @@ void Client::flush_snaps(Inode *in, bool all_again, CapSnap *again)
 
     capsnap->flush_tid = ++last_flush_tid;
     MClientCaps *m = new MClientCaps(CEPH_CAP_OP_FLUSHSNAP, in->ino, in->snaprealm->ino, 0, mseq,
-        cap_epoch_barrier);
+                                    cap_epoch_barrier);
+    if (user_id >= 0)
+      m->caller_uid = user_id;
+    if (group_id >= 0)
+      m->caller_gid = group_id;
+
     m->set_client_tid(capsnap->flush_tid);
     m->head.snap_follows = p->first;
 
index 6a92a8a33e4b03edfa8bd36e488f6b94c859d412..4428e653347f26f4b2615bd756d7687cde29f6b9 100644 (file)
@@ -262,11 +262,13 @@ class Client : public Dispatcher, public md_config_obs_t {
 public:
   void tick();
 
- protected:
+protected:
   MonClient *monclient;
   Messenger *messenger;  
   client_t whoami;
 
+  int user_id, group_id;
+
   void set_cap_epoch_barrier(epoch_t e);
   epoch_t cap_epoch_barrier;
 
index 71a2ebca9e79fa8487828f9869e7fc291e533b76..7a1980165611f83ad8824a989561f906f5264b49 100644 (file)
@@ -354,6 +354,7 @@ OPTION(client_debug_inject_tick_delay, OPT_INT, 0) // delay the client tick for
 OPTION(client_max_inline_size, OPT_U64, 4096)
 OPTION(client_inject_release_failure, OPT_BOOL, false)  // synthetic client bug for testing
 OPTION(client_inject_fixed_oldest_tid, OPT_BOOL, false)  // synthetic client bug for testing
+
 // note: the max amount of "in flight" dirty data is roughly (max - target)
 OPTION(fuse_use_invalidate_cb, OPT_BOOL, false) // use fuse 2.8+ invalidate callback to keep page cache consistent
 OPTION(fuse_allow_other, OPT_BOOL, true)
@@ -363,6 +364,9 @@ OPTION(fuse_atomic_o_trunc, OPT_BOOL, true)
 OPTION(fuse_debug, OPT_BOOL, false)
 OPTION(fuse_multithreaded, OPT_BOOL, true)
 OPTION(fuse_require_active_mds, OPT_BOOL, true) // if ceph_fuse requires active mds server
+
+OPTION(client_user_id, OPT_INT, -1)
+OPTION(client_group_id, OPT_INT, -1)
 OPTION(client_try_dentry_invalidate, OPT_BOOL, true) // the client should try to use dentry invaldation instead of remounting, on kernels it believes that will work for
 OPTION(client_die_on_failed_remount, OPT_BOOL, true)
 OPTION(client_check_pool_perm, OPT_BOOL, true)