Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80608
b: refs/heads/master
c: 861e236
h: refs/heads/master
v: v3
  • Loading branch information
David Teigland committed Jan 30, 2008
1 parent e7277ed commit 20c2347
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 550283e30ccec5ddab9749a77b0022ebcaf0f3af
refs/heads/master: 861e2369e9e7e003677f99f22c4d1f05d3ed66d3
57 changes: 55 additions & 2 deletions trunk/fs/dlm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
#include "rcom.h"
#include "util.h"

#define DLM_ERRNO_EDEADLK 35
#define DLM_ERRNO_EBADR 53
#define DLM_ERRNO_EBADSLT 57
#define DLM_ERRNO_EPROTO 71
#define DLM_ERRNO_EOPNOTSUPP 95
#define DLM_ERRNO_ETIMEDOUT 110
#define DLM_ERRNO_EINPROGRESS 115

static void header_out(struct dlm_header *hd)
{
hd->h_version = cpu_to_le32(hd->h_version);
Expand All @@ -30,6 +38,51 @@ static void header_in(struct dlm_header *hd)
hd->h_length = le16_to_cpu(hd->h_length);
}

/* higher errno values are inconsistent across architectures, so select
one set of values for on the wire */

static int to_dlm_errno(int err)
{
switch (err) {
case -EDEADLK:
return -DLM_ERRNO_EDEADLK;
case -EBADR:
return -DLM_ERRNO_EBADR;
case -EBADSLT:
return -DLM_ERRNO_EBADSLT;
case -EPROTO:
return -DLM_ERRNO_EPROTO;
case -EOPNOTSUPP:
return -DLM_ERRNO_EOPNOTSUPP;
case -ETIMEDOUT:
return -DLM_ERRNO_ETIMEDOUT;
case -EINPROGRESS:
return -DLM_ERRNO_EINPROGRESS;
}
return err;
}

static int from_dlm_errno(int err)
{
switch (err) {
case -DLM_ERRNO_EDEADLK:
return -EDEADLK;
case -DLM_ERRNO_EBADR:
return -EBADR;
case -DLM_ERRNO_EBADSLT:
return -EBADSLT;
case -DLM_ERRNO_EPROTO:
return -EPROTO;
case -DLM_ERRNO_EOPNOTSUPP:
return -EOPNOTSUPP;
case -DLM_ERRNO_ETIMEDOUT:
return -ETIMEDOUT;
case -DLM_ERRNO_EINPROGRESS:
return -EINPROGRESS;
}
return err;
}

void dlm_message_out(struct dlm_message *ms)
{
struct dlm_header *hd = (struct dlm_header *) ms;
Expand All @@ -53,7 +106,7 @@ void dlm_message_out(struct dlm_message *ms)
ms->m_rqmode = cpu_to_le32(ms->m_rqmode);
ms->m_bastmode = cpu_to_le32(ms->m_bastmode);
ms->m_asts = cpu_to_le32(ms->m_asts);
ms->m_result = cpu_to_le32(ms->m_result);
ms->m_result = cpu_to_le32(to_dlm_errno(ms->m_result));
}

void dlm_message_in(struct dlm_message *ms)
Expand All @@ -79,7 +132,7 @@ void dlm_message_in(struct dlm_message *ms)
ms->m_rqmode = le32_to_cpu(ms->m_rqmode);
ms->m_bastmode = le32_to_cpu(ms->m_bastmode);
ms->m_asts = le32_to_cpu(ms->m_asts);
ms->m_result = le32_to_cpu(ms->m_result);
ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result));
}

static void rcom_lock_out(struct rcom_lock *rl)
Expand Down

0 comments on commit 20c2347

Please sign in to comment.