]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add config for osd_max_object_name_len = 2048 (was hard-coded at 4096)
authorSage Weil <sage@redhat.com>
Wed, 16 Jul 2014 21:17:27 +0000 (14:17 -0700)
committerSage Weil <sage@redhat.com>
Fri, 18 Jul 2014 17:44:05 +0000 (10:44 -0700)
Previously we had a hard coded limit of 4096.  Objects > 3k crash the OSD
when running on ext4, although they probably work on xfs.  But rgw only
generates objects a bit over 1024 bytes (maybe 1200 tops?), so let set a
more reasonable limit here.  2048 is a nice round number and should be
safe.

Add a test.

Fixes: #8174
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/include/object.h
src/osd/OSD.cc
src/test/librados/misc.cc

index c0d4a104ac513bd3ba0ac7347f005bcf53d7ecfe..9acdc1a742eaf31915145612cbd948316790ad42 100644 (file)
@@ -596,6 +596,7 @@ OPTION(osd_recovery_op_warn_multiple, OPT_U32, 16)
 OPTION(osd_mon_shutdown_timeout, OPT_DOUBLE, 5)
 
 OPTION(osd_max_object_size, OPT_U64, 100*1024L*1024L*1024L) // OSD's maximum object size
+OPTION(osd_max_object_name_len, OPT_U32, 2048) // max rados object name len
 OPTION(osd_max_attr_size, OPT_U64, 0)
 
 OPTION(osd_objectstore, OPT_STR, "filestore")  // ObjectStore backend type
index d9fc27594deeda2e75c2abdb86b6c31ae6d28011..b2a4e85b7c83c80e1a9133253cdf48525e95847f 100644 (file)
@@ -30,9 +30,6 @@ using namespace std;
 #include "ceph_hash.h"
 #include "cmp.h"
 
-/// Maximum supported object name length for Ceph, in bytes.
-#define MAX_CEPH_OBJECT_NAME_LEN 4096
-
 struct object_t {
   string name;
 
index 52a38394bd065175588f0a8737689a098971f052..f211557cab4ca069818b244a686a0de7dcf5269e 100644 (file)
@@ -7846,9 +7846,11 @@ void OSD::handle_op(OpRequestRef& op, OSDMapRef& osdmap)
   m->clear_payload();
 
   // object name too long?
-  if (m->get_oid().name.size() > MAX_CEPH_OBJECT_NAME_LEN) {
+  unsigned max_name_len = MIN(g_conf->osd_max_object_name_len,
+                             store->get_max_object_name_length());
+  if (m->get_oid().name.size() > max_name_len) {
     dout(4) << "handle_op '" << m->get_oid().name << "' is longer than "
-           << MAX_CEPH_OBJECT_NAME_LEN << " bytes!" << dendl;
+           << max_name_len << " bytes" << dendl;
     service.reply_op_error(op, -ENAMETOOLONG);
     return;
   }
index ea990b50a98cc8efc041c6d134f7b608b4cf1dc9..f0fee02d9a1c817e47a81f2bc1c033a32e2059ee 100644 (file)
@@ -50,6 +50,17 @@ TEST_F(LibRadosMiscPP, WaitOSDMapPP) {
   ASSERT_EQ(0, cluster.wait_for_latest_osdmap());
 }
 
+TEST_F(LibRadosMiscPP, LongNamePP) {
+  bufferlist bl;
+  bl.append("content");
+  int maxlen = g_conf->osd_max_object_name_len;
+  ASSERT_EQ(0, ioctx.write(string(maxlen/2, 'a').c_str(), bl, bl.length(), 0));
+  ASSERT_EQ(0, ioctx.write(string(maxlen-1, 'a').c_str(), bl, bl.length(), 0));
+  ASSERT_EQ(0, ioctx.write(string(maxlen, 'a').c_str(), bl, bl.length(), 0));
+  ASSERT_EQ(-ENAMETOOLONG, ioctx.write(string(maxlen+1, 'a').c_str(), bl, bl.length(), 0));
+  ASSERT_EQ(-ENAMETOOLONG, ioctx.write(string(maxlen*2, 'a').c_str(), bl, bl.length(), 0));
+}
+
 static std::string read_key_from_tmap(IoCtx& ioctx, const std::string &obj,
                                      const std::string &key)
 {