aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-10-21 19:42:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-22 11:13:21 -0400
commite38f981758118d829cd40cfe9c09e3fa81e422aa (patch)
tree73a071109999b31697925ca7a4336f3d4beeef21 /Documentation
parent39655164405940d4818224a085e35420e2f97aed (diff)
exportfs: update documentation
Update documentation to the current state of affairs. Remove duplicated method descruptions in exportfs.h and point to Documentation/filesystems/ Exporting instead. Add a little file header comment in expfs.c describing what's going on and mentioning Neils and my copyright [1]. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Neil Brown <neilb@suse.de> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: <linux-ext4@vger.kernel.org> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Anton Altaparmakov <aia21@cantab.net> Cc: David Chinner <dgc@sgi.com> Cc: Timothy Shimmin <tes@sgi.com> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Hugh Dickins <hugh@veritas.com> Cc: Chris Mason <mason@suse.com> Cc: Jeff Mahoney <jeffm@suse.com> Cc: "Vladimir V. Saveliev" <vs@namesys.com> Cc: Steven Whitehouse <swhiteho@redhat.com> Cc: Mark Fasheh <mark.fasheh@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/filesystems/Exporting115
1 files changed, 43 insertions, 72 deletions
diff --git a/Documentation/filesystems/Exporting b/Documentation/filesystems/Exporting
index 31047e0fe14b..87019d2b5981 100644
--- a/Documentation/filesystems/Exporting
+++ b/Documentation/filesystems/Exporting
@@ -2,9 +2,12 @@
2Making Filesystems Exportable 2Making Filesystems Exportable
3============================= 3=============================
4 4
5Most filesystem operations require a dentry (or two) as a starting 5Overview
6--------
7
8All filesystem operations require a dentry (or two) as a starting
6point. Local applications have a reference-counted hold on suitable 9point. Local applications have a reference-counted hold on suitable
7dentrys via open file descriptors or cwd/root. However remote 10dentries via open file descriptors or cwd/root. However remote
8applications that access a filesystem via a remote filesystem protocol 11applications that access a filesystem via a remote filesystem protocol
9such as NFS may not be able to hold such a reference, and so need a 12such as NFS may not be able to hold such a reference, and so need a
10different way to refer to a particular dentry. As the alternative 13different way to refer to a particular dentry. As the alternative
@@ -13,14 +16,14 @@ server-reboot (among other things, though these tend to be the most
13problematic), there is no simple answer like 'filename'. 16problematic), there is no simple answer like 'filename'.
14 17
15The mechanism discussed here allows each filesystem implementation to 18The mechanism discussed here allows each filesystem implementation to
16specify how to generate an opaque (out side of the filesystem) byte 19specify how to generate an opaque (outside of the filesystem) byte
17string for any dentry, and how to find an appropriate dentry for any 20string for any dentry, and how to find an appropriate dentry for any
18given opaque byte string. 21given opaque byte string.
19This byte string will be called a "filehandle fragment" as it 22This byte string will be called a "filehandle fragment" as it
20corresponds to part of an NFS filehandle. 23corresponds to part of an NFS filehandle.
21 24
22A filesystem which supports the mapping between filehandle fragments 25A filesystem which supports the mapping between filehandle fragments
23and dentrys will be termed "exportable". 26and dentries will be termed "exportable".
24 27
25 28
26 29
@@ -89,11 +92,9 @@ For a filesystem to be exportable it must:
89 1/ provide the filehandle fragment routines described below. 92 1/ provide the filehandle fragment routines described below.
90 2/ make sure that d_splice_alias is used rather than d_add 93 2/ make sure that d_splice_alias is used rather than d_add
91 when ->lookup finds an inode for a given parent and name. 94 when ->lookup finds an inode for a given parent and name.
92 Typically the ->lookup routine will end: 95 Typically the ->lookup routine will end with a:
93 if (inode) 96
94 return d_splice(inode, dentry); 97 return d_splice_alias(inode, dentry);
95 d_add(dentry, inode);
96 return NULL;
97 } 98 }
98 99
99 100
@@ -101,67 +102,39 @@ For a filesystem to be exportable it must:
101 A file system implementation declares that instances of the filesystem 102 A file system implementation declares that instances of the filesystem
102are exportable by setting the s_export_op field in the struct 103are exportable by setting the s_export_op field in the struct
103super_block. This field must point to a "struct export_operations" 104super_block. This field must point to a "struct export_operations"
104struct which could potentially be full of NULLs, though normally at 105struct which has the following members:
105least get_parent will be set. 106
106 107 encode_fh (optional)
107 The primary operations are decode_fh and encode_fh. 108 Takes a dentry and creates a filehandle fragment which can later be used
108decode_fh takes a filehandle fragment and tries to find or create a 109 to find or create a dentry for the same object. The default
109dentry for the object referred to by the filehandle. 110 implementation creates a filehandle fragment that encodes a 32bit inode
110encode_fh takes a dentry and creates a filehandle fragment which can 111 and generation number for the inode encoded, and if necessary the
111later be used to find/create a dentry for the same object. 112 same information for the parent.
112 113
113decode_fh will probably make use of "find_exported_dentry". 114 fh_to_dentry (mandatory)
114This function lives in the "exportfs" module which a filesystem does 115 Given a filehandle fragment, this should find the implied object and
115not need unless it is being exported. So rather that calling 116 create a dentry for it (possibly with d_alloc_anon).
116find_exported_dentry directly, each filesystem should call it through 117
117the find_exported_dentry pointer in it's export_operations table. 118 fh_to_parent (optional but strongly recommended)
118This field is set correctly by the exporting agent (e.g. nfsd) when a 119 Given a filehandle fragment, this should find the parent of the
119filesystem is exported, and before any export operations are called. 120 implied object and create a dentry for it (possibly with d_alloc_anon).
120 121 May fail if the filehandle fragment is too small.
121find_exported_dentry needs three support functions from the 122
122filesystem: 123 get_parent (optional but strongly recommended)
123 get_name. When given a parent dentry and a child dentry, this 124 When given a dentry for a directory, this should return a dentry for
124 should find a name in the directory identified by the parent 125 the parent. Quite possibly the parent dentry will have been allocated
125 dentry, which leads to the object identified by the child dentry. 126 by d_alloc_anon. The default get_parent function just returns an error
126 If no get_name function is supplied, a default implementation is 127 so any filehandle lookup that requires finding a parent will fail.
127 provided which uses vfs_readdir to find potential names, and 128 ->lookup("..") is *not* used as a default as it can leave ".." entries
128 matches inode numbers to find the correct match. 129 in the dcache which are too messy to work with.
129 130
130 get_parent. When given a dentry for a directory, this should return 131 get_name (optional)
131 a dentry for the parent. Quite possibly the parent dentry will 132 When given a parent dentry and a child dentry, this should find a name
132 have been allocated by d_alloc_anon. 133 in the directory identified by the parent dentry, which leads to the
133 The default get_parent function just returns an error so any 134 object identified by the child dentry. If no get_name function is
134 filehandle lookup that requires finding a parent will fail. 135 supplied, a default implementation is provided which uses vfs_readdir
135 ->lookup("..") is *not* used as a default as it can leave ".." 136 to find potential names, and matches inode numbers to find the correct
136 entries in the dcache which are too messy to work with. 137 match.
137
138 get_dentry. When given an opaque datum, this should find the
139 implied object and create a dentry for it (possibly with
140 d_alloc_anon).
141 The opaque datum is whatever is passed down by the decode_fh
142 function, and is often simply a fragment of the filehandle
143 fragment.
144 decode_fh passes two datums through find_exported_dentry. One that
145 should be used to identify the target object, and one that can be
146 used to identify the object's parent, should that be necessary.
147 The default get_dentry function assumes that the datum contains an
148 inode number and a generation number, and it attempts to get the
149 inode using "iget" and check it's validity by matching the
150 generation number. A filesystem should only depend on the default
151 if iget can safely be used this way.
152
153If decode_fh and/or encode_fh are left as NULL, then default
154implementations are used. These defaults are suitable for ext2 and
155extremely similar filesystems (like ext3).
156
157The default encode_fh creates a filehandle fragment from the inode
158number and generation number of the target together with the inode
159number and generation number of the parent (if the parent is
160required).
161
162The default decode_fh extract the target and parent datums from the
163filehandle assuming the format used by the default encode_fh and
164passed them to find_exported_dentry.
165 138
166 139
167A filehandle fragment consists of an array of 1 or more 4byte words, 140A filehandle fragment consists of an array of 1 or more 4byte words,
@@ -172,5 +145,3 @@ generated by encode_fh, in which case it will have been padded with
172nuls. Rather, the encode_fh routine should choose a "type" which 145nuls. Rather, the encode_fh routine should choose a "type" which
173indicates the decode_fh how much of the filehandle is valid, and how 146indicates the decode_fh how much of the filehandle is valid, and how
174it should be interpreted. 147it should be interpreted.
175
176