]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Check for invalid layout input in uclient and MDS, replace with sane if needed
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 30 Sep 2009 18:23:19 +0000 (11:23 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Fri, 2 Oct 2009 22:22:09 +0000 (15:22 -0700)
src/client/Client.cc
src/include/ceph_fs.h
src/mds/Server.cc

index 61d19ca31552dceaee4c96390960f1daa87bb611..0426ec32f6e2782a3ae67c9e683ffa5c37d2de33 100644 (file)
@@ -5774,26 +5774,31 @@ int Client::ll_release(Fh *fh)
 // layout
 void Client::set_default_file_stripe_unit(int stripe_unit)
 {
-  file_stripe_unit = stripe_unit;
+  if (stripe_unit > 0)
+    file_stripe_unit = stripe_unit;
 }
 
 void Client::set_default_file_stripe_count(int count)
 {
-  file_stripe_count = count;
+  if (count > 0)
+    file_stripe_count = count;
 }
 
 void Client::set_default_object_size(int size)
 {
-  object_size = size;
+  if (size > 0)
+    object_size = size;
 }
 
 void Client::set_default_file_replication(int replication)
 {
-  file_replication = replication;
+  if (replication >= 0)
+    file_replication = replication;
 }
 
 void Client::set_default_preferred_pg(int pg)
 {
+  if (pg >= 0)
   preferred_pg = pg;
 }
 
index 98dc9a02626e8fa5746fad57bf249d1a9868a580..07482b216ef2d17beeeb39b60dabd06274055baa 100644 (file)
@@ -72,6 +72,8 @@ struct ceph_file_layout {
        __le32 fl_pg_pool;      /* namespace, crush ruleset, rep level */
 } __attribute__ ((packed));
 
+#define CEPH_DEFAULT_OBJECT_SIZE 2<<22
+#define CEPH_DEFAULT_STRIPE_COUNT 1
 
 
 
index 68fc25d6d692aeffbb7eea52ab16fe83d384fb93..3a5bda949002efbc246a6ffa3de8760a474896c7 100644 (file)
@@ -2557,9 +2557,15 @@ void Server::handle_client_setlayout(MDRequest *mdr)
   // project update
   inode_t *pi = cur->project_inode();
   // FIXME: only set striping parameters, for now.
-  pi->layout.fl_stripe_unit = req->head.args.setlayout.layout.fl_stripe_unit;
-  pi->layout.fl_stripe_count = req->head.args.setlayout.layout.fl_stripe_count;
-  pi->layout.fl_object_size = req->head.args.setlayout.layout.fl_object_size;
+  if (req->head.args.setlayout.layout.fl_object_size > 0)
+    pi->layout.fl_object_size = req->head.args.setlayout.layout.fl_object_size;
+  else pi->layout.fl_object_size = CEPH_DEFAULT_OBJECT_SIZE;
+  if (req->head.args.setlayout.layout.fl_stripe_unit > 0)
+    pi->layout.fl_stripe_unit = req->head.args.setlayout.layout.fl_stripe_unit;
+  else pi->layout.fl_stripe_unit = pi->layout.fl_object_size;
+  if (req->head.args.setlayout.layout.fl_stripe_count > 0)
+    pi->layout.fl_stripe_count=req->head.args.setlayout.layout.fl_stripe_count;
+  else pi->layout.fl_stripe_count = CEPH_DEFAULT_STRIPE_COUNT;
   pi->version = cur->pre_dirty();
   pi->ctime = g_clock.real_now();