2 * Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
5 * This software was developed for the FreeBSD Project by Marshall
6 * Kirk McKusick and Network Associates Laboratories, the Security
7 * Research Division of Network Associates, Inc. under DARPA/SPAWAR
8 * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * Copyright (c) 1982, 1986, 1989, 1993
33 * The Regents of the University of California. All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 4. Neither the name of the University nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * from: @(#)ufs_readwrite.c 8.11 (Berkeley) 5/8/95
60 * from: $FreeBSD: .../ufs/ufs_readwrite.c,v 1.96 2002/08/12 09:22:11 phk ...
61 * @(#)ffs_vnops.c 8.15 (Berkeley) 5/14/95
64 #include <sys/cdefs.h>
65 __FBSDID("$FreeBSD$");
67 #include <sys/param.h>
69 #include <sys/systm.h>
72 #include <sys/extattr.h>
73 #include <sys/kernel.h>
74 #include <sys/limits.h>
75 #include <sys/malloc.h>
76 #include <sys/mount.h>
78 #include <sys/rwlock.h>
80 #include <sys/vmmeter.h>
81 #include <sys/vnode.h>
84 #include <vm/vm_param.h>
85 #include <vm/vm_extern.h>
86 #include <vm/vm_object.h>
87 #include <vm/vm_page.h>
88 #include <vm/vm_pager.h>
89 #include <vm/vnode_pager.h>
91 #include <ufs/ufs/extattr.h>
92 #include <ufs/ufs/quota.h>
93 #include <ufs/ufs/inode.h>
94 #include <ufs/ufs/ufs_extern.h>
95 #include <ufs/ufs/ufsmount.h>
97 #include <ufs/ffs/fs.h>
98 #include <ufs/ffs/ffs_extern.h>
99 #include "opt_directio.h"
103 extern int ffs_rawread(struct vnode *vp, struct uio *uio, int *workdone);
105 static vop_fsync_t ffs_fsync;
106 static vop_lock1_t ffs_lock;
107 static vop_getpages_t ffs_getpages;
108 static vop_read_t ffs_read;
109 static vop_write_t ffs_write;
110 static int ffs_extread(struct vnode *vp, struct uio *uio, int ioflag);
111 static int ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag,
113 static vop_strategy_t ffsext_strategy;
114 static vop_closeextattr_t ffs_closeextattr;
115 static vop_deleteextattr_t ffs_deleteextattr;
116 static vop_getextattr_t ffs_getextattr;
117 static vop_listextattr_t ffs_listextattr;
118 static vop_openextattr_t ffs_openextattr;
119 static vop_setextattr_t ffs_setextattr;
120 static vop_vptofh_t ffs_vptofh;
123 /* Global vfs data structures for ufs. */
124 struct vop_vector ffs_vnodeops1 = {
125 .vop_default = &ufs_vnodeops,
126 .vop_fsync = ffs_fsync,
127 .vop_getpages = ffs_getpages,
128 .vop_lock1 = ffs_lock,
129 .vop_read = ffs_read,
130 .vop_reallocblks = ffs_reallocblks,
131 .vop_write = ffs_write,
132 .vop_vptofh = ffs_vptofh,
135 struct vop_vector ffs_fifoops1 = {
136 .vop_default = &ufs_fifoops,
137 .vop_fsync = ffs_fsync,
138 .vop_reallocblks = ffs_reallocblks, /* XXX: really ??? */
139 .vop_vptofh = ffs_vptofh,
142 /* Global vfs data structures for ufs. */
143 struct vop_vector ffs_vnodeops2 = {
144 .vop_default = &ufs_vnodeops,
145 .vop_fsync = ffs_fsync,
146 .vop_getpages = ffs_getpages,
147 .vop_lock1 = ffs_lock,
148 .vop_read = ffs_read,
149 .vop_reallocblks = ffs_reallocblks,
150 .vop_write = ffs_write,
151 .vop_closeextattr = ffs_closeextattr,
152 .vop_deleteextattr = ffs_deleteextattr,
153 .vop_getextattr = ffs_getextattr,
154 .vop_listextattr = ffs_listextattr,
155 .vop_openextattr = ffs_openextattr,
156 .vop_setextattr = ffs_setextattr,
157 .vop_vptofh = ffs_vptofh,
160 struct vop_vector ffs_fifoops2 = {
161 .vop_default = &ufs_fifoops,
162 .vop_fsync = ffs_fsync,
163 .vop_lock1 = ffs_lock,
164 .vop_reallocblks = ffs_reallocblks,
165 .vop_strategy = ffsext_strategy,
166 .vop_closeextattr = ffs_closeextattr,
167 .vop_deleteextattr = ffs_deleteextattr,
168 .vop_getextattr = ffs_getextattr,
169 .vop_listextattr = ffs_listextattr,
170 .vop_openextattr = ffs_openextattr,
171 .vop_setextattr = ffs_setextattr,
172 .vop_vptofh = ffs_vptofh,
176 * Synch an open file.
180 ffs_fsync(struct vop_fsync_args *ap)
189 error = ffs_syncvnode(vp, ap->a_waitfor, 0);
192 if (ap->a_waitfor == MNT_WAIT && DOINGSOFTDEP(vp)) {
193 error = softdep_fsync(vp);
198 * The softdep_fsync() function may drop vp lock,
199 * allowing for dirty buffers to reappear on the
200 * bo_dirty list. Recheck and resync as needed.
203 if ((vp->v_type == VREG || vp->v_type == VDIR) &&
204 (bo->bo_numoutput > 0 || bo->bo_dirty.bv_cnt > 0)) {
214 ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
221 int error, wait, passes;
224 ip->i_flag &= ~IN_NEEDSYNC;
228 * When doing MNT_WAIT we must first flush all dependencies
231 if (DOINGSOFTDEP(vp) && waitfor == MNT_WAIT &&
232 (error = softdep_sync_metadata(vp)) != 0)
236 * Flush all dirty buffers associated with a vnode.
240 wait = 0; /* Always do an async pass first. */
241 lbn = lblkno(ip->i_fs, (ip->i_size + ip->i_fs->fs_bsize - 1));
244 TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs)
245 bp->b_vflags &= ~BV_SCANNED;
246 TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) {
248 * Reasons to skip this buffer: it has already been considered
249 * on this pass, the buffer has dependencies that will cause
250 * it to be redirtied and it has not already been deferred,
251 * or it is already being written.
253 if ((bp->b_vflags & BV_SCANNED) != 0)
255 bp->b_vflags |= BV_SCANNED;
256 /* Flush indirects in order. */
257 if (waitfor == MNT_WAIT && bp->b_lblkno <= -NDADDR &&
258 lbn_level(bp->b_lblkno) >= passes)
260 if (bp->b_lblkno > lbn)
261 panic("ffs_syncvnode: syncing truncated data.");
262 if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) == 0) {
264 } else if (wait != 0) {
266 LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK,
267 BO_LOCKPTR(bo)) != 0) {
268 bp->b_vflags &= ~BV_SCANNED;
273 if ((bp->b_flags & B_DELWRI) == 0)
274 panic("ffs_fsync: not dirty");
276 * Check for dependencies and potentially complete them.
278 if (!LIST_EMPTY(&bp->b_dep) &&
279 (error = softdep_sync_buf(vp, bp,
280 wait ? MNT_WAIT : MNT_NOWAIT)) != 0) {
282 if (error != EBUSY) {
286 /* If we deferred once, don't defer again. */
287 if ((bp->b_flags & B_DEFERRED) == 0) {
288 bp->b_flags |= B_DEFERRED;
295 if ((error = bwrite(bp)) != 0)
297 } else if ((bp->b_flags & B_CLUSTEROK)) {
298 (void) vfs_bio_awrite(bp);
305 * Since we may have slept during the I/O, we need
306 * to start from a known point.
309 nbp = TAILQ_FIRST(&bo->bo_dirty.bv_hd);
311 if (waitfor != MNT_WAIT) {
313 if ((flags & NO_INO_UPDT) != 0)
316 return (ffs_update(vp, 0));
318 /* Drain IO to see if we're done. */
319 bufobj_wwait(bo, 0, 0);
321 * Block devices associated with filesystems may have new I/O
322 * requests posted for them even if the vnode is locked, so no
323 * amount of trying will get them clean. We make several passes
326 * Regular files may need multiple passes to flush all dependency
327 * work as it is possible that we must write once per indirect
328 * level, once for the leaf, and once for the inode and each of
329 * these will be done with one sync and one async pass.
331 if (bo->bo_dirty.bv_cnt > 0) {
332 /* Write the inode after sync passes to flush deps. */
333 if (wait && DOINGSOFTDEP(vp) && (flags & NO_INO_UPDT) == 0) {
338 /* switch between sync/async. */
340 if (wait == 1 || ++passes < NIADDR + 2)
343 if (!vn_isdisk(vp, NULL))
344 vprint("ffs_fsync: dirty", vp);
349 if ((flags & NO_INO_UPDT) == 0)
350 error = ffs_update(vp, 1);
352 softdep_journal_fsync(VTOI(vp));
358 struct vop_lock1_args /* {
366 #ifndef NO_FFS_SNAPSHOT
372 switch (ap->a_flags & LK_TYPE_MASK) {
379 #ifdef DEBUG_VFS_LOCKS
380 KASSERT(vp->v_holdcnt != 0,
381 ("ffs_lock %p: zero hold count", vp));
384 result = _lockmgr_args(lkp, flags, VI_MTX(vp),
385 LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT,
386 ap->a_file, ap->a_line);
387 if (lkp == vp->v_vnlock || result != 0)
390 * Apparent success, except that the vnode
391 * mutated between snapshot file vnode and
392 * regular file vnode while this process
393 * slept. The lock currently held is not the
394 * right lock. Release it, and try to get the
397 (void) _lockmgr_args(lkp, LK_RELEASE, NULL,
398 LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT,
399 ap->a_file, ap->a_line);
400 if ((flags & (LK_INTERLOCK | LK_NOWAIT)) ==
401 (LK_INTERLOCK | LK_NOWAIT))
403 if ((flags & LK_TYPE_MASK) == LK_UPGRADE)
404 flags = (flags & ~LK_TYPE_MASK) | LK_EXCLUSIVE;
405 flags &= ~LK_INTERLOCK;
409 result = VOP_LOCK1_APV(&ufs_vnodeops, ap);
413 return (VOP_LOCK1_APV(&ufs_vnodeops, ap));
418 * Vnode op for reading.
422 struct vop_read_args /* {
426 struct ucred *a_cred;
434 ufs_lbn_t lbn, nextlbn;
436 long size, xfersize, blkoffset;
444 ioflag = ap->a_ioflag;
445 if (ap->a_ioflag & IO_EXT)
447 return (ffs_extread(vp, uio, ioflag));
449 panic("ffs_read+IO_EXT");
452 if ((ioflag & IO_DIRECT) != 0) {
455 error = ffs_rawread(vp, uio, &workdone);
456 if (error != 0 || workdone != 0)
461 seqcount = ap->a_ioflag >> IO_SEQSHIFT;
465 if (uio->uio_rw != UIO_READ)
466 panic("ffs_read: mode");
468 if (vp->v_type == VLNK) {
469 if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen)
470 panic("ffs_read: short symlink");
471 } else if (vp->v_type != VREG && vp->v_type != VDIR)
472 panic("ffs_read: type %d", vp->v_type);
474 orig_resid = uio->uio_resid;
475 KASSERT(orig_resid >= 0, ("ffs_read: uio->uio_resid < 0"));
478 KASSERT(uio->uio_offset >= 0, ("ffs_read: uio->uio_offset < 0"));
480 if (uio->uio_offset < ip->i_size &&
481 uio->uio_offset >= fs->fs_maxfilesize)
484 for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) {
485 if ((bytesinfile = ip->i_size - uio->uio_offset) <= 0)
487 lbn = lblkno(fs, uio->uio_offset);
491 * size of buffer. The buffer representing the
492 * end of the file is rounded up to the size of
493 * the block type ( fragment or full block,
496 size = blksize(fs, ip, lbn);
497 blkoffset = blkoff(fs, uio->uio_offset);
500 * The amount we want to transfer in this iteration is
501 * one FS block less the amount of the data before
502 * our startpoint (duh!)
504 xfersize = fs->fs_bsize - blkoffset;
507 * But if we actually want less than the block,
508 * or the file doesn't have a whole block more of data,
509 * then use the lesser number.
511 if (uio->uio_resid < xfersize)
512 xfersize = uio->uio_resid;
513 if (bytesinfile < xfersize)
514 xfersize = bytesinfile;
516 if (lblktosize(fs, nextlbn) >= ip->i_size) {
518 * Don't do readahead if this is the end of the file.
520 error = bread_gb(vp, lbn, size, NOCRED,
522 } else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
524 * Otherwise if we are allowed to cluster,
525 * grab as much as we can.
527 * XXX This may not be a win if we are not
528 * doing sequential access.
530 error = cluster_read(vp, ip->i_size, lbn,
531 size, NOCRED, blkoffset + uio->uio_resid,
532 seqcount, GB_UNMAPPED, &bp);
533 } else if (seqcount > 1) {
535 * If we are NOT allowed to cluster, then
536 * if we appear to be acting sequentially,
537 * fire off a request for a readahead
538 * as well as a read. Note that the 4th and 5th
539 * arguments point to arrays of the size specified in
542 u_int nextsize = blksize(fs, ip, nextlbn);
543 error = breadn_flags(vp, lbn, size, &nextlbn,
544 &nextsize, 1, NOCRED, GB_UNMAPPED, &bp);
547 * Failing all of the above, just read what the
548 * user asked for. Interestingly, the same as
549 * the first option above.
551 error = bread_gb(vp, lbn, size, NOCRED,
561 * If IO_DIRECT then set B_DIRECT for the buffer. This
562 * will cause us to attempt to release the buffer later on
563 * and will cause the buffer cache to attempt to free the
566 if (ioflag & IO_DIRECT)
567 bp->b_flags |= B_DIRECT;
570 * We should only get non-zero b_resid when an I/O error
571 * has occurred, which should cause us to break above.
572 * However, if the short read did not cause an error,
573 * then we want to ensure that we do not uiomove bad
574 * or uninitialized data.
577 if (size < xfersize) {
583 if ((bp->b_flags & B_UNMAPPED) == 0) {
584 error = vn_io_fault_uiomove((char *)bp->b_data +
585 blkoffset, (int)xfersize, uio);
587 error = vn_io_fault_pgmove(bp->b_pages, blkoffset,
593 if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
594 (LIST_EMPTY(&bp->b_dep))) {
596 * If there are no dependencies, and it's VMIO,
597 * then we don't need the buf, mark it available
598 * for freeing. For non-direct VMIO reads, the VM
601 bp->b_flags |= B_RELBUF;
605 * Otherwise let whoever
606 * made the request take care of
607 * freeing it. We just queue
608 * it onto another list.
615 * This can only happen in the case of an error
616 * because the loop above resets bp to NULL on each iteration
617 * and on normal completion has not set a new value into it.
618 * so it must have come from a 'break' statement
621 if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
622 (LIST_EMPTY(&bp->b_dep))) {
623 bp->b_flags |= B_RELBUF;
630 if ((error == 0 || uio->uio_resid != orig_resid) &&
631 (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0 &&
632 (ip->i_flag & IN_ACCESS) == 0) {
634 ip->i_flag |= IN_ACCESS;
641 * Vnode op for writing.
645 struct vop_write_args /* {
649 struct ucred *a_cred;
661 int blkoffset, error, flags, ioflag, size, xfersize;
665 ioflag = ap->a_ioflag;
666 if (ap->a_ioflag & IO_EXT)
668 return (ffs_extwrite(vp, uio, ioflag, ap->a_cred));
670 panic("ffs_write+IO_EXT");
673 seqcount = ap->a_ioflag >> IO_SEQSHIFT;
677 if (uio->uio_rw != UIO_WRITE)
678 panic("ffs_write: mode");
681 switch (vp->v_type) {
683 if (ioflag & IO_APPEND)
684 uio->uio_offset = ip->i_size;
685 if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size)
691 panic("ffs_write: dir write");
694 panic("ffs_write: type %p %d (%d,%d)", vp, (int)vp->v_type,
695 (int)uio->uio_offset,
700 KASSERT(uio->uio_resid >= 0, ("ffs_write: uio->uio_resid < 0"));
701 KASSERT(uio->uio_offset >= 0, ("ffs_write: uio->uio_offset < 0"));
703 if ((uoff_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
706 * Maybe this should be above the vnode op call, but so long as
707 * file servers have no limits, I don't think it matters.
709 if (vn_rlimit_fsize(vp, uio, uio->uio_td))
712 resid = uio->uio_resid;
714 if (seqcount > BA_SEQMAX)
715 flags = BA_SEQMAX << BA_SEQSHIFT;
717 flags = seqcount << BA_SEQSHIFT;
718 if ((ioflag & IO_SYNC) && !DOINGASYNC(vp))
720 flags |= BA_UNMAPPED;
722 for (error = 0; uio->uio_resid > 0;) {
723 lbn = lblkno(fs, uio->uio_offset);
724 blkoffset = blkoff(fs, uio->uio_offset);
725 xfersize = fs->fs_bsize - blkoffset;
726 if (uio->uio_resid < xfersize)
727 xfersize = uio->uio_resid;
728 if (uio->uio_offset + xfersize > ip->i_size)
729 vnode_pager_setsize(vp, uio->uio_offset + xfersize);
732 * We must perform a read-before-write if the transfer size
733 * does not cover the entire buffer.
735 if (fs->fs_bsize > xfersize)
739 /* XXX is uio->uio_offset the right thing here? */
740 error = UFS_BALLOC(vp, uio->uio_offset, xfersize,
741 ap->a_cred, flags, &bp);
743 vnode_pager_setsize(vp, ip->i_size);
746 if (ioflag & IO_DIRECT)
747 bp->b_flags |= B_DIRECT;
748 if ((ioflag & (IO_SYNC|IO_INVAL)) == (IO_SYNC|IO_INVAL))
749 bp->b_flags |= B_NOCACHE;
751 if (uio->uio_offset + xfersize > ip->i_size) {
752 ip->i_size = uio->uio_offset + xfersize;
753 DIP_SET(ip, i_size, ip->i_size);
756 size = blksize(fs, ip, lbn) - bp->b_resid;
760 if ((bp->b_flags & B_UNMAPPED) == 0) {
761 error = vn_io_fault_uiomove((char *)bp->b_data +
762 blkoffset, (int)xfersize, uio);
764 error = vn_io_fault_pgmove(bp->b_pages, blkoffset,
768 * If the buffer is not already filled and we encounter an
769 * error while trying to fill it, we have to clear out any
770 * garbage data from the pages instantiated for the buffer.
771 * If we do not, a failed uiomove() during a write can leave
772 * the prior contents of the pages exposed to a userland mmap.
774 * Note that we need only clear buffers with a transfer size
775 * equal to the block size because buffers with a shorter
776 * transfer size were cleared above by the call to UFS_BALLOC()
777 * with the BA_CLRBUF flag set.
779 * If the source region for uiomove identically mmaps the
780 * buffer, uiomove() performed the NOP copy, and the buffer
781 * content remains valid because the page fault handler
782 * validated the pages.
784 if (error != 0 && (bp->b_flags & B_CACHE) == 0 &&
785 fs->fs_bsize == xfersize)
787 if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
788 (LIST_EMPTY(&bp->b_dep))) {
789 bp->b_flags |= B_RELBUF;
793 * If IO_SYNC each buffer is written synchronously. Otherwise
794 * if we have a severe page deficiency write the buffer
795 * asynchronously. Otherwise try to cluster, and if that
796 * doesn't do it then either do an async write (if O_DIRECT),
797 * or a delayed write (if not).
799 if (ioflag & IO_SYNC) {
801 } else if (vm_page_count_severe() ||
802 buf_dirty_count_severe() ||
803 (ioflag & IO_ASYNC)) {
804 bp->b_flags |= B_CLUSTEROK;
806 } else if (xfersize + blkoffset == fs->fs_bsize) {
807 if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
808 bp->b_flags |= B_CLUSTEROK;
809 cluster_write(vp, bp, ip->i_size, seqcount,
814 } else if (ioflag & IO_DIRECT) {
815 bp->b_flags |= B_CLUSTEROK;
818 bp->b_flags |= B_CLUSTEROK;
821 if (error || xfersize == 0)
823 ip->i_flag |= IN_CHANGE | IN_UPDATE;
826 * If we successfully wrote any data, and we are not the superuser
827 * we clear the setuid and setgid bits as a precaution against
830 if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid &&
832 if (priv_check_cred(ap->a_cred, PRIV_VFS_RETAINSUGID, 0)) {
833 ip->i_mode &= ~(ISUID | ISGID);
834 DIP_SET(ip, i_mode, ip->i_mode);
838 if (ioflag & IO_UNIT) {
839 (void)ffs_truncate(vp, osize,
840 IO_NORMAL | (ioflag & IO_SYNC), ap->a_cred);
841 uio->uio_offset -= resid - uio->uio_resid;
842 uio->uio_resid = resid;
844 } else if (resid > uio->uio_resid && (ioflag & IO_SYNC))
845 error = ffs_update(vp, 1);
854 struct vop_getpages_args *ap;
860 pcount = round_page(ap->a_count) / PAGE_SIZE;
861 mreq = ap->a_m[ap->a_reqpage];
864 * if ANY DEV_BSIZE blocks are valid on a large filesystem block,
865 * then the entire page is valid. Since the page may be mapped,
866 * user programs might reference data beyond the actual end of file
867 * occuring within the page. We have to zero that data.
869 VM_OBJECT_WLOCK(mreq->object);
871 if (mreq->valid != VM_PAGE_BITS_ALL)
872 vm_page_zero_invalid(mreq, TRUE);
873 for (i = 0; i < pcount; i++) {
874 if (i != ap->a_reqpage) {
875 vm_page_lock(ap->a_m[i]);
876 vm_page_free(ap->a_m[i]);
877 vm_page_unlock(ap->a_m[i]);
880 VM_OBJECT_WUNLOCK(mreq->object);
883 VM_OBJECT_WUNLOCK(mreq->object);
885 return vnode_pager_generic_getpages(ap->a_vp, ap->a_m,
892 * Extended attribute area reading.
895 ffs_extread(struct vnode *vp, struct uio *uio, int ioflag)
898 struct ufs2_dinode *dp;
901 ufs_lbn_t lbn, nextlbn;
903 long size, xfersize, blkoffset;
912 if (uio->uio_rw != UIO_READ || fs->fs_magic != FS_UFS2_MAGIC)
913 panic("ffs_extread: mode");
916 orig_resid = uio->uio_resid;
917 KASSERT(orig_resid >= 0, ("ffs_extread: uio->uio_resid < 0"));
920 KASSERT(uio->uio_offset >= 0, ("ffs_extread: uio->uio_offset < 0"));
922 for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) {
923 if ((bytesinfile = dp->di_extsize - uio->uio_offset) <= 0)
925 lbn = lblkno(fs, uio->uio_offset);
929 * size of buffer. The buffer representing the
930 * end of the file is rounded up to the size of
931 * the block type ( fragment or full block,
934 size = sblksize(fs, dp->di_extsize, lbn);
935 blkoffset = blkoff(fs, uio->uio_offset);
938 * The amount we want to transfer in this iteration is
939 * one FS block less the amount of the data before
940 * our startpoint (duh!)
942 xfersize = fs->fs_bsize - blkoffset;
945 * But if we actually want less than the block,
946 * or the file doesn't have a whole block more of data,
947 * then use the lesser number.
949 if (uio->uio_resid < xfersize)
950 xfersize = uio->uio_resid;
951 if (bytesinfile < xfersize)
952 xfersize = bytesinfile;
954 if (lblktosize(fs, nextlbn) >= dp->di_extsize) {
956 * Don't do readahead if this is the end of the info.
958 error = bread(vp, -1 - lbn, size, NOCRED, &bp);
961 * If we have a second block, then
962 * fire off a request for a readahead
963 * as well as a read. Note that the 4th and 5th
964 * arguments point to arrays of the size specified in
967 u_int nextsize = sblksize(fs, dp->di_extsize, nextlbn);
969 nextlbn = -1 - nextlbn;
970 error = breadn(vp, -1 - lbn,
971 size, &nextlbn, &nextsize, 1, NOCRED, &bp);
980 * If IO_DIRECT then set B_DIRECT for the buffer. This
981 * will cause us to attempt to release the buffer later on
982 * and will cause the buffer cache to attempt to free the
985 if (ioflag & IO_DIRECT)
986 bp->b_flags |= B_DIRECT;
989 * We should only get non-zero b_resid when an I/O error
990 * has occurred, which should cause us to break above.
991 * However, if the short read did not cause an error,
992 * then we want to ensure that we do not uiomove bad
993 * or uninitialized data.
996 if (size < xfersize) {
1002 error = uiomove((char *)bp->b_data + blkoffset,
1003 (int)xfersize, uio);
1007 if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
1008 (LIST_EMPTY(&bp->b_dep))) {
1010 * If there are no dependencies, and it's VMIO,
1011 * then we don't need the buf, mark it available
1012 * for freeing. For non-direct VMIO reads, the VM
1015 bp->b_flags |= B_RELBUF;
1019 * Otherwise let whoever
1020 * made the request take care of
1021 * freeing it. We just queue
1022 * it onto another list.
1029 * This can only happen in the case of an error
1030 * because the loop above resets bp to NULL on each iteration
1031 * and on normal completion has not set a new value into it.
1032 * so it must have come from a 'break' statement
1035 if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
1036 (LIST_EMPTY(&bp->b_dep))) {
1037 bp->b_flags |= B_RELBUF;
1047 * Extended attribute area writing.
1050 ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *ucred)
1053 struct ufs2_dinode *dp;
1059 int blkoffset, error, flags, size, xfersize;
1066 if (uio->uio_rw != UIO_WRITE || fs->fs_magic != FS_UFS2_MAGIC)
1067 panic("ffs_extwrite: mode");
1070 if (ioflag & IO_APPEND)
1071 uio->uio_offset = dp->di_extsize;
1072 KASSERT(uio->uio_offset >= 0, ("ffs_extwrite: uio->uio_offset < 0"));
1073 KASSERT(uio->uio_resid >= 0, ("ffs_extwrite: uio->uio_resid < 0"));
1074 if ((uoff_t)uio->uio_offset + uio->uio_resid > NXADDR * fs->fs_bsize)
1077 resid = uio->uio_resid;
1078 osize = dp->di_extsize;
1080 if ((ioflag & IO_SYNC) && !DOINGASYNC(vp))
1083 for (error = 0; uio->uio_resid > 0;) {
1084 lbn = lblkno(fs, uio->uio_offset);
1085 blkoffset = blkoff(fs, uio->uio_offset);
1086 xfersize = fs->fs_bsize - blkoffset;
1087 if (uio->uio_resid < xfersize)
1088 xfersize = uio->uio_resid;
1091 * We must perform a read-before-write if the transfer size
1092 * does not cover the entire buffer.
1094 if (fs->fs_bsize > xfersize)
1097 flags &= ~BA_CLRBUF;
1098 error = UFS_BALLOC(vp, uio->uio_offset, xfersize,
1103 * If the buffer is not valid we have to clear out any
1104 * garbage data from the pages instantiated for the buffer.
1105 * If we do not, a failed uiomove() during a write can leave
1106 * the prior contents of the pages exposed to a userland
1107 * mmap(). XXX deal with uiomove() errors a better way.
1109 if ((bp->b_flags & B_CACHE) == 0 && fs->fs_bsize <= xfersize)
1111 if (ioflag & IO_DIRECT)
1112 bp->b_flags |= B_DIRECT;
1114 if (uio->uio_offset + xfersize > dp->di_extsize)
1115 dp->di_extsize = uio->uio_offset + xfersize;
1117 size = sblksize(fs, dp->di_extsize, lbn) - bp->b_resid;
1118 if (size < xfersize)
1122 uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
1123 if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
1124 (LIST_EMPTY(&bp->b_dep))) {
1125 bp->b_flags |= B_RELBUF;
1129 * If IO_SYNC each buffer is written synchronously. Otherwise
1130 * if we have a severe page deficiency write the buffer
1131 * asynchronously. Otherwise try to cluster, and if that
1132 * doesn't do it then either do an async write (if O_DIRECT),
1133 * or a delayed write (if not).
1135 if (ioflag & IO_SYNC) {
1137 } else if (vm_page_count_severe() ||
1138 buf_dirty_count_severe() ||
1139 xfersize + blkoffset == fs->fs_bsize ||
1140 (ioflag & (IO_ASYNC | IO_DIRECT)))
1144 if (error || xfersize == 0)
1146 ip->i_flag |= IN_CHANGE;
1149 * If we successfully wrote any data, and we are not the superuser
1150 * we clear the setuid and setgid bits as a precaution against
1153 if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && ucred) {
1154 if (priv_check_cred(ucred, PRIV_VFS_RETAINSUGID, 0)) {
1155 ip->i_mode &= ~(ISUID | ISGID);
1156 dp->di_mode = ip->i_mode;
1160 if (ioflag & IO_UNIT) {
1161 (void)ffs_truncate(vp, osize,
1162 IO_EXT | (ioflag&IO_SYNC), ucred);
1163 uio->uio_offset -= resid - uio->uio_resid;
1164 uio->uio_resid = resid;
1166 } else if (resid > uio->uio_resid && (ioflag & IO_SYNC))
1167 error = ffs_update(vp, 1);
1173 * Vnode operating to retrieve a named extended attribute.
1175 * Locate a particular EA (nspace:name) in the area (ptr:length), and return
1176 * the length of the EA, and possibly the pointer to the entry and to the data.
1179 ffs_findextattr(u_char *ptr, u_int length, int nspace, const char *name, u_char **eap, u_char **eac)
1181 u_char *p, *pe, *pn, *p0;
1182 int eapad1, eapad2, ealength, ealen, nlen;
1186 nlen = strlen(name);
1188 for (p = ptr; p < pe; p = pn) {
1190 bcopy(p, &ul, sizeof(ul));
1192 /* make sure this entry is complete */
1195 p += sizeof(uint32_t);
1203 if (bcmp(p, name, nlen))
1205 ealength = sizeof(uint32_t) + 3 + nlen;
1206 eapad1 = 8 - (ealength % 8);
1210 ealen = ul - ealength - eapad2;
1222 ffs_rdextattr(u_char **p, struct vnode *vp, struct thread *td, int extra)
1225 struct ufs2_dinode *dp;
1228 struct iovec liovec;
1236 easize = dp->di_extsize;
1237 if ((uoff_t)easize + extra > NXADDR * fs->fs_bsize)
1240 eae = malloc(easize + extra, M_TEMP, M_WAITOK);
1242 liovec.iov_base = eae;
1243 liovec.iov_len = easize;
1244 luio.uio_iov = &liovec;
1245 luio.uio_iovcnt = 1;
1246 luio.uio_offset = 0;
1247 luio.uio_resid = easize;
1248 luio.uio_segflg = UIO_SYSSPACE;
1249 luio.uio_rw = UIO_READ;
1252 error = ffs_extread(vp, &luio, IO_EXT | IO_SYNC);
1262 ffs_lock_ea(struct vnode *vp)
1268 while (ip->i_flag & IN_EA_LOCKED) {
1269 ip->i_flag |= IN_EA_LOCKWAIT;
1270 msleep(&ip->i_ea_refs, &vp->v_interlock, PINOD + 2, "ufs_ea",
1273 ip->i_flag |= IN_EA_LOCKED;
1278 ffs_unlock_ea(struct vnode *vp)
1284 if (ip->i_flag & IN_EA_LOCKWAIT)
1285 wakeup(&ip->i_ea_refs);
1286 ip->i_flag &= ~(IN_EA_LOCKED | IN_EA_LOCKWAIT);
1291 ffs_open_ea(struct vnode *vp, struct ucred *cred, struct thread *td)
1294 struct ufs2_dinode *dp;
1300 if (ip->i_ea_area != NULL) {
1306 error = ffs_rdextattr(&ip->i_ea_area, vp, td, 0);
1311 ip->i_ea_len = dp->di_extsize;
1319 * Vnode extattr transaction commit/abort
1322 ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td)
1326 struct iovec liovec;
1328 struct ufs2_dinode *dp;
1333 if (ip->i_ea_area == NULL) {
1338 error = ip->i_ea_error;
1339 if (commit && error == 0) {
1340 ASSERT_VOP_ELOCKED(vp, "ffs_close_ea commit");
1342 cred = vp->v_mount->mnt_cred;
1343 liovec.iov_base = ip->i_ea_area;
1344 liovec.iov_len = ip->i_ea_len;
1345 luio.uio_iov = &liovec;
1346 luio.uio_iovcnt = 1;
1347 luio.uio_offset = 0;
1348 luio.uio_resid = ip->i_ea_len;
1349 luio.uio_segflg = UIO_SYSSPACE;
1350 luio.uio_rw = UIO_WRITE;
1352 /* XXX: I'm not happy about truncating to zero size */
1353 if (ip->i_ea_len < dp->di_extsize)
1354 error = ffs_truncate(vp, 0, IO_EXT, cred);
1355 error = ffs_extwrite(vp, &luio, IO_EXT | IO_SYNC, cred);
1357 if (--ip->i_ea_refs == 0) {
1358 free(ip->i_ea_area, M_TEMP);
1359 ip->i_ea_area = NULL;
1368 * Vnode extattr strategy routine for fifos.
1370 * We need to check for a read or write of the external attributes.
1371 * Otherwise we just fall through and do the usual thing.
1374 ffsext_strategy(struct vop_strategy_args *ap)
1376 struct vop_strategy_args {
1377 struct vnodeop_desc *a_desc;
1387 lbn = ap->a_bp->b_lblkno;
1388 if (VTOI(vp)->i_fs->fs_magic == FS_UFS2_MAGIC &&
1389 lbn < 0 && lbn >= -NXADDR)
1390 return (VOP_STRATEGY_APV(&ufs_vnodeops, ap));
1391 if (vp->v_type == VFIFO)
1392 return (VOP_STRATEGY_APV(&ufs_fifoops, ap));
1393 panic("spec nodes went here");
1397 * Vnode extattr transaction commit/abort
1400 ffs_openextattr(struct vop_openextattr_args *ap)
1402 struct vop_openextattr_args {
1403 struct vnodeop_desc *a_desc;
1405 IN struct ucred *a_cred;
1406 IN struct thread *a_td;
1411 if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
1412 return (EOPNOTSUPP);
1414 return (ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td));
1419 * Vnode extattr transaction commit/abort
1422 ffs_closeextattr(struct vop_closeextattr_args *ap)
1424 struct vop_closeextattr_args {
1425 struct vnodeop_desc *a_desc;
1428 IN struct ucred *a_cred;
1429 IN struct thread *a_td;
1434 if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
1435 return (EOPNOTSUPP);
1437 if (ap->a_commit && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY))
1440 return (ffs_close_ea(ap->a_vp, ap->a_commit, ap->a_cred, ap->a_td));
1444 * Vnode operation to remove a named attribute.
1447 ffs_deleteextattr(struct vop_deleteextattr_args *ap)
1450 IN struct vnode *a_vp;
1451 IN int a_attrnamespace;
1452 IN const char *a_name;
1453 IN struct ucred *a_cred;
1454 IN struct thread *a_td;
1460 uint32_t ealength, ul;
1461 int ealen, olen, eapad1, eapad2, error, i, easize;
1464 ip = VTOI(ap->a_vp);
1467 if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
1468 return (EOPNOTSUPP);
1470 if (strlen(ap->a_name) == 0)
1473 if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
1476 error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
1477 ap->a_cred, ap->a_td, VWRITE);
1481 * ffs_lock_ea is not needed there, because the vnode
1482 * must be exclusively locked.
1484 if (ip->i_ea_area != NULL && ip->i_ea_error == 0)
1485 ip->i_ea_error = error;
1489 error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td);
1493 ealength = eapad1 = ealen = eapad2 = 0;
1495 eae = malloc(ip->i_ea_len, M_TEMP, M_WAITOK);
1496 bcopy(ip->i_ea_area, eae, ip->i_ea_len);
1497 easize = ip->i_ea_len;
1499 olen = ffs_findextattr(eae, easize, ap->a_attrnamespace, ap->a_name,
1502 /* delete but nonexistent */
1504 ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
1507 bcopy(p, &ul, sizeof ul);
1509 if (ul != ealength) {
1510 bcopy(p + ul, p + ealength, easize - i);
1511 easize += (ealength - ul);
1513 if (easize > NXADDR * fs->fs_bsize) {
1515 ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
1516 if (ip->i_ea_area != NULL && ip->i_ea_error == 0)
1517 ip->i_ea_error = ENOSPC;
1521 ip->i_ea_area = eae;
1522 ip->i_ea_len = easize;
1524 error = ffs_close_ea(ap->a_vp, 1, ap->a_cred, ap->a_td);
1529 * Vnode operation to retrieve a named extended attribute.
1532 ffs_getextattr(struct vop_getextattr_args *ap)
1535 IN struct vnode *a_vp;
1536 IN int a_attrnamespace;
1537 IN const char *a_name;
1538 INOUT struct uio *a_uio;
1540 IN struct ucred *a_cred;
1541 IN struct thread *a_td;
1550 ip = VTOI(ap->a_vp);
1552 if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
1553 return (EOPNOTSUPP);
1555 error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
1556 ap->a_cred, ap->a_td, VREAD);
1560 error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td);
1564 eae = ip->i_ea_area;
1565 easize = ip->i_ea_len;
1567 ealen = ffs_findextattr(eae, easize, ap->a_attrnamespace, ap->a_name,
1571 if (ap->a_size != NULL)
1572 *ap->a_size = ealen;
1573 else if (ap->a_uio != NULL)
1574 error = uiomove(p, ealen, ap->a_uio);
1578 ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
1583 * Vnode operation to retrieve extended attributes on a vnode.
1586 ffs_listextattr(struct vop_listextattr_args *ap)
1589 IN struct vnode *a_vp;
1590 IN int a_attrnamespace;
1591 INOUT struct uio *a_uio;
1593 IN struct ucred *a_cred;
1594 IN struct thread *a_td;
1599 u_char *eae, *p, *pe, *pn;
1604 ip = VTOI(ap->a_vp);
1606 if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
1607 return (EOPNOTSUPP);
1609 error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
1610 ap->a_cred, ap->a_td, VREAD);
1614 error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td);
1617 eae = ip->i_ea_area;
1618 easize = ip->i_ea_len;
1621 if (ap->a_size != NULL)
1624 for(p = eae; error == 0 && p < pe; p = pn) {
1625 bcopy(p, &ul, sizeof(ul));
1630 if (*p++ != ap->a_attrnamespace)
1634 if (ap->a_size != NULL) {
1635 *ap->a_size += ealen + 1;
1636 } else if (ap->a_uio != NULL) {
1637 error = uiomove(p, ealen + 1, ap->a_uio);
1640 ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
1645 * Vnode operation to set a named attribute.
1648 ffs_setextattr(struct vop_setextattr_args *ap)
1651 IN struct vnode *a_vp;
1652 IN int a_attrnamespace;
1653 IN const char *a_name;
1654 INOUT struct uio *a_uio;
1655 IN struct ucred *a_cred;
1656 IN struct thread *a_td;
1662 uint32_t ealength, ul;
1664 int olen, eapad1, eapad2, error, i, easize;
1667 ip = VTOI(ap->a_vp);
1670 if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
1671 return (EOPNOTSUPP);
1673 if (strlen(ap->a_name) == 0)
1676 /* XXX Now unsupported API to delete EAs using NULL uio. */
1677 if (ap->a_uio == NULL)
1678 return (EOPNOTSUPP);
1680 if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)
1683 ealen = ap->a_uio->uio_resid;
1684 if (ealen < 0 || ealen > lblktosize(fs, NXADDR))
1687 error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
1688 ap->a_cred, ap->a_td, VWRITE);
1692 * ffs_lock_ea is not needed there, because the vnode
1693 * must be exclusively locked.
1695 if (ip->i_ea_area != NULL && ip->i_ea_error == 0)
1696 ip->i_ea_error = error;
1700 error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td);
1704 ealength = sizeof(uint32_t) + 3 + strlen(ap->a_name);
1705 eapad1 = 8 - (ealength % 8);
1708 eapad2 = 8 - (ealen % 8);
1711 ealength += eapad1 + ealen + eapad2;
1713 eae = malloc(ip->i_ea_len + ealength, M_TEMP, M_WAITOK);
1714 bcopy(ip->i_ea_area, eae, ip->i_ea_len);
1715 easize = ip->i_ea_len;
1717 olen = ffs_findextattr(eae, easize,
1718 ap->a_attrnamespace, ap->a_name, &p, NULL);
1720 /* new, append at end */
1724 bcopy(p, &ul, sizeof ul);
1726 if (ul != ealength) {
1727 bcopy(p + ul, p + ealength, easize - i);
1728 easize += (ealength - ul);
1731 if (easize > lblktosize(fs, NXADDR)) {
1733 ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
1734 if (ip->i_ea_area != NULL && ip->i_ea_error == 0)
1735 ip->i_ea_error = ENOSPC;
1738 bcopy(&ealength, p, sizeof(ealength));
1739 p += sizeof(ealength);
1740 *p++ = ap->a_attrnamespace;
1742 *p++ = strlen(ap->a_name);
1743 strcpy(p, ap->a_name);
1744 p += strlen(ap->a_name);
1747 error = uiomove(p, ealen, ap->a_uio);
1750 ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
1751 if (ip->i_ea_area != NULL && ip->i_ea_error == 0)
1752 ip->i_ea_error = error;
1759 ip->i_ea_area = eae;
1760 ip->i_ea_len = easize;
1762 error = ffs_close_ea(ap->a_vp, 1, ap->a_cred, ap->a_td);
1767 * Vnode pointer to File handle
1770 ffs_vptofh(struct vop_vptofh_args *ap)
1773 IN struct vnode *a_vp;
1774 IN struct fid *a_fhp;
1781 ip = VTOI(ap->a_vp);
1782 ufhp = (struct ufid *)ap->a_fhp;
1783 ufhp->ufid_len = sizeof(struct ufid);
1784 ufhp->ufid_ino = ip->i_number;
1785 ufhp->ufid_gen = ip->i_gen;