2 * Copyright (c) 2007 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.21 2008/01/17 05:06:09 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_nsymlink(struct vop_nsymlink_args *);
79 static int hammer_vop_nwhiteout(struct vop_nwhiteout_args *);
81 static int hammer_vop_fifoclose (struct vop_close_args *);
82 static int hammer_vop_fiforead (struct vop_read_args *);
83 static int hammer_vop_fifowrite (struct vop_write_args *);
85 static int hammer_vop_specclose (struct vop_close_args *);
86 static int hammer_vop_specread (struct vop_read_args *);
87 static int hammer_vop_specwrite (struct vop_write_args *);
89 struct vop_ops hammer_vnode_vops = {
90 .vop_default = vop_defaultop,
91 .vop_fsync = hammer_vop_fsync,
92 .vop_getpages = vop_stdgetpages,
93 .vop_putpages = vop_stdputpages,
94 .vop_read = hammer_vop_read,
95 .vop_write = hammer_vop_write,
96 .vop_access = hammer_vop_access,
97 .vop_advlock = hammer_vop_advlock,
98 .vop_close = hammer_vop_close,
99 .vop_ncreate = hammer_vop_ncreate,
100 .vop_getattr = hammer_vop_getattr,
101 .vop_inactive = hammer_vop_inactive,
102 .vop_reclaim = hammer_vop_reclaim,
103 .vop_nresolve = hammer_vop_nresolve,
104 .vop_nlookupdotdot = hammer_vop_nlookupdotdot,
105 .vop_nlink = hammer_vop_nlink,
106 .vop_nmkdir = hammer_vop_nmkdir,
107 .vop_nmknod = hammer_vop_nmknod,
108 .vop_open = hammer_vop_open,
109 .vop_pathconf = hammer_vop_pathconf,
110 .vop_print = hammer_vop_print,
111 .vop_readdir = hammer_vop_readdir,
112 .vop_readlink = hammer_vop_readlink,
113 .vop_nremove = hammer_vop_nremove,
114 .vop_nrename = hammer_vop_nrename,
115 .vop_nrmdir = hammer_vop_nrmdir,
116 .vop_setattr = hammer_vop_setattr,
117 .vop_strategy = hammer_vop_strategy,
118 .vop_nsymlink = hammer_vop_nsymlink,
119 .vop_nwhiteout = hammer_vop_nwhiteout
122 struct vop_ops hammer_spec_vops = {
123 .vop_default = spec_vnoperate,
124 .vop_fsync = hammer_vop_fsync,
125 .vop_read = hammer_vop_specread,
126 .vop_write = hammer_vop_specwrite,
127 .vop_access = hammer_vop_access,
128 .vop_close = hammer_vop_specclose,
129 .vop_getattr = hammer_vop_getattr,
130 .vop_inactive = hammer_vop_inactive,
131 .vop_reclaim = hammer_vop_reclaim,
132 .vop_setattr = hammer_vop_setattr
135 struct vop_ops hammer_fifo_vops = {
136 .vop_default = fifo_vnoperate,
137 .vop_fsync = hammer_vop_fsync,
138 .vop_read = hammer_vop_fiforead,
139 .vop_write = hammer_vop_fifowrite,
140 .vop_access = hammer_vop_access,
141 .vop_close = hammer_vop_fifoclose,
142 .vop_getattr = hammer_vop_getattr,
143 .vop_inactive = hammer_vop_inactive,
144 .vop_reclaim = hammer_vop_reclaim,
145 .vop_setattr = hammer_vop_setattr
148 static int hammer_dounlink(struct nchandle *nch, struct vnode *dvp,
149 struct ucred *cred, int flags);
150 static int hammer_vop_strategy_read(struct vop_strategy_args *ap);
151 static int hammer_vop_strategy_write(struct vop_strategy_args *ap);
156 hammer_vop_vnoperate(struct vop_generic_args *)
158 return (VOCALL(&hammer_vnode_vops, ap));
163 * hammer_vop_fsync { vp, waitfor }
167 hammer_vop_fsync(struct vop_fsync_args *ap)
173 error = hammer_sync_inode(ip, ap->a_waitfor, 0);
178 * hammer_vop_read { vp, uio, ioflag, cred }
182 hammer_vop_read(struct vop_read_args *ap)
184 struct hammer_transaction trans;
193 if (ap->a_vp->v_type != VREG)
197 seqcount = ap->a_ioflag >> 16;
199 hammer_start_transaction(&trans, ip->hmp);
202 * Access the data in HAMMER_BUFSIZE blocks via the buffer cache.
205 while (uio->uio_resid > 0 && uio->uio_offset < ip->ino_rec.ino_size) {
206 offset = uio->uio_offset & HAMMER_BUFMASK;
208 error = cluster_read(ap->a_vp, ip->ino_rec.ino_size,
209 uio->uio_offset - offset, HAMMER_BUFSIZE,
210 MAXBSIZE, seqcount, &bp);
212 error = bread(ap->a_vp, uio->uio_offset - offset,
213 HAMMER_BUFSIZE, &bp);
218 /* bp->b_flags |= B_CLUSTEROK; temporarily disabled */
219 n = HAMMER_BUFSIZE - offset;
220 if (n > uio->uio_resid)
222 if (n > ip->ino_rec.ino_size - uio->uio_offset)
223 n = (int)(ip->ino_rec.ino_size - uio->uio_offset);
224 error = uiomove((char *)bp->b_data + offset, n, uio);
229 if ((ip->flags & HAMMER_INODE_RO) == 0) {
230 ip->ino_rec.ino_atime = trans.tid;
231 hammer_modify_inode(&trans, ip, HAMMER_INODE_ITIMES);
235 hammer_commit_transaction(&trans);
240 * hammer_vop_write { vp, uio, ioflag, cred }
244 hammer_vop_write(struct vop_write_args *ap)
246 struct hammer_transaction trans;
247 struct hammer_inode *ip;
255 if (ap->a_vp->v_type != VREG)
260 if (ip->flags & HAMMER_INODE_RO)
264 * Create a transaction to cover the operations we perform.
266 hammer_start_transaction(&trans, ip->hmp);
272 if (ap->a_ioflag & IO_APPEND)
273 uio->uio_offset = ip->ino_rec.ino_size;
276 * Check for illegal write offsets. Valid range is 0...2^63-1
278 if (uio->uio_offset < 0 || uio->uio_offset + uio->uio_resid <= 0) {
279 hammer_commit_transaction(&trans);
284 * Access the data in HAMMER_BUFSIZE blocks via the buffer cache.
286 while (uio->uio_resid > 0) {
287 offset = uio->uio_offset & HAMMER_BUFMASK;
288 if (uio->uio_segflg == UIO_NOCOPY) {
290 * Issuing a write with the same data backing the
291 * buffer. Instantiate the buffer to collect the
292 * backing vm pages, then read-in any missing bits.
294 * This case is used by vop_stdputpages().
296 bp = getblk(ap->a_vp, uio->uio_offset, HAMMER_BUFSIZE,
298 if ((bp->b_flags & B_CACHE) == 0) {
300 error = bread(ap->a_vp,
301 uio->uio_offset - offset,
302 HAMMER_BUFSIZE, &bp);
308 } else if (offset == 0 && uio->uio_resid >= HAMMER_BUFSIZE) {
310 * entirely overwrite the buffer
312 bp = getblk(ap->a_vp, uio->uio_offset, HAMMER_BUFSIZE,
314 } else if (offset == 0 && uio->uio_offset >= ip->ino_rec.ino_size) {
318 bp = getblk(ap->a_vp, uio->uio_offset, HAMMER_BUFSIZE,
323 * Partial overwrite, read in any missing bits then
324 * replace the portion being written.
326 error = bread(ap->a_vp, uio->uio_offset - offset,
327 HAMMER_BUFSIZE, &bp);
334 n = HAMMER_BUFSIZE - offset;
335 if (n > uio->uio_resid)
337 error = uiomove((char *)bp->b_data + offset, n, uio);
342 /* bp->b_flags |= B_CLUSTEROK; temporarily disabled */
343 if (ip->ino_rec.ino_size < uio->uio_offset) {
344 ip->ino_rec.ino_size = uio->uio_offset;
345 flags = HAMMER_INODE_RDIRTY;
346 vnode_pager_setsize(ap->a_vp, ip->ino_rec.ino_size);
350 ip->ino_rec.ino_mtime = trans.tid;
351 flags |= HAMMER_INODE_ITIMES | HAMMER_INODE_BUFS;
352 hammer_modify_inode(&trans, ip, flags);
353 if (ap->a_ioflag & IO_SYNC) {
355 } else if (ap->a_ioflag & IO_DIRECT) {
362 hammer_abort_transaction(&trans);
364 hammer_commit_transaction(&trans);
369 * hammer_vop_access { vp, mode, cred }
373 hammer_vop_access(struct vop_access_args *ap)
375 struct hammer_inode *ip = VTOI(ap->a_vp);
380 uid = hammer_to_unix_xid(&ip->ino_data.uid);
381 gid = hammer_to_unix_xid(&ip->ino_data.gid);
383 error = vop_helper_access(ap, uid, gid, ip->ino_data.mode,
384 ip->ino_data.uflags);
389 * hammer_vop_advlock { vp, id, op, fl, flags }
393 hammer_vop_advlock(struct vop_advlock_args *ap)
395 struct hammer_inode *ip = VTOI(ap->a_vp);
397 return (lf_advlock(ap, &ip->advlock, ip->ino_rec.ino_size));
401 * hammer_vop_close { vp, fflag }
405 hammer_vop_close(struct vop_close_args *ap)
407 return (vop_stdclose(ap));
411 * hammer_vop_ncreate { nch, dvp, vpp, cred, vap }
413 * The operating system has already ensured that the directory entry
414 * does not exist and done all appropriate namespace locking.
418 hammer_vop_ncreate(struct vop_ncreate_args *ap)
420 struct hammer_transaction trans;
421 struct hammer_inode *dip;
422 struct hammer_inode *nip;
423 struct nchandle *nch;
427 dip = VTOI(ap->a_dvp);
429 if (dip->flags & HAMMER_INODE_RO)
433 * Create a transaction to cover the operations we perform.
435 hammer_start_transaction(&trans, dip->hmp);
438 * Create a new filesystem object of the requested type. The
439 * returned inode will be referenced but not locked.
442 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
444 kprintf("hammer_create_inode error %d\n", error);
446 hammer_abort_transaction(&trans);
452 * Add the new filesystem object to the directory. This will also
453 * bump the inode's link count.
455 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
457 kprintf("hammer_ip_add_directory error %d\n", error);
463 hammer_rel_inode(nip, 0);
464 hammer_abort_transaction(&trans);
467 hammer_commit_transaction(&trans);
468 error = hammer_get_vnode(nip, LK_EXCLUSIVE, ap->a_vpp);
469 hammer_rel_inode(nip, 0);
471 cache_setunresolved(ap->a_nch);
472 cache_setvp(ap->a_nch, *ap->a_vpp);
479 * hammer_vop_getattr { vp, vap }
483 hammer_vop_getattr(struct vop_getattr_args *ap)
485 struct hammer_inode *ip = VTOI(ap->a_vp);
486 struct vattr *vap = ap->a_vap;
489 if (cache_check_fsmid_vp(ap->a_vp, &ip->fsmid) &&
490 (vp->v_mount->mnt_flag & MNT_RDONLY) == 0 &&
495 hammer_itimes(ap->a_vp);
498 vap->va_fsid = ip->hmp->fsid_udev;
499 vap->va_fileid = ip->ino_rec.base.base.obj_id;
500 vap->va_mode = ip->ino_data.mode;
501 vap->va_nlink = ip->ino_rec.ino_nlinks;
502 vap->va_uid = hammer_to_unix_xid(&ip->ino_data.uid);
503 vap->va_gid = hammer_to_unix_xid(&ip->ino_data.gid);
506 vap->va_size = ip->ino_rec.ino_size;
507 hammer_to_timespec(ip->ino_rec.ino_atime, &vap->va_atime);
508 hammer_to_timespec(ip->ino_rec.ino_mtime, &vap->va_mtime);
509 hammer_to_timespec(ip->ino_data.ctime, &vap->va_ctime);
510 vap->va_flags = ip->ino_data.uflags;
511 vap->va_gen = 1; /* hammer inums are unique for all time */
512 vap->va_blocksize = 32768; /* XXX - extract from root volume */
513 vap->va_bytes = ip->ino_rec.ino_size;
514 vap->va_type = hammer_get_vnode_type(ip->ino_rec.base.base.obj_type);
515 vap->va_filerev = 0; /* XXX */
516 /* mtime uniquely identifies any adjustments made to the file */
517 vap->va_fsmid = ip->ino_rec.ino_mtime;
518 vap->va_uid_uuid = ip->ino_data.uid;
519 vap->va_gid_uuid = ip->ino_data.gid;
520 vap->va_fsid_uuid = ip->hmp->fsid;
521 vap->va_vaflags = VA_UID_UUID_VALID | VA_GID_UUID_VALID |
524 switch (ip->ino_rec.base.base.obj_type) {
525 case HAMMER_OBJTYPE_CDEV:
526 case HAMMER_OBJTYPE_BDEV:
527 vap->va_rmajor = ip->ino_data.rmajor;
528 vap->va_rminor = ip->ino_data.rminor;
538 * hammer_vop_nresolve { nch, dvp, cred }
540 * Locate the requested directory entry.
544 hammer_vop_nresolve(struct vop_nresolve_args *ap)
546 struct namecache *ncp;
550 struct hammer_cursor cursor;
551 union hammer_record_ondisk *rec;
560 * Misc initialization, plus handle as-of name extensions. Look for
561 * the '@@' extension. Note that as-of files and directories cannot
564 dip = VTOI(ap->a_dvp);
565 ncp = ap->a_nch->ncp;
566 asof = dip->obj_asof;
570 for (i = 0; i < nlen; ++i) {
571 if (ncp->nc_name[i] == '@' && ncp->nc_name[i+1] == '@') {
572 asof = hammer_str_to_tid(ncp->nc_name + i + 2);
573 kprintf("ASOF %016llx\n", asof);
574 flags |= HAMMER_INODE_RO;
581 * If there is no path component the time extension is relative to
585 ip = hammer_get_inode(dip->hmp, &dip->cache[1], dip->obj_id,
586 asof, flags, &error);
588 error = hammer_get_vnode(ip, LK_EXCLUSIVE, &vp);
589 hammer_rel_inode(ip, 0);
595 cache_setvp(ap->a_nch, vp);
602 * Calculate the namekey and setup the key range for the scan. This
603 * works kinda like a chained hash table where the lower 32 bits
604 * of the namekey synthesize the chain.
606 * The key range is inclusive of both key_beg and key_end.
608 namekey = hammer_directory_namekey(ncp->nc_name, nlen);
610 hammer_init_cursor_hmp(&cursor, &dip->cache[0], dip->hmp);
611 cursor.key_beg.obj_id = dip->obj_id;
612 cursor.key_beg.key = namekey;
613 cursor.key_beg.create_tid = 0;
614 cursor.key_beg.delete_tid = 0;
615 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
616 cursor.key_beg.obj_type = 0;
618 cursor.key_end = cursor.key_beg;
619 cursor.key_end.key |= 0xFFFFFFFFULL;
621 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
624 * Scan all matching records (the chain), locate the one matching
625 * the requested path component.
627 * The hammer_ip_*() functions merge in-memory records with on-disk
628 * records for the purposes of the search.
630 error = hammer_ip_first(&cursor, dip);
633 error = hammer_ip_resolve_data(&cursor);
637 if (nlen == rec->entry.base.data_len &&
638 bcmp(ncp->nc_name, cursor.data, nlen) == 0) {
641 error = hammer_ip_next(&cursor);
644 ip = hammer_get_inode(dip->hmp, &dip->cache[1],
645 rec->entry.obj_id, asof,
648 error = hammer_get_vnode(ip, LK_EXCLUSIVE, &vp);
649 hammer_rel_inode(ip, 0);
655 cache_setvp(ap->a_nch, vp);
658 } else if (error == ENOENT) {
659 cache_setvp(ap->a_nch, NULL);
661 hammer_done_cursor(&cursor);
666 * hammer_vop_nlookupdotdot { dvp, vpp, cred }
668 * Locate the parent directory of a directory vnode.
670 * dvp is referenced but not locked. *vpp must be returned referenced and
671 * locked. A parent_obj_id of 0 does not necessarily indicate that we are
672 * at the root, instead it could indicate that the directory we were in was
677 hammer_vop_nlookupdotdot(struct vop_nlookupdotdot_args *ap)
679 struct hammer_inode *dip;
680 struct hammer_inode *ip;
681 u_int64_t parent_obj_id;
684 dip = VTOI(ap->a_dvp);
685 if ((parent_obj_id = dip->ino_data.parent_obj_id) == 0) {
690 ip = hammer_get_inode(dip->hmp, &dip->cache[1], parent_obj_id,
691 dip->obj_asof, dip->flags, &error);
696 error = hammer_get_vnode(ip, LK_EXCLUSIVE, ap->a_vpp);
697 hammer_rel_inode(ip, 0);
702 * hammer_vop_nlink { nch, dvp, vp, cred }
706 hammer_vop_nlink(struct vop_nlink_args *ap)
708 struct hammer_transaction trans;
709 struct hammer_inode *dip;
710 struct hammer_inode *ip;
711 struct nchandle *nch;
715 dip = VTOI(ap->a_dvp);
718 if (dip->flags & HAMMER_INODE_RO)
720 if (ip->flags & HAMMER_INODE_RO)
724 * Create a transaction to cover the operations we perform.
726 hammer_start_transaction(&trans, dip->hmp);
729 * Add the filesystem object to the directory. Note that neither
730 * dip nor ip are referenced or locked, but their vnodes are
731 * referenced. This function will bump the inode's link count.
733 error = hammer_ip_add_directory(&trans, dip, nch->ncp, ip);
739 hammer_abort_transaction(&trans);
741 cache_setunresolved(nch);
742 cache_setvp(nch, ap->a_vp);
743 hammer_commit_transaction(&trans);
749 * hammer_vop_nmkdir { nch, dvp, vpp, cred, vap }
751 * The operating system has already ensured that the directory entry
752 * does not exist and done all appropriate namespace locking.
756 hammer_vop_nmkdir(struct vop_nmkdir_args *ap)
758 struct hammer_transaction trans;
759 struct hammer_inode *dip;
760 struct hammer_inode *nip;
761 struct nchandle *nch;
765 dip = VTOI(ap->a_dvp);
767 if (dip->flags & HAMMER_INODE_RO)
771 * Create a transaction to cover the operations we perform.
773 hammer_start_transaction(&trans, dip->hmp);
776 * Create a new filesystem object of the requested type. The
777 * returned inode will be referenced but not locked.
779 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
781 kprintf("hammer_mkdir error %d\n", error);
783 hammer_abort_transaction(&trans);
789 * Add the new filesystem object to the directory. This will also
790 * bump the inode's link count.
792 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
794 kprintf("hammer_mkdir (add) error %d\n", error);
800 hammer_rel_inode(nip, 0);
801 hammer_abort_transaction(&trans);
804 hammer_commit_transaction(&trans);
805 error = hammer_get_vnode(nip, LK_EXCLUSIVE, ap->a_vpp);
806 hammer_rel_inode(nip, 0);
808 cache_setunresolved(ap->a_nch);
809 cache_setvp(ap->a_nch, *ap->a_vpp);
816 * hammer_vop_nmknod { nch, dvp, vpp, cred, vap }
818 * The operating system has already ensured that the directory entry
819 * does not exist and done all appropriate namespace locking.
823 hammer_vop_nmknod(struct vop_nmknod_args *ap)
825 struct hammer_transaction trans;
826 struct hammer_inode *dip;
827 struct hammer_inode *nip;
828 struct nchandle *nch;
832 dip = VTOI(ap->a_dvp);
834 if (dip->flags & HAMMER_INODE_RO)
838 * Create a transaction to cover the operations we perform.
840 hammer_start_transaction(&trans, dip->hmp);
843 * Create a new filesystem object of the requested type. The
844 * returned inode will be referenced but not locked.
846 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
848 hammer_abort_transaction(&trans);
854 * Add the new filesystem object to the directory. This will also
855 * bump the inode's link count.
857 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
863 hammer_rel_inode(nip, 0);
864 hammer_abort_transaction(&trans);
867 hammer_commit_transaction(&trans);
868 error = hammer_get_vnode(nip, LK_EXCLUSIVE, ap->a_vpp);
869 hammer_rel_inode(nip, 0);
871 cache_setunresolved(ap->a_nch);
872 cache_setvp(ap->a_nch, *ap->a_vpp);
879 * hammer_vop_open { vp, mode, cred, fp }
883 hammer_vop_open(struct vop_open_args *ap)
885 if ((ap->a_mode & FWRITE) && (VTOI(ap->a_vp)->flags & HAMMER_INODE_RO))
888 return(vop_stdopen(ap));
892 * hammer_vop_pathconf { vp, name, retval }
896 hammer_vop_pathconf(struct vop_pathconf_args *ap)
902 * hammer_vop_print { vp }
906 hammer_vop_print(struct vop_print_args *ap)
912 * hammer_vop_readdir { vp, uio, cred, *eofflag, *ncookies, off_t **cookies }
916 hammer_vop_readdir(struct vop_readdir_args *ap)
918 struct hammer_cursor cursor;
919 struct hammer_inode *ip;
921 hammer_record_ondisk_t rec;
922 hammer_base_elm_t base;
932 saveoff = uio->uio_offset;
934 if (ap->a_ncookies) {
935 ncookies = uio->uio_resid / 16 + 1;
938 cookies = kmalloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
947 * Handle artificial entries
951 r = vop_write_dirent(&error, uio, ip->obj_id, DT_DIR, 1, ".");
955 cookies[cookie_index] = saveoff;
958 if (cookie_index == ncookies)
962 if (ip->ino_data.parent_obj_id) {
963 r = vop_write_dirent(&error, uio,
964 ip->ino_data.parent_obj_id,
967 r = vop_write_dirent(&error, uio,
968 ip->obj_id, DT_DIR, 2, "..");
973 cookies[cookie_index] = saveoff;
976 if (cookie_index == ncookies)
981 * Key range (begin and end inclusive) to scan. Directory keys
982 * directly translate to a 64 bit 'seek' position.
984 hammer_init_cursor_hmp(&cursor, &ip->cache[0], ip->hmp);
985 cursor.key_beg.obj_id = ip->obj_id;
986 cursor.key_beg.create_tid = 0;
987 cursor.key_beg.delete_tid = 0;
988 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
989 cursor.key_beg.obj_type = 0;
990 cursor.key_beg.key = saveoff;
992 cursor.key_end = cursor.key_beg;
993 cursor.key_end.key = HAMMER_MAX_KEY;
994 cursor.asof = ip->obj_asof;
995 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
997 error = hammer_ip_first(&cursor, ip);
1000 error = hammer_ip_resolve_data(&cursor);
1003 rec = cursor.record;
1004 base = &rec->base.base;
1005 saveoff = base->key;
1007 if (base->obj_id != ip->obj_id)
1008 panic("readdir: bad record at %p", cursor.node);
1010 r = vop_write_dirent(
1011 &error, uio, rec->entry.obj_id,
1012 hammer_get_dtype(rec->entry.base.base.obj_type),
1013 rec->entry.base.data_len,
1014 (void *)cursor.data);
1019 cookies[cookie_index] = base->key;
1021 if (cookie_index == ncookies)
1023 error = hammer_ip_next(&cursor);
1025 hammer_done_cursor(&cursor);
1029 *ap->a_eofflag = (error == ENOENT);
1030 uio->uio_offset = saveoff;
1031 if (error && cookie_index == 0) {
1032 if (error == ENOENT)
1035 kfree(cookies, M_TEMP);
1036 *ap->a_ncookies = 0;
1037 *ap->a_cookies = NULL;
1040 if (error == ENOENT)
1043 *ap->a_ncookies = cookie_index;
1044 *ap->a_cookies = cookies;
1051 * hammer_vop_readlink { vp, uio, cred }
1055 hammer_vop_readlink(struct vop_readlink_args *ap)
1057 struct hammer_cursor cursor;
1058 struct hammer_inode *ip;
1061 ip = VTOI(ap->a_vp);
1062 hammer_init_cursor_hmp(&cursor, &ip->cache[0], ip->hmp);
1065 * Key range (begin and end inclusive) to scan. Directory keys
1066 * directly translate to a 64 bit 'seek' position.
1068 cursor.key_beg.obj_id = ip->obj_id;
1069 cursor.key_beg.create_tid = 0;
1070 cursor.key_beg.delete_tid = 0;
1071 cursor.key_beg.rec_type = HAMMER_RECTYPE_FIX;
1072 cursor.key_beg.obj_type = 0;
1073 cursor.key_beg.key = HAMMER_FIXKEY_SYMLINK;
1074 cursor.asof = ip->obj_asof;
1075 cursor.flags |= HAMMER_CURSOR_ASOF;
1077 error = hammer_ip_lookup(&cursor, ip);
1079 error = hammer_ip_resolve_data(&cursor);
1081 error = uiomove((char *)cursor.data,
1082 cursor.record->generic.base.data_len,
1086 hammer_done_cursor(&cursor);
1091 * hammer_vop_nremove { nch, dvp, cred }
1095 hammer_vop_nremove(struct vop_nremove_args *ap)
1097 return(hammer_dounlink(ap->a_nch, ap->a_dvp, ap->a_cred, 0));
1101 * hammer_vop_nrename { fnch, tnch, fdvp, tdvp, cred }
1105 hammer_vop_nrename(struct vop_nrename_args *ap)
1107 struct hammer_transaction trans;
1108 struct namecache *fncp;
1109 struct namecache *tncp;
1110 struct hammer_inode *fdip;
1111 struct hammer_inode *tdip;
1112 struct hammer_inode *ip;
1113 struct hammer_cursor cursor;
1114 union hammer_record_ondisk *rec;
1118 fdip = VTOI(ap->a_fdvp);
1119 tdip = VTOI(ap->a_tdvp);
1120 fncp = ap->a_fnch->ncp;
1121 tncp = ap->a_tnch->ncp;
1122 ip = VTOI(fncp->nc_vp);
1123 KKASSERT(ip != NULL);
1125 if (fdip->flags & HAMMER_INODE_RO)
1127 if (tdip->flags & HAMMER_INODE_RO)
1129 if (ip->flags & HAMMER_INODE_RO)
1132 hammer_start_transaction(&trans, fdip->hmp);
1135 * Remove tncp from the target directory and then link ip as
1136 * tncp. XXX pass trans to dounlink
1138 error = hammer_dounlink(ap->a_tnch, ap->a_tdvp, ap->a_cred, 0);
1139 if (error == 0 || error == ENOENT)
1140 error = hammer_ip_add_directory(&trans, tdip, tncp, ip);
1142 goto failed; /* XXX */
1145 * Locate the record in the originating directory and remove it.
1147 * Calculate the namekey and setup the key range for the scan. This
1148 * works kinda like a chained hash table where the lower 32 bits
1149 * of the namekey synthesize the chain.
1151 * The key range is inclusive of both key_beg and key_end.
1153 namekey = hammer_directory_namekey(fncp->nc_name, fncp->nc_nlen);
1155 hammer_init_cursor_hmp(&cursor, &fdip->cache[0], fdip->hmp);
1156 cursor.key_beg.obj_id = fdip->obj_id;
1157 cursor.key_beg.key = namekey;
1158 cursor.key_beg.create_tid = 0;
1159 cursor.key_beg.delete_tid = 0;
1160 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
1161 cursor.key_beg.obj_type = 0;
1163 cursor.key_end = cursor.key_beg;
1164 cursor.key_end.key |= 0xFFFFFFFFULL;
1165 cursor.asof = fdip->obj_asof;
1166 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
1169 * Scan all matching records (the chain), locate the one matching
1170 * the requested path component.
1172 * The hammer_ip_*() functions merge in-memory records with on-disk
1173 * records for the purposes of the search.
1175 error = hammer_ip_first(&cursor, fdip);
1176 while (error == 0) {
1177 if (hammer_ip_resolve_data(&cursor) != 0)
1179 rec = cursor.record;
1180 if (fncp->nc_nlen == rec->entry.base.data_len &&
1181 bcmp(fncp->nc_name, cursor.data, fncp->nc_nlen) == 0) {
1184 error = hammer_ip_next(&cursor);
1188 * If all is ok we have to get the inode so we can adjust nlinks.
1192 error = hammer_ip_del_directory(&trans, &cursor, fdip, ip);
1195 cache_rename(ap->a_fnch, ap->a_tnch);
1197 hammer_done_cursor(&cursor);
1200 hammer_commit_transaction(&trans);
1202 hammer_abort_transaction(&trans);
1208 * hammer_vop_nrmdir { nch, dvp, cred }
1212 hammer_vop_nrmdir(struct vop_nrmdir_args *ap)
1214 return(hammer_dounlink(ap->a_nch, ap->a_dvp, ap->a_cred, 0));
1218 * hammer_vop_setattr { vp, vap, cred }
1222 hammer_vop_setattr(struct vop_setattr_args *ap)
1224 struct hammer_transaction trans;
1225 struct hammer_cursor *spike = NULL;
1227 struct hammer_inode *ip;
1230 int64_t aligned_size;
1235 ip = ap->a_vp->v_data;
1238 if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
1240 if (ip->flags & HAMMER_INODE_RO)
1243 hammer_start_transaction(&trans, ip->hmp);
1246 if (vap->va_flags != VNOVAL) {
1247 flags = ip->ino_data.uflags;
1248 error = vop_helper_setattr_flags(&flags, vap->va_flags,
1249 hammer_to_unix_xid(&ip->ino_data.uid),
1252 if (ip->ino_data.uflags != flags) {
1253 ip->ino_data.uflags = flags;
1254 modflags |= HAMMER_INODE_DDIRTY;
1256 if (ip->ino_data.uflags & (IMMUTABLE | APPEND)) {
1263 if (ip->ino_data.uflags & (IMMUTABLE | APPEND)) {
1267 if (vap->va_uid != (uid_t)VNOVAL) {
1268 hammer_guid_to_uuid(&uuid, vap->va_uid);
1269 if (bcmp(&uuid, &ip->ino_data.uid, sizeof(uuid)) != 0) {
1270 ip->ino_data.uid = uuid;
1271 modflags |= HAMMER_INODE_DDIRTY;
1274 if (vap->va_gid != (uid_t)VNOVAL) {
1275 hammer_guid_to_uuid(&uuid, vap->va_gid);
1276 if (bcmp(&uuid, &ip->ino_data.gid, sizeof(uuid)) != 0) {
1277 ip->ino_data.gid = uuid;
1278 modflags |= HAMMER_INODE_DDIRTY;
1281 while (vap->va_size != VNOVAL && ip->ino_rec.ino_size != vap->va_size) {
1282 switch(ap->a_vp->v_type) {
1284 if (vap->va_size < ip->ino_rec.ino_size) {
1285 vtruncbuf(ap->a_vp, vap->va_size,
1287 } else if (vap->va_size > ip->ino_rec.ino_size) {
1288 vnode_pager_setsize(ap->a_vp, vap->va_size);
1290 aligned_size = (vap->va_size + HAMMER_BUFMASK) &
1291 ~(int64_t)HAMMER_BUFMASK;
1292 error = hammer_ip_delete_range(&trans, ip,
1294 0x7FFFFFFFFFFFFFFFLL,
1296 ip->ino_rec.ino_size = vap->va_size;
1297 modflags |= HAMMER_INODE_RDIRTY;
1300 error = hammer_ip_delete_range(&trans, ip,
1302 0x7FFFFFFFFFFFFFFFLL,
1304 ip->ino_rec.ino_size = vap->va_size;
1305 modflags |= HAMMER_INODE_RDIRTY;
1311 if (error == ENOSPC) {
1312 error = hammer_spike(&spike);
1316 KKASSERT(spike == NULL);
1319 if (vap->va_atime.tv_sec != VNOVAL) {
1320 ip->ino_rec.ino_atime =
1321 hammer_timespec_to_transid(&vap->va_atime);
1322 modflags |= HAMMER_INODE_ITIMES;
1324 if (vap->va_mtime.tv_sec != VNOVAL) {
1325 ip->ino_rec.ino_mtime =
1326 hammer_timespec_to_transid(&vap->va_mtime);
1327 modflags |= HAMMER_INODE_ITIMES;
1329 if (vap->va_mode != (mode_t)VNOVAL) {
1330 if (ip->ino_data.mode != vap->va_mode) {
1331 ip->ino_data.mode = vap->va_mode;
1332 modflags |= HAMMER_INODE_DDIRTY;
1337 hammer_abort_transaction(&trans);
1339 hammer_modify_inode(&trans, ip, modflags);
1340 hammer_commit_transaction(&trans);
1346 * hammer_vop_nsymlink { nch, dvp, vpp, cred, vap, target }
1350 hammer_vop_nsymlink(struct vop_nsymlink_args *ap)
1352 struct hammer_transaction trans;
1353 struct hammer_inode *dip;
1354 struct hammer_inode *nip;
1355 struct nchandle *nch;
1356 hammer_record_t record;
1360 ap->a_vap->va_type = VLNK;
1363 dip = VTOI(ap->a_dvp);
1365 if (dip->flags & HAMMER_INODE_RO)
1369 * Create a transaction to cover the operations we perform.
1371 hammer_start_transaction(&trans, dip->hmp);
1374 * Create a new filesystem object of the requested type. The
1375 * returned inode will be referenced but not locked.
1378 error = hammer_create_inode(&trans, ap->a_vap, ap->a_cred, dip, &nip);
1380 hammer_abort_transaction(&trans);
1386 * Add the new filesystem object to the directory. This will also
1387 * bump the inode's link count.
1389 error = hammer_ip_add_directory(&trans, dip, nch->ncp, nip);
1392 * Add a record representing the symlink. symlink stores the link
1393 * as pure data, not a string, and is no \0 terminated.
1396 record = hammer_alloc_mem_record(nip);
1397 bytes = strlen(ap->a_target);
1399 record->rec.generic.base.base.key = HAMMER_FIXKEY_SYMLINK;
1400 record->rec.generic.base.base.rec_type = HAMMER_RECTYPE_FIX;
1401 record->rec.generic.base.data_len = bytes;
1402 if (bytes <= sizeof(record->rec.generic.filler)) {
1403 record->data = (void *)record->rec.generic.filler;
1404 bcopy(ap->a_target, record->data, bytes);
1406 record->data = (void *)ap->a_target;
1407 /* will be reallocated by routine below */
1409 error = hammer_ip_add_record(&trans, record);
1416 hammer_rel_inode(nip, 0);
1417 hammer_abort_transaction(&trans);
1420 hammer_commit_transaction(&trans);
1421 error = hammer_get_vnode(nip, LK_EXCLUSIVE, ap->a_vpp);
1422 hammer_rel_inode(nip, 0);
1424 cache_setunresolved(ap->a_nch);
1425 cache_setvp(ap->a_nch, *ap->a_vpp);
1432 * hammer_vop_nwhiteout { nch, dvp, cred, flags }
1436 hammer_vop_nwhiteout(struct vop_nwhiteout_args *ap)
1438 return(hammer_dounlink(ap->a_nch, ap->a_dvp, ap->a_cred, ap->a_flags));
1442 * hammer_vop_strategy { vp, bio }
1444 * Strategy call, used for regular file read & write only. Note that the
1445 * bp may represent a cluster.
1447 * To simplify operation and allow better optimizations in the future,
1448 * this code does not make any assumptions with regards to buffer alignment
1453 hammer_vop_strategy(struct vop_strategy_args *ap)
1458 bp = ap->a_bio->bio_buf;
1462 error = hammer_vop_strategy_read(ap);
1465 error = hammer_vop_strategy_write(ap);
1471 bp->b_error = error;
1473 bp->b_flags |= B_ERROR;
1479 * Read from a regular file. Iterate the related records and fill in the
1480 * BIO/BUF. Gaps are zero-filled.
1482 * The support code in hammer_object.c should be used to deal with mixed
1483 * in-memory and on-disk records.
1489 hammer_vop_strategy_read(struct vop_strategy_args *ap)
1491 struct hammer_inode *ip = ap->a_vp->v_data;
1492 struct hammer_cursor cursor;
1493 hammer_record_ondisk_t rec;
1494 hammer_base_elm_t base;
1508 hammer_init_cursor_hmp(&cursor, &ip->cache[0], ip->hmp);
1511 * Key range (begin and end inclusive) to scan. Note that the key's
1512 * stored in the actual records represent BASE+LEN, not BASE. The
1513 * first record containing bio_offset will have a key > bio_offset.
1515 cursor.key_beg.obj_id = ip->obj_id;
1516 cursor.key_beg.create_tid = 0;
1517 cursor.key_beg.delete_tid = 0;
1518 cursor.key_beg.obj_type = 0;
1519 cursor.key_beg.key = bio->bio_offset + 1;
1520 cursor.asof = ip->obj_asof;
1521 cursor.flags |= HAMMER_CURSOR_ASOF;
1523 cursor.key_end = cursor.key_beg;
1524 if (ip->ino_rec.base.base.obj_type == HAMMER_OBJTYPE_DBFILE) {
1525 cursor.key_beg.rec_type = HAMMER_RECTYPE_DB;
1526 cursor.key_end.rec_type = HAMMER_RECTYPE_DB;
1527 cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
1529 ran_end = bio->bio_offset + bp->b_bufsize;
1530 cursor.key_beg.rec_type = HAMMER_RECTYPE_DATA;
1531 cursor.key_end.rec_type = HAMMER_RECTYPE_DATA;
1532 tmp64 = ran_end + MAXPHYS + 1; /* work-around GCC-4 bug */
1533 if (tmp64 < ran_end)
1534 cursor.key_end.key = 0x7FFFFFFFFFFFFFFFLL;
1536 cursor.key_end.key = ran_end + MAXPHYS + 1;
1538 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE;
1540 error = hammer_ip_first(&cursor, ip);
1543 while (error == 0) {
1544 error = hammer_ip_resolve_data(&cursor);
1547 rec = cursor.record;
1548 base = &rec->base.base;
1550 rec_offset = base->key - rec->data.base.data_len;
1553 * Calculate the gap, if any, and zero-fill it.
1555 n = (int)(rec_offset - (bio->bio_offset + boff));
1557 if (n > bp->b_bufsize - boff)
1558 n = bp->b_bufsize - boff;
1559 kprintf("zfill %d bytes\n", n);
1560 bzero((char *)bp->b_data + boff, n);
1566 * Calculate the data offset in the record and the number
1567 * of bytes we can copy.
1569 * Note there is a degenerate case here where boff may
1570 * already be at bp->b_bufsize.
1573 n = rec->data.base.data_len - roff;
1575 if (n > bp->b_bufsize - boff)
1576 n = bp->b_bufsize - boff;
1577 bcopy((char *)cursor.data + roff, (char *)bp->b_data + boff, n);
1579 if (boff == bp->b_bufsize)
1581 error = hammer_ip_next(&cursor);
1583 hammer_done_cursor(&cursor);
1586 * There may have been a gap after the last record
1588 if (error == ENOENT)
1590 if (error == 0 && boff != bp->b_bufsize) {
1591 KKASSERT(boff < bp->b_bufsize);
1592 bzero((char *)bp->b_data + boff, bp->b_bufsize - boff);
1593 /* boff = bp->b_bufsize; */
1600 * Write to a regular file. Iterate the related records and mark for
1601 * deletion. If existing edge records (left and right side) overlap our
1602 * write they have to be marked deleted and new records created, usually
1603 * referencing a portion of the original data. Then add a record to
1604 * represent the buffer.
1606 * The support code in hammer_object.c should be used to deal with mixed
1607 * in-memory and on-disk records.
1611 hammer_vop_strategy_write(struct vop_strategy_args *ap)
1613 struct hammer_transaction trans;
1614 struct hammer_cursor *spike = NULL;
1622 ip = ap->a_vp->v_data;
1624 if (ip->flags & HAMMER_INODE_RO)
1627 hammer_start_transaction(&trans, ip->hmp);
1631 * Delete any records overlapping our range. This function will
1632 * (eventually) properly truncate partial overlaps.
1634 if (ip->ino_rec.base.base.obj_type == HAMMER_OBJTYPE_DBFILE) {
1635 error = hammer_ip_delete_range(&trans, ip, bio->bio_offset,
1636 bio->bio_offset, &spike);
1638 error = hammer_ip_delete_range(&trans, ip, bio->bio_offset,
1645 * Add a single record to cover the write
1648 error = hammer_ip_sync_data(&trans, ip, bio->bio_offset,
1649 bp->b_data, bp->b_bufsize,
1654 * If we ran out of space the spike structure will be filled in
1655 * and we must call hammer_spike with it, then retry.
1657 if (error == ENOSPC) {
1658 error = hammer_spike(&spike);
1662 KKASSERT(spike == NULL);
1665 * If an error occured abort the transaction
1668 /* XXX undo deletion */
1669 hammer_abort_transaction(&trans);
1670 bp->b_resid = bp->b_bufsize;
1672 hammer_commit_transaction(&trans);
1679 * dounlink - disconnect a directory entry
1681 * XXX whiteout support not really in yet
1684 hammer_dounlink(struct nchandle *nch, struct vnode *dvp, struct ucred *cred,
1687 struct hammer_transaction trans;
1688 struct namecache *ncp;
1691 hammer_record_ondisk_t rec;
1692 struct hammer_cursor cursor;
1697 * Calculate the namekey and setup the key range for the scan. This
1698 * works kinda like a chained hash table where the lower 32 bits
1699 * of the namekey synthesize the chain.
1701 * The key range is inclusive of both key_beg and key_end.
1706 if (dip->flags & HAMMER_INODE_RO)
1709 namekey = hammer_directory_namekey(ncp->nc_name, ncp->nc_nlen);
1711 hammer_init_cursor_hmp(&cursor, &dip->cache[0], dip->hmp);
1712 cursor.key_beg.obj_id = dip->obj_id;
1713 cursor.key_beg.key = namekey;
1714 cursor.key_beg.create_tid = 0;
1715 cursor.key_beg.delete_tid = 0;
1716 cursor.key_beg.rec_type = HAMMER_RECTYPE_DIRENTRY;
1717 cursor.key_beg.obj_type = 0;
1719 cursor.key_end = cursor.key_beg;
1720 cursor.key_end.key |= 0xFFFFFFFFULL;
1721 cursor.asof = dip->obj_asof;
1722 cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE | HAMMER_CURSOR_ASOF;
1724 hammer_start_transaction(&trans, dip->hmp);
1727 * Scan all matching records (the chain), locate the one matching
1728 * the requested path component. info->last_error contains the
1729 * error code on search termination and could be 0, ENOENT, or
1732 * The hammer_ip_*() functions merge in-memory records with on-disk
1733 * records for the purposes of the search.
1735 error = hammer_ip_first(&cursor, dip);
1736 while (error == 0) {
1737 error = hammer_ip_resolve_data(&cursor);
1740 rec = cursor.record;
1741 if (ncp->nc_nlen == rec->entry.base.data_len &&
1742 bcmp(ncp->nc_name, cursor.data, ncp->nc_nlen) == 0) {
1745 error = hammer_ip_next(&cursor);
1749 * If all is ok we have to get the inode so we can adjust nlinks.
1751 * If the target is a directory, it must be empty.
1754 ip = hammer_get_inode(dip->hmp, &dip->cache[1],
1756 dip->hmp->asof, 0, &error);
1757 KKASSERT(error != ENOENT);
1758 if (error == 0 && ip->ino_rec.base.base.obj_type ==
1759 HAMMER_OBJTYPE_DIRECTORY) {
1760 error = hammer_ip_check_directory_empty(&trans, ip);
1763 error = hammer_ip_del_directory(&trans, &cursor, dip, ip);
1765 cache_setunresolved(nch);
1766 cache_setvp(nch, NULL);
1769 cache_inval_vp(ip->vp, CINV_DESTROY);
1771 hammer_rel_inode(ip, 0);
1775 hammer_commit_transaction(&trans);
1777 hammer_abort_transaction(&trans);
1778 hammer_done_cursor(&cursor);
1782 /************************************************************************
1783 * FIFO AND SPECFS OPS *
1784 ************************************************************************
1789 hammer_vop_fifoclose (struct vop_close_args *ap)
1791 /* XXX update itimes */
1792 return (VOCALL(&fifo_vnode_vops, &ap->a_head));
1796 hammer_vop_fiforead (struct vop_read_args *ap)
1800 error = VOCALL(&fifo_vnode_vops, &ap->a_head);
1801 /* XXX update access time */
1806 hammer_vop_fifowrite (struct vop_write_args *ap)
1810 error = VOCALL(&fifo_vnode_vops, &ap->a_head);
1811 /* XXX update access time */
1816 hammer_vop_specclose (struct vop_close_args *ap)
1818 /* XXX update itimes */
1819 return (VOCALL(&spec_vnode_vops, &ap->a_head));
1823 hammer_vop_specread (struct vop_read_args *ap)
1825 /* XXX update access time */
1826 return (VOCALL(&spec_vnode_vops, &ap->a_head));
1830 hammer_vop_specwrite (struct vop_write_args *ap)
1832 /* XXX update last change time */
1833 return (VOCALL(&spec_vnode_vops, &ap->a_head));