]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/fs/tmpfs/tmpfs.h
This commit was generated by cvs2svn to compensate for changes in r174187,
[FreeBSD/FreeBSD.git] / sys / fs / tmpfs / tmpfs.h
1 /*      $NetBSD: tmpfs.h,v 1.26 2007/02/22 06:37:00 thorpej Exp $       */
2
3 /*
4  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
9  * 2005 program.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *        This product includes software developed by the NetBSD
22  *        Foundation, Inc. and its contributors.
23  * 4. Neither the name of The NetBSD Foundation nor the names of its
24  *    contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  *
39  * $FreeBSD$
40  */
41
42 #ifndef _FS_TMPFS_TMPFS_H_
43 #define _FS_TMPFS_TMPFS_H_
44
45 /* ---------------------------------------------------------------------
46  * KERNEL-SPECIFIC DEFINITIONS
47  * --------------------------------------------------------------------- */
48 #include <sys/dirent.h>
49 #include <sys/mount.h>
50 #include <sys/queue.h>
51 #include <sys/vnode.h>
52 #include <sys/file.h>
53 #include <sys/lock.h>
54 #include <sys/mutex.h>
55
56 /* --------------------------------------------------------------------- */
57 #include <sys/malloc.h>
58 #include <sys/systm.h>
59 #include <sys/vmmeter.h>
60 #include <vm/swap_pager.h>
61
62 MALLOC_DECLARE(M_TMPFSMNT);
63 MALLOC_DECLARE(M_TMPFSNAME);
64
65 /* --------------------------------------------------------------------- */
66
67 /*
68  * Internal representation of a tmpfs directory entry.
69  */
70 struct tmpfs_dirent {
71         TAILQ_ENTRY(tmpfs_dirent)       td_entries;
72
73         /* Length of the name stored in this directory entry.  This avoids
74          * the need to recalculate it every time the name is used. */
75         uint16_t                        td_namelen;
76
77         /* The name of the entry, allocated from a string pool.  This
78         * string is not required to be zero-terminated; therefore, the
79         * td_namelen field must always be used when accessing its value. */
80         char *                          td_name;
81
82         /* Pointer to the node this entry refers to. */
83         struct tmpfs_node *             td_node;
84 };
85
86 /* A directory in tmpfs holds a sorted list of directory entries, which in
87  * turn point to other files (which can be directories themselves).
88  *
89  * In tmpfs, this list is managed by a tail queue, whose head is defined by
90  * the struct tmpfs_dir type.
91  *
92  * It is imporant to notice that directories do not have entries for . and
93  * .. as other file systems do.  These can be generated when requested
94  * based on information available by other means, such as the pointer to
95  * the node itself in the former case or the pointer to the parent directory
96  * in the latter case.  This is done to simplify tmpfs's code and, more
97  * importantly, to remove redundancy. */
98 TAILQ_HEAD(tmpfs_dir, tmpfs_dirent);
99
100 /* Each entry in a directory has a cookie that identifies it.  Cookies
101  * supersede offsets within directories because, given how tmpfs stores
102  * directories in memory, there is no such thing as an offset.  (Emulating
103  * a real offset could be very difficult.)
104  * 
105  * The '.', '..' and the end of directory markers have fixed cookies which
106  * cannot collide with the cookies generated by other entries.  The cookies
107  * fot the other entries are generated based on the memory address on which
108  * stores their information is stored.
109  *
110  * Ideally, using the entry's memory pointer as the cookie would be enough
111  * to represent it and it wouldn't cause collisions in any system.
112  * Unfortunately, this results in "offsets" with very large values which
113  * later raise problems in the Linux compatibility layer (and maybe in other
114  * places) as described in PR kern/32034.  Hence we need to workaround this
115  * with a rather ugly hack.
116  *
117  * Linux 32-bit binaries, unless built with _FILE_OFFSET_BITS=64, have off_t
118  * set to 'long', which is a 32-bit *signed* long integer.  Regardless of
119  * the macro value, GLIBC (2.3 at least) always uses the getdents64
120  * system call (when calling readdir) which internally returns off64_t
121  * offsets.  In order to make 32-bit binaries work, *GLIBC* converts the
122  * 64-bit values returned by the kernel to 32-bit ones and aborts with
123  * EOVERFLOW if the conversion results in values that won't fit in 32-bit
124  * integers (which it assumes is because the directory is extremely large).
125  * This wouldn't cause problems if we were dealing with unsigned integers,
126  * but as we have signed integers, this check fails due to sign expansion.
127  *
128  * For example, consider that the kernel returns the 0xc1234567 cookie to
129  * userspace in a off64_t integer.  Later on, GLIBC casts this value to
130  * off_t (remember, signed) with code similar to:
131  *     system call returns the offset in kernel_value;
132  *     off_t casted_value = kernel_value;
133  *     if (sizeof(off_t) != sizeof(off64_t) &&
134  *         kernel_value != casted_value)
135  *             error!
136  * In this case, casted_value still has 0xc1234567, but when it is compared
137  * for equality against kernel_value, it is promoted to a 64-bit integer and
138  * becomes 0xffffffffc1234567, which is different than 0x00000000c1234567.
139  * Then, GLIBC assumes this is because the directory is very large.
140  *
141  * Given that all the above happens in user-space, we have no control over
142  * it; therefore we must workaround the issue here.  We do this by
143  * truncating the pointer value to a 32-bit integer and hope that there
144  * won't be collisions.  In fact, this will not cause any problems in
145  * 32-bit platforms but some might arise in 64-bit machines (I'm not sure
146  * if they can happen at all in practice).
147  *
148  * XXX A nicer solution shall be attempted. */
149 #ifdef _KERNEL
150 #define TMPFS_DIRCOOKIE_DOT     0
151 #define TMPFS_DIRCOOKIE_DOTDOT  1
152 #define TMPFS_DIRCOOKIE_EOF     2
153 static __inline
154 off_t
155 tmpfs_dircookie(struct tmpfs_dirent *de)
156 {
157         off_t cookie;
158
159         cookie = ((off_t)(uintptr_t)de >> 1) & 0x7FFFFFFF;
160         MPASS(cookie != TMPFS_DIRCOOKIE_DOT);
161         MPASS(cookie != TMPFS_DIRCOOKIE_DOTDOT);
162         MPASS(cookie != TMPFS_DIRCOOKIE_EOF);
163
164         return cookie;
165 }
166 #endif
167
168 /* --------------------------------------------------------------------- */
169
170 /*
171  * Internal representation of a tmpfs file system node.
172  *
173  * This structure is splitted in two parts: one holds attributes common
174  * to all file types and the other holds data that is only applicable to
175  * a particular type.  The code must be careful to only access those
176  * attributes that are actually allowed by the node's type.
177  *
178  *
179  * Below is the key of locks used to protected the fields in the following
180  * structures.
181  *
182  */
183 struct tmpfs_node {
184         /* Doubly-linked list entry which links all existing nodes for a
185          * single file system.  This is provided to ease the removal of
186          * all nodes during the unmount operation. */
187         LIST_ENTRY(tmpfs_node)  tn_entries;
188
189         /* The node's type.  Any of 'VBLK', 'VCHR', 'VDIR', 'VFIFO',
190          * 'VLNK', 'VREG' and 'VSOCK' is allowed.  The usage of vnode
191          * types instead of a custom enumeration is to make things simpler
192          * and faster, as we do not need to convert between two types. */
193         enum vtype              tn_type;
194
195         /* Node identifier. */
196         ino_t                   tn_id;
197
198         /* Node's internal status.  This is used by several file system
199          * operations to do modifications to the node in a delayed
200          * fashion. */
201         int                     tn_status;
202 #define TMPFS_NODE_ACCESSED     (1 << 1)
203 #define TMPFS_NODE_MODIFIED     (1 << 2)
204 #define TMPFS_NODE_CHANGED      (1 << 3)
205
206         /* The node size.  It does not necessarily match the real amount
207          * of memory consumed by it. */
208         off_t                   tn_size;
209
210         /* Generic node attributes. */
211         uid_t                   tn_uid;
212         gid_t                   tn_gid;
213         mode_t                  tn_mode;
214         int                     tn_flags;
215         nlink_t                 tn_links;
216         struct timespec         tn_atime;
217         struct timespec         tn_mtime;
218         struct timespec         tn_ctime;
219         struct timespec         tn_birthtime;
220         unsigned long           tn_gen;
221
222         /* Head of byte-level lock list (used by tmpfs_advlock). */
223         struct lockf *          tn_lockf;
224
225         /* As there is a single vnode for each active file within the
226          * system, care has to be taken to avoid allocating more than one
227          * vnode per file.  In order to do this, a bidirectional association
228          * is kept between vnodes and nodes.
229          *
230          * Whenever a vnode is allocated, its v_data field is updated to
231          * point to the node it references.  At the same time, the node's
232          * tn_vnode field is modified to point to the new vnode representing
233          * it.  Further attempts to allocate a vnode for this same node will
234          * result in returning a new reference to the value stored in
235          * tn_vnode.
236          *
237          * May be NULL when the node is unused (that is, no vnode has been
238          * allocated for it or it has been reclaimed). */
239         struct vnode *          tn_vnode;
240
241         /* interlock to protect tn_vpstate */
242         struct mtx      tn_interlock;
243
244         /* Identify if current node has vnode assiocate with
245          * or allocating vnode.
246          */
247         int             tn_vpstate;
248
249         /* misc data field for different tn_type node */
250         union {
251                 /* Valid when tn_type == VBLK || tn_type == VCHR. */
252                 dev_t                   tn_rdev;
253
254                 /* Valid when tn_type == VDIR. */
255                 struct tn_dir{
256                         /* Pointer to the parent directory.  The root
257                          * directory has a pointer to itself in this field;
258                          * this property identifies the root node. */
259                         struct tmpfs_node *     tn_parent;
260
261                         /* Head of a tail-queue that links the contents of
262                          * the directory together.  See above for a
263                          * description of its contents. */
264                         struct tmpfs_dir        tn_dirhead;
265
266                         /* Number and pointer of the first directory entry
267                          * returned by the readdir operation if it were
268                          * called again to continue reading data from the
269                          * same directory as before.  This is used to speed
270                          * up reads of long directories, assuming that no
271                          * more than one read is in progress at a given time.
272                          * Otherwise, these values are discarded and a linear
273                          * scan is performed from the beginning up to the
274                          * point where readdir starts returning values. */
275                         off_t                   tn_readdir_lastn;
276                         struct tmpfs_dirent *   tn_readdir_lastp;
277                 }tn_dir;
278
279                 /* Valid when tn_type == VLNK. */
280                 /* The link's target, allocated from a string pool. */
281                 char *                  tn_link;
282
283                 /* Valid when tn_type == VREG. */
284                 struct tn_reg {
285                         /* The contents of regular files stored in a tmpfs
286                          * file system are represented by a single anonymous
287                          * memory object (aobj, for short).  The aobj provides
288                          * direct access to any position within the file,
289                          * because its contents are always mapped in a
290                          * contiguous region of virtual memory.  It is a task
291                          * of the memory management subsystem (see uvm(9)) to
292                          * issue the required page ins or page outs whenever
293                          * a position within the file is accessed. */
294                         vm_object_t             tn_aobj;
295                         size_t                  tn_aobj_pages;
296
297                 }tn_reg;
298
299                 /* Valid when tn_type = VFIFO */
300                 struct tn_fifo {
301                         fo_rdwr_t               *tn_fo_read;
302                         fo_rdwr_t               *tn_fo_write;
303                 }tn_fifo;
304         }tn_spec;
305 };
306 LIST_HEAD(tmpfs_node_list, tmpfs_node);
307
308 #define tn_rdev tn_spec.tn_rdev
309 #define tn_dir tn_spec.tn_dir
310 #define tn_link tn_spec.tn_link
311 #define tn_reg tn_spec.tn_reg
312 #define tn_fifo tn_spec.tn_fifo
313
314 #define TMPFS_NODE_LOCK(node) mtx_lock(&(node)->tn_interlock)
315 #define TMPFS_NODE_UNLOCK(node) mtx_unlock(&(node)->tn_interlock)
316 #define        TMPFS_NODE_MTX(node) (&(node)->tn_interlock)
317
318 #define TMPFS_VNODE_ALLOCATING  1
319 #define TMPFS_VNODE_WANT        2
320 /* --------------------------------------------------------------------- */
321
322 /*
323  * Internal representation of a tmpfs mount point.
324  */
325 struct tmpfs_mount {
326         /* Maximum number of memory pages available for use by the file
327          * system, set during mount time.  This variable must never be
328          * used directly as it may be bigger than the current amount of
329          * free memory; in the extreme case, it will hold the SIZE_MAX
330          * value.  Instead, use the TMPFS_PAGES_MAX macro. */
331         size_t                  tm_pages_max;
332
333         /* Number of pages in use by the file system.  Cannot be bigger
334          * than the value returned by TMPFS_PAGES_MAX in any case. */
335         size_t                  tm_pages_used;
336
337         /* Pointer to the node representing the root directory of this
338          * file system. */
339         struct tmpfs_node *     tm_root;
340
341         /* Maximum number of possible nodes for this file system; set
342          * during mount time.  We need a hard limit on the maximum number
343          * of nodes to avoid allocating too much of them; their objects
344          * cannot be released until the file system is unmounted.
345          * Otherwise, we could easily run out of memory by creating lots
346          * of empty files and then simply removing them. */
347         ino_t                   tm_nodes_max;
348
349         /* unrhdr used to allocate inode numbers */
350         struct unrhdr *         tm_ino_unr;
351
352         /* Number of nodes currently that are in use. */
353         ino_t                   tm_nodes_inuse;
354
355         /* maximum representable file size */
356         u_int64_t               tm_maxfilesize;
357
358         /* Nodes are organized in two different lists.  The used list
359          * contains all nodes that are currently used by the file system;
360          * i.e., they refer to existing files.  The available list contains
361          * all nodes that are currently available for use by new files.
362          * Nodes must be kept in this list (instead of deleting them)
363          * because we need to keep track of their generation number (tn_gen
364          * field).
365          *
366          * Note that nodes are lazily allocated: if the available list is
367          * empty and we have enough space to create more nodes, they will be
368          * created and inserted in the used list.  Once these are released,
369          * they will go into the available list, remaining alive until the
370          * file system is unmounted. */
371         struct tmpfs_node_list  tm_nodes_used;
372
373         /* All node lock to protect the node list and tmp_pages_used */
374         struct mtx allnode_lock;
375
376         /* Pools used to store file system meta data.  These are not shared
377          * across several instances of tmpfs for the reasons described in
378          * tmpfs_pool.c. */
379         uma_zone_t              tm_dirent_pool;
380         uma_zone_t              tm_node_pool;
381 };
382 #define TMPFS_LOCK(tm) mtx_lock(&(tm)->allnode_lock)
383 #define TMPFS_UNLOCK(tm) mtx_unlock(&(tm)->allnode_lock)
384
385 /* --------------------------------------------------------------------- */
386
387 /*
388  * This structure maps a file identifier to a tmpfs node.  Used by the
389  * NFS code.
390  */
391 struct tmpfs_fid {
392         uint16_t                tf_len;
393         uint16_t                tf_pad;
394         ino_t                   tf_id;
395         unsigned long           tf_gen;
396 };
397
398 /* --------------------------------------------------------------------- */
399
400 #ifdef _KERNEL
401 /*
402  * Prototypes for tmpfs_subr.c.
403  */
404
405 int     tmpfs_alloc_node(struct tmpfs_mount *, enum vtype,
406             uid_t uid, gid_t gid, mode_t mode, struct tmpfs_node *,
407             char *, dev_t, struct thread *, struct tmpfs_node **);
408 void    tmpfs_free_node(struct tmpfs_mount *, struct tmpfs_node *);
409 int     tmpfs_alloc_dirent(struct tmpfs_mount *, struct tmpfs_node *,
410             const char *, uint16_t, struct tmpfs_dirent **);
411 void    tmpfs_free_dirent(struct tmpfs_mount *, struct tmpfs_dirent *,
412             boolean_t);
413 int     tmpfs_alloc_vp(struct mount *, struct tmpfs_node *, int,
414             struct vnode **, struct thread *);
415 void    tmpfs_free_vp(struct vnode *);
416 int     tmpfs_alloc_file(struct vnode *, struct vnode **, struct vattr *,
417             struct componentname *, char *);
418 void    tmpfs_dir_attach(struct vnode *, struct tmpfs_dirent *);
419 void    tmpfs_dir_detach(struct vnode *, struct tmpfs_dirent *);
420 struct tmpfs_dirent *   tmpfs_dir_lookup(struct tmpfs_node *node,
421                             struct componentname *cnp);
422 struct tmpfs_dirent *tmpfs_dir_search(struct tmpfs_node *node,
423     struct tmpfs_node *f);
424 int     tmpfs_dir_getdotdent(struct tmpfs_node *, struct uio *);
425 int     tmpfs_dir_getdotdotdent(struct tmpfs_node *, struct uio *);
426 struct tmpfs_dirent *   tmpfs_dir_lookupbycookie(struct tmpfs_node *, off_t);
427 int     tmpfs_dir_getdents(struct tmpfs_node *, struct uio *, off_t *);
428 int     tmpfs_reg_resize(struct vnode *, off_t);
429 int     tmpfs_chflags(struct vnode *, int, struct ucred *, struct thread *);
430 int     tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *);
431 int     tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *,
432             struct thread *);
433 int     tmpfs_chsize(struct vnode *, u_quad_t, struct ucred *, struct thread *);
434 int     tmpfs_chtimes(struct vnode *, struct timespec *, struct timespec *,
435             struct timespec *, int, struct ucred *, struct thread *);
436 void    tmpfs_itimes(struct vnode *, const struct timespec *,
437             const struct timespec *);
438
439 void    tmpfs_update(struct vnode *);
440 int     tmpfs_truncate(struct vnode *, off_t);
441
442 /* --------------------------------------------------------------------- */
443
444 /*
445  * Convenience macros to simplify some logical expressions.
446  */
447 #define IMPLIES(a, b) (!(a) || (b))
448 #define IFF(a, b) (IMPLIES(a, b) && IMPLIES(b, a))
449
450 /* --------------------------------------------------------------------- */
451
452 /*
453  * Checks that the directory entry pointed by 'de' matches the name 'name'
454  * with a length of 'len'.
455  */
456 #define TMPFS_DIRENT_MATCHES(de, name, len) \
457     (de->td_namelen == (uint16_t)len && \
458     memcmp((de)->td_name, (name), (de)->td_namelen) == 0)
459
460 /* --------------------------------------------------------------------- */
461
462 /*
463  * Ensures that the node pointed by 'node' is a directory and that its
464  * contents are consistent with respect to directories.
465  */
466 #define TMPFS_VALIDATE_DIR(node) \
467     MPASS((node)->tn_type == VDIR); \
468     MPASS((node)->tn_size % sizeof(struct tmpfs_dirent) == 0); \
469     MPASS((node)->tn_dir.tn_readdir_lastp == NULL || \
470         tmpfs_dircookie((node)->tn_dir.tn_readdir_lastp) == (node)->tn_dir.tn_readdir_lastn);
471
472 /* --------------------------------------------------------------------- */
473
474 /*
475  * Memory management stuff.
476  */
477
478 /* Amount of memory pages to reserve for the system (e.g., to not use by
479  * tmpfs).
480  * XXX: Should this be tunable through sysctl, for instance? */
481 #define TMPFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE)
482
483 /*
484  * Returns information about the number of available memory pages,
485  * including physical and virtual ones.
486  *
487  * If 'total' is TRUE, the value returned is the total amount of memory
488  * pages configured for the system (either in use or free).
489  * If it is FALSE, the value returned is the amount of free memory pages.
490  *
491  * Remember to remove TMPFS_PAGES_RESERVED from the returned value to avoid
492  * excessive memory usage.
493  *
494  */
495 static __inline size_t
496 tmpfs_mem_info(void)
497 {
498         size_t size;
499
500         size = swap_pager_avail + cnt.v_free_count + cnt.v_inactive_count;
501         size -= size > cnt.v_wire_count ? cnt.v_wire_count : size;
502         return size;
503 }
504
505 /* Returns the maximum size allowed for a tmpfs file system.  This macro
506  * must be used instead of directly retrieving the value from tm_pages_max.
507  * The reason is that the size of a tmpfs file system is dynamic: it lets
508  * the user store files as long as there is enough free memory (including
509  * physical memory and swap space).  Therefore, the amount of memory to be
510  * used is either the limit imposed by the user during mount time or the
511  * amount of available memory, whichever is lower.  To avoid consuming all
512  * the memory for a given mount point, the system will always reserve a
513  * minimum of TMPFS_PAGES_RESERVED pages, which is also taken into account
514  * by this macro (see above). */
515 static __inline size_t
516 TMPFS_PAGES_MAX(struct tmpfs_mount *tmp)
517 {
518         size_t freepages;
519
520         freepages = tmpfs_mem_info();
521         freepages -= freepages < TMPFS_PAGES_RESERVED ?
522             freepages : TMPFS_PAGES_RESERVED;
523
524         return MIN(tmp->tm_pages_max, freepages + tmp->tm_pages_used);
525 }
526
527 /* Returns the available space for the given file system. */
528 #define TMPFS_META_PAGES(tmp) (howmany((tmp)->tm_nodes_inuse * (sizeof(struct tmpfs_node) \
529                                 + sizeof(struct tmpfs_dirent)), PAGE_SIZE))
530 #define TMPFS_FILE_PAGES(tmp) ((tmp)->tm_pages_used)
531
532 #define TMPFS_PAGES_AVAIL(tmp) (TMPFS_PAGES_MAX(tmp) > \
533                         TMPFS_META_PAGES(tmp)+TMPFS_FILE_PAGES(tmp)? \
534                         TMPFS_PAGES_MAX(tmp) - TMPFS_META_PAGES(tmp) \
535                         - TMPFS_FILE_PAGES(tmp):0)
536
537 #endif
538
539 /* --------------------------------------------------------------------- */
540
541 /*
542  * Macros/functions to convert from generic data structures to tmpfs
543  * specific ones.
544  */
545
546 static inline
547 struct tmpfs_mount *
548 VFS_TO_TMPFS(struct mount *mp)
549 {
550         struct tmpfs_mount *tmp;
551
552         MPASS((mp) != NULL && (mp)->mnt_data != NULL);
553         tmp = (struct tmpfs_mount *)(mp)->mnt_data;
554         return tmp;
555 }
556
557 static inline
558 struct tmpfs_node *
559 VP_TO_TMPFS_NODE(struct vnode *vp)
560 {
561         struct tmpfs_node *node;
562
563         MPASS((vp) != NULL && (vp)->v_data != NULL);
564         node = (struct tmpfs_node *)vp->v_data;
565         return node;
566 }
567
568 static inline
569 struct tmpfs_node *
570 VP_TO_TMPFS_DIR(struct vnode *vp)
571 {
572         struct tmpfs_node *node;
573
574         node = VP_TO_TMPFS_NODE(vp);
575         TMPFS_VALIDATE_DIR(node);
576         return node;
577 }
578
579 #endif /* _FS_TMPFS_TMPFS_H_ */