]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: make SETDIRLAYOUT start with ancestor policy
authorSage Weil <sage.weil@dreamhost.com>
Thu, 3 Feb 2011 19:54:01 +0000 (11:54 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Thu, 3 Feb 2011 19:54:01 +0000 (11:54 -0800)
When we set a new policy on a directory, make the starting point the
current policy, as specified by an ancestor.  Remove any reference to
g_default_file_layout.

This aligns the code with the inode creation paths (the other time we
look at the layout policy).

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/mds/Server.cc
src/mds/Server.h

index 109539f37d56d63626ffd798020e2bd1ec7f1fd4..6794c4059c4d4ac636bf47abc650e1e5282ab542 100644 (file)
@@ -1766,8 +1766,9 @@ CDir *Server::traverse_to_auth_dir(MDRequest *mdr, vector<CDentry*> &trace, file
 CInode* Server::rdlock_path_pin_ref(MDRequest *mdr, int n,
                                    set<SimpleLock*> &rdlocks,
                                    bool want_auth,
-                                   bool no_want_auth)  /* for readdir, who doesn't want auth _even_if_ it's
-                                                          a snapped dir */
+                                   bool no_want_auth, /* for readdir, who doesn't want auth _even_if_ it's
+                                                         a snapped dir */
+                                   ceph_file_layout **layout) 
 {
   MClientRequest *req = mdr->client_request;
   const filepath& refpath = n ? req->get_filepath2() : req->get_filepath();
@@ -1822,7 +1823,10 @@ CInode* Server::rdlock_path_pin_ref(MDRequest *mdr, int n,
 
   for (int i=0; i<(int)mdr->dn[n].size(); i++) 
     rdlocks.insert(&mdr->dn[n][i]->lock);
-  mds->locker->include_snap_rdlocks(rdlocks, ref);
+  if (layout)
+    mds->locker->include_snap_rdlocks_wlayout(rdlocks, ref, layout);
+  else
+    mds->locker->include_snap_rdlocks(rdlocks, ref);
 
   // set and pin ref
   mdr->pin(ref);
@@ -2989,7 +2993,8 @@ void Server::handle_client_setdirlayout(MDRequest *mdr)
 {
   MClientRequest *req = mdr->client_request;
   set<SimpleLock*> rdlocks, wrlocks, xlocks;
-  CInode *cur = rdlock_path_pin_ref(mdr, 0, rdlocks, true);
+  ceph_file_layout *dir_layout = NULL;
+  CInode *cur = rdlock_path_pin_ref(mdr, 0, rdlocks, true, false, &dir_layout);
   if (!cur) return;
 
   if (mdr->snapid != CEPH_NOSNAP) {
@@ -3010,10 +3015,10 @@ void Server::handle_client_setdirlayout(MDRequest *mdr)
   default_file_layout *layout = new default_file_layout;
   if (cur->get_projected_dir_layout())
     layout->layout = *cur->get_projected_dir_layout();
-  else {
-    layout->layout = g_default_file_layout;
-    layout->layout.fl_pg_pool = mds->mdsmap->get_data_pg_pool();
-  }
+  else if (dir_layout)
+    layout->layout = *dir_layout;
+  else
+    layout->layout = mds->mdcache->default_file_layout;
 
   if (req->head.args.setlayout.layout.fl_object_size > 0)
     layout->layout.fl_object_size = req->head.args.setlayout.layout.fl_object_size;
index 76a7310621799f321240bb7769beb81708fd79cd..721b266928b38f4de4967ddef97cd11c805c5363 100644 (file)
@@ -124,7 +124,8 @@ public:
   void apply_allocated_inos(MDRequest *mdr);
 
   CInode* rdlock_path_pin_ref(MDRequest *mdr, int n, set<SimpleLock*>& rdlocks, bool want_auth,
-                             bool no_want_auth=false);
+                             bool no_want_auth=false,
+                             ceph_file_layout **layout=NULL);
   CDentry* rdlock_path_xlock_dentry(MDRequest *mdr, int n, set<SimpleLock*>& rdlocks, set<SimpleLock*>& wrlocks, 
                                    set<SimpleLock*>& xlocks, bool okexist, bool mustexist, bool alwaysxlock,
                                    ceph_file_layout **layout=NULL);