diff --git a/configure.ac b/configure.ac index 2ee4c6a92ab..e748d0a5202 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_PREREQ(2.59) # NOTE: This version is _only_ used for naming the tarball. The # VERSION define is not used by the code. It gets a version string # from 'git describe'; see src/ceph_ver.[ch] -AC_INIT([ceph], [0.30], [ceph-devel@vger.kernel.org]) +AC_INIT([ceph], [0.31], [ceph-devel@vger.kernel.org]) AC_CONFIG_SUBDIRS([src/gtest]) diff --git a/src/crushtool.cc b/src/crushtool.cc index 7b02eeafcc4..f2a35f94a6b 100644 --- a/src/crushtool.cc +++ b/src/crushtool.cc @@ -1178,7 +1178,7 @@ int main(int argc, const char **argv) for (unsigned i = 0; i < per.size(); i++) cout << " device " << i << ":\t" << per[i] << std::endl; for (map::iterator p = sizes.begin(); p != sizes.end(); p++) - cout << " num results " << p->first << ":\t" << p->second << std::endl; + cout << " result size " << p->first << "x:\t" << p->second << std::endl; } } diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index d6e3a0a2a33..32b415eb831 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -169,10 +169,13 @@ static int get_kernel_version(int *a, int *b, int *c) } if (sscanf(buf, "Linux version %d.%d.%d", a, b, c) != 3) { - derr << "get_kernel_version: failed to parse string: '" - << buf << "'" << dendl; - ret = EIO; - goto close_fd; + if (sscanf(buf, "Linux version %d.%d", a, b) != 2) { + derr << "get_kernel_version: failed to parse string: '" + << buf << "'" << dendl; + ret = EIO; + goto close_fd; + } + *c = 0; } dout(0) << " kernel version is " << *a <<"." << *b << "." << *c << dendl; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index d970e64f4f4..1bff3b93ab1 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1464,23 +1464,9 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops, } else { t.touch(coll, soid); } - if (ssc->snapset.clones.size()) { - snapid_t newest = *ssc->snapset.clones.rbegin(); - interval_set ch; - if (op.extent.length) - ch.insert(op.extent.offset, op.extent.length); - ch.intersection_of(ssc->snapset.clone_overlap[newest]); - ssc->snapset.clone_overlap[newest].subtract(ch); - add_interval_usage(ch, ctx->new_stats); - } - if (op.extent.length && (op.extent.offset + op.extent.length > oi.size)) { - uint64_t new_size = op.extent.offset + op.extent.length; - ctx->new_stats.num_bytes += new_size - oi.size; - ctx->new_stats.num_kb += SHIFT_ROUND_UP(new_size, 10) - SHIFT_ROUND_UP(oi.size, 10); - oi.size = new_size; - } - ctx->new_stats.num_wr++; - ctx->new_stats.num_wr_kb += SHIFT_ROUND_UP(op.extent.length, 10); + write_update_size_and_usage(ctx->new_stats, oi, ssc->snapset, + op.extent.offset, op.extent.length, true); + maybe_created = true; } break; @@ -1610,21 +1596,15 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops, { bufferlist::iterator p = osd_op.data.begin(); - if (!obs.exists) + if (!obs.exists) { t.touch(coll, obs.oi.soid); + maybe_created = true; + } t.clone_range(coll, osd_op.soid, obs.oi.soid, op.clonerange.src_offset, op.clonerange.length, op.clonerange.offset); - // fix up accounting - uint64_t endoff = op.clonerange.offset + op.clonerange.length; - if (endoff > oi.size) { - info.stats.num_bytes -= oi.size; - info.stats.num_kb -= SHIFT_ROUND_UP(oi.size, 10); - oi.size = endoff; - info.stats.num_bytes += oi.size; - info.stats.num_kb += SHIFT_ROUND_UP(oi.size, 10); - } - ssc->snapset.head_exists = true; - info.stats.num_wr++; + + write_update_size_and_usage(ctx->new_stats, oi, ssc->snapset, + op.clonerange.offset, op.clonerange.length, false); } break; @@ -1684,8 +1664,6 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops, string name = "_" + aname; bufferlist bl; bp.copy(op.xattr.value_len, bl); - if (!obs.exists) // create object if it doesn't yet exist. - t.touch(coll, soid); t.setattr(coll, soid, name, bl); ctx->new_stats.num_wr++; } @@ -2224,6 +2202,29 @@ void ReplicatedPG::make_writeable(OpContext *ctx) } +void ReplicatedPG::write_update_size_and_usage(pg_stat_t& stats, object_info_t& oi, SnapSet& ss, + uint64_t offset, uint64_t length, bool count_bytes) +{ + if (ss.clones.size()) { + snapid_t newest = *ss.clones.rbegin(); + interval_set ch; + if (length) + ch.insert(offset, length); + ch.intersection_of(ss.clone_overlap[newest]); + ss.clone_overlap[newest].subtract(ch); + add_interval_usage(ch, stats); + } + if (length && (offset + length > oi.size)) { + uint64_t new_size = offset + length; + stats.num_bytes += new_size - oi.size; + stats.num_kb += SHIFT_ROUND_UP(new_size, 10) - SHIFT_ROUND_UP(oi.size, 10); + oi.size = new_size; + } + stats.num_wr++; + if (count_bytes) + stats.num_wr_kb += SHIFT_ROUND_UP(length, 10); +} + void ReplicatedPG::add_interval_usage(interval_set& s, pg_stat_t& stats) { for (interval_set::const_iterator p = s.begin(); p != s.end(); ++p) { diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index c2aeb937eda..7537d81c822 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -581,6 +581,9 @@ protected: object_info_t *poi); void make_writeable(OpContext *ctx); void log_op_stats(OpContext *ctx); + + void write_update_size_and_usage(pg_stat_t& stats, object_info_t& oi, SnapSet& ss, + uint64_t offset, uint64_t length, bool count_bytes); void add_interval_usage(interval_set& s, pg_stat_t& st); int prepare_transaction(OpContext *ctx); diff --git a/src/rados.cc b/src/rados.cc index 6650ff30aa5..004e955febb 100644 --- a/src/rados.cc +++ b/src/rados.cc @@ -38,9 +38,9 @@ using namespace librados; int rados_tool_sync(const std::map < std::string, std::string > &opts, std::vector &args); -void usage() +void usage(ostream& out) { - cerr << \ + out << \ "usage: rados [options] [commands]\n" "POOL COMMANDS\n" " lspools list pools\n" @@ -111,6 +111,12 @@ void usage() } +static void usage_exit() +{ + usage(cerr); + exit(1); +} + static int do_get(IoCtx& io_ctx, const char *objname, const char *outfile, bool check_stdio) { string oid(objname); @@ -645,7 +651,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, if (create_pool && !pool_name) { cerr << "--create-pool requested but pool_name was not specified!" << std::endl; - usage(); + usage_exit(); } if (create_pool) { @@ -759,7 +765,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "chown") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); uint64_t new_auid = strtol(nargs[1], 0, 10); ret = io_ctx.set_auid(new_auid); @@ -771,7 +777,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "mapext") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); string oid(nargs[1]); std::map m; ret = io_ctx.mapext(oid, 0, -1, m); @@ -786,7 +792,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "stat") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); string oid(nargs[1]); uint64_t size; time_t mtime; @@ -802,7 +808,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "get") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); ret = do_get(io_ctx, nargs[1], nargs[2], true); if (ret < 0) { cerr << "error getting " << pool_name << "/" << nargs[1] << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl; @@ -811,7 +817,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "put") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); ret = do_put(io_ctx, nargs[1], nargs[2], op_size, true); if (ret < 0) { cerr << "error putting " << pool_name << "/" << nargs[1] << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl; @@ -820,7 +826,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "setxattr") == 0) { if (!pool_name || nargs.size() < 4) - usage(); + usage_exit(); string oid(nargs[1]); string attr_name(nargs[2]); @@ -839,7 +845,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "getxattr") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); string oid(nargs[1]); string attr_name(nargs[2]); @@ -856,7 +862,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, cout << s << std::endl; } else if (strcmp(nargs[0], "rmxattr") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); string oid(nargs[1]); string attr_name(nargs[2]); @@ -868,7 +874,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } } else if (strcmp(nargs[0], "listxattr") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); string oid(nargs[1]); map attrset; @@ -886,7 +892,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "rm") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); string oid(nargs[1]); ret = io_ctx.remove(oid); if (ret < 0) { @@ -896,7 +902,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "create") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); string oid(nargs[1]); ret = io_ctx.create(oid, true); if (ret < 0) { @@ -907,7 +913,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else if (strcmp(nargs[0], "tmap") == 0) { if (nargs.size() < 3) - usage(); + usage_exit(); if (strcmp(nargs[1], "dump") == 0) { bufferlist outdata; string oid(nargs[2]); @@ -934,7 +940,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else if (strcmp(nargs[1], "set") == 0 || strcmp(nargs[1], "create") == 0) { if (nargs.size() < 5) - usage(); + usage_exit(); string oid(nargs[2]); string k(nargs[3]); string v(nargs[4]); @@ -951,7 +957,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, int auid = 0; __u8 crush_rule = 0; if (nargs.size() < 2) - usage(); + usage_exit(); if (nargs.size() > 2) { auid = strtol(nargs[2], 0, 10); cerr << "setting auid:" << auid << std::endl; @@ -970,7 +976,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "rmpool") == 0) { if (nargs.size() < 2) - usage(); + usage_exit(); ret = rados.pool_delete(nargs[1]); if (ret >= 0) { cout << "successfully deleted pool " << nargs[1] << std::endl; @@ -980,7 +986,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "lssnap") == 0) { if (!pool_name || nargs.size() != 1) - usage(); + usage_exit(); vector snaps; io_ctx.snap_list(&snaps); @@ -1014,7 +1020,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else if (strcmp(nargs[0], "mksnap") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); ret = io_ctx.snap_create(nargs[1]); if (ret < 0) { @@ -1027,7 +1033,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else if (strcmp(nargs[0], "rmsnap") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); ret = io_ctx.snap_remove(nargs[1]); if (ret < 0) { @@ -1040,7 +1046,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else if (strcmp(nargs[0], "rollback") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); ret = io_ctx.rollback(nargs[1], nargs[2]); if (ret < 0) { @@ -1053,7 +1059,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "bench") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); int seconds = atoi(nargs[1]); int operation = 0; if (strcmp(nargs[2], "write") == 0) @@ -1063,14 +1069,14 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else if (strcmp(nargs[2], "rand") == 0) operation = OP_RAND_READ; else - usage(); + usage_exit(); ret = aio_bench(rados, io_ctx, operation, seconds, concurrent_ios, op_size); if (ret != 0) cerr << "error during benchmark: " << ret << std::endl; } else if (strcmp(nargs[0], "watch") == 0) { if (!pool_name || nargs.size() < 2) - usage(); + usage_exit(); string oid(nargs[1]); RadosWatchCtx ctx(oid.c_str()); uint64_t cookie; @@ -1084,7 +1090,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else if (strcmp(nargs[0], "notify") == 0) { if (!pool_name || nargs.size() < 3) - usage(); + usage_exit(); string oid(nargs[1]); string msg(nargs[2]); bufferlist bl; @@ -1094,7 +1100,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, cerr << "error calling notify: " << ret << std::endl; } else if (strcmp(nargs[0], "load-gen") == 0) { if (!pool_name) - usage(); + usage_exit(); LoadGen lg(&rados); if (min_obj_len) lg.min_obj_len = min_obj_len; @@ -1126,7 +1132,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, lg.cleanup(); } else { cerr << "unrecognized command " << nargs[0] << std::endl; - usage(); + usage_exit(); } if (ret) @@ -1136,7 +1142,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, int main(int argc, const char **argv) { - DEFINE_CONF_VARS(usage); + DEFINE_CONF_VARS(usage_exit); vector args; argv_to_vec(argc, argv, args); env_to_vec(args); @@ -1149,7 +1155,7 @@ int main(int argc, const char **argv) std::string val; for (i = args.begin(); i != args.end(); ) { if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) { - usage(); + usage(cout); exit(0); } else if (ceph_argparse_flag(args, i, "-f", "--force", (char*)NULL)) { opts["force"] = "true"; @@ -1184,7 +1190,7 @@ int main(int argc, const char **argv) opts["num-objects"] = val; } else { if (val[0] == '-') - usage(); + usage_exit(); i++; } }