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_vnops.c,v 1.72 2008/06/18 01:13:30 dillon Exp $
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/fcntl.h>
41 #include <sys/namecache.h>
42 #include <sys/vnode.h>
43 #include <sys/lockf.h>
44 #include <sys/event.h>
46 #include <sys/dirent.h>
47 #include <vm/vm_extern.h>
48 #include <vfs/fifofs/fifo.h>
54 /*static int hammer_vop_vnoperate(struct vop_generic_args *);*/
55 static int hammer_vop_fsync(struct vop_fsync_args *);
56 static int hammer_vop_read(struct vop_read_args *);
57 static int hammer_vop_write(struct vop_write_args *);
58 static int hammer_vop_access(struct vop_access_args *);
59 static int hammer_vop_advlock(struct vop_advlock_args *);
60 static int hammer_vop_close(struct vop_close_args *);
61 static int hammer_vop_ncreate(struct vop_ncreate_args *);
62 static int hammer_vop_getattr(struct vop_getattr_args *);
63 static int hammer_vop_nresolve(struct vop_nresolve_args *);
64 static int hammer_vop_nlookupdotdot(struct vop_nlookupdotdot_args *);
65 static int hammer_vop_nlink(struct vop_nlink_args *);
66 static int hammer_vop_nmkdir(struct vop_nmkdir_args *);
67 static int hammer_vop_nmknod(struct vop_nmknod_args *);
68 static int hammer_vop_open(struct vop_open_args *);
69 static int hammer_vop_pathconf(struct vop_pathconf_args *);
70 static int hammer_vop_print(struct vop_print_args *);
71 static int hammer_vop_readdir(struct vop_readdir_args *);
72 static int hammer_vop_readlink(struct vop_readlink_args *);
73 static int hammer_vop_nremove(struct vop_nremove_args *);
74 static int hammer_vop_nrename(struct vop_nrename_args *);
75 static int hammer_vop_nrmdir(struct vop_nrmdir_args *);
76 static int hammer_vop_setattr(struct vop_setattr_args *);
77 static int hammer_vop_strategy(struct vop_strategy_args *);
78 static int hammer_vop_bmap(struct vop_bmap_args *ap);
79 static int hammer_vop_nsymlink(struct vop_nsymlink_args *);
80 static int hammer_vop_nwhiteout(struct vop_nwhiteout_args *);
81 static int hammer_vop_ioctl(struct vop_ioctl_args *);
82 static int hammer_vop_mountctl(struct vop_mountctl_args *);
84 static int hammer_vop_fifoclose (struct vop_close_args *);
85 static int hammer_vop_fiforead (struct vop_read_args *);
86 static int hammer_vop_fifowrite (struct vop_write_args *);
88 static int hammer_vop_specclose (struct vop_close_args *);
89 static int hammer_vop_specread (struct vop_read_args *);
90 static int hammer_vop_specwrite (struct vop_write_args *);
92 struct vop_ops hammer_vnode_vops = {
93 .vop_default = vop_defaultop,
94 .vop_fsync = hammer_vop_fsync,
95 .vop_getpages = vop_stdgetpages,
96 .vop_putpages = vop_stdputpages,
97 .vop_read = hammer_vop_read,
98 .vop_write = hammer_vop_write,
99 .vop_access = hammer_vop_access,
100 .vop_advlock = hammer_vop_advlock,
101 .vop_close = hammer_vop_close,
102 .vop_ncreate = hammer_vop_ncreate,
103 .vop_getattr = hammer_vop_getattr,
104 .vop_inactive = hammer_vop_inactive,
105 .vop_reclaim = hammer_vop_reclaim,
106 .vop_nresolve = hammer_vop_nresolve,
107 .vop_nlookupdotdot = hammer_vop_nlookupdotdot,
108 .vop_nlink = hammer_vop_nlink,
109 .vop_nmkdir = hammer_vop_nmkdir,
110 .vop_nmknod = hammer_vop_nmknod,
111 .vop_open = hammer_vop_open,
112 .vop_pathconf = hammer_vop_pathconf,
113 .vop_print = hammer_vop_print,
114 .vop_readdir = hammer_vop_readdir,
115 .vop_readlink = hammer_vop_readlink,
116 .vop_nremove = hammer_vop_nremove,
117 .vop_nrename = hammer_vop_nrename,
118 .vop_nrmdir = hammer_vop_nrmdir,
119 .vop_setattr = hammer_vop_setattr,
120 .vop_bmap = hammer_vop_bmap,
121 .vop_strategy = hammer_vop_strategy,
122 .vop_nsymlink = hammer_vop_nsymlink,
123 .vop_nwhiteout = hammer_vop_nwhiteout,
124 .vop_ioctl = hammer_vop_ioctl,
125 .vop_mountctl = hammer_vop_mountctl
128 struct vop_ops hammer_spec_vops = {
129 .vop_default = spec_vnoperate,
130 .vop_fsync = hammer_vop_fsync,
131 .vop_read = hammer_vop_specread,
132 .vop_write = hammer_vop_specwrite,
133 .vop_access = hammer_vop_access,
134 .vop_close = hammer_vop_specclose,
135 .vop_getattr = hammer_vop_getattr,
136 .vop_inactive = hammer_vop_inactive,
137 .vop_reclaim = hammer_vop_reclaim,
138 .vop_setattr = hammer_vop_setattr
141 struct vop_ops hammer_fifo_vops = {
142 .vop_default = fifo_vnoperate,
143 .vop_fsync = hammer_vop_fsync,
144 .vop_read = hammer_vop_fiforead,
145 .vop_write = hammer_vop_fifowrite,
146 .vop_access = hammer_vop_access,
147 .vop_close = hammer_vop_fifoclose,
148 .vop_getattr = hammer_vop_getattr,
149 .vop_inactive = hammer_vop_inactive,
150 .vop_reclaim = hammer_vop_reclaim,
151 .vop_setattr = hammer_vop_setattr
154 #ifdef DEBUG_TRUNCATE
155 struct hammer_inode *HammerTruncIp;
158 static int hammer_dounlink(hammer_transaction_t trans, struct nchandle *nch,
159 struct vnode *dvp, struct ucred *cred, int flags);
160 static int hammer_vop_strategy_read(struct vop_strategy_args *ap);
161 static int hammer_vop_strategy_write(struct vop_strategy_args *ap);
162 static void hammer_cleanup_write_io(hammer_inode_t ip);
163 static void hammer_update_rsv_databufs(hammer_inode_t ip);
168 hammer_vop_vnoperate(struct vop_generic_args *)
170 return (VOCALL(&hammer_vnode_vops, ap));
175 * hammer_vop_fsync { vp, waitfor }
179 hammer_vop_fsync(struct vop_fsync_args *ap)
181 hammer_inode_t ip = VTOI(ap->a_vp);
183 vfsync(ap->a_vp, ap->a_waitfor, 1, NULL, NULL);
184 hammer_flush_inode(ip, HAMMER_FLUSH_SIGNAL);
185 if (ap->a_waitfor == MNT_WAIT)
186 hammer_wait_inode(ip);
191 * hammer_vop_read { vp, uio, ioflag, cred }
195 hammer_vop_read(struct vop_read_args *ap)
197 struct hammer_transaction trans;
206 if (ap->a_vp->v_type != VREG)
210 seqcount = ap->a_ioflag >> 16;
212 hammer_start_transaction(&trans, ip->hmp);
215 * Access the data in HAMMER_BUFSIZE blocks via the buffer cache.
218 while (uio->uio_resid > 0 && uio->uio_offset < ip->ino_data.size) {
219 offset = uio->uio_offset & HAMMER_BUFMASK;
220 if (hammer_debug_cluster_enable) {
221 error = cluster_read(ap->a_vp, ip->ino_data.size,
222 uio->uio_offset - offset,
224 MAXBSIZE, seqcount, &bp);
226 error = bread(ap->a_vp, uio->uio_offset - offset,
227 HAMMER_BUFSIZE, &bp);
234 /* bp->b_flags |= B_CLUSTEROK; temporarily disabled */
235 n = HAMMER_BUFSIZE - offset;
236 if (n > uio->uio_resid)
238 if (n > ip->ino_data.size - uio->uio_offset)
239 n = (int)(ip->ino_data.size - uio->uio_offset);
240 error = uiomove((char *)bp->b_data + offset, n, uio);
242 /* data has a lower priority then meta-data */
243 bp->b_flags |= B_AGE;
248 if ((ip->flags & HAMMER_INODE_RO) == 0 &&
249 (ip->hmp->mp->mnt_flag & MNT_NOATIME) == 0) {
250 ip->ino_data.atime = trans.time;
251 hammer_modify_inode(ip, HAMMER_INODE_ITIMES);
253 hammer_done_transaction(&trans);
258 * hammer_vop_write { vp, uio, ioflag, cred }
262 hammer_vop_write(struct vop_write_args *ap)
264 struct hammer_transaction trans;
265 struct hammer_inode *ip;
276 if (ap->a_vp->v_type != VREG)
280 seqcount = ap->a_ioflag >> 16;
282 if (ip->flags & HAMMER_INODE_RO)
286 * Create a transaction to cover the operations we perform.
288 hammer_start_transaction(&trans, ip->hmp);
294 if (ap->a_ioflag & IO_APPEND)
295 uio->uio_offset = ip->ino_data.size;
298 * Check for illegal write offsets. Valid range is 0...2^63-1.
300 * NOTE: the base_off assignment is required to work around what
301 * I consider to be a GCC-4 optimization bug.
303 if (uio->uio_offset < 0) {
304 hammer_done_transaction(&trans);
307 base_offset = uio->uio_offset + uio->uio_resid; /* work around gcc-4 */
308 if (uio->uio_resid > 0 && base_offset <= 0) {
309 hammer_done_transaction(&trans);
314 * Access the data in HAMMER_BUFSIZE blocks via the buffer cache.
317 while (uio->uio_resid > 0) {
320 if ((error = hammer_checkspace(trans.hmp)) != 0)
324 * Do not allow HAMMER to blow out the buffer cache.
326 * Do not allow HAMMER to blow out system memory by
327 * accumulating too many records. Records are decoupled
328 * from the buffer cache.
330 * Always check at the beginning so separate writes are
331 * not able to bypass this code.
333 * WARNING: Cannot unlock vp when doing a NOCOPY write as
334 * part of a putpages operation. Doing so could cause us
335 * to deadlock against the VM system when we try to re-lock.
337 if ((count++ & 15) == 0) {
338 if (uio->uio_segflg != UIO_NOCOPY) {
340 if ((ap->a_ioflag & IO_NOBWILL) == 0)
343 if (ip->rsv_recs > hammer_limit_irecs)
344 hammer_wait_inode_recs(ip);
345 if (uio->uio_segflg != UIO_NOCOPY)
346 vn_lock(ap->a_vp, LK_EXCLUSIVE|LK_RETRY);
349 rel_offset = (int)(uio->uio_offset & HAMMER_BUFMASK);
350 base_offset = uio->uio_offset & ~HAMMER_BUFMASK64;
351 n = HAMMER_BUFSIZE - rel_offset;
352 if (n > uio->uio_resid)
354 if (uio->uio_offset + n > ip->ino_data.size) {
355 vnode_pager_setsize(ap->a_vp, uio->uio_offset + n);
359 if (uio->uio_segflg == UIO_NOCOPY) {
361 * Issuing a write with the same data backing the
362 * buffer. Instantiate the buffer to collect the
363 * backing vm pages, then read-in any missing bits.
365 * This case is used by vop_stdputpages().
367 bp = getblk(ap->a_vp, base_offset,
368 HAMMER_BUFSIZE, GETBLK_BHEAVY, 0);
369 if ((bp->b_flags & B_CACHE) == 0) {
371 error = bread(ap->a_vp, base_offset,
372 HAMMER_BUFSIZE, &bp);
374 } else if (rel_offset == 0 && uio->uio_resid >= HAMMER_BUFSIZE) {
376 * Even though we are entirely overwriting the buffer
377 * we may still have to zero it out to avoid a
378 * mmap/write visibility issue.
380 bp = getblk(ap->a_vp, base_offset,
381 HAMMER_BUFSIZE, GETBLK_BHEAVY, 0);
382 if ((bp->b_flags & B_CACHE) == 0)
384 } else if (base_offset >= ip->ino_data.size) {
386 * If the base offset of the buffer is beyond the
387 * file EOF, we don't have to issue a read.
389 bp = getblk(ap->a_vp, base_offset,
390 HAMMER_BUFSIZE, GETBLK_BHEAVY, 0);
394 * Partial overwrite, read in any missing bits then
395 * replace the portion being written.
397 error = bread(ap->a_vp, base_offset,
398 HAMMER_BUFSIZE, &bp);
403 error = uiomove((char *)bp->b_data + rel_offset,
408 * If we screwed up we have to undo any VM size changes we
414 vtruncbuf(ap->a_vp, ip->ino_data.size,
419 /* bp->b_flags |= B_CLUSTEROK; temporarily disabled */
420 if (ip->ino_data.size < uio->uio_offset) {
421 ip->ino_data.size = uio->uio_offset;
422 flags = HAMMER_INODE_DDIRTY;
423 vnode_pager_setsize(ap->a_vp, ip->ino_data.size);
427 ip->ino_data.mtime = trans.time;
428 flags |= HAMMER_INODE_ITIMES | HAMMER_INODE_BUFS;
429 flags |= HAMMER_INODE_DDIRTY; /* XXX mtime */
430 hammer_modify_inode(ip, flags);
433 * Try to keep track of cached dirty data.
435 if ((bp->b_flags & B_DIRTY) == 0) {
437 ++ip->hmp->rsv_databufs;
441 * Final buffer disposition.
443 * If write_mode is non-zero we call bawrite()
444 * unconditionally. Otherwise we only use bawrite()
445 * if the writes are clearly sequential.
447 bp->b_flags |= B_AGE;
448 if (ap->a_ioflag & IO_SYNC) {
450 } else if (ap->a_ioflag & IO_DIRECT) {
452 } else if (hammer_write_mode &&
453 (uio->uio_offset & HAMMER_BUFMASK) == 0) {
455 bp->b_flags |= B_CLUSTEROK;
456 cluster_write(bp, ip->ino_data.size, seqcount);
460 } else if ((ap->a_ioflag >> 16) == IO_SEQMAX &&
461 (uio->uio_offset & HAMMER_BUFMASK) == 0) {
463 * If seqcount indicates sequential operation and
464 * we just finished filling a buffer, push it out
465 * now to prevent the buffer cache from becoming
466 * too full, which would trigger non-optimal
474 hammer_done_transaction(&trans);
479 * hammer_vop_access { vp, mode, cred }
483 hammer_vop_access(struct vop_access_args *ap)
485 struct hammer_inode *ip = VTOI(ap->a_vp);
490 uid = hammer_to_unix_xid(&ip->ino_data.uid);
491 gid = hammer_to_unix_xid(&ip->ino_data.gid);
493 error = vop_helper_access(ap, uid, gid, ip->ino_data.mode,
494 ip->ino_data.uflags);
499 * hammer_vop_advlock { vp, id, op, fl, flags }
503 hammer_vop_advlock(struct vop_advlock_args *ap)
505 struct hammer_inode *ip = VTOI(ap->a_vp);
507 return (lf_advlock(ap, &ip->advlock, ip->ino_data.size));
511 * hammer_vop_close { vp, fflag }
515 hammer_vop_close(struct vop_close_args *ap)
517 return (vop_stdclose(ap));
521 * hammer_vop_ncreate { nch, dvp, vpp, cred, vap }
523 * The operating system has already ensured that the directory entry
524 * does not exist and done all appropriate namespace locking.
528 hammer_vop_ncreate(struct vop_ncreate_args *ap)
530 struct hammer_transaction trans;
531 struct hammer_inode *dip;
532 struct hammer_inode *nip;
533 struct nchandle *nch;
537 dip = VTOI(ap->a_dvp);
539 if (dip->flags & HAMMER_INODE_RO)
541 if ((error = hammer_checkspace(dip->hmp)) != 0)
545 * Create a transaction to cover the operations we perform.
547 hammer_start_transaction(&trans, dip->hmp);
550 * Create a new filesystem object of the requested type. The
551 * returned inode will be referenced and shared-locked to prevent
552 * it from being moved to the flusher.
555 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
557 hkprintf("hammer_create_inode error %d\n", error);
558 hammer_done_transaction(&trans);
564 * Add the new filesystem object to the directory. This will also
565 * bump the inode's link count.
567 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
569 hkprintf("hammer_ip_add_directory error %d\n", error);
575 hammer_rel_inode(nip, 0);
576 hammer_done_transaction(&trans);
579 error = hammer_get_vnode(nip, ap->a_vpp);
580 hammer_done_transaction(&trans);
581 hammer_rel_inode(nip, 0);
583 cache_setunresolved(ap->a_nch);
584 cache_setvp(ap->a_nch, *ap->a_vpp);
591 * hammer_vop_getattr { vp, vap }
593 * Retrieve an inode's attribute information. When accessing inodes
594 * historically we fake the atime field to ensure consistent results.
595 * The atime field is stored in the B-Tree element and allowed to be
596 * updated without cycling the element.
600 hammer_vop_getattr(struct vop_getattr_args *ap)
602 struct hammer_inode *ip = VTOI(ap->a_vp);
603 struct vattr *vap = ap->a_vap;
606 if (cache_check_fsmid_vp(ap->a_vp, &ip->fsmid) &&
607 (vp->v_mount->mnt_flag & MNT_RDONLY) == 0 &&
612 hammer_itimes(ap->a_vp);
615 vap->va_fsid = ip->hmp->fsid_udev;
616 vap->va_fileid = ip->ino_leaf.base.obj_id;
617 vap->va_mode = ip->ino_data.mode;
618 vap->va_nlink = ip->ino_data.nlinks;
619 vap->va_uid = hammer_to_unix_xid(&ip->ino_data.uid);
620 vap->va_gid = hammer_to_unix_xid(&ip->ino_data.gid);
623 vap->va_size = ip->ino_data.size;
626 * We must provide a consistent atime and mtime for snapshots
627 * so people can do a 'tar cf - ... | md5' on them and get
628 * consistent results.
630 if (ip->flags & HAMMER_INODE_RO) {
631 hammer_to_timespec(ip->ino_data.ctime, &vap->va_atime);
632 hammer_to_timespec(ip->ino_data.ctime, &vap->va_mtime);
634 hammer_to_timespec(ip->ino_data.atime, &vap->va_atime);
635 hammer_to_timespec(ip->ino_data.mtime, &vap->va_mtime);
637 hammer_to_timespec(ip->ino_data.ctime, &vap->va_ctime);
638 vap->va_flags = ip->ino_data.uflags;
639 vap->va_gen = 1; /* hammer inums are unique for all time */
640 vap->va_blocksize = HAMMER_BUFSIZE;
641 vap->va_bytes = (ip->ino_data.size + 63) & ~63;
642 vap->va_type = hammer_get_vnode_type(ip->ino_data.obj_type);
643 vap->va_filerev = 0; /* XXX */
644 /* mtime uniquely identifies any adjustments made to the file */
645 vap->va_fsmid = ip->ino_data.mtime;
646 vap->va_uid_uuid = ip->ino_data.uid;
647 vap->va_gid_uuid = ip->ino_data.gid;
648 vap->va_fsid_uuid = ip->hmp->fsid;
649 vap->va_vaflags = VA_UID_UUID_VALID | VA_GID_UUID_VALID |
652 switch (ip->ino_data.obj_type) {
653 case HAMMER_OBJTYPE_CDEV:
654 case HAMMER_OBJTYPE_BDEV:
655 vap->va_rmajor = ip->ino_data.rmajor;
656 vap->va_rminor = ip->ino_data.rminor;
666 * hammer_vop_nresolve { nch, dvp, cred }
668 * Locate the requested directory entry.
672 hammer_vop_nresolve(struct vop_nresolve_args *ap)
674 struct hammer_transaction trans;
675 struct namecache *ncp;
679 struct hammer_cursor cursor;
689 * Misc initialization, plus handle as-of name extensions. Look for
690 * the '@@' extension. Note that as-of files and directories cannot
693 dip = VTOI(ap->a_dvp);
694 ncp = ap->a_nch->ncp;
695 asof = dip->obj_asof;
699 hammer_simple_transaction(&trans, dip->hmp);
701 for (i = 0; i < nlen; ++i) {
702 if (ncp->nc_name[i] == '@' && ncp->nc_name[i+1] == '@') {
703 asof = hammer_str_to_tid(ncp->nc_name + i + 2);
704 flags |= HAMMER_INODE_RO;
711 * If there is no path component the time extension is relative to
715 ip = hammer_get_inode(&trans, dip, dip->obj_id,
716 asof, flags, &error);
718 error = hammer_get_vnode(ip, &vp);
719 hammer_rel_inode(ip, 0);
725 cache_setvp(ap->a_nch, vp);
732 * Calculate the namekey and setup the key range for the scan. This
733 * works kinda like a chained hash table where the lower 32 bits
734 * of the namekey synthesize the chain.
736 * The key range is inclusive of both key_beg and key_end.
738 namekey = hammer_directory_namekey(ncp->nc_name, nlen);
740 error = hammer_init_cursor(&trans, &cursor, &dip->cache[1], dip);
741 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC;
742 cursor.key_beg.obj_id = dip->obj_id;
743 cursor.key_beg.key = namekey;
744 cursor.key_beg.create_tid = 0;
745 cursor.key_beg.delete_tid = 0;
746 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
747 cursor.key_beg.obj_type = 0;
749 cursor.key_end = cursor.key_beg;
750 cursor.key_end.key |= 0xFFFFFFFFULL;
752 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
755 * Scan all matching records (the chain), locate the one matching
756 * the requested path component.
758 * The hammer_ip_*() functions merge in-memory records with on-disk
759 * records for the purposes of the search.
764 error = hammer_ip_first(&cursor);
766 error = hammer_ip_resolve_data(&cursor);
769 if (nlen == cursor.leaf->data_len - HAMMER_ENTRY_NAME_OFF &&
770 bcmp(ncp->nc_name, cursor.data->entry.name, nlen) == 0) {
771 obj_id = cursor.data->entry.obj_id;
774 error = hammer_ip_next(&cursor);
777 hammer_done_cursor(&cursor);
779 ip = hammer_get_inode(&trans, dip, obj_id,
780 asof, flags, &error);
782 error = hammer_get_vnode(ip, &vp);
783 hammer_rel_inode(ip, 0);
789 cache_setvp(ap->a_nch, vp);
792 } else if (error == ENOENT) {
793 cache_setvp(ap->a_nch, NULL);
796 hammer_done_transaction(&trans);
801 * hammer_vop_nlookupdotdot { dvp, vpp, cred }
803 * Locate the parent directory of a directory vnode.
805 * dvp is referenced but not locked. *vpp must be returned referenced and
806 * locked. A parent_obj_id of 0 does not necessarily indicate that we are
807 * at the root, instead it could indicate that the directory we were in was
810 * NOTE: as-of sequences are not linked into the directory structure. If
811 * we are at the root with a different asof then the mount point, reload
812 * the same directory with the mount point's asof. I'm not sure what this
813 * will do to NFS. We encode ASOF stamps in NFS file handles so it might not
814 * get confused, but it hasn't been tested.
818 hammer_vop_nlookupdotdot(struct vop_nlookupdotdot_args *ap)
820 struct hammer_transaction trans;
821 struct hammer_inode *dip;
822 struct hammer_inode *ip;
823 int64_t parent_obj_id;
827 dip = VTOI(ap->a_dvp);
828 asof = dip->obj_asof;
829 parent_obj_id = dip->ino_data.parent_obj_id;
831 if (parent_obj_id == 0) {
832 if (dip->obj_id == HAMMER_OBJID_ROOT &&
833 asof != dip->hmp->asof) {
834 parent_obj_id = dip->obj_id;
835 asof = dip->hmp->asof;
836 *ap->a_fakename = kmalloc(19, M_TEMP, M_WAITOK);
837 ksnprintf(*ap->a_fakename, 19, "0x%016llx",
845 hammer_simple_transaction(&trans, dip->hmp);
847 ip = hammer_get_inode(&trans, dip, parent_obj_id,
848 asof, dip->flags, &error);
850 error = hammer_get_vnode(ip, ap->a_vpp);
851 hammer_rel_inode(ip, 0);
855 hammer_done_transaction(&trans);
860 * hammer_vop_nlink { nch, dvp, vp, cred }
864 hammer_vop_nlink(struct vop_nlink_args *ap)
866 struct hammer_transaction trans;
867 struct hammer_inode *dip;
868 struct hammer_inode *ip;
869 struct nchandle *nch;
873 dip = VTOI(ap->a_dvp);
876 if (dip->flags & HAMMER_INODE_RO)
878 if (ip->flags & HAMMER_INODE_RO)
880 if ((error = hammer_checkspace(dip->hmp)) != 0)
884 * Create a transaction to cover the operations we perform.
886 hammer_start_transaction(&trans, dip->hmp);
889 * Add the filesystem object to the directory. Note that neither
890 * dip nor ip are referenced or locked, but their vnodes are
891 * referenced. This function will bump the inode's link count.
893 error = hammer_ip_add_directory(&trans, dip, nch->ncp, ip);
899 cache_setunresolved(nch);
900 cache_setvp(nch, ap->a_vp);
902 hammer_done_transaction(&trans);
907 * hammer_vop_nmkdir { nch, dvp, vpp, cred, vap }
909 * The operating system has already ensured that the directory entry
910 * does not exist and done all appropriate namespace locking.
914 hammer_vop_nmkdir(struct vop_nmkdir_args *ap)
916 struct hammer_transaction trans;
917 struct hammer_inode *dip;
918 struct hammer_inode *nip;
919 struct nchandle *nch;
923 dip = VTOI(ap->a_dvp);
925 if (dip->flags & HAMMER_INODE_RO)
927 if ((error = hammer_checkspace(dip->hmp)) != 0)
931 * Create a transaction to cover the operations we perform.
933 hammer_start_transaction(&trans, dip->hmp);
936 * Create a new filesystem object of the requested type. The
937 * returned inode will be referenced but not locked.
939 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
941 hkprintf("hammer_mkdir error %d\n", error);
942 hammer_done_transaction(&trans);
947 * Add the new filesystem object to the directory. This will also
948 * bump the inode's link count.
950 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
952 hkprintf("hammer_mkdir (add) error %d\n", error);
958 hammer_rel_inode(nip, 0);
961 error = hammer_get_vnode(nip, ap->a_vpp);
962 hammer_rel_inode(nip, 0);
964 cache_setunresolved(ap->a_nch);
965 cache_setvp(ap->a_nch, *ap->a_vpp);
968 hammer_done_transaction(&trans);
973 * hammer_vop_nmknod { nch, dvp, vpp, cred, vap }
975 * The operating system has already ensured that the directory entry
976 * does not exist and done all appropriate namespace locking.
980 hammer_vop_nmknod(struct vop_nmknod_args *ap)
982 struct hammer_transaction trans;
983 struct hammer_inode *dip;
984 struct hammer_inode *nip;
985 struct nchandle *nch;
989 dip = VTOI(ap->a_dvp);
991 if (dip->flags & HAMMER_INODE_RO)
993 if ((error = hammer_checkspace(dip->hmp)) != 0)
997 * Create a transaction to cover the operations we perform.
999 hammer_start_transaction(&trans, dip->hmp);
1002 * Create a new filesystem object of the requested type. The
1003 * returned inode will be referenced but not locked.
1005 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
1007 hammer_done_transaction(&trans);
1013 * Add the new filesystem object to the directory. This will also
1014 * bump the inode's link count.
1016 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
1022 hammer_rel_inode(nip, 0);
1025 error = hammer_get_vnode(nip, ap->a_vpp);
1026 hammer_rel_inode(nip, 0);
1028 cache_setunresolved(ap->a_nch);
1029 cache_setvp(ap->a_nch, *ap->a_vpp);
1032 hammer_done_transaction(&trans);
1037 * hammer_vop_open { vp, mode, cred, fp }
1041 hammer_vop_open(struct vop_open_args *ap)
1045 ip = VTOI(ap->a_vp);
1047 if ((ap->a_mode & FWRITE) && (ip->flags & HAMMER_INODE_RO))
1049 return(vop_stdopen(ap));
1053 * hammer_vop_pathconf { vp, name, retval }
1057 hammer_vop_pathconf(struct vop_pathconf_args *ap)
1063 * hammer_vop_print { vp }
1067 hammer_vop_print(struct vop_print_args *ap)
1073 * hammer_vop_readdir { vp, uio, cred, *eofflag, *ncookies, off_t **cookies }
1077 hammer_vop_readdir(struct vop_readdir_args *ap)
1079 struct hammer_transaction trans;
1080 struct hammer_cursor cursor;
1081 struct hammer_inode *ip;
1083 hammer_base_elm_t base;
1091 ip = VTOI(ap->a_vp);
1093 saveoff = uio->uio_offset;
1095 if (ap->a_ncookies) {
1096 ncookies = uio->uio_resid / 16 + 1;
1097 if (ncookies > 1024)
1099 cookies = kmalloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
1107 hammer_simple_transaction(&trans, ip->hmp);
1110 * Handle artificial entries
1114 r = vop_write_dirent(&error, uio, ip->obj_id, DT_DIR, 1, ".");
1118 cookies[cookie_index] = saveoff;
1121 if (cookie_index == ncookies)
1125 if (ip->ino_data.parent_obj_id) {
1126 r = vop_write_dirent(&error, uio,
1127 ip->ino_data.parent_obj_id,
1130 r = vop_write_dirent(&error, uio,
1131 ip->obj_id, DT_DIR, 2, "..");
1136 cookies[cookie_index] = saveoff;
1139 if (cookie_index == ncookies)
1144 * Key range (begin and end inclusive) to scan. Directory keys
1145 * directly translate to a 64 bit 'seek' position.
1147 hammer_init_cursor(&trans, &cursor, &ip->cache[1], ip);
1148 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC;
1149 cursor.key_beg.obj_id = ip->obj_id;
1150 cursor.key_beg.create_tid = 0;
1151 cursor.key_beg.delete_tid = 0;
1152 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
1153 cursor.key_beg.obj_type = 0;
1154 cursor.key_beg.key = saveoff;
1156 cursor.key_end = cursor.key_beg;
1157 cursor.key_end.key = HAMMER_MAX_KEY;
1158 cursor.asof = ip->obj_asof;
1159 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
1161 error = hammer_ip_first(&cursor);
1163 while (error == 0) {
1164 error = hammer_ip_resolve_data(&cursor);
1167 base = &cursor.leaf->base;
1168 saveoff = base->key;
1169 KKASSERT(cursor.leaf->data_len > HAMMER_ENTRY_NAME_OFF);
1171 if (base->obj_id != ip->obj_id)
1172 panic("readdir: bad record at %p", cursor.node);
1174 r = vop_write_dirent(
1175 &error, uio, cursor.data->entry.obj_id,
1176 hammer_get_dtype(cursor.leaf->base.obj_type),
1177 cursor.leaf->data_len - HAMMER_ENTRY_NAME_OFF ,
1178 (void *)cursor.data->entry.name);
1183 cookies[cookie_index] = base->key;
1185 if (cookie_index == ncookies)
1187 error = hammer_ip_next(&cursor);
1189 hammer_done_cursor(&cursor);
1192 hammer_done_transaction(&trans);
1195 *ap->a_eofflag = (error == ENOENT);
1196 uio->uio_offset = saveoff;
1197 if (error && cookie_index == 0) {
1198 if (error == ENOENT)
1201 kfree(cookies, M_TEMP);
1202 *ap->a_ncookies = 0;
1203 *ap->a_cookies = NULL;
1206 if (error == ENOENT)
1209 *ap->a_ncookies = cookie_index;
1210 *ap->a_cookies = cookies;
1217 * hammer_vop_readlink { vp, uio, cred }
1221 hammer_vop_readlink(struct vop_readlink_args *ap)
1223 struct hammer_transaction trans;
1224 struct hammer_cursor cursor;
1225 struct hammer_inode *ip;
1228 ip = VTOI(ap->a_vp);
1231 * Shortcut if the symlink data was stuffed into ino_data.
1233 if (ip->ino_data.size <= HAMMER_INODE_BASESYMLEN) {
1234 error = uiomove(ip->ino_data.ext.symlink,
1235 ip->ino_data.size, ap->a_uio);
1242 hammer_simple_transaction(&trans, ip->hmp);
1243 hammer_init_cursor(&trans, &cursor, &ip->cache[1], ip);
1246 * Key range (begin and end inclusive) to scan. Directory keys
1247 * directly translate to a 64 bit 'seek' position.
1249 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC; /* XXX */
1250 cursor.key_beg.obj_id = ip->obj_id;
1251 cursor.key_beg.create_tid = 0;
1252 cursor.key_beg.delete_tid = 0;
1253 cursor.key_beg.rec_type = HAMMER_RECTYPE_FIX;
1254 cursor.key_beg.obj_type = 0;
1255 cursor.key_beg.key = HAMMER_FIXKEY_SYMLINK;
1256 cursor.asof = ip->obj_asof;
1257 cursor.flags |= HAMMER_CURSOR_ASOF;
1259 error = hammer_ip_lookup(&cursor);
1261 error = hammer_ip_resolve_data(&cursor);
1263 KKASSERT(cursor.leaf->data_len >=
1264 HAMMER_SYMLINK_NAME_OFF);
1265 error = uiomove(cursor.data->symlink.name,
1266 cursor.leaf->data_len -
1267 HAMMER_SYMLINK_NAME_OFF,
1271 hammer_done_cursor(&cursor);
1272 hammer_done_transaction(&trans);
1277 * hammer_vop_nremove { nch, dvp, cred }
1281 hammer_vop_nremove(struct vop_nremove_args *ap)
1283 struct hammer_transaction trans;
1284 struct hammer_inode *dip;
1287 dip = VTOI(ap->a_dvp);
1289 if (hammer_nohistory(dip) == 0 &&
1290 (error = hammer_checkspace(dip->hmp)) != 0) {
1294 hammer_start_transaction(&trans, dip->hmp);
1295 error = hammer_dounlink(&trans, ap->a_nch, ap->a_dvp, ap->a_cred, 0);
1296 hammer_done_transaction(&trans);
1302 * hammer_vop_nrename { fnch, tnch, fdvp, tdvp, cred }
1306 hammer_vop_nrename(struct vop_nrename_args *ap)
1308 struct hammer_transaction trans;
1309 struct namecache *fncp;
1310 struct namecache *tncp;
1311 struct hammer_inode *fdip;
1312 struct hammer_inode *tdip;
1313 struct hammer_inode *ip;
1314 struct hammer_cursor cursor;
1318 fdip = VTOI(ap->a_fdvp);
1319 tdip = VTOI(ap->a_tdvp);
1320 fncp = ap->a_fnch->ncp;
1321 tncp = ap->a_tnch->ncp;
1322 ip = VTOI(fncp->nc_vp);
1323 KKASSERT(ip != NULL);
1325 if (fdip->flags & HAMMER_INODE_RO)
1327 if (tdip->flags & HAMMER_INODE_RO)
1329 if (ip->flags & HAMMER_INODE_RO)
1331 if ((error = hammer_checkspace(fdip->hmp)) != 0)
1334 hammer_start_transaction(&trans, fdip->hmp);
1337 * Remove tncp from the target directory and then link ip as
1338 * tncp. XXX pass trans to dounlink
1340 * Force the inode sync-time to match the transaction so it is
1341 * in-sync with the creation of the target directory entry.
1343 error = hammer_dounlink(&trans, ap->a_tnch, ap->a_tdvp, ap->a_cred, 0);
1344 if (error == 0 || error == ENOENT) {
1345 error = hammer_ip_add_directory(&trans, tdip, tncp, ip);
1347 ip->ino_data.parent_obj_id = tdip->obj_id;
1348 hammer_modify_inode(ip, HAMMER_INODE_DDIRTY);
1352 goto failed; /* XXX */
1355 * Locate the record in the originating directory and remove it.
1357 * Calculate the namekey and setup the key range for the scan. This
1358 * works kinda like a chained hash table where the lower 32 bits
1359 * of the namekey synthesize the chain.
1361 * The key range is inclusive of both key_beg and key_end.
1363 namekey = hammer_directory_namekey(fncp->nc_name, fncp->nc_nlen);
1365 hammer_init_cursor(&trans, &cursor, &fdip->cache[1], fdip);
1366 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC;
1367 cursor.key_beg.obj_id = fdip->obj_id;
1368 cursor.key_beg.key = namekey;
1369 cursor.key_beg.create_tid = 0;
1370 cursor.key_beg.delete_tid = 0;
1371 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
1372 cursor.key_beg.obj_type = 0;
1374 cursor.key_end = cursor.key_beg;
1375 cursor.key_end.key |= 0xFFFFFFFFULL;
1376 cursor.asof = fdip->obj_asof;
1377 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
1380 * Scan all matching records (the chain), locate the one matching
1381 * the requested path component.
1383 * The hammer_ip_*() functions merge in-memory records with on-disk
1384 * records for the purposes of the search.
1386 error = hammer_ip_first(&cursor);
1387 while (error == 0) {
1388 if (hammer_ip_resolve_data(&cursor) != 0)
1390 nlen = cursor.leaf->data_len - HAMMER_ENTRY_NAME_OFF;
1392 if (fncp->nc_nlen == nlen &&
1393 bcmp(fncp->nc_name, cursor.data->entry.name, nlen) == 0) {
1396 error = hammer_ip_next(&cursor);
1400 * If all is ok we have to get the inode so we can adjust nlinks.
1402 * WARNING: hammer_ip_del_directory() may have to terminate the
1403 * cursor to avoid a recursion. It's ok to call hammer_done_cursor()
1407 error = hammer_ip_del_directory(&trans, &cursor, fdip, ip);
1410 * XXX A deadlock here will break rename's atomicy for the purposes
1411 * of crash recovery.
1413 if (error == EDEADLK) {
1414 hammer_done_cursor(&cursor);
1419 * Cleanup and tell the kernel that the rename succeeded.
1421 hammer_done_cursor(&cursor);
1423 cache_rename(ap->a_fnch, ap->a_tnch);
1426 hammer_done_transaction(&trans);
1431 * hammer_vop_nrmdir { nch, dvp, cred }
1435 hammer_vop_nrmdir(struct vop_nrmdir_args *ap)
1437 struct hammer_transaction trans;
1438 struct hammer_inode *dip;
1441 dip = VTOI(ap->a_dvp);
1443 if (hammer_nohistory(dip) == 0 &&
1444 (error = hammer_checkspace(dip->hmp)) != 0) {
1448 hammer_start_transaction(&trans, dip->hmp);
1449 error = hammer_dounlink(&trans, ap->a_nch, ap->a_dvp, ap->a_cred, 0);
1450 hammer_done_transaction(&trans);
1456 * hammer_vop_setattr { vp, vap, cred }
1460 hammer_vop_setattr(struct vop_setattr_args *ap)
1462 struct hammer_transaction trans;
1464 struct hammer_inode *ip;
1472 ip = ap->a_vp->v_data;
1475 if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
1477 if (ip->flags & HAMMER_INODE_RO)
1479 if (hammer_nohistory(ip) == 0 &&
1480 (error = hammer_checkspace(ip->hmp)) != 0) {
1484 hammer_start_transaction(&trans, ip->hmp);
1487 if (vap->va_flags != VNOVAL) {
1488 flags = ip->ino_data.uflags;
1489 error = vop_helper_setattr_flags(&flags, vap->va_flags,
1490 hammer_to_unix_xid(&ip->ino_data.uid),
1493 if (ip->ino_data.uflags != flags) {
1494 ip->ino_data.uflags = flags;
1495 modflags |= HAMMER_INODE_DDIRTY;
1497 if (ip->ino_data.uflags & (IMMUTABLE | APPEND)) {
1504 if (ip->ino_data.uflags & (IMMUTABLE | APPEND)) {
1508 if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
1509 mode_t cur_mode = ip->ino_data.mode;
1510 uid_t cur_uid = hammer_to_unix_xid(&ip->ino_data.uid);
1511 gid_t cur_gid = hammer_to_unix_xid(&ip->ino_data.gid);
1515 error = vop_helper_chown(ap->a_vp, vap->va_uid, vap->va_gid,
1517 &cur_uid, &cur_gid, &cur_mode);
1519 hammer_guid_to_uuid(&uuid_uid, cur_uid);
1520 hammer_guid_to_uuid(&uuid_gid, cur_gid);
1521 if (bcmp(&uuid_uid, &ip->ino_data.uid,
1522 sizeof(uuid_uid)) ||
1523 bcmp(&uuid_gid, &ip->ino_data.gid,
1524 sizeof(uuid_gid)) ||
1525 ip->ino_data.mode != cur_mode
1527 ip->ino_data.uid = uuid_uid;
1528 ip->ino_data.gid = uuid_gid;
1529 ip->ino_data.mode = cur_mode;
1531 modflags |= HAMMER_INODE_DDIRTY;
1534 while (vap->va_size != VNOVAL && ip->ino_data.size != vap->va_size) {
1535 switch(ap->a_vp->v_type) {
1537 if (vap->va_size == ip->ino_data.size)
1540 * XXX break atomicy, we can deadlock the backend
1541 * if we do not release the lock. Probably not a
1544 if (vap->va_size < ip->ino_data.size) {
1545 vtruncbuf(ap->a_vp, vap->va_size,
1549 vnode_pager_setsize(ap->a_vp, vap->va_size);
1552 ip->ino_data.size = vap->va_size;
1553 modflags |= HAMMER_INODE_DDIRTY;
1554 aligned_size = (vap->va_size + HAMMER_BUFMASK) &
1558 * on-media truncation is cached in the inode until
1559 * the inode is synchronized.
1562 hammer_ip_frontend_trunc(ip, vap->va_size);
1563 hammer_update_rsv_databufs(ip);
1564 #ifdef DEBUG_TRUNCATE
1565 if (HammerTruncIp == NULL)
1568 if ((ip->flags & HAMMER_INODE_TRUNCATED) == 0) {
1569 ip->flags |= HAMMER_INODE_TRUNCATED;
1570 ip->trunc_off = vap->va_size;
1571 #ifdef DEBUG_TRUNCATE
1572 if (ip == HammerTruncIp)
1573 kprintf("truncate1 %016llx\n", ip->trunc_off);
1575 } else if (ip->trunc_off > vap->va_size) {
1576 ip->trunc_off = vap->va_size;
1577 #ifdef DEBUG_TRUNCATE
1578 if (ip == HammerTruncIp)
1579 kprintf("truncate2 %016llx\n", ip->trunc_off);
1582 #ifdef DEBUG_TRUNCATE
1583 if (ip == HammerTruncIp)
1584 kprintf("truncate3 %016llx (ignored)\n", vap->va_size);
1590 * If truncating we have to clean out a portion of
1591 * the last block on-disk. We do this in the
1592 * front-end buffer cache.
1594 if (truncating && vap->va_size < aligned_size) {
1598 aligned_size -= HAMMER_BUFSIZE;
1600 offset = vap->va_size & HAMMER_BUFMASK;
1601 error = bread(ap->a_vp, aligned_size,
1602 HAMMER_BUFSIZE, &bp);
1603 hammer_ip_frontend_trunc(ip, aligned_size);
1605 bzero(bp->b_data + offset,
1606 HAMMER_BUFSIZE - offset);
1609 kprintf("ERROR %d\n", error);
1615 if ((ip->flags & HAMMER_INODE_TRUNCATED) == 0) {
1616 ip->flags |= HAMMER_INODE_TRUNCATED;
1617 ip->trunc_off = vap->va_size;
1618 } else if (ip->trunc_off > vap->va_size) {
1619 ip->trunc_off = vap->va_size;
1621 hammer_ip_frontend_trunc(ip, vap->va_size);
1622 ip->ino_data.size = vap->va_size;
1623 modflags |= HAMMER_INODE_DDIRTY;
1631 if (vap->va_atime.tv_sec != VNOVAL) {
1632 ip->ino_data.atime =
1633 hammer_timespec_to_transid(&vap->va_atime);
1634 modflags |= HAMMER_INODE_ITIMES;
1636 if (vap->va_mtime.tv_sec != VNOVAL) {
1637 ip->ino_data.mtime =
1638 hammer_timespec_to_transid(&vap->va_mtime);
1639 modflags |= HAMMER_INODE_ITIMES;
1640 modflags |= HAMMER_INODE_DDIRTY; /* XXX mtime */
1642 if (vap->va_mode != (mode_t)VNOVAL) {
1643 mode_t cur_mode = ip->ino_data.mode;
1644 uid_t cur_uid = hammer_to_unix_xid(&ip->ino_data.uid);
1645 gid_t cur_gid = hammer_to_unix_xid(&ip->ino_data.gid);
1647 error = vop_helper_chmod(ap->a_vp, vap->va_mode, ap->a_cred,
1648 cur_uid, cur_gid, &cur_mode);
1649 if (error == 0 && ip->ino_data.mode != cur_mode) {
1650 ip->ino_data.mode = cur_mode;
1651 modflags |= HAMMER_INODE_DDIRTY;
1656 hammer_modify_inode(ip, modflags);
1657 hammer_done_transaction(&trans);
1662 * hammer_vop_nsymlink { nch, dvp, vpp, cred, vap, target }
1666 hammer_vop_nsymlink(struct vop_nsymlink_args *ap)
1668 struct hammer_transaction trans;
1669 struct hammer_inode *dip;
1670 struct hammer_inode *nip;
1671 struct nchandle *nch;
1672 hammer_record_t record;
1676 ap->a_vap->va_type = VLNK;
1679 dip = VTOI(ap->a_dvp);
1681 if (dip->flags & HAMMER_INODE_RO)
1683 if ((error = hammer_checkspace(dip->hmp)) != 0)
1687 * Create a transaction to cover the operations we perform.
1689 hammer_start_transaction(&trans, dip->hmp);
1692 * Create a new filesystem object of the requested type. The
1693 * returned inode will be referenced but not locked.
1696 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
1698 hammer_done_transaction(&trans);
1704 * Add a record representing the symlink. symlink stores the link
1705 * as pure data, not a string, and is no \0 terminated.
1708 bytes = strlen(ap->a_target);
1710 if (bytes <= HAMMER_INODE_BASESYMLEN) {
1711 bcopy(ap->a_target, nip->ino_data.ext.symlink, bytes);
1713 record = hammer_alloc_mem_record(nip, bytes);
1714 record->type = HAMMER_MEM_RECORD_GENERAL;
1716 record->leaf.base.localization = HAMMER_LOCALIZE_MISC;
1717 record->leaf.base.key = HAMMER_FIXKEY_SYMLINK;
1718 record->leaf.base.rec_type = HAMMER_RECTYPE_FIX;
1719 record->leaf.data_len = bytes;
1720 KKASSERT(HAMMER_SYMLINK_NAME_OFF == 0);
1721 bcopy(ap->a_target, record->data->symlink.name, bytes);
1722 error = hammer_ip_add_record(&trans, record);
1726 * Set the file size to the length of the link.
1729 nip->ino_data.size = bytes;
1730 hammer_modify_inode(nip, HAMMER_INODE_DDIRTY);
1734 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
1740 hammer_rel_inode(nip, 0);
1743 error = hammer_get_vnode(nip, ap->a_vpp);
1744 hammer_rel_inode(nip, 0);
1746 cache_setunresolved(ap->a_nch);
1747 cache_setvp(ap->a_nch, *ap->a_vpp);
1750 hammer_done_transaction(&trans);
1755 * hammer_vop_nwhiteout { nch, dvp, cred, flags }
1759 hammer_vop_nwhiteout(struct vop_nwhiteout_args *ap)
1761 struct hammer_transaction trans;
1762 struct hammer_inode *dip;
1765 dip = VTOI(ap->a_dvp);
1767 if (hammer_nohistory(dip) == 0 &&
1768 (error = hammer_checkspace(dip->hmp)) != 0) {
1772 hammer_start_transaction(&trans, dip->hmp);
1773 error = hammer_dounlink(&trans, ap->a_nch, ap->a_dvp,
1774 ap->a_cred, ap->a_flags);
1775 hammer_done_transaction(&trans);
1781 * hammer_vop_ioctl { vp, command, data, fflag, cred }
1785 hammer_vop_ioctl(struct vop_ioctl_args *ap)
1787 struct hammer_inode *ip = ap->a_vp->v_data;
1789 return(hammer_ioctl(ip, ap->a_command, ap->a_data,
1790 ap->a_fflag, ap->a_cred));
1795 hammer_vop_mountctl(struct vop_mountctl_args *ap)
1800 mp = ap->a_head.a_ops->head.vv_mount;
1803 case MOUNTCTL_SET_EXPORT:
1804 if (ap->a_ctllen != sizeof(struct export_args))
1806 error = hammer_vfs_export(mp, ap->a_op,
1807 (const struct export_args *)ap->a_ctl);
1810 error = journal_mountctl(ap);
1817 * hammer_vop_strategy { vp, bio }
1819 * Strategy call, used for regular file read & write only. Note that the
1820 * bp may represent a cluster.
1822 * To simplify operation and allow better optimizations in the future,
1823 * this code does not make any assumptions with regards to buffer alignment
1828 hammer_vop_strategy(struct vop_strategy_args *ap)
1833 bp = ap->a_bio->bio_buf;
1837 error = hammer_vop_strategy_read(ap);
1840 error = hammer_vop_strategy_write(ap);
1843 bp->b_error = error = EINVAL;
1844 bp->b_flags |= B_ERROR;
1852 * Read from a regular file. Iterate the related records and fill in the
1853 * BIO/BUF. Gaps are zero-filled.
1855 * The support code in hammer_object.c should be used to deal with mixed
1856 * in-memory and on-disk records.
1862 hammer_vop_strategy_read(struct vop_strategy_args *ap)
1864 struct hammer_transaction trans;
1865 struct hammer_inode *ip;
1866 struct hammer_cursor cursor;
1867 hammer_base_elm_t base;
1881 ip = ap->a_vp->v_data;
1884 * The zone-2 disk offset may have been set by the cluster code via
1885 * a BMAP operation. Take care not to confuse it with the bio_offset
1886 * set by hammer_io_direct_write(), which is a device-relative offset.
1888 * Checking the high bits should suffice.
1890 nbio = push_bio(bio);
1891 if ((nbio->bio_offset & HAMMER_OFF_ZONE_MASK) ==
1892 HAMMER_ZONE_RAW_BUFFER) {
1893 error = hammer_io_direct_read(ip->hmp, nbio->bio_offset, bio);
1900 hammer_simple_transaction(&trans, ip->hmp);
1901 hammer_init_cursor(&trans, &cursor, &ip->cache[1], ip);
1904 * Key range (begin and end inclusive) to scan. Note that the key's
1905 * stored in the actual records represent BASE+LEN, not BASE. The
1906 * first record containing bio_offset will have a key > bio_offset.
1908 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC;
1909 cursor.key_beg.obj_id = ip->obj_id;
1910 cursor.key_beg.create_tid = 0;
1911 cursor.key_beg.delete_tid = 0;
1912 cursor.key_beg.obj_type = 0;
1913 cursor.key_beg.key = bio->bio_offset + 1;
1914 cursor.asof = ip->obj_asof;
1915 cursor.flags |= HAMMER_CURSOR_ASOF;
1917 cursor.key_end = cursor.key_beg;
1918 KKASSERT(ip->ino_data.obj_type == HAMMER_OBJTYPE_REGFILE);
1920 if (ip->ino_data.obj_type == HAMMER_OBJTYPE_DBFILE) {
1921 cursor.key_beg.rec_type = HAMMER_RECTYPE_DB;
1922 cursor.key_end.rec_type = HAMMER_RECTYPE_DB;
1923 cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
1927 ran_end = bio->bio_offset + bp->b_bufsize;
1928 cursor.key_beg.rec_type = HAMMER_RECTYPE_DATA;
1929 cursor.key_end.rec_type = HAMMER_RECTYPE_DATA;
1930 tmp64 = ran_end + MAXPHYS + 1; /* work-around GCC-4 bug */
1931 if (tmp64 < ran_end)
1932 cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
1934 cursor.key_end.key = ran_end + MAXPHYS + 1;
1936 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE;
1938 error = hammer_ip_first(&cursor);
1941 while (error == 0) {
1943 * Get the base file offset of the record. The key for
1944 * data records is (base + bytes) rather then (base).
1946 base = &cursor.leaf->base;
1947 rec_offset = base->key - cursor.leaf->data_len;
1950 * Calculate the gap, if any, and zero-fill it.
1952 * n is the offset of the start of the record verses our
1953 * current seek offset in the bio.
1955 n = (int)(rec_offset - (bio->bio_offset + boff));
1957 if (n > bp->b_bufsize - boff)
1958 n = bp->b_bufsize - boff;
1959 bzero((char *)bp->b_data + boff, n);
1965 * Calculate the data offset in the record and the number
1966 * of bytes we can copy.
1968 * There are two degenerate cases. First, boff may already
1969 * be at bp->b_bufsize. Secondly, the data offset within
1970 * the record may exceed the record's size.
1974 n = cursor.leaf->data_len - roff;
1976 kprintf("strategy_read: bad n=%d roff=%d\n", n, roff);
1978 } else if (n > bp->b_bufsize - boff) {
1979 n = bp->b_bufsize - boff;
1983 * Deal with cached truncations. This cool bit of code
1984 * allows truncate()/ftruncate() to avoid having to sync
1987 * If the frontend is truncated then all backend records are
1988 * subject to the frontend's truncation.
1990 * If the backend is truncated then backend records on-disk
1991 * (but not in-memory) are subject to the backend's
1992 * truncation. In-memory records owned by the backend
1993 * represent data written after the truncation point on the
1994 * backend and must not be truncated.
1996 * Truncate operations deal with frontend buffer cache
1997 * buffers and frontend-owned in-memory records synchronously.
1999 if (ip->flags & HAMMER_INODE_TRUNCATED) {
2000 if (hammer_cursor_ondisk(&cursor) ||
2001 cursor.iprec->flush_state == HAMMER_FST_FLUSH) {
2002 if (ip->trunc_off <= rec_offset)
2004 else if (ip->trunc_off < rec_offset + n)
2005 n = (int)(ip->trunc_off - rec_offset);
2008 if (ip->sync_flags & HAMMER_INODE_TRUNCATED) {
2009 if (hammer_cursor_ondisk(&cursor)) {
2010 if (ip->sync_trunc_off <= rec_offset)
2012 else if (ip->sync_trunc_off < rec_offset + n)
2013 n = (int)(ip->sync_trunc_off - rec_offset);
2018 * Try to issue a direct read into our bio if possible,
2019 * otherwise resolve the element data into a hammer_buffer
2022 if (n && boff == 0 &&
2023 ((cursor.leaf->data_offset + roff) & HAMMER_BUFMASK) == 0) {
2024 error = hammer_io_direct_read(
2026 cursor.leaf->data_offset + roff,
2030 error = hammer_ip_resolve_data(&cursor);
2032 bcopy((char *)cursor.data + roff,
2033 (char *)bp->b_data + boff, n);
2040 * Iterate until we have filled the request.
2043 if (boff == bp->b_bufsize)
2045 error = hammer_ip_next(&cursor);
2049 * There may have been a gap after the last record
2051 if (error == ENOENT)
2053 if (error == 0 && boff != bp->b_bufsize) {
2054 KKASSERT(boff < bp->b_bufsize);
2055 bzero((char *)bp->b_data + boff, bp->b_bufsize - boff);
2056 /* boff = bp->b_bufsize; */
2059 bp->b_error = error;
2061 bp->b_flags |= B_ERROR;
2066 hammer_cache_node(&ip->cache[1], cursor.node);
2067 hammer_done_cursor(&cursor);
2068 hammer_done_transaction(&trans);
2073 * BMAP operation - used to support cluster_read() only.
2075 * (struct vnode *vp, off_t loffset, off_t *doffsetp, int *runp, int *runb)
2077 * This routine may return EOPNOTSUPP if the opration is not supported for
2078 * the specified offset. The contents of the pointer arguments do not
2079 * need to be initialized in that case.
2081 * If a disk address is available and properly aligned return 0 with
2082 * *doffsetp set to the zone-2 address, and *runp / *runb set appropriately
2083 * to the run-length relative to that offset. Callers may assume that
2084 * *doffsetp is valid if 0 is returned, even if *runp is not sufficiently
2085 * large, so return EOPNOTSUPP if it is not sufficiently large.
2089 hammer_vop_bmap(struct vop_bmap_args *ap)
2091 struct hammer_transaction trans;
2092 struct hammer_inode *ip;
2093 struct hammer_cursor cursor;
2094 hammer_base_elm_t base;
2098 int64_t base_offset;
2099 int64_t base_disk_offset;
2100 int64_t last_offset;
2101 hammer_off_t last_disk_offset;
2102 hammer_off_t disk_offset;
2106 ip = ap->a_vp->v_data;
2109 * We can only BMAP regular files. We can't BMAP database files,
2112 if (ip->ino_data.obj_type != HAMMER_OBJTYPE_REGFILE)
2116 * bmap is typically called with runp/runb both NULL when used
2117 * for writing. We do not support BMAP for writing atm.
2119 if (ap->a_runp == NULL && ap->a_runb == NULL)
2123 * Scan the B-Tree to acquire blockmap addresses, then translate
2126 hammer_simple_transaction(&trans, ip->hmp);
2128 kprintf("bmap_beg %016llx ip->cache %p\n", ap->a_loffset, ip->cache[1]);
2130 hammer_init_cursor(&trans, &cursor, &ip->cache[1], ip);
2133 * Key range (begin and end inclusive) to scan. Note that the key's
2134 * stored in the actual records represent BASE+LEN, not BASE. The
2135 * first record containing bio_offset will have a key > bio_offset.
2137 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC;
2138 cursor.key_beg.obj_id = ip->obj_id;
2139 cursor.key_beg.create_tid = 0;
2140 cursor.key_beg.delete_tid = 0;
2141 cursor.key_beg.obj_type = 0;
2143 cursor.key_beg.key = ap->a_loffset - MAXPHYS + 1;
2145 cursor.key_beg.key = ap->a_loffset + 1;
2146 if (cursor.key_beg.key < 0)
2147 cursor.key_beg.key = 0;
2148 cursor.asof = ip->obj_asof;
2149 cursor.flags |= HAMMER_CURSOR_ASOF;
2151 cursor.key_end = cursor.key_beg;
2152 KKASSERT(ip->ino_data.obj_type == HAMMER_OBJTYPE_REGFILE);
2154 ran_end = ap->a_loffset + MAXPHYS;
2155 cursor.key_beg.rec_type = HAMMER_RECTYPE_DATA;
2156 cursor.key_end.rec_type = HAMMER_RECTYPE_DATA;
2157 tmp64 = ran_end + MAXPHYS + 1; /* work-around GCC-4 bug */
2158 if (tmp64 < ran_end)
2159 cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
2161 cursor.key_end.key = ran_end + MAXPHYS + 1;
2163 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE;
2165 error = hammer_ip_first(&cursor);
2166 base_offset = last_offset = 0;
2167 base_disk_offset = last_disk_offset = 0;
2169 while (error == 0) {
2171 * Get the base file offset of the record. The key for
2172 * data records is (base + bytes) rather then (base).
2174 base = &cursor.leaf->base;
2175 rec_offset = base->key - cursor.leaf->data_len;
2176 rec_len = cursor.leaf->data_len;
2179 * Incorporate any cached truncation
2181 if (ip->flags & HAMMER_INODE_TRUNCATED) {
2182 if (hammer_cursor_ondisk(&cursor) ||
2183 cursor.iprec->flush_state == HAMMER_FST_FLUSH) {
2184 if (ip->trunc_off <= rec_offset)
2186 else if (ip->trunc_off < rec_offset + rec_len)
2187 rec_len = (int)(ip->trunc_off - rec_offset);
2190 if (ip->sync_flags & HAMMER_INODE_TRUNCATED) {
2191 if (hammer_cursor_ondisk(&cursor)) {
2192 if (ip->sync_trunc_off <= rec_offset)
2194 else if (ip->sync_trunc_off < rec_offset + rec_len)
2195 rec_len = (int)(ip->sync_trunc_off - rec_offset);
2200 * Accumulate information. If we have hit a discontiguous
2201 * block reset base_offset unless we are already beyond the
2202 * requested offset. If we are, that's it, we stop.
2204 disk_offset = hammer_blockmap_lookup(trans.hmp,
2205 cursor.leaf->data_offset,
2209 if (rec_offset != last_offset ||
2210 disk_offset != last_disk_offset) {
2211 if (rec_offset > ap->a_loffset)
2213 base_offset = rec_offset;
2214 base_disk_offset = disk_offset;
2216 last_offset = rec_offset + rec_len;
2217 last_disk_offset = disk_offset + rec_len;
2219 error = hammer_ip_next(&cursor);
2223 kprintf("BMAP %016llx: %016llx - %016llx\n",
2224 ap->a_loffset, base_offset, last_offset);
2225 kprintf("BMAP %16s: %016llx - %016llx\n",
2226 "", base_disk_offset, last_disk_offset);
2230 hammer_cache_node(&ip->cache[1], cursor.node);
2232 kprintf("bmap_end2 %016llx ip->cache %p\n", ap->a_loffset, ip->cache[1]);
2235 hammer_done_cursor(&cursor);
2236 hammer_done_transaction(&trans);
2238 if (base_offset == 0 || base_offset > ap->a_loffset ||
2239 last_offset < ap->a_loffset) {
2242 disk_offset = base_disk_offset + (ap->a_loffset - base_offset);
2245 * If doffsetp is not aligned or the forward run size does
2246 * not cover a whole buffer, disallow the direct I/O.
2248 if ((disk_offset & HAMMER_BUFMASK) ||
2249 (last_offset - ap->a_loffset) < HAMMER_BUFSIZE) {
2252 *ap->a_doffsetp = disk_offset;
2254 *ap->a_runb = ap->a_loffset - base_offset;
2256 *ap->a_runp = last_offset - ap->a_loffset;
2264 * Write to a regular file. Because this is a strategy call the OS is
2265 * trying to actually get data onto the media.
2269 hammer_vop_strategy_write(struct vop_strategy_args *ap)
2271 hammer_record_t record;
2281 ip = ap->a_vp->v_data;
2284 if (ip->flags & HAMMER_INODE_RO) {
2285 bp->b_error = EROFS;
2286 bp->b_flags |= B_ERROR;
2288 hammer_cleanup_write_io(ip);
2293 * Interlock with inode destruction (no in-kernel or directory
2294 * topology visibility). If we queue new IO while trying to
2295 * destroy the inode we can deadlock the vtrunc call in
2296 * hammer_inode_unloadable_check().
2298 if (ip->flags & (HAMMER_INODE_DELETING|HAMMER_INODE_DELETED)) {
2301 hammer_cleanup_write_io(ip);
2306 * Reserve space and issue a direct-write from the front-end.
2307 * NOTE: The direct_io code will hammer_bread/bcopy smaller
2310 * An in-memory record will be installed to reference the storage
2311 * until the flusher can get to it.
2313 * Since we own the high level bio the front-end will not try to
2314 * do a direct-read until the write completes.
2316 * NOTE: The only time we do not reserve a full-sized buffers
2317 * worth of data is if the file is small. We do not try to
2318 * allocate a fragment (from the small-data zone) at the end of
2319 * an otherwise large file as this can lead to wildly separated
2322 KKASSERT((bio->bio_offset & HAMMER_BUFMASK) == 0);
2323 KKASSERT(bio->bio_offset < ip->ino_data.size);
2324 if (bio->bio_offset || ip->ino_data.size > HAMMER_BUFSIZE / 2)
2325 bytes = (bp->b_bufsize + HAMMER_BUFMASK) & ~HAMMER_BUFMASK;
2327 bytes = ((int)ip->ino_data.size + 15) & ~15;
2329 record = hammer_ip_add_bulk(ip, bio->bio_offset, bp->b_data,
2332 hammer_io_direct_write(hmp, &record->leaf, bio);
2333 hammer_rel_mem_record(record);
2334 if (hmp->rsv_recs > hammer_limit_recs &&
2335 ip->rsv_recs > hammer_limit_irecs / 10) {
2336 hammer_flush_inode(ip, HAMMER_FLUSH_SIGNAL);
2337 } else if (ip->rsv_recs > hammer_limit_irecs / 2) {
2338 hammer_flush_inode(ip, HAMMER_FLUSH_SIGNAL);
2341 bp->b_bio2.bio_offset = NOOFFSET;
2342 bp->b_error = error;
2343 bp->b_flags |= B_ERROR;
2346 hammer_cleanup_write_io(ip);
2351 * Clean-up after disposing of a dirty frontend buffer's data.
2352 * This is somewhat heuristical so try to be robust.
2355 hammer_cleanup_write_io(hammer_inode_t ip)
2357 if (ip->rsv_databufs) {
2359 --ip->hmp->rsv_databufs;
2364 * We can lose track of dirty buffer cache buffers if we truncate, this
2365 * routine will resynchronize the count.
2369 hammer_update_rsv_databufs(hammer_inode_t ip)
2377 RB_FOREACH(bp, buf_rb_tree, &ip->vp->v_rbdirty_tree) {
2383 delta = n - ip->rsv_databufs;
2384 ip->rsv_databufs += delta;
2385 ip->hmp->rsv_databufs += delta;
2389 * dounlink - disconnect a directory entry
2391 * XXX whiteout support not really in yet
2394 hammer_dounlink(hammer_transaction_t trans, struct nchandle *nch,
2395 struct vnode *dvp, struct ucred *cred, int flags)
2397 struct namecache *ncp;
2400 struct hammer_cursor cursor;
2405 * Calculate the namekey and setup the key range for the scan. This
2406 * works kinda like a chained hash table where the lower 32 bits
2407 * of the namekey synthesize the chain.
2409 * The key range is inclusive of both key_beg and key_end.
2414 if (dip->flags & HAMMER_INODE_RO)
2417 namekey = hammer_directory_namekey(ncp->nc_name, ncp->nc_nlen);
2419 hammer_init_cursor(trans, &cursor, &dip->cache[1], dip);
2420 cursor.key_beg.localization = HAMMER_LOCALIZE_MISC;
2421 cursor.key_beg.obj_id = dip->obj_id;
2422 cursor.key_beg.key = namekey;
2423 cursor.key_beg.create_tid = 0;
2424 cursor.key_beg.delete_tid = 0;
2425 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
2426 cursor.key_beg.obj_type = 0;
2428 cursor.key_end = cursor.key_beg;
2429 cursor.key_end.key |= 0xFFFFFFFFULL;
2430 cursor.asof = dip->obj_asof;
2431 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
2434 * Scan all matching records (the chain), locate the one matching
2435 * the requested path component. info->last_error contains the
2436 * error code on search termination and could be 0, ENOENT, or
2439 * The hammer_ip_*() functions merge in-memory records with on-disk
2440 * records for the purposes of the search.
2442 error = hammer_ip_first(&cursor);
2444 while (error == 0) {
2445 error = hammer_ip_resolve_data(&cursor);
2448 nlen = cursor.leaf->data_len - HAMMER_ENTRY_NAME_OFF;
2450 if (ncp->nc_nlen == nlen &&
2451 bcmp(ncp->nc_name, cursor.data->entry.name, nlen) == 0) {
2454 error = hammer_ip_next(&cursor);
2458 * If all is ok we have to get the inode so we can adjust nlinks.
2459 * To avoid a deadlock with the flusher we must release the inode
2460 * lock on the directory when acquiring the inode for the entry.
2462 * If the target is a directory, it must be empty.
2465 hammer_unlock(&cursor.ip->lock);
2466 ip = hammer_get_inode(trans, dip, cursor.data->entry.obj_id,
2467 dip->hmp->asof, 0, &error);
2468 hammer_lock_sh(&cursor.ip->lock);
2469 if (error == ENOENT) {
2470 kprintf("obj_id %016llx\n", cursor.data->entry.obj_id);
2471 Debugger("ENOENT unlinking object that should exist");
2475 * If we are trying to remove a directory the directory must
2478 * WARNING: hammer_ip_check_directory_empty() may have to
2479 * terminate the cursor to avoid a deadlock. It is ok to
2480 * call hammer_done_cursor() twice.
2482 if (error == 0 && ip->ino_data.obj_type ==
2483 HAMMER_OBJTYPE_DIRECTORY) {
2484 error = hammer_ip_check_directory_empty(trans, ip);
2488 * Delete the directory entry.
2490 * WARNING: hammer_ip_del_directory() may have to terminate
2491 * the cursor to avoid a deadlock. It is ok to call
2492 * hammer_done_cursor() twice.
2495 error = hammer_ip_del_directory(trans, &cursor,
2498 hammer_done_cursor(&cursor);
2500 cache_setunresolved(nch);
2501 cache_setvp(nch, NULL);
2504 cache_inval_vp(ip->vp, CINV_DESTROY);
2507 hammer_rel_inode(ip, 0);
2509 hammer_done_cursor(&cursor);
2511 if (error == EDEADLK)
2517 /************************************************************************
2518 * FIFO AND SPECFS OPS *
2519 ************************************************************************
2524 hammer_vop_fifoclose (struct vop_close_args *ap)
2526 /* XXX update itimes */
2527 return (VOCALL(&fifo_vnode_vops, &ap->a_head));
2531 hammer_vop_fiforead (struct vop_read_args *ap)
2535 error = VOCALL(&fifo_vnode_vops, &ap->a_head);
2536 /* XXX update access time */
2541 hammer_vop_fifowrite (struct vop_write_args *ap)
2545 error = VOCALL(&fifo_vnode_vops, &ap->a_head);
2546 /* XXX update access time */
2551 hammer_vop_specclose (struct vop_close_args *ap)
2553 /* XXX update itimes */
2554 return (VOCALL(&spec_vnode_vops, &ap->a_head));
2558 hammer_vop_specread (struct vop_read_args *ap)
2560 /* XXX update access time */
2561 return (VOCALL(&spec_vnode_vops, &ap->a_head));
2565 hammer_vop_specwrite (struct vop_write_args *ap)
2567 /* XXX update last change time */
2568 return (VOCALL(&spec_vnode_vops, &ap->a_head));