From 0748dd6076e1d901ac20b79f6eb78cc996145796 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 30 Sep 2009 11:23:19 -0700 Subject: [PATCH] Check for invalid layout input in uclient and MDS, replace with sane if needed --- src/client/Client.cc | 13 +++++++++---- src/include/ceph_fs.h | 2 ++ src/mds/Server.cc | 12 +++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 61d19ca31552d..0426ec32f6e27 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; } diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 98dc9a02626e8..07482b216ef2d 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -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 diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 68fc25d6d692a..3a5bda949002e 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -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(); -- 2.39.5