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
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;
}
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)
{