From: Rohan Mars Date: Wed, 28 Oct 2015 04:44:02 +0000 (-0700) Subject: error code translation logic X-Git-Tag: v10.0.1~63^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6a3aedd247299b4874fd8bb1af2f5e2120dae0d7;p=ceph.git error code translation logic Signed-off-by: Rohan Mars --- diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 782cfa1f084..12572e679a2 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -84,6 +84,11 @@ libcommon_internal_la_SOURCES += \ common/linux_version.c endif +if SOLARIS +libcommon_internal_la_SOURCES += \ + common/solaris_errno.cc +endif + if WITH_RBD if LINUX libcommon_internal_la_SOURCES += \ diff --git a/src/common/solaris_errno.cc b/src/common/solaris_errno.cc new file mode 100644 index 00000000000..0ce23c704c8 --- /dev/null +++ b/src/common/solaris_errno.cc @@ -0,0 +1,227 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include +#include "include/types.h" + + +// converts from linux errno values to host values +__s32 ceph_to_host_errno(__s32 r) +{ + if (r < -34) { + switch (r) { + case -35: + return -EDEADLK; + case -36: + return -ENAMETOOLONG; + case -37: + return -ENOLCK; + case -38: + return -ENOSYS; + case -39: + return -ENOTEMPTY; + case -40: + return -ELOOP; + case -42: + return -ENOMSG; + case -43: + return -EIDRM; + case -44: + return -ECHRNG; + case -45: + return -EL2NSYNC; + case -46: + return -EL3HLT; + case -47: + return -EL3RST; + case -48: + return -ELNRNG; + case -49: + return -EUNATCH; + case -50: + return -ENOCSI; + case -51: + return -EL2HLT; + case -52: + return -EBADE; + case -53: + return -EBADR; + case -54: + return -EXFULL; + case -55: + return -ENOANO; + case -56: + return -EBADRQC; + case -57: + return -EBADSLT; + case -59: + return -EBFONT; + case -60: + return -ENOSTR; + case -61: + return -ENODATA; + case -62: + return -ETIME; + case -63: + return -ENOSR; + //case -64: + // return -EPERM; //TODO ENONET + //case -65: + // return -EPERM; //TODO ENOPKG + //case -66: + // return -EREMOTE; + //case -67: + // return -ENOLINK; + //case -68: + // return -EPERM; //TODO EADV + //case -69: + // return -EPERM; //TODO ESRMNT + //case -70: + // return -EPERM; //TODO ECOMM + case -71: + return -EPROTO; + case -72: + return -EMULTIHOP; + case -73: + return -EPERM; //TODO EDOTDOT + case -74: + return -EBADMSG; + case -75: + return -EOVERFLOW; + case -76: + return -ENOTUNIQ; + case -77: + return -EBADFD; + case -78: + return -EREMCHG; + case -79: + return -ELIBACC; + case -80: + return -ELIBBAD; + case -81: + return -ELIBSCN; + case -82: + return -ELIBMAX; + case -83: + return -ELIBEXEC; + case -84: + return -EILSEQ; + case -85: + return -ERESTART; + case -86: + return -ESTRPIPE; + case -87: + return -EUSERS; + case -88: + return -ENOTSOCK; + case -89: + return -EDESTADDRREQ; + case -90: + return -EMSGSIZE; + case -91: + return -EPROTOTYPE; + case -92: + return -ENOPROTOOPT; + case -93: + return -EPROTONOSUPPORT; + case -94: + return -ESOCKTNOSUPPORT; + case -95: + return -EOPNOTSUPP; + case -96: + return -EPFNOSUPPORT; + case -97: + return -EAFNOSUPPORT; + case -98: + return -EADDRINUSE; + case -99: + return -EADDRNOTAVAIL; + case -100: + return -ENETDOWN; + case -101: + return -ENETUNREACH; + case -102: + return -ENETRESET; + case -103: + return -ECONNABORTED; + case -104: + return -ECONNRESET; + case -105: + return -ENOBUFS; + case -106: + return -EISCONN; + case -107: + return -ENOTCONN; + case -108: + return -ESHUTDOWN; + case -109: + return -ETOOMANYREFS; + case -110: + return -ETIMEDOUT; + case -111: + return -ECONNREFUSED; + case -112: + return -EHOSTDOWN; + case -113: + return -EHOSTUNREACH; + case -114: + return -EALREADY; + case -115: + return -EINPROGRESS; + case -116: + return -ESTALE; + case -117: + return -EPERM; //TODO EUCLEAN + case -118: + return -EPERM; //TODO ENOTNAM + case -119: + return -EPERM; //TODO ENAVAIL + case -120: + return -EPERM; //TODO EISNAM + case -121: + return -EPERM; //TODO EREMOTEIO + case -122: + return -EDQUOT; + case -123: + return -EPERM; //TODO ENOMEDIUM + case -124: + return -EPERM; //TODO EMEDIUMTYPE - not used + case -125: + return -ECANCELED; + case -126: + return -EPERM; //TODO ENOKEY + case -127: + return -EPERM; //TODO EKEYEXPIRED + case -128: + return -EPERM; //TODO EKEYREVOKED + case -129: + return -EPERM; //TODO EKEYREJECTED + case -130: + return -EOWNERDEAD; + case -131: + return -ENOTRECOVERABLE; + case -132: + return -EPERM; //TODO ERFKILL + case -133: + return -EPERM; //TODO EHWPOISON + + default: { + break; + } + } + } + return r; // otherwise return original value +} + + diff --git a/src/include/types.h b/src/include/types.h index 33e85437b11..bf369f3e961 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -520,4 +520,34 @@ WRITE_EQ_OPERATORS_1(shard_id_t, id) WRITE_CMP_OPERATORS_1(shard_id_t, id) ostream &operator<<(ostream &lhs, const shard_id_t &rhs); +#if defined(__sun) +__s32 ceph_to_host_errno(__s32 e); +#else +#define ceph_to_host_errno(e) (e) +#endif + +struct errorcode32_t { + int32_t code; + + errorcode32_t() {} + errorcode32_t(int32_t i) : code(i) {} + + operator int() const { return code; } + int operator==(int i) { + return code==i; + } + + void encode(bufferlist &bl) const { + ::encode(code, bl); + } + void decode(bufferlist::iterator &bl) { + ::decode(code, bl); + code = ceph_to_host_errno(code); + } +}; +WRITE_CLASS_ENCODER(errorcode32_t) +WRITE_EQ_OPERATORS_1(errorcode32_t, code) +WRITE_CMP_OPERATORS_1(errorcode32_t, code) + + #endif diff --git a/src/messages/MAuthReply.h b/src/messages/MAuthReply.h index 5fea5a55360..af9e884899a 100644 --- a/src/messages/MAuthReply.h +++ b/src/messages/MAuthReply.h @@ -20,7 +20,7 @@ struct MAuthReply : public Message { __u32 protocol; - __s32 result; + errorcode32_t result; uint64_t global_id; // if zero, meaningless string result_msg; bufferlist result_bl; diff --git a/src/messages/MCommandReply.h b/src/messages/MCommandReply.h index eda184f4ce0..6abd6fe8411 100644 --- a/src/messages/MCommandReply.h +++ b/src/messages/MCommandReply.h @@ -20,7 +20,7 @@ class MCommandReply : public Message { public: - __s32 r; + errorcode32_t r; string rs; MCommandReply() diff --git a/src/messages/MMonCommandAck.h b/src/messages/MMonCommandAck.h index bd3d62da54c..5ebecde30c7 100644 --- a/src/messages/MMonCommandAck.h +++ b/src/messages/MMonCommandAck.h @@ -20,7 +20,7 @@ class MMonCommandAck : public PaxosServiceMessage { public: vector cmd; - __s32 r; + errorcode32_t r; string rs; MMonCommandAck() : PaxosServiceMessage(MSG_MON_COMMAND_ACK, 0) {} diff --git a/src/messages/MOSDOpReply.h b/src/messages/MOSDOpReply.h index 45ec3d0dc25..087f165d3ab 100644 --- a/src/messages/MOSDOpReply.h +++ b/src/messages/MOSDOpReply.h @@ -39,7 +39,7 @@ class MOSDOpReply : public Message { pg_t pgid; vector ops; int64_t flags; - int32_t result; + errorcode32_t result; eversion_t bad_replay_version; eversion_t replay_version; version_t user_version; @@ -203,7 +203,7 @@ public: } ::decode_nohead(head.object_len, oid.name, p); pgid = pg_t(head.layout.ol_pgid); - result = head.result; + result = (int32_t)head.result; flags = head.flags; replay_version = head.reassert_version; user_version = replay_version.version; diff --git a/src/messages/MWatchNotify.h b/src/messages/MWatchNotify.h index 50657ca2d8f..9f7d568c491 100644 --- a/src/messages/MWatchNotify.h +++ b/src/messages/MWatchNotify.h @@ -29,7 +29,7 @@ class MWatchNotify : public Message { uint64_t notify_id; ///< osd unique id for a notify notification uint8_t opcode; ///< CEPH_WATCH_EVENT_* bufferlist bl; ///< notify payload (osd->client) - int32_t return_code; ///< notify result (osd->client) + errorcode32_t return_code; ///< notify result (osd->client) uint64_t notifier_gid; ///< who sent the notify MWatchNotify() diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 66db3115ab2..2e69f9d8190 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -50,7 +50,6 @@ #include "include/str_list.h" #include "common/errno.h" - #define dout_subsys ceph_subsys_objecter #undef dout_prefix #define dout_prefix *_dout << messenger->get_myname() << ".objecter " @@ -3147,10 +3146,10 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m) // set rval before running handlers so that handlers // can change it if e.g. decoding fails if (*pr) - **pr = p->rval; + **pr = ceph_to_host_errno(p->rval); if (*ph) { ldout(cct, 10) << " op " << i << " handler " << *ph << dendl; - (*ph)->complete(p->rval); + (*ph)->complete(ceph_to_host_errno(p->rval)); *ph = NULL; } }