From: Sage Weil Date: Wed, 16 Jul 2014 21:17:27 +0000 (-0700) Subject: osd: add config for osd_max_object_name_len = 2048 (was hard-coded at 4096) X-Git-Tag: v0.84~84^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7e0aca18a04a3848af77f5dd2093dc2e009386ec;p=ceph.git osd: add config for osd_max_object_name_len = 2048 (was hard-coded at 4096) 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 --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index c0d4a104ac5..9acdc1a742e 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/include/object.h b/src/include/object.h index d9fc27594de..b2a4e85b7c8 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -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; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 52a38394bd0..f211557cab4 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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; } diff --git a/src/test/librados/misc.cc b/src/test/librados/misc.cc index ea990b50a98..f0fee02d9a1 100644 --- a/src/test/librados/misc.cc +++ b/src/test/librados/misc.cc @@ -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) {