]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Explicitly initialize layout fields, and to the correct values.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 28 Jun 2011 00:03:42 +0000 (17:03 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 28 Jun 2011 15:19:57 +0000 (08:19 -0700)
We were previously encoding an fl_pg_preferred of 0, which did
horrible things to the kernel client since 0 is a valid osd to ask for!
To make such things easier to track down in the future, explicitly
fill in defaults when memsetting the struct here.

(There remain other places that memset the struct to zero without
a lot of checks. But we definitely don't want to force them all
to fill in the individual fields, as that's fragile, and since they
don't seem to be breaking anything yet I'm inclined to leave them as
they are.)

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/cephfs.cc
src/mds/Server.cc

index 8b3929299217751d8bf379762ff2a75adcb4398d..70198173d558387efe257d009e8cbbfc649bca92 100644 (file)
@@ -50,7 +50,7 @@ int main (int argc, char **argv) {
   int stripe_count = 0;
   int object_size = 0;
   int pool = 0;
-  int osd = 0;
+  int osd = -1;
   int file_offset = 0;
   bool dir = false;
 
index 05198cb2fab135efac7f02857ee2376f54341ab2..8602a8d433eda62e5fa42bf83fa2b28eb5d0aca5 100644 (file)
@@ -3142,6 +3142,9 @@ void Server::handle_client_setlayout(MDRequest *mdr)
   // FIXME: only set striping parameters, for now.
   ceph_file_layout layout;
   memset(&layout, 0, sizeof(layout));
+  layout.fl_cas_hash = 0; // default value; "none"
+  layout.fl_pg_pool = 0; // default value "data" pool
+  layout.fl_pg_preferred = -1; // default value; "none"
 
   if (req->head.args.setlayout.layout.fl_object_size > 0)
     layout.fl_object_size = req->head.args.setlayout.layout.fl_object_size;
@@ -3217,7 +3220,7 @@ void Server::handle_client_setdirlayout(MDRequest *mdr)
     layout->layout.fl_cas_hash = req->head.args.setlayout.layout.fl_cas_hash;
   if (req->head.args.setlayout.layout.fl_object_stripe_unit > 0)
     layout->layout.fl_object_stripe_unit = req->head.args.setlayout.layout.fl_object_stripe_unit;
-  if (req->head.args.setlayout.layout.fl_pg_preferred > 0)
+  if (req->head.args.setlayout.layout.fl_pg_preferred != -1)
     layout->layout.fl_pg_preferred = req->head.args.setlayout.layout.fl_pg_preferred;
   if (req->head.args.setlayout.layout.fl_pg_pool > 0)
     layout->layout.fl_pg_pool = req->head.args.setlayout.layout.fl_pg_pool;