2 * Copyright (c) 2007-2008 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/vfs/hammer/hammer_vfsops.c,v 1.40 2008/06/08 18:16:26 dillon Exp $
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/vnode.h>
41 #include <sys/mount.h>
42 #include <sys/malloc.h>
43 #include <sys/nlookup.h>
44 #include <sys/fcntl.h>
45 #include <sys/sysctl.h>
51 int hammer_debug_general;
52 int hammer_debug_debug;
53 int hammer_debug_inode;
54 int hammer_debug_locks;
55 int hammer_debug_btree;
57 int hammer_debug_recover; /* -1 will disable, +1 will force */
58 int hammer_debug_recover_faults;
59 int hammer_count_inodes;
60 int hammer_count_records;
61 int hammer_count_record_datas;
62 int hammer_count_volumes;
63 int hammer_count_buffers;
64 int hammer_count_nodes;
65 int hammer_count_dirtybufs; /* global */
66 int hammer_count_reservations;
67 int hammer_stats_btree_iterations;
68 int hammer_stats_record_iterations;
69 int hammer_limit_dirtybufs = 100; /* per-mount */
70 int hammer_limit_irecs; /* per-inode */
71 int hammer_limit_recs; /* as a whole XXX */
73 int64_t hammer_contention_count;
74 int64_t hammer_zone_limit;
76 SYSCTL_NODE(_vfs, OID_AUTO, hammer, CTLFLAG_RW, 0, "HAMMER filesystem");
77 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_general, CTLFLAG_RW,
78 &hammer_debug_general, 0, "");
79 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_io, CTLFLAG_RW,
80 &hammer_debug_io, 0, "");
81 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_debug, CTLFLAG_RW,
82 &hammer_debug_debug, 0, "");
83 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_inode, CTLFLAG_RW,
84 &hammer_debug_inode, 0, "");
85 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_locks, CTLFLAG_RW,
86 &hammer_debug_locks, 0, "");
87 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_btree, CTLFLAG_RW,
88 &hammer_debug_btree, 0, "");
89 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_tid, CTLFLAG_RW,
90 &hammer_debug_tid, 0, "");
91 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_recover, CTLFLAG_RW,
92 &hammer_debug_recover, 0, "");
93 SYSCTL_INT(_vfs_hammer, OID_AUTO, debug_recover_faults, CTLFLAG_RW,
94 &hammer_debug_recover_faults, 0, "");
96 SYSCTL_INT(_vfs_hammer, OID_AUTO, limit_dirtybufs, CTLFLAG_RW,
97 &hammer_limit_dirtybufs, 0, "");
98 SYSCTL_INT(_vfs_hammer, OID_AUTO, limit_irecs, CTLFLAG_RW,
99 &hammer_limit_irecs, 0, "");
100 SYSCTL_INT(_vfs_hammer, OID_AUTO, limit_recs, CTLFLAG_RW,
101 &hammer_limit_recs, 0, "");
103 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_inodes, CTLFLAG_RD,
104 &hammer_count_inodes, 0, "");
105 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_records, CTLFLAG_RD,
106 &hammer_count_records, 0, "");
107 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_record_datas, CTLFLAG_RD,
108 &hammer_count_record_datas, 0, "");
109 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_volumes, CTLFLAG_RD,
110 &hammer_count_volumes, 0, "");
111 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_buffers, CTLFLAG_RD,
112 &hammer_count_buffers, 0, "");
113 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_nodes, CTLFLAG_RD,
114 &hammer_count_nodes, 0, "");
115 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_dirtybufs, CTLFLAG_RD,
116 &hammer_count_dirtybufs, 0, "");
117 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_reservations, CTLFLAG_RD,
118 &hammer_count_reservations, 0, "");
119 SYSCTL_QUAD(_vfs_hammer, OID_AUTO, zone_limit, CTLFLAG_RW,
120 &hammer_zone_limit, 0, "");
121 SYSCTL_QUAD(_vfs_hammer, OID_AUTO, contention_count, CTLFLAG_RW,
122 &hammer_contention_count, 0, "");
127 static void hammer_free_hmp(struct mount *mp);
129 static int hammer_vfs_mount(struct mount *mp, char *path, caddr_t data,
131 static int hammer_vfs_unmount(struct mount *mp, int mntflags);
132 static int hammer_vfs_root(struct mount *mp, struct vnode **vpp);
133 static int hammer_vfs_statfs(struct mount *mp, struct statfs *sbp,
135 static int hammer_vfs_statvfs(struct mount *mp, struct statvfs *sbp,
137 static int hammer_vfs_sync(struct mount *mp, int waitfor);
138 static int hammer_vfs_vget(struct mount *mp, ino_t ino,
140 static int hammer_vfs_init(struct vfsconf *conf);
141 static int hammer_vfs_fhtovp(struct mount *mp, struct fid *fhp,
143 static int hammer_vfs_vptofh(struct vnode *vp, struct fid *fhp);
144 static int hammer_vfs_checkexp(struct mount *mp, struct sockaddr *nam,
145 int *exflagsp, struct ucred **credanonp);
148 static struct vfsops hammer_vfsops = {
149 .vfs_mount = hammer_vfs_mount,
150 .vfs_unmount = hammer_vfs_unmount,
151 .vfs_root = hammer_vfs_root,
152 .vfs_statfs = hammer_vfs_statfs,
153 .vfs_statvfs = hammer_vfs_statvfs,
154 .vfs_sync = hammer_vfs_sync,
155 .vfs_vget = hammer_vfs_vget,
156 .vfs_init = hammer_vfs_init,
157 .vfs_vptofh = hammer_vfs_vptofh,
158 .vfs_fhtovp = hammer_vfs_fhtovp,
159 .vfs_checkexp = hammer_vfs_checkexp
162 MALLOC_DEFINE(M_HAMMER, "hammer-mount", "hammer mount");
164 VFS_SET(hammer_vfsops, hammer, 0);
165 MODULE_VERSION(hammer, 1);
168 hammer_vfs_init(struct vfsconf *conf)
170 if (hammer_limit_irecs == 0)
171 hammer_limit_irecs = nbuf;
172 if (hammer_limit_recs == 0) /* XXX TODO */
173 hammer_limit_recs = hammer_limit_irecs * 4;
178 hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data,
181 struct hammer_mount_info info;
183 hammer_volume_t rootvol;
184 struct vnode *rootvp;
185 const char *upath; /* volume name in userspace */
186 char *path; /* volume name in system space */
190 if ((error = copyin(data, &info, sizeof(info))) != 0)
192 if ((mp->mnt_flag & MNT_UPDATE) == 0) {
193 if (info.nvolumes <= 0 || info.nvolumes >= 32768)
198 * Interal mount data structure
200 if (mp->mnt_flag & MNT_UPDATE) {
201 hmp = (void *)mp->mnt_data;
202 KKASSERT(hmp != NULL);
204 hmp = kmalloc(sizeof(*hmp), M_HAMMER, M_WAITOK | M_ZERO);
205 mp->mnt_data = (qaddr_t)hmp;
207 hmp->zbuf = kmalloc(HAMMER_BUFSIZE, M_HAMMER, M_WAITOK|M_ZERO);
208 hmp->namekey_iterator = mycpu->gd_time_seconds;
209 /*TAILQ_INIT(&hmp->recycle_list);*/
211 hmp->root_btree_beg.localization = HAMMER_MIN_LOCALIZATION;
212 hmp->root_btree_beg.obj_id = -0x8000000000000000LL;
213 hmp->root_btree_beg.key = -0x8000000000000000LL;
214 hmp->root_btree_beg.create_tid = 1;
215 hmp->root_btree_beg.delete_tid = 1;
216 hmp->root_btree_beg.rec_type = 0;
217 hmp->root_btree_beg.obj_type = 0;
219 hmp->root_btree_end.localization = HAMMER_MAX_LOCALIZATION;
220 hmp->root_btree_end.obj_id = 0x7FFFFFFFFFFFFFFFLL;
221 hmp->root_btree_end.key = 0x7FFFFFFFFFFFFFFFLL;
222 hmp->root_btree_end.create_tid = 0xFFFFFFFFFFFFFFFFULL;
223 hmp->root_btree_end.delete_tid = 0; /* special case */
224 hmp->root_btree_end.rec_type = 0xFFFFU;
225 hmp->root_btree_end.obj_type = 0;
226 lockinit(&hmp->blockmap_lock, "blkmap", 0, 0);
228 hmp->sync_lock.refs = 1;
229 hmp->free_lock.refs = 1;
231 TAILQ_INIT(&hmp->flush_list);
232 TAILQ_INIT(&hmp->objid_cache_list);
233 TAILQ_INIT(&hmp->undo_lru_list);
236 * Set default zone limits. This value can be reduced
237 * further by the zone limit specified in the root volume.
239 * The sysctl can force a small zone limit for debugging
242 for (i = 0; i < HAMMER_MAX_ZONES; ++i) {
243 hmp->zone_limits[i] =
244 HAMMER_ZONE_ENCODE(i, HAMMER_ZONE_LIMIT);
246 if (hammer_zone_limit) {
247 hmp->zone_limits[i] =
248 HAMMER_ZONE_ENCODE(i, hammer_zone_limit);
250 hammer_init_holes(hmp, &hmp->holes[i]);
253 hmp->hflags &= ~HMNT_USERFLAGS;
254 hmp->hflags |= info.hflags & HMNT_USERFLAGS;
257 mp->mnt_flag |= MNT_RDONLY;
258 hmp->asof = info.asof;
260 hmp->asof = HAMMER_MAX_TID;
264 * Re-open read-write if originally read-only, or vise-versa.
266 if (mp->mnt_flag & MNT_UPDATE) {
268 if (hmp->ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
269 kprintf("HAMMER read-only -> read-write\n");
271 RB_SCAN(hammer_vol_rb_tree, &hmp->rb_vols_root, NULL,
272 hammer_adjust_volume_mode, NULL);
273 rootvol = hammer_get_root_volume(hmp, &error);
275 hammer_recover_flush_buffers(hmp, rootvol);
276 hammer_rel_volume(rootvol, 0);
278 RB_SCAN(hammer_ino_rb_tree, &hmp->rb_inos_root, NULL,
279 hammer_reload_inode, NULL);
280 /* kernel clears MNT_RDONLY */
281 } else if (hmp->ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) {
282 kprintf("HAMMER read-write -> read-only\n");
283 hmp->ronly = 1; /* messy */
284 RB_SCAN(hammer_ino_rb_tree, &hmp->rb_inos_root, NULL,
285 hammer_reload_inode, NULL);
287 hammer_flusher_sync(hmp);
288 hammer_flusher_sync(hmp);
289 hammer_flusher_sync(hmp);
291 RB_SCAN(hammer_vol_rb_tree, &hmp->rb_vols_root, NULL,
292 hammer_adjust_volume_mode, NULL);
297 RB_INIT(&hmp->rb_vols_root);
298 RB_INIT(&hmp->rb_inos_root);
299 RB_INIT(&hmp->rb_nods_root);
300 RB_INIT(&hmp->rb_undo_root);
301 RB_INIT(&hmp->rb_resv_root);
302 RB_INIT(&hmp->rb_bufs_root);
304 hmp->ronly = ((mp->mnt_flag & MNT_RDONLY) != 0);
306 TAILQ_INIT(&hmp->volu_list);
307 TAILQ_INIT(&hmp->undo_list);
308 TAILQ_INIT(&hmp->data_list);
309 TAILQ_INIT(&hmp->meta_list);
310 TAILQ_INIT(&hmp->lose_list);
315 path = objcache_get(namei_oc, M_WAITOK);
316 hmp->nvolumes = info.nvolumes;
317 for (i = 0; i < info.nvolumes; ++i) {
318 error = copyin(&info.volumes[i], &upath, sizeof(char *));
320 error = copyinstr(upath, path, MAXPATHLEN, NULL);
322 error = hammer_install_volume(hmp, path);
326 objcache_put(namei_oc, path);
329 * Make sure we found a root volume
331 if (error == 0 && hmp->rootvol == NULL) {
332 kprintf("hammer_mount: No root volume found!\n");
341 * No errors, setup enough of the mount point so we can lookup the
344 mp->mnt_iosize_max = MAXPHYS;
345 mp->mnt_kern_flag |= MNTK_FSMID;
348 * note: f_iosize is used by vnode_pager_haspage() when constructing
351 mp->mnt_stat.f_iosize = HAMMER_BUFSIZE;
352 mp->mnt_stat.f_bsize = HAMMER_BUFSIZE;
354 mp->mnt_vstat.f_frsize = HAMMER_BUFSIZE;
355 mp->mnt_vstat.f_bsize = HAMMER_BUFSIZE;
357 mp->mnt_maxsymlinklen = 255;
358 mp->mnt_flag |= MNT_LOCAL;
360 vfs_add_vnodeops(mp, &hammer_vnode_vops, &mp->mnt_vn_norm_ops);
361 vfs_add_vnodeops(mp, &hammer_spec_vops, &mp->mnt_vn_spec_ops);
362 vfs_add_vnodeops(mp, &hammer_fifo_vops, &mp->mnt_vn_fifo_ops);
365 * The root volume's ondisk pointer is only valid if we hold a
368 rootvol = hammer_get_root_volume(hmp, &error);
373 * Perform any necessary UNDO operations. The recover code does
374 * call hammer_undo_lookup() so we have to pre-cache the blockmap,
375 * and then re-copy it again after recovery is complete.
377 * The recovery code will load hmp->flusher_undo_start.
379 * If this is a read-only mount the UNDO information is retained
380 * in memory in the form of dirty buffer cache buffers, and not
381 * written back to the media.
383 bcopy(rootvol->ondisk->vol0_blockmap, hmp->blockmap,
384 sizeof(hmp->blockmap));
386 error = hammer_recover(hmp, rootvol);
388 kprintf("Failed to recover HAMMER filesystem on mount\n");
393 * Finish setup now that we have a good root volume
395 ksnprintf(mp->mnt_stat.f_mntfromname,
396 sizeof(mp->mnt_stat.f_mntfromname), "%s",
397 rootvol->ondisk->vol_name);
398 mp->mnt_stat.f_fsid.val[0] =
399 crc32((char *)&rootvol->ondisk->vol_fsid + 0, 8);
400 mp->mnt_stat.f_fsid.val[1] =
401 crc32((char *)&rootvol->ondisk->vol_fsid + 8, 8);
403 mp->mnt_vstat.f_fsid_uuid = rootvol->ondisk->vol_fsid;
404 mp->mnt_vstat.f_fsid = crc32(&mp->mnt_vstat.f_fsid_uuid,
405 sizeof(mp->mnt_vstat.f_fsid_uuid));
408 * Certain often-modified fields in the root volume are cached in
409 * the hammer_mount structure so we do not have to generate lots
410 * of little UNDO structures for them.
412 * Recopy after recovery.
414 hmp->next_tid = rootvol->ondisk->vol0_next_tid;
415 bcopy(rootvol->ondisk->vol0_blockmap, hmp->blockmap,
416 sizeof(hmp->blockmap));
417 hmp->copy_stat_freebigblocks = rootvol->ondisk->vol0_stat_freebigblocks;
420 * Use the zone limit set by newfs_hammer, or the zone limit set by
421 * sysctl (for debugging), whichever is smaller.
423 if (rootvol->ondisk->vol0_zone_limit) {
424 hammer_off_t vol0_zone_limit;
426 vol0_zone_limit = rootvol->ondisk->vol0_zone_limit;
427 for (i = 0; i < HAMMER_MAX_ZONES; ++i) {
428 if (hmp->zone_limits[i] > vol0_zone_limit)
429 hmp->zone_limits[i] = vol0_zone_limit;
433 hammer_flusher_create(hmp);
436 * Locate the root directory using the root cluster's B-Tree as a
437 * starting point. The root directory uses an obj_id of 1.
439 * FUTURE: Leave the root directory cached referenced but unlocked
440 * in hmp->rootvp (need to flush it on unmount).
442 error = hammer_vfs_vget(mp, 1, &rootvp);
446 /*vn_unlock(hmp->rootvp);*/
449 hammer_rel_volume(rootvol, 0);
452 * Cleanup and return.
460 hammer_vfs_unmount(struct mount *mp, int mntflags)
463 struct hammer_mount *hmp = (void *)mp->mnt_data;
469 * Clean out the vnodes
472 if (mntflags & MNT_FORCE)
474 if ((error = vflush(mp, 0, flags)) != 0)
478 * Clean up the internal mount structure and related entities. This
486 * Clean up the internal mount structure and disassociate it from the mount.
487 * This may issue I/O.
490 hammer_free_hmp(struct mount *mp)
492 struct hammer_mount *hmp = (void *)mp->mnt_data;
497 * Clean up the root vnode
504 hammer_flusher_sync(hmp);
505 hammer_flusher_sync(hmp);
506 hammer_flusher_destroy(hmp);
508 KKASSERT(RB_EMPTY(&hmp->rb_inos_root));
512 * Unload & flush inodes
514 * XXX illegal to call this from here, it can only be done from
517 RB_SCAN(hammer_ino_rb_tree, &hmp->rb_inos_root, NULL,
518 hammer_unload_inode, (void *)MNT_WAIT);
521 * Unload & flush volumes
525 * Unload buffers and then volumes
527 RB_SCAN(hammer_buf_rb_tree, &hmp->rb_bufs_root, NULL,
528 hammer_unload_buffer, NULL);
529 RB_SCAN(hammer_vol_rb_tree, &hmp->rb_vols_root, NULL,
530 hammer_unload_volume, NULL);
533 mp->mnt_flag &= ~MNT_LOCAL;
535 hammer_destroy_objid_cache(hmp);
536 kfree(hmp->zbuf, M_HAMMER);
537 lockuninit(&hmp->blockmap_lock);
539 for (i = 0; i < HAMMER_MAX_ZONES; ++i)
540 hammer_free_holes(hmp, &hmp->holes[i]);
542 kfree(hmp, M_HAMMER);
546 * Obtain a vnode for the specified inode number. An exclusively locked
550 hammer_vfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
552 struct hammer_transaction trans;
553 struct hammer_mount *hmp = (void *)mp->mnt_data;
554 struct hammer_inode *ip;
557 hammer_simple_transaction(&trans, hmp);
560 * Lookup the requested HAMMER inode. The structure must be
561 * left unlocked while we manipulate the related vnode to avoid
564 ip = hammer_get_inode(&trans, NULL, ino, hmp->asof, 0, &error);
569 error = hammer_get_vnode(ip, vpp);
570 hammer_rel_inode(ip, 0);
571 hammer_done_transaction(&trans);
576 * Return the root vnode for the filesystem.
578 * HAMMER stores the root vnode in the hammer_mount structure so
579 * getting it is easy.
582 hammer_vfs_root(struct mount *mp, struct vnode **vpp)
585 struct hammer_mount *hmp = (void *)mp->mnt_data;
589 error = hammer_vfs_vget(mp, 1, vpp);
594 hammer_vfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred)
596 struct hammer_mount *hmp = (void *)mp->mnt_data;
597 hammer_volume_t volume;
598 hammer_volume_ondisk_t ondisk;
602 volume = hammer_get_root_volume(hmp, &error);
605 ondisk = volume->ondisk;
610 mp->mnt_stat.f_files = ondisk->vol0_stat_inodes;
611 bfree = ondisk->vol0_stat_freebigblocks * HAMMER_LARGEBLOCK_SIZE;
612 hammer_rel_volume(volume, 0);
614 mp->mnt_stat.f_bfree = bfree / HAMMER_BUFSIZE;
615 mp->mnt_stat.f_bavail = mp->mnt_stat.f_bfree;
616 if (mp->mnt_stat.f_files < 0)
617 mp->mnt_stat.f_files = 0;
624 hammer_vfs_statvfs(struct mount *mp, struct statvfs *sbp, struct ucred *cred)
626 struct hammer_mount *hmp = (void *)mp->mnt_data;
627 hammer_volume_t volume;
628 hammer_volume_ondisk_t ondisk;
632 volume = hammer_get_root_volume(hmp, &error);
635 ondisk = volume->ondisk;
640 mp->mnt_vstat.f_files = ondisk->vol0_stat_inodes;
641 bfree = ondisk->vol0_stat_freebigblocks * HAMMER_LARGEBLOCK_SIZE;
642 hammer_rel_volume(volume, 0);
644 mp->mnt_vstat.f_bfree = bfree / HAMMER_BUFSIZE;
645 mp->mnt_vstat.f_bavail = mp->mnt_stat.f_bfree;
646 if (mp->mnt_vstat.f_files < 0)
647 mp->mnt_vstat.f_files = 0;
648 *sbp = mp->mnt_vstat;
653 * Sync the filesystem. Currently we have to run it twice, the second
654 * one will advance the undo start index to the end index, so if a crash
655 * occurs no undos will be run on mount.
657 * We do not sync the filesystem if we are called from a panic. If we did
658 * we might end up blowing up a sync that was already in progress.
661 hammer_vfs_sync(struct mount *mp, int waitfor)
663 struct hammer_mount *hmp = (void *)mp->mnt_data;
666 if (panicstr == NULL) {
667 error = hammer_sync_hmp(hmp, waitfor);
669 error = hammer_sync_hmp(hmp, waitfor);
678 * Convert a vnode to a file handle.
681 hammer_vfs_vptofh(struct vnode *vp, struct fid *fhp)
685 KKASSERT(MAXFIDSZ >= 16);
687 fhp->fid_len = offsetof(struct fid, fid_data[16]);
688 fhp->fid_reserved = 0;
689 bcopy(&ip->obj_id, fhp->fid_data + 0, sizeof(ip->obj_id));
690 bcopy(&ip->obj_asof, fhp->fid_data + 8, sizeof(ip->obj_asof));
696 * Convert a file handle back to a vnode.
699 hammer_vfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
701 struct hammer_transaction trans;
702 struct hammer_inode *ip;
703 struct hammer_inode_info info;
706 bcopy(fhp->fid_data + 0, &info.obj_id, sizeof(info.obj_id));
707 bcopy(fhp->fid_data + 8, &info.obj_asof, sizeof(info.obj_asof));
709 hammer_simple_transaction(&trans, (void *)mp->mnt_data);
712 * Get/allocate the hammer_inode structure. The structure must be
713 * unlocked while we manipulate the related vnode to avoid a
716 ip = hammer_get_inode(&trans, NULL, info.obj_id, info.obj_asof,
722 error = hammer_get_vnode(ip, vpp);
723 hammer_rel_inode(ip, 0);
724 hammer_done_transaction(&trans);
729 hammer_vfs_checkexp(struct mount *mp, struct sockaddr *nam,
730 int *exflagsp, struct ucred **credanonp)
732 hammer_mount_t hmp = (void *)mp->mnt_data;
736 np = vfs_export_lookup(mp, &hmp->export, nam);
738 *exflagsp = np->netc_exflags;
739 *credanonp = &np->netc_anon;
749 hammer_vfs_export(struct mount *mp, int op, const struct export_args *export)
751 hammer_mount_t hmp = (void *)mp->mnt_data;
755 case MOUNTCTL_SET_EXPORT:
756 error = vfs_export(mp, &hmp->export, export);