1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*
Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
GlusterFS is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
GlusterFS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef _NFS_FH_H_
#define _NFS_FH_H_
#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif
#include "xlator.h"
#include "xdr-nfs3.h"
#include "iatt.h"
#include <sys/types.h>
#include "uuid.h"
/* BIG FAT WARNING: The file handle code is tightly coupled to NFSv3 file
* handles for now. This will change if and when we need v4. */
#define GF_NFSFH_IDENT0 ':'
#define GF_NFSFH_IDENT1 'O'
#define GF_NFSFH_IDENT_SIZE (sizeof(char) * 2)
#define GF_NFSFH_STATIC_SIZE (GF_NFSFH_IDENT_SIZE + (2*sizeof (uuid_t)) + sizeof (uint16_t))
#define GF_NFSFH_MAX_HASH_BYTES (NFS3_FHSIZE - GF_NFSFH_STATIC_SIZE)
/* Each hash element in the file handle is of 2 bytes thus giving
* us theoretically 65536 unique entries in a directory.
*/
typedef uint16_t nfs3_hash_entry_t;
#define GF_NFSFH_ENTRYHASH_SIZE (sizeof (nfs3_hash_entry_t))
#define GF_NFSFH_MAXHASHES ((int)(GF_NFSFH_MAX_HASH_BYTES / GF_NFSFH_ENTRYHASH_SIZE))
#define nfs3_fh_hashcounted_size(hcount) (GF_NFSFH_STATIC_SIZE + (hcount * GF_NFSFH_ENTRYHASH_SIZE))
#define nfs3_fh_exportid_to_index(exprtid) ((uint16_t)exprtid[15])
/* ATTENTION: Change in size of the structure below should be reflected in the
* GF_NFSFH_STATIC_SIZE.
*/
struct nfs3_fh {
/* Used to ensure that a bunch of bytes are actually a GlusterFS NFS
* file handle. Should contain ":O"
*/
char ident[2];
/* UUID that identifies an export. The value stored in exportid
* depends on the usage of gluster nfs. If the DVM is enabled using
* the nfs.dynamic-volumes option then exportid will contain the UUID
* of the volume so that gnfs is able to identify volumes uniquely
* through volume additions,deletions,migrations, etc.
*
* When not using dvm, exportid contains the index of the volume
* based on the position of the volume in the list of subvolumes
* for gnfs.
*/
uuid_t exportid;
/* File/dir gfid. */
uuid_t gfid;
/* Number of file/ino hash elements that follow the ino. */
uint16_t hashcount;
nfs3_hash_entry_t entryhash[GF_NFSFH_MAXHASHES];
} __attribute__((__packed__));
#define GF_NFS3FH_STATIC_INITIALIZER {{0},}
extern uint32_t
nfs3_fh_compute_size (struct nfs3_fh *fh);
extern int
nfs3_fh_hash_index_is_beyond (struct nfs3_fh *fh, int hashidx);
extern uint16_t
nfs3_fh_hash_entry (uuid_t gfid);
extern int
nfs3_fh_validate (struct nfs3_fh *fh);
extern struct nfs3_fh
nfs3_fh_build_indexed_root_fh (xlator_list_t *cl, xlator_t *xl);
extern int
nfs3_fh_is_root_fh (struct nfs3_fh *fh);
extern int
nfs3_fh_build_child_fh (struct nfs3_fh *parent, struct iatt *newstat,
struct nfs3_fh *newfh);
extern void
nfs3_log_fh (struct nfs3_fh *fh);
extern void
nfs3_fh_to_str (struct nfs3_fh *fh, char *str);
extern int
nfs3_fh_build_parent_fh (struct nfs3_fh *child, struct iatt *newstat,
struct nfs3_fh *newfh);
extern struct nfs3_fh
nfs3_fh_build_uuid_root_fh (uuid_t volumeid);
#endif
|