]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: take the first inode as root, rather than whatever comes out
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 6 Jul 2010 19:02:18 +0000 (12:02 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 6 Jul 2010 19:02:33 +0000 (12:02 -0700)
with ino=1.

Also, translate root inode properly in fuse_ll.

man/cfuse.8
src/cfuse.cc
src/client/Client.cc
src/client/Client.h
src/client/fuse_ll.cc
src/config.cc
src/config.h

index 318194eef0baa5c17113aa32aebe457292ec4ae4..e51b751365ae124f83ae7664fe478534e46ff345 100644 (file)
@@ -30,6 +30,9 @@ to determine monitor addresses during startup.
 .TP
 \fB\-m\fI monaddress[:port]\fR
 Connect to specified monitor (instead of looking through \fIceph.conf\fR).
+.TP
+\fB\-r\fI root_directory\fR
+Use root_directory as the mounted root, rather than the full Ceph tree.
 .SH AVAILABILITY
 .B cfuse
 is part of the Ceph distributed file system.  Please refer to the Ceph wiki at
index e4382f62dae8864d8e8e9a46d4189a8213fff7ad..c8f5e43625184a5a5cf92ea5a394e003bb356b08 100644 (file)
@@ -105,7 +105,7 @@ int main(int argc, const char **argv, const char *envp[]) {
     
     // start up fuse
     // use my argc, argv (make sure you pass a mount point!)
-    int r = client->mount();
+    int r = client->mount(g_conf.client_mountpoint);
     if (r < 0) {
       cerr << "cfuse[" << getpid() << "]: ceph mount failed with " << strerror(-r) << std::endl;
       goto out_shutdown;
index 18524b96256d64ee0024a4bd00f803fdbed7779f..529bcdadfe9b2505688412e8e0a59e32c2625f3e 100644 (file)
@@ -426,7 +426,9 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from, int mds)
   else {
     in = new Inode(st->vino, &st->layout);
     inode_map[st->vino] = in;
-    if (in->ino == 1) {
+    bool new_root = false;
+    if (!root) {
+      new_root = true;
       root = in;
       cwd = root;
       cwd->get();
@@ -437,6 +439,7 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from, int mds)
     in->snapid = st->vino.snapid;
     in->rdev = st->rdev;
     in->mode = st->mode & S_IFMT;
+    if (new_root) dout(10) << "setting this inode as root! " << *in << "; ino: " << root->ino << "; snapid" << root->snapid << dendl;
     if (in->is_symlink())
       in->symlink = st->symlink;
   }
@@ -2748,7 +2751,7 @@ void Client::handle_cap_grant(Inode *in, int mds, InodeCap *cap, MClientCaps *m)
 // -------------------
 // MOUNT
 
-int Client::mount()
+int Client::mount(const char *mount_root)
 {
   Mutex::Locker lock(client_lock);
 
@@ -2781,6 +2784,7 @@ int Client::mount()
   //  fuse assumes it's always there.
   MetaRequest *req = new MetaRequest(CEPH_MDS_OP_GETATTR);
   filepath fp(CEPH_INO_ROOT);
+  if (mount_root) fp = filepath(mount_root);
   req->set_filepath(fp);
   req->head.args.getattr.mask = CEPH_STAT_CAP_INODE_ALL;
   int res = make_request(req, -1, -1);
index 81c914e9379a8fe3543e41b19b5440c8413d00a4..d5d409b16a9a7b67a9526da258e3ca67d68c4bd1 100644 (file)
@@ -1019,6 +1019,7 @@ protected:
   void tear_down_cache();   
 
   client_t get_nodeid() { return whoami; }
+  inodeno_t get_root_ino() { return root->ino; }
 
   void init();
   void shutdown();
@@ -1145,7 +1146,7 @@ private:
                    Dentry **pdn, bool expect_null=false);
 
 public:
-  int mount();
+  int mount(const char *mount_root = NULL);
   int unmount();
 
   // these shoud (more or less) mirror the actual system calls.
index b452e5aa1b1133dace08541415c8ad8a268db210..0c238d93b44b355adb0e94c27e550fdb8b5f476a 100644 (file)
@@ -47,6 +47,9 @@ static uint64_t fino_snap(uint64_t fino)
 }
 static vinodeno_t fino_vino(inodeno_t fino)
 {
+  if (fino.val == 1) {
+    fino = inodeno_t(client->get_root_ino());
+  }
   vinodeno_t vino(FINO_INO(fino), fino_snap(fino));
   //cout << "fino_vino " << fino << " -> " << vino << std::endl;
   return vino;
index bca6c15898874ec5a2728b8501f484f8507b0d46..f6eaee3d4a872aa432562afddf80bb6f23270ae5 100644 (file)
@@ -351,6 +351,7 @@ static struct config_option config_optionsp[] = {
        OPTION(client_readahead_max_bytes, 0, OPT_LONGLONG, 0),  //8 * 1024*1024,
        OPTION(client_readahead_max_periods, 0, OPT_LONGLONG, 4),  // as multiple of file layout period (object size * num stripes)
        OPTION(client_snapdir, 0, OPT_STR, ".snap"),
+       OPTION(client_mountpoint, 'r', OPT_STR, "/"),
        OPTION(fuse_direct_io, 0, OPT_INT, 0),
        OPTION(fuse_ll, 0, OPT_BOOL, true),
        OPTION(client_oc, 0, OPT_BOOL, true),
index f8f8e1317ee91ed1f7e0bb1c9bd011e693becf20..c13f9bd2d1cb531ad9fd7dd608685db066b4182b 100644 (file)
@@ -185,6 +185,7 @@ struct md_config_t {
   long long client_readahead_max_bytes;
   long long client_readahead_max_periods;
   const char *client_snapdir;
+  const char *client_mountpoint;
   int fuse_direct_io;
   bool fuse_ll;