]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
error code translation logic
authorRohan Mars <code@rohanmars.com>
Wed, 28 Oct 2015 04:44:02 +0000 (21:44 -0700)
committerRohan Mars <code@rohanmars.com>
Fri, 13 Nov 2015 01:30:49 +0000 (17:30 -0800)
Signed-off-by: Rohan Mars <code@rohanmars.com>
src/common/Makefile.am
src/common/solaris_errno.cc [new file with mode: 0644]
src/include/types.h
src/messages/MAuthReply.h
src/messages/MCommandReply.h
src/messages/MMonCommandAck.h
src/messages/MOSDOpReply.h
src/messages/MWatchNotify.h
src/osdc/Objecter.cc

index 782cfa1f0841d7a8461cf70c2e39f74710d3b9fd..12572e679a26c9de0149ed233bdcb2c250880a18 100644 (file)
@@ -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 (file)
index 0000000..0ce23c7
--- /dev/null
@@ -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 <errno.h>
+#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
+}
+
+
index 33e85437b11a27e3dc9c64ea49ae6c0d6dfbd88d..bf369f3e9611c8cdb157238b956f76966730a80a 100644 (file)
@@ -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
index 5fea5a55360667e779772c6246b359b41e1b98ab..af9e884899ab2b125bbbf645bcd79b0c41bd23e0 100644 (file)
@@ -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;
index eda184f4ce003c8c6a113a520b21358b2b366cf2..6abd6fe8411f1ac64ad4eef3d81ae004953d5cb5 100644 (file)
@@ -20,7 +20,7 @@
 
 class MCommandReply : public Message {
  public:
-  __s32 r;
+  errorcode32_t r;
   string rs;
   
   MCommandReply()
index bd3d62da54cf8eef7119863fb87f76df5b17480e..5ebecde30c79549dba171d8175fe68c1d5bfd18c 100644 (file)
@@ -20,7 +20,7 @@
 class MMonCommandAck : public PaxosServiceMessage {
  public:
   vector<string> cmd;
-  __s32 r;
+  errorcode32_t r;
   string rs;
   
   MMonCommandAck() : PaxosServiceMessage(MSG_MON_COMMAND_ACK, 0) {}
index 45ec3d0dc25de312637b34cdeace6d4811753211..087f165d3aba7245dccf5aca5a8c096989df0bcb 100644 (file)
@@ -39,7 +39,7 @@ class MOSDOpReply : public Message {
   pg_t pgid;
   vector<OSDOp> 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;
index 50657ca2d8f7908d6dc705f0ffb9932a367a5450..9f7d568c491a74cf7c146e05a166bd0ca1d0b440 100644 (file)
@@ -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()
index 66db3115ab230bc6f83d3384fee4e531bdb251b6..2e69f9d81907b1fa81a87518d599d3051fab14be 100644 (file)
@@ -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;
     }
   }