]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: allow data pool to be specfied on create
authorSage Weil <sage@inktank.com>
Thu, 6 Dec 2012 08:10:29 +0000 (00:10 -0800)
committerSage Weil <sage@inktank.com>
Mon, 24 Dec 2012 03:39:22 +0000 (19:39 -0800)
Reuse old preferred_pg field.  Only use if the new CREATEPOOLID feature
is present, and the value is >= 0.

Verify that the data pool is allowed, or return EINVAL to the client.

Signed-off-by: Sage Weil <sage@inktank.com>
src/include/ceph_features.h
src/include/ceph_fs.h
src/mds/MDSMap.h
src/mds/Server.cc

index e8a043f528043cfc9a18d0a5c31e3f55787a17c9..24c082d67a1fd51cac63d8471cba4ebc72f07db9 100644 (file)
@@ -30,6 +30,7 @@
 #define CEPH_FEATURE_MSG_AUTH      (1<<23)
 #define CEPH_FEATURE_RECOVERY_RESERVATION (1<<24)
 #define CEPH_FEATURE_CRUSH_TUNABLES2 (1<<25)
+#define CEPH_FEATURE_CREATEPOOLID   (1<<26)
 
 /*
  * Features supported.  Should be everything above.
@@ -60,7 +61,8 @@
         CEPH_FEATURE_BACKFILL_RESERVATION | \
         CEPH_FEATURE_MSG_AUTH |         \
         CEPH_FEATURE_RECOVERY_RESERVATION | \
-        CEPH_FEATURE_CRUSH_TUNABLES2)
+        CEPH_FEATURE_CRUSH_TUNABLES2 |      \
+        CEPH_FEATURE_CREATEPOOLID)
 
 #define CEPH_FEATURES_SUPPORTED_DEFAULT  CEPH_FEATURES_ALL
 
index 31fd4d78a20aca5fc46d8df958aae58d5d27af01..ddfe2fc7924c9dd2571b64957b231bec23f3ecdd 100644 (file)
@@ -382,7 +382,7 @@ union ceph_mds_request_args {
                __le32 stripe_unit;          /* layout for newly created file */
                __le32 stripe_count;         /* ... */
                __le32 object_size;
-               __le32 file_replication;
+               __le32 pool;                 /* if >= 0 and CREATEPOOLID feature */
                __le32 unused;               /* used to be preferred */
                __le64 old_size;             /* if O_TRUNC */
        } __attribute__ ((packed)) open;
index dc8969c3cff0dba48ce9a4b5c8050763338f28fc..044449b291469cbb61c305a1d26d6e3fe21d7c18 100644 (file)
@@ -243,6 +243,9 @@ public:
   int64_t get_data_pg_pool() const { return data_pg_pools[0]; }
   int64_t get_cas_pg_pool() const { return cas_pg_pool; }
   int64_t get_metadata_pg_pool() const { return metadata_pg_pool; }
+  bool is_data_pg_pool(int64_t poolid) const {
+    return std::find(data_pg_pools.begin(), data_pg_pools.end(), poolid) != data_pg_pools.end();
+  }
 
   const map<uint64_t,mds_info_t>& get_mds_info() { return mds_info; }
   const mds_info_t& get_mds_info_gid(uint64_t gid) {
index ba436566dec27d034a502957d90c419ddb8f8cb0..11c56ddbc277fe094bbcaddb970ee4ff08812aab 100644 (file)
@@ -50,6 +50,7 @@
 #include "common/Timer.h"
 #include "common/perf_counters.h"
 #include "include/compat.h"
+#include "osd/OSDMap.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -2613,13 +2614,21 @@ void Server::handle_client_openc(MDRequest *mdr)
     layout.fl_stripe_count = req->head.args.open.stripe_count;
   if (req->head.args.open.object_size)
     layout.fl_object_size = req->head.args.open.object_size;
+  if (req->get_connection()->has_feature(CEPH_FEATURE_CREATEPOOLID) &&
+      (__s32)req->head.args.open.pool >= 0)
+    layout.fl_pg_pool = req->head.args.open.pool;
 
   if (!ceph_file_layout_is_valid(&layout)) {
     dout(10) << " invalid initial file layout" << dendl;
     reply_request(mdr, -EINVAL);
     return;
   }
-
+  if (!mds->osdmap->have_pg_pool(layout.fl_pg_pool) ||
+      !mds->mdsmap->is_data_pg_pool(layout.fl_pg_pool)) {
+    dout(10) << " invalid data pool " << layout.fl_pg_pool << dendl;
+    reply_request(mdr, -EINVAL);
+    return;
+  }
 
   CInode *diri = dn->get_dir()->get_inode();
   rdlocks.insert(&diri->authlock);