glusterfs  8.2
About: GlusterFS is a network/cluster filesystem. The storage server (or each in a cluster) runs glusterfsd and the clients use mount command or glusterfs client to mount the exported filesystem. Release series 8.x (latest version).
  Fossies Dox: glusterfs-8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

lkowner.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
3  This file is part of GlusterFS.
4 
5  This file is licensed to you under your choice of the GNU Lesser
6  General Public License, version 3 or any later version (LGPLv3 or
7  later), or the GNU General Public License, version 2 (GPLv2), in all
8  cases as published by the Free Software Foundation.
9 */
10 
11 #ifndef _LK_OWNER_H
12 #define _LK_OWNER_H
13 
15 
16 /* LKOWNER to string functions */
17 static inline void
18 lkowner_unparse(gf_lkowner_t *lkowner, char *buf, int buf_len)
19 {
20  int i = 0;
21  int j = 0;
22 
23  for (i = 0; i < lkowner->len; i++) {
24  if (i && !(i % 8)) {
25  buf[j] = '-';
26  j++;
27  }
28  sprintf(&buf[j], "%02hhx", lkowner->data[i]);
29  j += 2;
30  if (j == buf_len)
31  break;
32  }
33  if (j < buf_len)
34  buf[j] = '\0';
35 }
36 
37 static inline void
38 set_lk_owner_from_ptr(gf_lkowner_t *lkowner, void *data)
39 {
40  int i = 0;
41  int j = 0;
42 
43  lkowner->len = sizeof(unsigned long);
44  for (i = 0, j = 0; i < lkowner->len; i++, j += 8) {
45  lkowner->data[i] = (char)((((unsigned long)data) >> j) & 0xff);
46  }
47 }
48 
49 static inline void
50 set_lk_owner_from_uint64(gf_lkowner_t *lkowner, uint64_t data)
51 {
52  int i = 0;
53  int j = 0;
54 
55  lkowner->len = 8;
56  for (i = 0, j = 0; i < lkowner->len; i++, j += 8) {
57  lkowner->data[i] = (char)((data >> j) & 0xff);
58  }
59 }
60 
61 /* Return true if the locks have the same owner */
62 static inline int
64 {
65  return ((l1->len == l2->len) && !memcmp(l1->data, l2->data, l1->len));
66 }
67 
68 static inline int
70 {
71  int is_null = 1;
72  int i = 0;
73 
74  if (lkowner == NULL || lkowner->len == 0)
75  goto out;
76 
77  for (i = 0; i < lkowner->len; i++) {
78  if (lkowner->data[i] != 0) {
79  is_null = 0;
80  break;
81  }
82  }
83 out:
84  return is_null;
85 }
86 
87 static inline void
89 {
90  dst->len = src->len;
91  memcpy(dst->data, src->data, src->len);
92 }
93 #endif /* _LK_OWNER_H */
gf_lkowner_t
Definition: glusterfs-fops.h:190
out
#define out(x...)
Definition: gcrawler.c:35
lk_owner_copy
static void lk_owner_copy(gf_lkowner_t *dst, gf_lkowner_t *src)
Definition: lkowner.h:88
set_lk_owner_from_uint64
static void set_lk_owner_from_uint64(gf_lkowner_t *lkowner, uint64_t data)
Definition: lkowner.h:50
gf_lkowner_t::data
char data[1024]
Definition: glusterfs-fops.h:192
lkowner_unparse
static void lkowner_unparse(gf_lkowner_t *lkowner, char *buf, int buf_len)
Definition: lkowner.h:18
set_lk_owner_from_ptr
static void set_lk_owner_from_ptr(gf_lkowner_t *lkowner, void *data)
Definition: lkowner.h:38
glusterfs-fops.h
gf_lkowner_t::len
int len
Definition: glusterfs-fops.h:191
src
Definition: __init__.py:1
is_same_lkowner
static int is_same_lkowner(gf_lkowner_t *l1, gf_lkowner_t *l2)
Definition: lkowner.h:63
is_lk_owner_null
static int is_lk_owner_null(gf_lkowner_t *lkowner)
Definition: lkowner.h:69