2 * Copyright (c) 2011-2018 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
6 * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
7 * by Daniel Flores (GSOC 2013 - mentored by Matthew Dillon, compression)
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
19 * 3. Neither the name of The DragonFly Project nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific, prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * Kernel Filesystem interface
39 * NOTE! local ipdata pointers must be reloaded on any modifying operation
40 * to the inode as its underlying chain may have changed.
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
46 #include <sys/fcntl.h>
49 #include <sys/namei.h>
50 #include <sys/mount.h>
51 #include <sys/vnode.h>
52 #include <sys/mountctl.h>
53 #include <sys/dirent.h>
55 #include <sys/objcache.h>
56 #include <sys/event.h>
58 #include <vfs/fifofs/fifo.h>
62 static int hammer2_read_file(hammer2_inode_t
*ip
, struct uio
*uio
,
64 static int hammer2_write_file(hammer2_inode_t
*ip
, struct uio
*uio
,
65 int ioflag
, int seqcount
);
66 static void hammer2_extend_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
);
67 static void hammer2_truncate_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
);
69 struct objcache
*cache_xops
;
73 hammer2_knote(struct vnode
*vp
, int flags
)
76 KNOTE(&vp
->v_pollinfo
.vpi_kqinfo
.ki_note
, flags
);
80 * Last reference to a vnode is going away but it is still cached.
84 hammer2_vop_inactive(struct vop_inactive_args
*ap
)
101 * Check for deleted inodes and recycle immediately on the last
102 * release. Be sure to destroy any left-over buffer cache buffers
103 * so we do not waste time trying to flush them.
105 * Note that deleting the file block chains under the inode chain
106 * would just be a waste of energy, so don't do it.
108 * WARNING: nvtruncbuf() can only be safely called without the inode
109 * lock held due to the way our write thread works.
111 if (ip
->flags
& HAMMER2_INODE_ISUNLINKED
) {
116 * Detect updates to the embedded data which may be
117 * synchronized by the strategy code. Simply mark the
118 * inode modified so it gets picked up by our normal flush.
120 nblksize
= hammer2_calc_logical(ip
, 0, &lbase
, NULL
);
121 nvtruncbuf(vp
, 0, nblksize
, 0, 0);
128 * Reclaim a vnode so that it can be reused; after the inode is
129 * disassociated, the filesystem must manage it alone.
133 hammer2_vop_reclaim(struct vop_reclaim_args
*ap
)
147 * The final close of a deleted file or directory marks it for
148 * destruction. The DELETED flag allows the flusher to shortcut
149 * any modified blocks still unflushed (that is, just ignore them).
151 * HAMMER2 usually does not try to optimize the freemap by returning
152 * deleted blocks to it as it does not usually know how many snapshots
153 * might be referencing portions of the file/dir.
159 * NOTE! We do not attempt to flush chains here, flushing is
160 * really fragile and could also deadlock.
165 * A modified inode may require chain synchronization. This
166 * synchronization is usually handled by VOP_SYNC / VOP_FSYNC
167 * when vfsync() is called. However, that requires a vnode.
169 * When the vnode is disassociated we must keep track of any modified
170 * inode via the sideq so that it is properly flushed. We cannot
171 * safely synchronize the inode from inside the reclaim due to
172 * potentially deep locks held as-of when the reclaim occurs.
173 * Interactions and potential deadlocks abound.
175 if ((ip
->flags
& (HAMMER2_INODE_ISUNLINKED
|
176 HAMMER2_INODE_MODIFIED
|
177 HAMMER2_INODE_RESIZED
|
178 HAMMER2_INODE_DIRTYDATA
)) &&
179 (ip
->flags
& HAMMER2_INODE_ISDELETED
) == 0) {
180 hammer2_inode_sideq_t
*ipul
;
182 ipul
= kmalloc(sizeof(*ipul
), pmp
->minode
, M_WAITOK
| M_ZERO
);
185 hammer2_spin_ex(&pmp
->list_spin
);
186 if ((ip
->flags
& HAMMER2_INODE_ONSIDEQ
) == 0) {
188 atomic_set_int(&ip
->flags
, HAMMER2_INODE_ONSIDEQ
);
189 TAILQ_INSERT_TAIL(&pmp
->sideq
, ipul
, entry
);
191 hammer2_spin_unex(&pmp
->list_spin
);
193 hammer2_spin_unex(&pmp
->list_spin
);
194 kfree(ipul
, pmp
->minode
);
195 hammer2_inode_drop(ip
); /* vp ref */
197 /* retain ref from vp for ipul */
199 hammer2_inode_drop(ip
); /* vp ref */
203 * XXX handle background sync when ip dirty, kernel will no longer
204 * notify us regarding this inode because there is no longer a
205 * vnode attached to it.
212 * Currently this function synchronizes the front-end inode state to the
213 * backend chain topology, then flushes the inode's chain and sub-topology
214 * to backend media. This function does not flush the root topology down to
219 hammer2_vop_fsync(struct vop_fsync_args
*ap
)
230 hammer2_trans_init(ip
->pmp
, 0);
233 * Flush dirty buffers in the file's logical buffer cache.
234 * It is best to wait for the strategy code to commit the
235 * buffers to the device's backing buffer cache before
236 * then trying to flush the inode.
238 * This should be quick, but certain inode modifications cached
239 * entirely in the hammer2_inode structure may not trigger a
240 * buffer read until the flush so the fsync can wind up also
241 * doing scattered reads.
243 vfsync(vp
, ap
->a_waitfor
, 1, NULL
, NULL
);
244 bio_track_wait(&vp
->v_track_write
, 0, 0);
247 * Flush any inode changes
249 hammer2_inode_lock(ip
, 0);
250 if (ip
->flags
& (HAMMER2_INODE_RESIZED
|HAMMER2_INODE_MODIFIED
))
251 error1
= hammer2_inode_chain_sync(ip
);
254 * Flush dirty chains related to the inode.
256 * NOTE! XXX We do not currently flush to the volume root, ultimately
257 * we will want to have a shortcut for the flushed inode stored
258 * in the volume root for recovery purposes.
260 error2
= hammer2_inode_chain_flush(ip
);
265 * We may be able to clear the vnode dirty flag. The
266 * hammer2_pfs_moderate() code depends on this usually working.
268 if ((ip
->flags
& (HAMMER2_INODE_MODIFIED
|
269 HAMMER2_INODE_RESIZED
|
270 HAMMER2_INODE_DIRTYDATA
)) == 0 &&
271 RB_EMPTY(&vp
->v_rbdirty_tree
) &&
272 !bio_track_active(&vp
->v_track_write
)) {
275 hammer2_inode_unlock(ip
);
276 hammer2_trans_done(ip
->pmp
, 0);
283 hammer2_vop_access(struct vop_access_args
*ap
)
285 hammer2_inode_t
*ip
= VTOI(ap
->a_vp
);
290 hammer2_inode_lock(ip
, HAMMER2_RESOLVE_SHARED
);
291 uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
292 gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
293 error
= vop_helper_access(ap
, uid
, gid
, ip
->meta
.mode
, ip
->meta
.uflags
);
294 hammer2_inode_unlock(ip
);
301 hammer2_vop_getattr(struct vop_getattr_args
*ap
)
307 hammer2_chain_t
*chain
;
316 hammer2_inode_lock(ip
, HAMMER2_RESOLVE_SHARED
);
318 vap
->va_fsid
= pmp
->mp
->mnt_stat
.f_fsid
.val
[0];
319 vap
->va_fileid
= ip
->meta
.inum
;
320 vap
->va_mode
= ip
->meta
.mode
;
321 vap
->va_nlink
= ip
->meta
.nlinks
;
322 vap
->va_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
323 vap
->va_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
326 vap
->va_size
= ip
->meta
.size
; /* protected by shared lock */
327 vap
->va_blocksize
= HAMMER2_PBUFSIZE
;
328 vap
->va_flags
= ip
->meta
.uflags
;
329 hammer2_time_to_timespec(ip
->meta
.ctime
, &vap
->va_ctime
);
330 hammer2_time_to_timespec(ip
->meta
.mtime
, &vap
->va_mtime
);
331 hammer2_time_to_timespec(ip
->meta
.mtime
, &vap
->va_atime
);
334 if (ip
->meta
.type
== HAMMER2_OBJTYPE_DIRECTORY
) {
336 * Can't really calculate directory use sans the files under
337 * it, just assume one block for now.
339 vap
->va_bytes
+= HAMMER2_INODE_BYTES
;
341 for (i
= 0; i
< ip
->cluster
.nchains
; ++i
) {
342 if ((chain
= ip
->cluster
.array
[i
].chain
) != NULL
) {
344 chain
->bref
.embed
.stats
.data_count
) {
346 chain
->bref
.embed
.stats
.data_count
;
351 vap
->va_type
= hammer2_get_vtype(ip
->meta
.type
);
353 vap
->va_uid_uuid
= ip
->meta
.uid
;
354 vap
->va_gid_uuid
= ip
->meta
.gid
;
355 vap
->va_vaflags
= VA_UID_UUID_VALID
| VA_GID_UUID_VALID
|
358 hammer2_inode_unlock(ip
);
365 hammer2_vop_setattr(struct vop_setattr_args
*ap
)
376 hammer2_update_time(&ctime
);
382 if (hammer2_vfs_enospace(ip
, 0, ap
->a_cred
) > 1)
385 hammer2_pfs_memory_wait(ip
, 0);
386 hammer2_trans_init(ip
->pmp
, 0);
387 hammer2_inode_lock(ip
, 0);
390 if (vap
->va_flags
!= VNOVAL
) {
393 flags
= ip
->meta
.uflags
;
394 error
= vop_helper_setattr_flags(&flags
, vap
->va_flags
,
395 hammer2_to_unix_xid(&ip
->meta
.uid
),
398 if (ip
->meta
.uflags
!= flags
) {
399 hammer2_inode_modify(ip
);
400 ip
->meta
.uflags
= flags
;
401 ip
->meta
.ctime
= ctime
;
402 kflags
|= NOTE_ATTRIB
;
404 if (ip
->meta
.uflags
& (IMMUTABLE
| APPEND
)) {
411 if (ip
->meta
.uflags
& (IMMUTABLE
| APPEND
)) {
415 if (vap
->va_uid
!= (uid_t
)VNOVAL
|| vap
->va_gid
!= (gid_t
)VNOVAL
) {
416 mode_t cur_mode
= ip
->meta
.mode
;
417 uid_t cur_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
418 gid_t cur_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
422 error
= vop_helper_chown(ap
->a_vp
, vap
->va_uid
, vap
->va_gid
,
424 &cur_uid
, &cur_gid
, &cur_mode
);
426 hammer2_guid_to_uuid(&uuid_uid
, cur_uid
);
427 hammer2_guid_to_uuid(&uuid_gid
, cur_gid
);
428 if (bcmp(&uuid_uid
, &ip
->meta
.uid
, sizeof(uuid_uid
)) ||
429 bcmp(&uuid_gid
, &ip
->meta
.gid
, sizeof(uuid_gid
)) ||
430 ip
->meta
.mode
!= cur_mode
432 hammer2_inode_modify(ip
);
433 ip
->meta
.uid
= uuid_uid
;
434 ip
->meta
.gid
= uuid_gid
;
435 ip
->meta
.mode
= cur_mode
;
436 ip
->meta
.ctime
= ctime
;
438 kflags
|= NOTE_ATTRIB
;
445 if (vap
->va_size
!= VNOVAL
&& ip
->meta
.size
!= vap
->va_size
) {
448 if (vap
->va_size
== ip
->meta
.size
)
450 if (vap
->va_size
< ip
->meta
.size
) {
451 hammer2_mtx_ex(&ip
->truncate_lock
);
452 hammer2_truncate_file(ip
, vap
->va_size
);
453 hammer2_mtx_unlock(&ip
->truncate_lock
);
454 kflags
|= NOTE_WRITE
;
456 hammer2_extend_file(ip
, vap
->va_size
);
457 kflags
|= NOTE_WRITE
| NOTE_EXTEND
;
459 hammer2_inode_modify(ip
);
460 ip
->meta
.mtime
= ctime
;
461 vclrflags(vp
, VLASTWRITETS
);
469 /* atime not supported */
470 if (vap
->va_atime
.tv_sec
!= VNOVAL
) {
471 hammer2_inode_modify(ip
);
472 ip
->meta
.atime
= hammer2_timespec_to_time(&vap
->va_atime
);
473 kflags
|= NOTE_ATTRIB
;
476 if (vap
->va_mode
!= (mode_t
)VNOVAL
) {
477 mode_t cur_mode
= ip
->meta
.mode
;
478 uid_t cur_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
479 gid_t cur_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
481 error
= vop_helper_chmod(ap
->a_vp
, vap
->va_mode
, ap
->a_cred
,
482 cur_uid
, cur_gid
, &cur_mode
);
483 if (error
== 0 && ip
->meta
.mode
!= cur_mode
) {
484 hammer2_inode_modify(ip
);
485 ip
->meta
.mode
= cur_mode
;
486 ip
->meta
.ctime
= ctime
;
487 kflags
|= NOTE_ATTRIB
;
491 if (vap
->va_mtime
.tv_sec
!= VNOVAL
) {
492 hammer2_inode_modify(ip
);
493 ip
->meta
.mtime
= hammer2_timespec_to_time(&vap
->va_mtime
);
494 kflags
|= NOTE_ATTRIB
;
495 vclrflags(vp
, VLASTWRITETS
);
500 * If a truncation occurred we must call chain_sync() now in order
501 * to trim the related data chains, otherwise a later expansion can
504 * If an extend occured that changed the DIRECTDATA state, we must
505 * call inode_fsync now in order to prepare the inode's indirect
508 * WARNING! This means we are making an adjustment to the inode's
509 * chain outside of sync/fsync, and not just to inode->meta, which
510 * may result in some consistency issues if a crash were to occur
511 * at just the wrong time.
513 if (ip
->flags
& HAMMER2_INODE_RESIZED
)
514 hammer2_inode_chain_sync(ip
);
519 hammer2_inode_unlock(ip
);
520 hammer2_trans_done(ip
->pmp
, 1);
521 hammer2_knote(ip
->vp
, kflags
);
528 hammer2_vop_readdir(struct vop_readdir_args
*ap
)
530 hammer2_xop_readdir_t
*xop
;
531 hammer2_blockref_t bref
;
546 saveoff
= uio
->uio_offset
;
551 * Setup cookies directory entry cookies if requested
553 if (ap
->a_ncookies
) {
554 ncookies
= uio
->uio_resid
/ 16 + 1;
557 cookies
= kmalloc(ncookies
* sizeof(off_t
), M_TEMP
, M_WAITOK
);
564 hammer2_inode_lock(ip
, HAMMER2_RESOLVE_SHARED
);
567 * Handle artificial entries. To ensure that only positive 64 bit
568 * quantities are returned to userland we always strip off bit 63.
569 * The hash code is designed such that codes 0x0000-0x7FFF are not
570 * used, allowing us to use these codes for articial entries.
572 * Entry 0 is used for '.' and entry 1 is used for '..'. Do not
573 * allow '..' to cross the mount point into (e.g.) the super-root.
576 inum
= ip
->meta
.inum
& HAMMER2_DIRHASH_USERMSK
;
577 r
= vop_write_dirent(&error
, uio
, inum
, DT_DIR
, 1, ".");
581 cookies
[cookie_index
] = saveoff
;
584 if (cookie_index
== ncookies
)
590 * Be careful with lockorder when accessing ".."
592 * (ip is the current dir. xip is the parent dir).
594 inum
= ip
->meta
.inum
& HAMMER2_DIRHASH_USERMSK
;
595 if (ip
!= ip
->pmp
->iroot
)
596 inum
= ip
->meta
.iparent
& HAMMER2_DIRHASH_USERMSK
;
597 r
= vop_write_dirent(&error
, uio
, inum
, DT_DIR
, 2, "..");
601 cookies
[cookie_index
] = saveoff
;
604 if (cookie_index
== ncookies
)
608 lkey
= saveoff
| HAMMER2_DIRHASH_VISIBLE
;
609 if (hammer2_debug
& 0x0020)
610 kprintf("readdir: lkey %016jx\n", lkey
);
615 * Use XOP for cluster scan.
617 * parent is the inode cluster, already locked for us. Don't
618 * double lock shared locks as this will screw up upgrades.
620 xop
= hammer2_xop_alloc(ip
, 0);
622 hammer2_xop_start(&xop
->head
, hammer2_xop_readdir
);
625 const hammer2_inode_data_t
*ripdata
;
629 error
= hammer2_xop_collect(&xop
->head
, 0);
630 error
= hammer2_error_to_errno(error
);
634 if (cookie_index
== ncookies
)
636 if (hammer2_debug
& 0x0020)
637 kprintf("cluster chain %p %p\n",
638 xop
->head
.cluster
.focus
,
639 (xop
->head
.cluster
.focus
?
640 xop
->head
.cluster
.focus
->data
: (void *)-1));
641 hammer2_cluster_bref(&xop
->head
.cluster
, &bref
);
643 if (bref
.type
== HAMMER2_BREF_TYPE_INODE
) {
644 ripdata
= &hammer2_xop_gdata(&xop
->head
)->ipdata
;
645 dtype
= hammer2_get_dtype(ripdata
->meta
.type
);
646 saveoff
= bref
.key
& HAMMER2_DIRHASH_USERMSK
;
647 r
= vop_write_dirent(&error
, uio
,
649 HAMMER2_DIRHASH_USERMSK
,
651 ripdata
->meta
.name_len
,
653 hammer2_xop_pdata(&xop
->head
);
657 cookies
[cookie_index
] = saveoff
;
659 } else if (bref
.type
== HAMMER2_BREF_TYPE_DIRENT
) {
662 dtype
= hammer2_get_dtype(bref
.embed
.dirent
.type
);
663 saveoff
= bref
.key
& HAMMER2_DIRHASH_USERMSK
;
664 namlen
= bref
.embed
.dirent
.namlen
;
665 if (namlen
<= sizeof(bref
.check
.buf
)) {
666 dname
= bref
.check
.buf
;
668 dname
= hammer2_xop_gdata(&xop
->head
)->buf
;
670 r
= vop_write_dirent(&error
, uio
,
671 bref
.embed
.dirent
.inum
, dtype
,
673 if (namlen
> sizeof(bref
.check
.buf
))
674 hammer2_xop_pdata(&xop
->head
);
678 cookies
[cookie_index
] = saveoff
;
681 /* XXX chain error */
682 kprintf("bad chain type readdir %d\n", bref
.type
);
685 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
686 if (error
== ENOENT
) {
689 saveoff
= (hammer2_key_t
)-1;
691 saveoff
= bref
.key
& HAMMER2_DIRHASH_USERMSK
;
694 hammer2_inode_unlock(ip
);
696 *ap
->a_eofflag
= eofflag
;
697 if (hammer2_debug
& 0x0020)
698 kprintf("readdir: done at %016jx\n", saveoff
);
699 uio
->uio_offset
= saveoff
& ~HAMMER2_DIRHASH_VISIBLE
;
700 if (error
&& cookie_index
== 0) {
702 kfree(cookies
, M_TEMP
);
704 *ap
->a_cookies
= NULL
;
708 *ap
->a_ncookies
= cookie_index
;
709 *ap
->a_cookies
= cookies
;
716 * hammer2_vop_readlink { vp, uio, cred }
720 hammer2_vop_readlink(struct vop_readlink_args
*ap
)
727 if (vp
->v_type
!= VLNK
)
731 error
= hammer2_read_file(ip
, ap
->a_uio
, 0);
737 hammer2_vop_read(struct vop_read_args
*ap
)
747 * Read operations supported on this vnode?
750 if (vp
->v_type
!= VREG
)
760 seqcount
= ap
->a_ioflag
>> 16;
761 bigread
= (uio
->uio_resid
> 100 * 1024 * 1024);
763 error
= hammer2_read_file(ip
, uio
, seqcount
);
769 hammer2_vop_write(struct vop_write_args
*ap
)
780 * Read operations supported on this vnode?
783 if (vp
->v_type
!= VREG
)
790 ioflag
= ap
->a_ioflag
;
795 switch (hammer2_vfs_enospace(ip
, uio
->uio_resid
, ap
->a_cred
)) {
799 ioflag
|= IO_DIRECT
; /* semi-synchronous */
805 seqcount
= ioflag
>> 16;
808 * Check resource limit
810 if (uio
->uio_resid
> 0 && (td
= uio
->uio_td
) != NULL
&& td
->td_proc
&&
811 uio
->uio_offset
+ uio
->uio_resid
>
812 td
->td_proc
->p_rlimit
[RLIMIT_FSIZE
].rlim_cur
) {
813 lwpsignal(td
->td_proc
, td
->td_lwp
, SIGXFSZ
);
818 * The transaction interlocks against flush initiations
819 * (note: but will run concurrently with the actual flush).
821 * To avoid deadlocking against the VM system, we must flag any
822 * transaction related to the buffer cache or other direct
823 * VM page manipulation.
825 if (uio
->uio_segflg
== UIO_NOCOPY
) {
826 hammer2_trans_init(ip
->pmp
, HAMMER2_TRANS_BUFCACHE
);
828 hammer2_pfs_memory_wait(ip
, 0);
829 hammer2_trans_init(ip
->pmp
, 0);
831 error
= hammer2_write_file(ip
, uio
, ioflag
, seqcount
);
832 hammer2_trans_done(ip
->pmp
, 1);
838 * Perform read operations on a file or symlink given an UNLOCKED
841 * The passed ip is not locked.
845 hammer2_read_file(hammer2_inode_t
*ip
, struct uio
*uio
, int seqcount
)
856 * WARNING! Assumes that the kernel interlocks size changes at the
859 hammer2_mtx_sh(&ip
->lock
);
860 hammer2_mtx_sh(&ip
->truncate_lock
);
861 size
= ip
->meta
.size
;
862 hammer2_mtx_unlock(&ip
->lock
);
864 while (uio
->uio_resid
> 0 && uio
->uio_offset
< size
) {
871 lblksize
= hammer2_calc_logical(ip
, uio
->uio_offset
,
876 error
= cluster_readx(ip
->vp
, leof
, lbase
, lblksize
,
877 B_NOTMETA
| B_KVABIO
,
882 if (uio
->uio_segflg
== UIO_NOCOPY
) {
883 bp
= getblk(ip
->vp
, lbase
, lblksize
,
884 GETBLK_BHEAVY
| GETBLK_KVABIO
, 0);
885 if (bp
->b_flags
& B_CACHE
) {
888 if (bp
->b_xio
.xio_npages
!= 16)
889 kprintf("NPAGES BAD\n");
890 for (i
= 0; i
< bp
->b_xio
.xio_npages
; ++i
) {
892 m
= bp
->b_xio
.xio_pages
[i
];
893 if (m
== NULL
|| m
->valid
== 0) {
894 kprintf("bp %016jx %016jx pg %d inv",
897 kprintf("m->object %p/%p", m
->object
, ip
->vp
->v_object
);
903 kprintf("b_flags %08x, b_error %d\n", bp
->b_flags
, bp
->b_error
);
907 error
= bread_kvabio(ip
->vp
, lbase
, lblksize
, &bp
);
914 loff
= (int)(uio
->uio_offset
- lbase
);
916 if (n
> uio
->uio_resid
)
918 if (n
> size
- uio
->uio_offset
)
919 n
= (int)(size
- uio
->uio_offset
);
920 bp
->b_flags
|= B_AGE
;
921 uiomovebp(bp
, (char *)bp
->b_data
+ loff
, n
, uio
);
924 hammer2_mtx_unlock(&ip
->truncate_lock
);
930 * Write to the file represented by the inode via the logical buffer cache.
931 * The inode may represent a regular file or a symlink.
933 * The inode must not be locked.
937 hammer2_write_file(hammer2_inode_t
*ip
, struct uio
*uio
,
938 int ioflag
, int seqcount
)
940 hammer2_key_t old_eof
;
941 hammer2_key_t new_eof
;
950 * WARNING! Assumes that the kernel interlocks size changes at the
953 hammer2_mtx_ex(&ip
->lock
);
954 hammer2_mtx_sh(&ip
->truncate_lock
);
955 if (ioflag
& IO_APPEND
)
956 uio
->uio_offset
= ip
->meta
.size
;
957 old_eof
= ip
->meta
.size
;
960 * Extend the file if necessary. If the write fails at some point
961 * we will truncate it back down to cover as much as we were able
964 * Doing this now makes it easier to calculate buffer sizes in
971 if (uio
->uio_offset
+ uio
->uio_resid
> old_eof
) {
972 new_eof
= uio
->uio_offset
+ uio
->uio_resid
;
974 hammer2_extend_file(ip
, new_eof
);
975 kflags
|= NOTE_EXTEND
;
979 hammer2_mtx_unlock(&ip
->lock
);
984 while (uio
->uio_resid
> 0) {
993 * Don't allow the buffer build to blow out the buffer
996 if ((ioflag
& IO_RECURSE
) == 0)
997 bwillwrite(HAMMER2_PBUFSIZE
);
1000 * This nominally tells us how much we can cluster and
1001 * what the logical buffer size needs to be. Currently
1002 * we don't try to cluster the write and just handle one
1005 lblksize
= hammer2_calc_logical(ip
, uio
->uio_offset
,
1007 loff
= (int)(uio
->uio_offset
- lbase
);
1009 KKASSERT(lblksize
<= 65536);
1012 * Calculate bytes to copy this transfer and whether the
1013 * copy completely covers the buffer or not.
1016 n
= lblksize
- loff
;
1017 if (n
> uio
->uio_resid
) {
1019 if (loff
== lbase
&& uio
->uio_offset
+ n
== new_eof
)
1027 if (lbase
>= new_eof
)
1033 if (uio
->uio_segflg
== UIO_NOCOPY
) {
1035 * Issuing a write with the same data backing the
1036 * buffer. Instantiate the buffer to collect the
1037 * backing vm pages, then read-in any missing bits.
1039 * This case is used by vop_stdputpages().
1041 bp
= getblk(ip
->vp
, lbase
, lblksize
,
1042 GETBLK_BHEAVY
| GETBLK_KVABIO
, 0);
1043 if ((bp
->b_flags
& B_CACHE
) == 0) {
1045 error
= bread_kvabio(ip
->vp
, lbase
,
1048 } else if (trivial
) {
1050 * Even though we are entirely overwriting the buffer
1051 * we may still have to zero it out to avoid a
1052 * mmap/write visibility issue.
1054 bp
= getblk(ip
->vp
, lbase
, lblksize
,
1055 GETBLK_BHEAVY
| GETBLK_KVABIO
, 0);
1056 if ((bp
->b_flags
& B_CACHE
) == 0)
1060 * Partial overwrite, read in any missing bits then
1061 * replace the portion being written.
1063 * (The strategy code will detect zero-fill physical
1064 * blocks for this case).
1066 error
= bread_kvabio(ip
->vp
, lbase
, lblksize
, &bp
);
1077 * Ok, copy the data in
1080 error
= uiomovebp(bp
, bp
->b_data
+ loff
, n
, uio
);
1081 kflags
|= NOTE_WRITE
;
1089 * WARNING: Pageout daemon will issue UIO_NOCOPY writes
1090 * with IO_SYNC or IO_ASYNC set. These writes
1091 * must be handled as the pageout daemon expects.
1093 * NOTE! H2 relies on cluster_write() here because it
1094 * cannot preallocate disk blocks at the logical
1095 * level due to not knowing what the compression
1096 * size will be at this time.
1098 * We must use cluster_write() here and we depend
1099 * on the write-behind feature to flush buffers
1100 * appropriately. If we let the buffer daemons do
1101 * it the block allocations will be all over the
1104 if (ioflag
& IO_SYNC
) {
1106 } else if ((ioflag
& IO_DIRECT
) && endofblk
) {
1108 } else if (ioflag
& IO_ASYNC
) {
1110 } else if (ip
->vp
->v_mount
->mnt_flag
& MNT_NOCLUSTERW
) {
1114 bp
->b_flags
|= B_CLUSTEROK
;
1115 cluster_write(bp
, new_eof
, lblksize
, seqcount
);
1117 bp
->b_flags
|= B_CLUSTEROK
;
1124 * Cleanup. If we extended the file EOF but failed to write through
1125 * the entire write is a failure and we have to back-up.
1127 if (error
&& new_eof
!= old_eof
) {
1128 hammer2_mtx_unlock(&ip
->truncate_lock
);
1129 hammer2_mtx_ex(&ip
->lock
);
1130 hammer2_mtx_ex(&ip
->truncate_lock
);
1131 hammer2_truncate_file(ip
, old_eof
);
1132 if (ip
->flags
& HAMMER2_INODE_MODIFIED
)
1133 hammer2_inode_chain_sync(ip
);
1134 hammer2_mtx_unlock(&ip
->lock
);
1135 } else if (modified
) {
1136 struct vnode
*vp
= ip
->vp
;
1138 hammer2_mtx_ex(&ip
->lock
);
1139 hammer2_inode_modify(ip
);
1140 if (uio
->uio_segflg
== UIO_NOCOPY
) {
1141 if (vp
->v_flag
& VLASTWRITETS
) {
1143 (unsigned long)vp
->v_lastwrite_ts
.tv_sec
*
1145 vp
->v_lastwrite_ts
.tv_nsec
/ 1000;
1148 hammer2_update_time(&ip
->meta
.mtime
);
1149 vclrflags(vp
, VLASTWRITETS
);
1154 * REMOVED - handled by hammer2_extend_file(). Do not issue
1155 * a chain_sync() outside of a sync/fsync except for DIRECTDATA
1158 * Under normal conditions we only issue a chain_sync if
1159 * the inode's DIRECTDATA state changed.
1161 if (ip
->flags
& HAMMER2_INODE_RESIZED
)
1162 hammer2_inode_chain_sync(ip
);
1164 hammer2_mtx_unlock(&ip
->lock
);
1165 hammer2_knote(ip
->vp
, kflags
);
1167 hammer2_trans_assert_strategy(ip
->pmp
);
1168 hammer2_mtx_unlock(&ip
->truncate_lock
);
1174 * Truncate the size of a file. The inode must not be locked.
1176 * We must unconditionally set HAMMER2_INODE_RESIZED to properly
1177 * ensure that any on-media data beyond the new file EOF has been destroyed.
1179 * WARNING: nvtruncbuf() can only be safely called without the inode lock
1180 * held due to the way our write thread works. If the truncation
1181 * occurs in the middle of a buffer, nvtruncbuf() is responsible
1182 * for dirtying that buffer and zeroing out trailing bytes.
1184 * WARNING! Assumes that the kernel interlocks size changes at the
1187 * WARNING! Caller assumes responsibility for removing dead blocks
1188 * if INODE_RESIZED is set.
1192 hammer2_truncate_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
)
1194 hammer2_key_t lbase
;
1197 hammer2_mtx_unlock(&ip
->lock
);
1199 nblksize
= hammer2_calc_logical(ip
, nsize
, &lbase
, NULL
);
1200 nvtruncbuf(ip
->vp
, nsize
,
1201 nblksize
, (int)nsize
& (nblksize
- 1),
1204 hammer2_mtx_ex(&ip
->lock
);
1205 KKASSERT((ip
->flags
& HAMMER2_INODE_RESIZED
) == 0);
1206 ip
->osize
= ip
->meta
.size
;
1207 ip
->meta
.size
= nsize
;
1208 atomic_set_int(&ip
->flags
, HAMMER2_INODE_RESIZED
);
1209 hammer2_inode_modify(ip
);
1213 * Extend the size of a file. The inode must not be locked.
1215 * Even though the file size is changing, we do not have to set the
1216 * INODE_RESIZED bit unless the file size crosses the EMBEDDED_BYTES
1217 * boundary. When this occurs a hammer2_inode_chain_sync() is required
1218 * to prepare the inode cluster's indirect block table, otherwise
1219 * async execution of the strategy code will implode on us.
1221 * WARNING! Assumes that the kernel interlocks size changes at the
1224 * WARNING! Caller assumes responsibility for transitioning out
1225 * of the inode DIRECTDATA mode if INODE_RESIZED is set.
1229 hammer2_extend_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
)
1231 hammer2_key_t lbase
;
1232 hammer2_key_t osize
;
1236 KKASSERT((ip
->flags
& HAMMER2_INODE_RESIZED
) == 0);
1237 hammer2_inode_modify(ip
);
1238 osize
= ip
->meta
.size
;
1240 ip
->meta
.size
= nsize
;
1243 * We must issue a chain_sync() when the DIRECTDATA state changes
1244 * to prevent confusion between the flush code and the in-memory
1245 * state. This is not perfect because we are doing it outside of
1246 * a sync/fsync operation, so it might not be fully synchronized
1247 * with the meta-data topology flush.
1249 if (osize
<= HAMMER2_EMBEDDED_BYTES
&& nsize
> HAMMER2_EMBEDDED_BYTES
) {
1250 atomic_set_int(&ip
->flags
, HAMMER2_INODE_RESIZED
);
1251 hammer2_inode_chain_sync(ip
);
1254 hammer2_mtx_unlock(&ip
->lock
);
1256 oblksize
= hammer2_calc_logical(ip
, osize
, &lbase
, NULL
);
1257 nblksize
= hammer2_calc_logical(ip
, nsize
, &lbase
, NULL
);
1263 hammer2_mtx_ex(&ip
->lock
);
1268 hammer2_vop_nresolve(struct vop_nresolve_args
*ap
)
1270 hammer2_xop_nresolve_t
*xop
;
1271 hammer2_inode_t
*ip
;
1272 hammer2_inode_t
*dip
;
1273 struct namecache
*ncp
;
1277 dip
= VTOI(ap
->a_dvp
);
1278 xop
= hammer2_xop_alloc(dip
, 0);
1280 ncp
= ap
->a_nch
->ncp
;
1281 hammer2_xop_setname(&xop
->head
, ncp
->nc_name
, ncp
->nc_nlen
);
1284 * Note: In DragonFly the kernel handles '.' and '..'.
1286 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1287 hammer2_xop_start(&xop
->head
, hammer2_xop_nresolve
);
1289 error
= hammer2_xop_collect(&xop
->head
, 0);
1290 error
= hammer2_error_to_errno(error
);
1294 ip
= hammer2_inode_get(dip
->pmp
, dip
, &xop
->head
, -1);
1296 hammer2_inode_unlock(dip
);
1299 * Acquire the related vnode
1301 * NOTE: For error processing, only ENOENT resolves the namecache
1302 * entry to NULL, otherwise we just return the error and
1303 * leave the namecache unresolved.
1305 * NOTE: multiple hammer2_inode structures can be aliased to the
1306 * same chain element, for example for hardlinks. This
1307 * use case does not 'reattach' inode associations that
1308 * might already exist, but always allocates a new one.
1310 * WARNING: inode structure is locked exclusively via inode_get
1311 * but chain was locked shared. inode_unlock()
1312 * will handle it properly.
1315 vp
= hammer2_igetv(ip
, &error
); /* error set to UNIX error */
1318 cache_setvp(ap
->a_nch
, vp
);
1319 } else if (error
== ENOENT
) {
1320 cache_setvp(ap
->a_nch
, NULL
);
1322 hammer2_inode_unlock(ip
);
1325 * The vp should not be released until after we've disposed
1326 * of our locks, because it might cause vop_inactive() to
1333 cache_setvp(ap
->a_nch
, NULL
);
1335 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1336 KASSERT(error
|| ap
->a_nch
->ncp
->nc_vp
!= NULL
,
1337 ("resolve error %d/%p ap %p\n",
1338 error
, ap
->a_nch
->ncp
->nc_vp
, ap
));
1345 hammer2_vop_nlookupdotdot(struct vop_nlookupdotdot_args
*ap
)
1347 hammer2_inode_t
*dip
;
1351 dip
= VTOI(ap
->a_dvp
);
1352 inum
= dip
->meta
.iparent
;
1356 error
= hammer2_vfs_vget(ap
->a_dvp
->v_mount
, NULL
,
1366 hammer2_vop_nmkdir(struct vop_nmkdir_args
*ap
)
1368 hammer2_inode_t
*dip
;
1369 hammer2_inode_t
*nip
;
1370 struct namecache
*ncp
;
1371 const uint8_t *name
;
1376 dip
= VTOI(ap
->a_dvp
);
1377 if (dip
->pmp
->ronly
)
1379 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1382 ncp
= ap
->a_nch
->ncp
;
1383 name
= ncp
->nc_name
;
1384 name_len
= ncp
->nc_nlen
;
1386 hammer2_pfs_memory_wait(dip
, 1);
1387 hammer2_trans_init(dip
->pmp
, 0);
1389 inum
= hammer2_trans_newinum(dip
->pmp
);
1392 * Create the actual inode as a hidden file in the iroot, then
1393 * create the directory entry. The creation of the actual inode
1394 * sets its nlinks to 1 which is the value we desire.
1396 nip
= hammer2_inode_create(dip
->pmp
->iroot
, dip
, ap
->a_vap
, ap
->a_cred
,
1401 error
= hammer2_error_to_errno(error
);
1403 error
= hammer2_dirent_create(dip
, name
, name_len
,
1404 nip
->meta
.inum
, nip
->meta
.type
);
1405 /* returns UNIX error code */
1409 hammer2_inode_unlink_finisher(nip
, 0);
1410 hammer2_inode_unlock(nip
);
1415 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1416 hammer2_inode_unlock(nip
);
1420 * Update dip's mtime
1422 * We can use a shared inode lock and allow the meta.mtime update
1423 * SMP race. hammer2_inode_modify() is MPSAFE w/a shared lock.
1428 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1429 hammer2_update_time(&mtime
);
1430 hammer2_inode_modify(dip
);
1431 dip
->meta
.mtime
= mtime
;
1432 hammer2_inode_unlock(dip
);
1435 hammer2_trans_done(dip
->pmp
, 1);
1438 cache_setunresolved(ap
->a_nch
);
1439 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1440 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
| NOTE_LINK
);
1447 hammer2_vop_open(struct vop_open_args
*ap
)
1449 return vop_stdopen(ap
);
1453 * hammer2_vop_advlock { vp, id, op, fl, flags }
1457 hammer2_vop_advlock(struct vop_advlock_args
*ap
)
1459 hammer2_inode_t
*ip
= VTOI(ap
->a_vp
);
1462 size
= ip
->meta
.size
;
1463 return (lf_advlock(ap
, &ip
->advlock
, size
));
1468 hammer2_vop_close(struct vop_close_args
*ap
)
1470 return vop_stdclose(ap
);
1474 * hammer2_vop_nlink { nch, dvp, vp, cred }
1476 * Create a hardlink from (vp) to {dvp, nch}.
1480 hammer2_vop_nlink(struct vop_nlink_args
*ap
)
1482 hammer2_inode_t
*tdip
; /* target directory to create link in */
1483 hammer2_inode_t
*ip
; /* inode we are hardlinking to */
1484 struct namecache
*ncp
;
1485 const uint8_t *name
;
1489 if (ap
->a_dvp
->v_mount
!= ap
->a_vp
->v_mount
)
1492 tdip
= VTOI(ap
->a_dvp
);
1493 if (tdip
->pmp
->ronly
)
1495 if (hammer2_vfs_enospace(tdip
, 0, ap
->a_cred
) > 1)
1498 ncp
= ap
->a_nch
->ncp
;
1499 name
= ncp
->nc_name
;
1500 name_len
= ncp
->nc_nlen
;
1503 * ip represents the file being hardlinked. The file could be a
1504 * normal file or a hardlink target if it has already been hardlinked.
1505 * (with the new semantics, it will almost always be a hardlink
1508 * Bump nlinks and potentially also create or move the hardlink
1509 * target in the parent directory common to (ip) and (tdip). The
1510 * consolidation code can modify ip->cluster. The returned cluster
1513 ip
= VTOI(ap
->a_vp
);
1514 KASSERT(ip
->pmp
, ("ip->pmp is NULL %p %p", ip
, ip
->pmp
));
1515 hammer2_pfs_memory_wait(ip
, 0);
1516 hammer2_trans_init(ip
->pmp
, 0);
1519 * Target should be an indexed inode or there's no way we will ever
1520 * be able to find it!
1522 KKASSERT((ip
->meta
.name_key
& HAMMER2_DIRHASH_VISIBLE
) == 0);
1527 * Can return NULL and error == EXDEV if the common parent
1528 * crosses a directory with the xlink flag set.
1530 hammer2_inode_lock(tdip
, 0);
1531 hammer2_inode_lock(ip
, 0);
1534 * Create the directory entry and bump nlinks.
1537 error
= hammer2_dirent_create(tdip
, name
, name_len
,
1538 ip
->meta
.inum
, ip
->meta
.type
);
1539 hammer2_inode_modify(ip
);
1544 * Update dip's mtime
1548 hammer2_update_time(&mtime
);
1549 hammer2_inode_modify(tdip
);
1550 tdip
->meta
.mtime
= mtime
;
1552 cache_setunresolved(ap
->a_nch
);
1553 cache_setvp(ap
->a_nch
, ap
->a_vp
);
1555 hammer2_inode_unlock(ip
);
1556 hammer2_inode_unlock(tdip
);
1558 hammer2_trans_done(ip
->pmp
, 1);
1559 hammer2_knote(ap
->a_vp
, NOTE_LINK
);
1560 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1566 * hammer2_vop_ncreate { nch, dvp, vpp, cred, vap }
1568 * The operating system has already ensured that the directory entry
1569 * does not exist and done all appropriate namespace locking.
1573 hammer2_vop_ncreate(struct vop_ncreate_args
*ap
)
1575 hammer2_inode_t
*dip
;
1576 hammer2_inode_t
*nip
;
1577 struct namecache
*ncp
;
1578 const uint8_t *name
;
1583 dip
= VTOI(ap
->a_dvp
);
1584 if (dip
->pmp
->ronly
)
1586 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1589 ncp
= ap
->a_nch
->ncp
;
1590 name
= ncp
->nc_name
;
1591 name_len
= ncp
->nc_nlen
;
1592 hammer2_pfs_memory_wait(dip
, 1);
1593 hammer2_trans_init(dip
->pmp
, 0);
1595 inum
= hammer2_trans_newinum(dip
->pmp
);
1598 * Create the actual inode as a hidden file in the iroot, then
1599 * create the directory entry. The creation of the actual inode
1600 * sets its nlinks to 1 which is the value we desire.
1602 nip
= hammer2_inode_create(dip
->pmp
->iroot
, dip
, ap
->a_vap
, ap
->a_cred
,
1608 error
= hammer2_error_to_errno(error
);
1610 error
= hammer2_dirent_create(dip
, name
, name_len
,
1611 nip
->meta
.inum
, nip
->meta
.type
);
1615 hammer2_inode_unlink_finisher(nip
, 0);
1616 hammer2_inode_unlock(nip
);
1621 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1622 hammer2_inode_unlock(nip
);
1626 * Update dip's mtime
1631 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1632 hammer2_update_time(&mtime
);
1633 hammer2_inode_modify(dip
);
1634 dip
->meta
.mtime
= mtime
;
1635 hammer2_inode_unlock(dip
);
1638 hammer2_trans_done(dip
->pmp
, 1);
1641 cache_setunresolved(ap
->a_nch
);
1642 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1643 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1649 * Make a device node (typically a fifo)
1653 hammer2_vop_nmknod(struct vop_nmknod_args
*ap
)
1655 hammer2_inode_t
*dip
;
1656 hammer2_inode_t
*nip
;
1657 struct namecache
*ncp
;
1658 const uint8_t *name
;
1663 dip
= VTOI(ap
->a_dvp
);
1664 if (dip
->pmp
->ronly
)
1666 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1669 ncp
= ap
->a_nch
->ncp
;
1670 name
= ncp
->nc_name
;
1671 name_len
= ncp
->nc_nlen
;
1672 hammer2_pfs_memory_wait(dip
, 1);
1673 hammer2_trans_init(dip
->pmp
, 0);
1676 * Create the device inode and then create the directory entry.
1678 inum
= hammer2_trans_newinum(dip
->pmp
);
1679 nip
= hammer2_inode_create(dip
->pmp
->iroot
, dip
, ap
->a_vap
, ap
->a_cred
,
1684 error
= hammer2_dirent_create(dip
, name
, name_len
,
1685 nip
->meta
.inum
, nip
->meta
.type
);
1689 hammer2_inode_unlink_finisher(nip
, 0);
1690 hammer2_inode_unlock(nip
);
1695 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1696 hammer2_inode_unlock(nip
);
1700 * Update dip's mtime
1705 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1706 hammer2_update_time(&mtime
);
1707 hammer2_inode_modify(dip
);
1708 dip
->meta
.mtime
= mtime
;
1709 hammer2_inode_unlock(dip
);
1712 hammer2_trans_done(dip
->pmp
, 1);
1715 cache_setunresolved(ap
->a_nch
);
1716 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1717 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1723 * hammer2_vop_nsymlink { nch, dvp, vpp, cred, vap, target }
1727 hammer2_vop_nsymlink(struct vop_nsymlink_args
*ap
)
1729 hammer2_inode_t
*dip
;
1730 hammer2_inode_t
*nip
;
1731 struct namecache
*ncp
;
1732 const uint8_t *name
;
1737 dip
= VTOI(ap
->a_dvp
);
1738 if (dip
->pmp
->ronly
)
1740 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1743 ncp
= ap
->a_nch
->ncp
;
1744 name
= ncp
->nc_name
;
1745 name_len
= ncp
->nc_nlen
;
1746 hammer2_pfs_memory_wait(dip
, 1);
1747 hammer2_trans_init(dip
->pmp
, 0);
1749 ap
->a_vap
->va_type
= VLNK
; /* enforce type */
1752 * Create the softlink as an inode and then create the directory
1755 inum
= hammer2_trans_newinum(dip
->pmp
);
1757 nip
= hammer2_inode_create(dip
->pmp
->iroot
, dip
, ap
->a_vap
, ap
->a_cred
,
1762 error
= hammer2_dirent_create(dip
, name
, name_len
,
1763 nip
->meta
.inum
, nip
->meta
.type
);
1767 hammer2_inode_unlink_finisher(nip
, 0);
1768 hammer2_inode_unlock(nip
);
1772 hammer2_trans_done(dip
->pmp
, 1);
1775 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1778 * Build the softlink (~like file data) and finalize the namecache.
1785 bytes
= strlen(ap
->a_target
);
1787 hammer2_inode_unlock(nip
);
1788 bzero(&auio
, sizeof(auio
));
1789 bzero(&aiov
, sizeof(aiov
));
1790 auio
.uio_iov
= &aiov
;
1791 auio
.uio_segflg
= UIO_SYSSPACE
;
1792 auio
.uio_rw
= UIO_WRITE
;
1793 auio
.uio_resid
= bytes
;
1794 auio
.uio_iovcnt
= 1;
1795 auio
.uio_td
= curthread
;
1796 aiov
.iov_base
= ap
->a_target
;
1797 aiov
.iov_len
= bytes
;
1798 error
= hammer2_write_file(nip
, &auio
, IO_APPEND
, 0);
1799 /* XXX handle error */
1802 hammer2_inode_unlock(nip
);
1806 * Update dip's mtime
1811 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1812 hammer2_update_time(&mtime
);
1813 hammer2_inode_modify(dip
);
1814 dip
->meta
.mtime
= mtime
;
1815 hammer2_inode_unlock(dip
);
1818 hammer2_trans_done(dip
->pmp
, 1);
1821 * Finalize namecache
1824 cache_setunresolved(ap
->a_nch
);
1825 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1826 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1832 * hammer2_vop_nremove { nch, dvp, cred }
1836 hammer2_vop_nremove(struct vop_nremove_args
*ap
)
1838 hammer2_xop_unlink_t
*xop
;
1839 hammer2_inode_t
*dip
;
1840 hammer2_inode_t
*ip
;
1841 struct namecache
*ncp
;
1845 dip
= VTOI(ap
->a_dvp
);
1846 if (dip
->pmp
->ronly
)
1849 /* allow removals, except user to also bulkfree */
1850 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1854 ncp
= ap
->a_nch
->ncp
;
1856 hammer2_pfs_memory_wait(dip
, 1);
1857 hammer2_trans_init(dip
->pmp
, 0);
1858 hammer2_inode_lock(dip
, 0);
1861 * The unlink XOP unlinks the path from the directory and
1862 * locates and returns the cluster associated with the real inode.
1863 * We have to handle nlinks here on the frontend.
1865 xop
= hammer2_xop_alloc(dip
, HAMMER2_XOP_MODIFYING
);
1866 hammer2_xop_setname(&xop
->head
, ncp
->nc_name
, ncp
->nc_nlen
);
1869 * The namecache entry is locked so nobody can use this namespace.
1870 * Calculate isopen to determine if this namespace has an open vp
1871 * associated with it and resolve the vp only if it does.
1873 * We try to avoid resolving the vnode if nobody has it open, but
1874 * note that the test is via this namespace only.
1876 isopen
= cache_isopen(ap
->a_nch
);
1878 xop
->dopermanent
= 0;
1879 hammer2_xop_start(&xop
->head
, hammer2_xop_unlink
);
1882 * Collect the real inode and adjust nlinks, destroy the real
1883 * inode if nlinks transitions to 0 and it was the real inode
1884 * (else it has already been removed).
1886 error
= hammer2_xop_collect(&xop
->head
, 0);
1887 error
= hammer2_error_to_errno(error
);
1888 hammer2_inode_unlock(dip
);
1891 ip
= hammer2_inode_get(dip
->pmp
, dip
, &xop
->head
, -1);
1892 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1894 hammer2_inode_unlink_finisher(ip
, isopen
);
1895 hammer2_inode_unlock(ip
);
1898 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1902 * Update dip's mtime
1907 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1908 hammer2_update_time(&mtime
);
1909 hammer2_inode_modify(dip
);
1910 dip
->meta
.mtime
= mtime
;
1911 hammer2_inode_unlock(dip
);
1914 hammer2_trans_done(dip
->pmp
, 1);
1916 cache_unlink(ap
->a_nch
);
1917 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1923 * hammer2_vop_nrmdir { nch, dvp, cred }
1927 hammer2_vop_nrmdir(struct vop_nrmdir_args
*ap
)
1929 hammer2_xop_unlink_t
*xop
;
1930 hammer2_inode_t
*dip
;
1931 hammer2_inode_t
*ip
;
1932 struct namecache
*ncp
;
1936 dip
= VTOI(ap
->a_dvp
);
1937 if (dip
->pmp
->ronly
)
1940 /* allow removals, except user to also bulkfree */
1941 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1945 hammer2_pfs_memory_wait(dip
, 1);
1946 hammer2_trans_init(dip
->pmp
, 0);
1947 hammer2_inode_lock(dip
, 0);
1949 xop
= hammer2_xop_alloc(dip
, HAMMER2_XOP_MODIFYING
);
1951 ncp
= ap
->a_nch
->ncp
;
1952 hammer2_xop_setname(&xop
->head
, ncp
->nc_name
, ncp
->nc_nlen
);
1953 isopen
= cache_isopen(ap
->a_nch
);
1955 xop
->dopermanent
= 0;
1956 hammer2_xop_start(&xop
->head
, hammer2_xop_unlink
);
1959 * Collect the real inode and adjust nlinks, destroy the real
1960 * inode if nlinks transitions to 0 and it was the real inode
1961 * (else it has already been removed).
1963 error
= hammer2_xop_collect(&xop
->head
, 0);
1964 error
= hammer2_error_to_errno(error
);
1965 hammer2_inode_unlock(dip
);
1968 ip
= hammer2_inode_get(dip
->pmp
, dip
, &xop
->head
, -1);
1969 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1971 hammer2_inode_unlink_finisher(ip
, isopen
);
1972 hammer2_inode_unlock(ip
);
1975 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1979 * Update dip's mtime
1984 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1985 hammer2_update_time(&mtime
);
1986 hammer2_inode_modify(dip
);
1987 dip
->meta
.mtime
= mtime
;
1988 hammer2_inode_unlock(dip
);
1991 hammer2_trans_done(dip
->pmp
, 1);
1993 cache_unlink(ap
->a_nch
);
1994 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
| NOTE_LINK
);
2000 * hammer2_vop_nrename { fnch, tnch, fdvp, tdvp, cred }
2004 hammer2_vop_nrename(struct vop_nrename_args
*ap
)
2006 struct namecache
*fncp
;
2007 struct namecache
*tncp
;
2008 hammer2_inode_t
*fdip
; /* source directory */
2009 hammer2_inode_t
*tdip
; /* target directory */
2010 hammer2_inode_t
*ip
; /* file being renamed */
2011 hammer2_inode_t
*tip
; /* replaced target during rename or NULL */
2012 const uint8_t *fname
;
2014 const uint8_t *tname
;
2021 if (ap
->a_fdvp
->v_mount
!= ap
->a_tdvp
->v_mount
)
2023 if (ap
->a_fdvp
->v_mount
!= ap
->a_fnch
->ncp
->nc_vp
->v_mount
)
2026 fdip
= VTOI(ap
->a_fdvp
); /* source directory */
2027 tdip
= VTOI(ap
->a_tdvp
); /* target directory */
2029 if (fdip
->pmp
->ronly
)
2031 if (hammer2_vfs_enospace(fdip
, 0, ap
->a_cred
) > 1)
2034 fncp
= ap
->a_fnch
->ncp
; /* entry name in source */
2035 fname
= fncp
->nc_name
;
2036 fname_len
= fncp
->nc_nlen
;
2038 tncp
= ap
->a_tnch
->ncp
; /* entry name in target */
2039 tname
= tncp
->nc_name
;
2040 tname_len
= tncp
->nc_nlen
;
2042 hammer2_pfs_memory_wait(tdip
, 0);
2043 hammer2_trans_init(tdip
->pmp
, 0);
2048 ip
= VTOI(fncp
->nc_vp
);
2049 hammer2_inode_ref(ip
); /* extra ref */
2052 * Lookup the target name to determine if a directory entry
2053 * is being overwritten. We only hold related inode locks
2054 * temporarily, the operating system is expected to protect
2055 * against rename races.
2057 tip
= tncp
->nc_vp
? VTOI(tncp
->nc_vp
) : NULL
;
2059 hammer2_inode_ref(tip
); /* extra ref */
2062 * Can return NULL and error == EXDEV if the common parent
2063 * crosses a directory with the xlink flag set.
2065 * For now try to avoid deadlocks with a simple pointer address
2066 * test. (tip) can be NULL.
2070 hammer2_inode_lock(fdip
, 0);
2071 hammer2_inode_lock(tdip
, 0);
2073 hammer2_inode_lock(tdip
, 0);
2074 hammer2_inode_lock(fdip
, 0);
2078 hammer2_inode_lock(ip
, 0);
2079 hammer2_inode_lock(tip
, 0);
2081 hammer2_inode_lock(tip
, 0);
2082 hammer2_inode_lock(ip
, 0);
2085 hammer2_inode_lock(ip
, 0);
2090 * Delete the target namespace.
2092 * REMOVED - NOW FOLDED INTO XOP_NRENAME OPERATION
2095 hammer2_xop_unlink_t
*xop2
;
2096 hammer2_inode_t
*tip
;
2100 * The unlink XOP unlinks the path from the directory and
2101 * locates and returns the cluster associated with the real
2102 * inode. We have to handle nlinks here on the frontend.
2104 xop2
= hammer2_xop_alloc(tdip
, HAMMER2_XOP_MODIFYING
);
2105 hammer2_xop_setname(&xop2
->head
, tname
, tname_len
);
2106 isopen
= cache_isopen(ap
->a_tnch
);
2108 xop2
->dopermanent
= 0;
2109 hammer2_xop_start(&xop2
->head
, hammer2_xop_unlink
);
2112 * Collect the real inode and adjust nlinks, destroy the real
2113 * inode if nlinks transitions to 0 and it was the real inode
2114 * (else it has already been removed).
2116 tnch_error
= hammer2_xop_collect(&xop2
->head
, 0);
2117 tnch_error
= hammer2_error_to_errno(tnch_error
);
2118 /* hammer2_inode_unlock(tdip); */
2120 if (tnch_error
== 0) {
2121 tip
= hammer2_inode_get(tdip
->pmp
, NULL
,
2123 hammer2_xop_retire(&xop2
->head
, HAMMER2_XOPMASK_VOP
);
2125 hammer2_inode_unlink_finisher(tip
, isopen
);
2126 hammer2_inode_unlock(tip
);
2129 hammer2_xop_retire(&xop2
->head
, HAMMER2_XOPMASK_VOP
);
2131 /* hammer2_inode_lock(tdip, 0); */
2133 if (tnch_error
&& tnch_error
!= ENOENT
) {
2142 * Resolve the collision space for (tdip, tname, tname_len)
2144 * tdip must be held exclusively locked to prevent races since
2145 * multiple filenames can end up in the same collision space.
2148 hammer2_xop_scanlhc_t
*sxop
;
2149 hammer2_tid_t lhcbase
;
2151 tlhc
= hammer2_dirhash(tname
, tname_len
);
2153 sxop
= hammer2_xop_alloc(tdip
, HAMMER2_XOP_MODIFYING
);
2155 hammer2_xop_start(&sxop
->head
, hammer2_xop_scanlhc
);
2156 while ((error
= hammer2_xop_collect(&sxop
->head
, 0)) == 0) {
2157 if (tlhc
!= sxop
->head
.cluster
.focus
->bref
.key
)
2161 error
= hammer2_error_to_errno(error
);
2162 hammer2_xop_retire(&sxop
->head
, HAMMER2_XOPMASK_VOP
);
2165 if (error
!= ENOENT
)
2170 if ((lhcbase
^ tlhc
) & ~HAMMER2_DIRHASH_LOMASK
) {
2177 * Ready to go, issue the rename to the backend. Note that meta-data
2178 * updates to the related inodes occur separately from the rename
2181 * NOTE: While it is not necessary to update ip->meta.name*, doing
2182 * so aids catastrophic recovery and debugging.
2185 hammer2_xop_nrename_t
*xop4
;
2187 xop4
= hammer2_xop_alloc(fdip
, HAMMER2_XOP_MODIFYING
);
2189 xop4
->ip_key
= ip
->meta
.name_key
;
2190 hammer2_xop_setip2(&xop4
->head
, ip
);
2191 hammer2_xop_setip3(&xop4
->head
, tdip
);
2192 hammer2_xop_setname(&xop4
->head
, fname
, fname_len
);
2193 hammer2_xop_setname2(&xop4
->head
, tname
, tname_len
);
2194 hammer2_xop_start(&xop4
->head
, hammer2_xop_nrename
);
2196 error
= hammer2_xop_collect(&xop4
->head
, 0);
2197 error
= hammer2_error_to_errno(error
);
2198 hammer2_xop_retire(&xop4
->head
, HAMMER2_XOPMASK_VOP
);
2200 if (error
== ENOENT
)
2204 * Update inode meta-data.
2206 * WARNING! The in-memory inode (ip) structure does not
2207 * maintain a copy of the inode's filename buffer.
2210 (ip
->meta
.name_key
& HAMMER2_DIRHASH_VISIBLE
)) {
2211 hammer2_inode_modify(ip
);
2212 ip
->meta
.name_len
= tname_len
;
2213 ip
->meta
.name_key
= tlhc
;
2216 hammer2_inode_modify(ip
);
2217 ip
->meta
.iparent
= tdip
->meta
.inum
;
2225 * If no error, the backend has replaced the target directory entry.
2226 * We must adjust nlinks on the original replace target if it exists.
2228 if (error
== 0 && tip
) {
2231 isopen
= cache_isopen(ap
->a_tnch
);
2232 hammer2_inode_unlink_finisher(tip
, isopen
);
2236 * Update directory mtimes to represent the something changed.
2238 if (update_fdip
|| update_tdip
) {
2241 hammer2_update_time(&mtime
);
2243 hammer2_inode_modify(fdip
);
2244 fdip
->meta
.mtime
= mtime
;
2247 hammer2_inode_modify(tdip
);
2248 tdip
->meta
.mtime
= mtime
;
2252 hammer2_inode_unlock(tip
);
2253 hammer2_inode_drop(tip
);
2255 hammer2_inode_unlock(ip
);
2256 hammer2_inode_unlock(tdip
);
2257 hammer2_inode_unlock(fdip
);
2258 hammer2_inode_drop(ip
);
2259 hammer2_trans_done(tdip
->pmp
, 1);
2262 * Issue the namecache update after unlocking all the internal
2263 * hammer2 structures, otherwise we might deadlock.
2265 * WARNING! The target namespace must be updated atomically,
2266 * and we depend on cache_rename() to handle that for
2267 * us. Do not do a separate cache_unlink() because
2268 * that leaves a small window of opportunity for other
2269 * threads to allocate the target namespace before we
2270 * manage to complete our rename.
2272 * WARNING! cache_rename() (and cache_unlink()) will properly
2273 * set VREF_FINALIZE on any attached vnode. Do not
2274 * call cache_setunresolved() manually before-hand as
2275 * this will prevent the flag from being set later via
2276 * cache_rename(). If VREF_FINALIZE is not properly set
2277 * and the inode is no longer in the topology, related
2278 * chains can remain dirty indefinitely.
2280 if (error
== 0 && tip
) {
2281 /*cache_unlink(ap->a_tnch); see above */
2282 /*cache_setunresolved(ap->a_tnch); see above */
2285 cache_rename(ap
->a_fnch
, ap
->a_tnch
);
2286 hammer2_knote(ap
->a_fdvp
, NOTE_WRITE
);
2287 hammer2_knote(ap
->a_tdvp
, NOTE_WRITE
);
2288 hammer2_knote(fncp
->nc_vp
, NOTE_RENAME
);
2295 * hammer2_vop_ioctl { vp, command, data, fflag, cred }
2299 hammer2_vop_ioctl(struct vop_ioctl_args
*ap
)
2301 hammer2_inode_t
*ip
;
2304 ip
= VTOI(ap
->a_vp
);
2306 error
= hammer2_ioctl(ip
, ap
->a_command
, (void *)ap
->a_data
,
2307 ap
->a_fflag
, ap
->a_cred
);
2313 hammer2_vop_mountctl(struct vop_mountctl_args
*ap
)
2320 case (MOUNTCTL_SET_EXPORT
):
2321 mp
= ap
->a_head
.a_ops
->head
.vv_mount
;
2324 if (ap
->a_ctllen
!= sizeof(struct export_args
))
2327 rc
= vfs_export(mp
, &pmp
->export
,
2328 (const struct export_args
*)ap
->a_ctl
);
2331 rc
= vop_stdmountctl(ap
);
2340 static void filt_hammer2detach(struct knote
*kn
);
2341 static int filt_hammer2read(struct knote
*kn
, long hint
);
2342 static int filt_hammer2write(struct knote
*kn
, long hint
);
2343 static int filt_hammer2vnode(struct knote
*kn
, long hint
);
2345 static struct filterops hammer2read_filtops
=
2346 { FILTEROP_ISFD
| FILTEROP_MPSAFE
,
2347 NULL
, filt_hammer2detach
, filt_hammer2read
};
2348 static struct filterops hammer2write_filtops
=
2349 { FILTEROP_ISFD
| FILTEROP_MPSAFE
,
2350 NULL
, filt_hammer2detach
, filt_hammer2write
};
2351 static struct filterops hammer2vnode_filtops
=
2352 { FILTEROP_ISFD
| FILTEROP_MPSAFE
,
2353 NULL
, filt_hammer2detach
, filt_hammer2vnode
};
2357 hammer2_vop_kqfilter(struct vop_kqfilter_args
*ap
)
2359 struct vnode
*vp
= ap
->a_vp
;
2360 struct knote
*kn
= ap
->a_kn
;
2362 switch (kn
->kn_filter
) {
2364 kn
->kn_fop
= &hammer2read_filtops
;
2367 kn
->kn_fop
= &hammer2write_filtops
;
2370 kn
->kn_fop
= &hammer2vnode_filtops
;
2373 return (EOPNOTSUPP
);
2376 kn
->kn_hook
= (caddr_t
)vp
;
2378 knote_insert(&vp
->v_pollinfo
.vpi_kqinfo
.ki_note
, kn
);
2384 filt_hammer2detach(struct knote
*kn
)
2386 struct vnode
*vp
= (void *)kn
->kn_hook
;
2388 knote_remove(&vp
->v_pollinfo
.vpi_kqinfo
.ki_note
, kn
);
2392 filt_hammer2read(struct knote
*kn
, long hint
)
2394 struct vnode
*vp
= (void *)kn
->kn_hook
;
2395 hammer2_inode_t
*ip
= VTOI(vp
);
2398 if (hint
== NOTE_REVOKE
) {
2399 kn
->kn_flags
|= (EV_EOF
| EV_NODATA
| EV_ONESHOT
);
2402 off
= ip
->meta
.size
- kn
->kn_fp
->f_offset
;
2403 kn
->kn_data
= (off
< INTPTR_MAX
) ? off
: INTPTR_MAX
;
2404 if (kn
->kn_sfflags
& NOTE_OLDAPI
)
2406 return (kn
->kn_data
!= 0);
2411 filt_hammer2write(struct knote
*kn
, long hint
)
2413 if (hint
== NOTE_REVOKE
)
2414 kn
->kn_flags
|= (EV_EOF
| EV_NODATA
| EV_ONESHOT
);
2420 filt_hammer2vnode(struct knote
*kn
, long hint
)
2422 if (kn
->kn_sfflags
& hint
)
2423 kn
->kn_fflags
|= hint
;
2424 if (hint
== NOTE_REVOKE
) {
2425 kn
->kn_flags
|= (EV_EOF
| EV_NODATA
);
2428 return (kn
->kn_fflags
!= 0);
2436 hammer2_vop_markatime(struct vop_markatime_args
*ap
)
2438 hammer2_inode_t
*ip
;
2451 hammer2_vop_fifokqfilter(struct vop_kqfilter_args
*ap
)
2455 error
= VOCALL(&fifo_vnode_vops
, &ap
->a_head
);
2457 error
= hammer2_vop_kqfilter(ap
);
2464 struct vop_ops hammer2_vnode_vops
= {
2465 .vop_default
= vop_defaultop
,
2466 .vop_fsync
= hammer2_vop_fsync
,
2467 .vop_getpages
= vop_stdgetpages
,
2468 .vop_putpages
= vop_stdputpages
,
2469 .vop_access
= hammer2_vop_access
,
2470 .vop_advlock
= hammer2_vop_advlock
,
2471 .vop_close
= hammer2_vop_close
,
2472 .vop_nlink
= hammer2_vop_nlink
,
2473 .vop_ncreate
= hammer2_vop_ncreate
,
2474 .vop_nsymlink
= hammer2_vop_nsymlink
,
2475 .vop_nremove
= hammer2_vop_nremove
,
2476 .vop_nrmdir
= hammer2_vop_nrmdir
,
2477 .vop_nrename
= hammer2_vop_nrename
,
2478 .vop_getattr
= hammer2_vop_getattr
,
2479 .vop_setattr
= hammer2_vop_setattr
,
2480 .vop_readdir
= hammer2_vop_readdir
,
2481 .vop_readlink
= hammer2_vop_readlink
,
2482 .vop_read
= hammer2_vop_read
,
2483 .vop_write
= hammer2_vop_write
,
2484 .vop_open
= hammer2_vop_open
,
2485 .vop_inactive
= hammer2_vop_inactive
,
2486 .vop_reclaim
= hammer2_vop_reclaim
,
2487 .vop_nresolve
= hammer2_vop_nresolve
,
2488 .vop_nlookupdotdot
= hammer2_vop_nlookupdotdot
,
2489 .vop_nmkdir
= hammer2_vop_nmkdir
,
2490 .vop_nmknod
= hammer2_vop_nmknod
,
2491 .vop_ioctl
= hammer2_vop_ioctl
,
2492 .vop_mountctl
= hammer2_vop_mountctl
,
2493 .vop_bmap
= hammer2_vop_bmap
,
2494 .vop_strategy
= hammer2_vop_strategy
,
2495 .vop_kqfilter
= hammer2_vop_kqfilter
2498 struct vop_ops hammer2_spec_vops
= {
2499 .vop_default
= vop_defaultop
,
2500 .vop_fsync
= hammer2_vop_fsync
,
2501 .vop_read
= vop_stdnoread
,
2502 .vop_write
= vop_stdnowrite
,
2503 .vop_access
= hammer2_vop_access
,
2504 .vop_close
= hammer2_vop_close
,
2505 .vop_markatime
= hammer2_vop_markatime
,
2506 .vop_getattr
= hammer2_vop_getattr
,
2507 .vop_inactive
= hammer2_vop_inactive
,
2508 .vop_reclaim
= hammer2_vop_reclaim
,
2509 .vop_setattr
= hammer2_vop_setattr
2512 struct vop_ops hammer2_fifo_vops
= {
2513 .vop_default
= fifo_vnoperate
,
2514 .vop_fsync
= hammer2_vop_fsync
,
2516 .vop_read
= hammer2_vop_fiforead
,
2517 .vop_write
= hammer2_vop_fifowrite
,
2519 .vop_access
= hammer2_vop_access
,
2521 .vop_close
= hammer2_vop_fifoclose
,
2523 .vop_markatime
= hammer2_vop_markatime
,
2524 .vop_getattr
= hammer2_vop_getattr
,
2525 .vop_inactive
= hammer2_vop_inactive
,
2526 .vop_reclaim
= hammer2_vop_reclaim
,
2527 .vop_setattr
= hammer2_vop_setattr
,
2528 .vop_kqfilter
= hammer2_vop_fifokqfilter