ReactOS  0.4.11-dev-946-g431643b
pnfs_debug.c
Go to the documentation of this file.
1 /* NFSv4.1 client for Windows
2  * Copyright 2012 The Regents of the University of Michigan
3  *
4  * Olga Kornievskaia <aglo@umich.edu>
5  * Casey Bodley <cbodley@umich.edu>
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * without any warranty; without even the implied warranty of merchantability
14  * or fitness for a particular purpose. See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  */
21 
22 #include <winsock2.h>
23 #include <strsafe.h>
24 #include "pnfs.h"
25 #include "daemon_debug.h"
26 
27 
29 {
30  switch (status) {
31  case PNFS_SUCCESS: return "PNFS_SUCCESS";
32  case PNFS_PENDING: return "PNFS_PENDING";
33  case PNFS_READ_EOF: return "PNFS_READ_EOF";
34  case PNFSERR_NOT_SUPPORTED: return "PNFSERR_NOT_SUPPORTED";
35  case PNFSERR_NOT_CONNECTED: return "PNFSERR_NOT_CONNECTED";
36  case PNFSERR_IO: return "PNFSERR_IO";
37  case PNFSERR_NO_DEVICE: return "PNFSERR_NO_DEVICE";
38  case PNFSERR_NO_LAYOUT: return "PNFSERR_NO_LAYOUT";
39  case PNFSERR_INVALID_FH_LIST: return "PNFSERR_INVALID_FH_LIST";
40  case PNFSERR_INVALID_DS_INDEX: return "PNFSERR_INVALID_DS_INDEX";
41  case PNFSERR_RESOURCES: return "PNFSERR_RESOURCES";
42  case PNFSERR_LAYOUT_RECALLED: return "PNFSERR_LAYOUT_RECALLED";
43  case PNFSERR_LAYOUT_CHANGED: return "PNFSERR_LAYOUT_CHANGED";
44  default: return "Invalid pnfs status";
45  }
46 }
47 
49 {
50  switch (type) {
51  case PNFS_LAYOUTTYPE_FILE: return "PNFS_LAYOUTTYPE_FILE";
52  case PNFS_LAYOUTTYPE_OBJECT: return "PNFS_LAYOUTTYPE_OBJECT";
53  case PNFS_LAYOUTTYPE_BLOCK: return "PNFS_LAYOUTTYPE_BLOCK";
54  default: return "Invalid layout type";
55  }
56 }
57 
58 const char* pnfs_iomode_string(enum pnfs_iomode iomode)
59 {
60  switch (iomode) {
61  case PNFS_IOMODE_READ: return "PNFS_IOMODE_READ";
62  case PNFS_IOMODE_RW: return "PNFS_IOMODE_RW";
63  case PNFS_IOMODE_ANY: return "PNFS_IOMODE_ANY";
64  default: return "Invalid io mode";
65  }
66 }
67 
69  IN int level,
70  IN const char *title,
71  IN const unsigned char *deviceid)
72 {
73  /* deviceid is 16 bytes, so print it as 4 uints */
74  uint32_t *p = (uint32_t*)deviceid;
75  dprintf(level, "%s%08X.%08X.%08X.%08X\n",
76  title, htonl(p[0]), htonl(p[1]), htonl(p[2]), htonl(p[3]));
77 }
78 
80  IN int level,
81  IN const pnfs_file_layout *layout)
82 {
83  dprintf(level, " type: %s\n", pnfs_layout_type_string(layout->layout.type));
84  dprintf(level, " iomode: %s\n", pnfs_iomode_string(layout->layout.iomode));
85  dprint_deviceid(level, " deviceid: ", layout->deviceid);
86  dprintf(level, " offset: %llu\n", layout->layout.offset);
87  dprintf(level, " length: %llu\n", layout->layout.length);
88  dprintf(level, " pattern_offset: %llu\n", layout->pattern_offset);
89  dprintf(level, " first_index: %u\n", layout->first_index);
90  dprintf(level, " dense: %u\n", is_dense(layout));
91  dprintf(level, " commit_to_mds: %u\n", should_commit_to_mds(layout));
92  dprintf(level, " stripe_unit_size: %u\n", layout_unit_size(layout));
93  dprintf(level, " file handles: %u\n", layout->filehandles.count);
94 }
95 
96 #define MULTI_ADDR_BUFFER_LEN \
97  (NFS41_ADDRS_PER_SERVER*(NFS41_UNIVERSAL_ADDR_LEN+1)+1)
98 
99 static void dprint_multi_addr(
100  IN int level,
101  IN uint32_t index,
102  IN const multi_addr4 *addrs)
103 {
104  char buffer[MULTI_ADDR_BUFFER_LEN] = "";
105  uint32_t i;
106  for (i = 0; i < addrs->count; i++) {
107  StringCchCatA(buffer, MULTI_ADDR_BUFFER_LEN, addrs->arr[i].uaddr);
108  StringCchCatA(buffer, MULTI_ADDR_BUFFER_LEN, " ");
109  }
110  dprintf(level, " servers[%d]: [ %s]\n", index, buffer);
111 }
112 
114  IN int level,
115  IN const pnfs_file_device *device)
116 {
117  uint32_t i;
118  dprint_deviceid(level, " deviceid: ", device->device.deviceid);
119  dprintf(level, " type: %s\n", pnfs_layout_type_string(device->device.type));
120  dprintf(level, " stripes: %u\n", device->stripes.count);
121  for (i = 0; i < device->servers.count; i++)
122  dprint_multi_addr(level, i, &device->servers.arr[i].addrs);
123 }
pnfs_status
Definition: pnfs.h:58
unsigned char deviceid[16]
GLint level
Definition: gl.h:1546
#define IN
Definition: typedefs.h:38
const char * pnfs_error_string(enum pnfs_status status)
Definition: pnfs_debug.c:28
#define htonl(x)
Definition: module.h:212
const char * pnfs_iomode_string(enum pnfs_iomode iomode)
Definition: pnfs_debug.c:58
#define MULTI_ADDR_BUFFER_LEN
Definition: pnfs_debug.c:96
__inline uint32_t layout_unit_size(IN const pnfs_file_layout *layout)
Definition: pnfs.h:315
static void dprint_multi_addr(IN int level, IN uint32_t index, IN const multi_addr4 *addrs)
Definition: pnfs_debug.c:99
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void dprint_device(IN int level, IN const pnfs_file_device *device)
Definition: pnfs_debug.c:113
Definition: devices.h:39
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
#define dprintf
Definition: regdump.c:33
const char * pnfs_layout_type_string(enum pnfs_layout_type type)
Definition: pnfs_debug.c:48
GLuint index
Definition: glext.h:6031
__inline int should_commit_to_mds(IN const pnfs_file_layout *layout)
Definition: pnfs.h:306
pnfs_layout_type
Definition: pnfs.h:74
void dprint_layout(IN int level, IN const pnfs_file_layout *layout)
Definition: pnfs_debug.c:79
void dprint_deviceid(IN int level, IN const char *title, IN const unsigned char *deviceid)
Definition: pnfs_debug.c:68
static DWORD layout
Definition: bitmap.c:46
UINT32 uint32_t
Definition: types.h:75
GLfloat GLfloat p
Definition: glext.h:8902
pnfs_iomode
Definition: pnfs.h:80
static char title[]
Definition: ps.c:92
__inline int is_dense(IN const pnfs_file_layout *layout)
Definition: pnfs.h:297
Definition: ps.c:97