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/mount.h>
50 #include <sys/vnode.h>
51 #include <sys/mountctl.h>
52 #include <sys/dirent.h>
54 #include <sys/objcache.h>
55 #include <sys/event.h>
57 #include <vfs/fifofs/fifo.h>
61 static int hammer2_read_file(hammer2_inode_t
*ip
, struct uio
*uio
,
63 static int hammer2_write_file(hammer2_inode_t
*ip
, struct uio
*uio
,
64 int ioflag
, int seqcount
);
65 static void hammer2_extend_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
);
66 static void hammer2_truncate_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
);
69 * Last reference to a vnode is going away but it is still cached.
73 hammer2_vop_inactive(struct vop_inactive_args
*ap
)
90 * Aquire the inode lock to interlock against vp updates via
91 * the inode path and file deletions and such (which can be
92 * namespace-only operations that might not hold the vnode).
94 hammer2_inode_lock(ip
, 0);
95 if (ip
->flags
& HAMMER2_INODE_ISUNLINKED
) {
100 * If the inode has been unlinked we can throw away all
101 * buffers (dirty or not) and clean the file out.
103 * Because vrecycle() calls are not guaranteed, try to
104 * dispose of the inode as much as possible right here.
106 nblksize
= hammer2_calc_logical(ip
, 0, &lbase
, NULL
);
107 nvtruncbuf(vp
, 0, nblksize
, 0, 0);
110 * Delete the file on-media.
112 if ((ip
->flags
& HAMMER2_INODE_DELETING
) == 0) {
113 atomic_set_int(&ip
->flags
, HAMMER2_INODE_DELETING
);
114 hammer2_inode_delayed_sideq(ip
);
116 hammer2_inode_unlock(ip
);
119 * Recycle immediately if possible
123 hammer2_inode_unlock(ip
);
129 * Reclaim a vnode so that it can be reused; after the inode is
130 * disassociated, the filesystem must manage it alone.
134 hammer2_vop_reclaim(struct vop_reclaim_args
*ap
)
145 * NOTE! We do not attempt to flush chains here, flushing is
146 * really fragile and could also deadlock.
151 * The inode lock is required to disconnect it.
153 hammer2_inode_lock(ip
, 0);
158 * Delete the file on-media. This should have been handled by the
159 * inactivation. The operation is likely still queued on the inode
160 * though so only complain if the stars don't align.
162 if ((ip
->flags
& (HAMMER2_INODE_ISUNLINKED
| HAMMER2_INODE_DELETING
)) ==
163 HAMMER2_INODE_ISUNLINKED
)
165 atomic_set_int(&ip
->flags
, HAMMER2_INODE_DELETING
);
166 hammer2_inode_delayed_sideq(ip
);
167 kprintf("hammer2: vp=%p ip=%p unlinked but not disposed\n",
170 hammer2_inode_unlock(ip
);
173 * Modified inodes will already be on SIDEQ or SYNCQ, no further
176 * We cannot safely synchronize the inode from inside the reclaim
177 * due to potentially deep locks held as-of when the reclaim occurs.
178 * Interactions and potential deadlocks abound. We also can't do it
179 * here without desynchronizing from the related directory entrie(s).
181 hammer2_inode_drop(ip
); /* vp ref */
184 * XXX handle background sync when ip dirty, kernel will no longer
185 * notify us regarding this inode because there is no longer a
186 * vnode attached to it.
193 * Currently this function synchronizes the front-end inode state to the
194 * backend chain topology, then flushes the inode's chain and sub-topology
195 * to backend media. This function does not flush the root topology down to
200 hammer2_vop_fsync(struct vop_fsync_args
*ap
)
211 hammer2_trans_init(ip
->pmp
, 0);
214 * Flush dirty buffers in the file's logical buffer cache.
215 * It is best to wait for the strategy code to commit the
216 * buffers to the device's backing buffer cache before
217 * then trying to flush the inode.
219 * This should be quick, but certain inode modifications cached
220 * entirely in the hammer2_inode structure may not trigger a
221 * buffer read until the flush so the fsync can wind up also
222 * doing scattered reads.
224 vfsync(vp
, ap
->a_waitfor
, 1, NULL
, NULL
);
225 bio_track_wait(&vp
->v_track_write
, 0, 0);
228 * Flush any inode changes
230 hammer2_inode_lock(ip
, 0);
231 if (ip
->flags
& (HAMMER2_INODE_RESIZED
|HAMMER2_INODE_MODIFIED
))
232 error1
= hammer2_inode_chain_sync(ip
);
235 * Flush dirty chains related to the inode.
237 * NOTE! We are not in a flush transaction. The inode remains on
238 * the sideq so the filesystem syncer can synchronize it to
241 error2
= hammer2_inode_chain_flush(ip
, HAMMER2_XOP_INODE_STOP
);
246 * We may be able to clear the vnode dirty flag.
248 if ((ip
->flags
& (HAMMER2_INODE_MODIFIED
|
249 HAMMER2_INODE_RESIZED
|
250 HAMMER2_INODE_DIRTYDATA
)) == 0 &&
251 RB_EMPTY(&vp
->v_rbdirty_tree
) &&
252 !bio_track_active(&vp
->v_track_write
)) {
255 hammer2_inode_unlock(ip
);
256 hammer2_trans_done(ip
->pmp
, 0);
262 * No lock needed, just handle ip->update
266 hammer2_vop_access(struct vop_access_args
*ap
)
268 hammer2_inode_t
*ip
= VTOI(ap
->a_vp
);
277 update
= spin_access_start(&ip
->cluster_spin
);
279 /*hammer2_inode_lock(ip, HAMMER2_RESOLVE_SHARED);*/
280 uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
281 gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
282 mode
= ip
->meta
.mode
;
283 uflags
= ip
->meta
.uflags
;
284 /*hammer2_inode_unlock(ip);*/
286 if (__predict_false(spin_access_end(&ip
->cluster_spin
, update
)))
289 error
= vop_helper_access(ap
, uid
, gid
, mode
, uflags
);
296 hammer2_vop_getattr(struct vop_getattr_args
*ap
)
311 update
= spin_access_start(&ip
->cluster_spin
);
313 vap
->va_fsid
= pmp
->mp
->mnt_stat
.f_fsid
.val
[0];
314 vap
->va_fileid
= ip
->meta
.inum
;
315 vap
->va_mode
= ip
->meta
.mode
;
316 vap
->va_nlink
= ip
->meta
.nlinks
;
317 vap
->va_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
318 vap
->va_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
321 vap
->va_size
= ip
->meta
.size
; /* protected by shared lock */
322 vap
->va_blocksize
= HAMMER2_PBUFSIZE
;
323 vap
->va_flags
= ip
->meta
.uflags
;
324 hammer2_time_to_timespec(ip
->meta
.ctime
, &vap
->va_ctime
);
325 hammer2_time_to_timespec(ip
->meta
.mtime
, &vap
->va_mtime
);
326 hammer2_time_to_timespec(ip
->meta
.mtime
, &vap
->va_atime
);
329 if (ip
->meta
.type
== HAMMER2_OBJTYPE_DIRECTORY
) {
331 * Can't really calculate directory use sans the files under
332 * it, just assume one block for now.
334 vap
->va_bytes
+= HAMMER2_INODE_BYTES
;
336 vap
->va_bytes
= hammer2_inode_data_count(ip
);
338 vap
->va_type
= hammer2_get_vtype(ip
->meta
.type
);
340 vap
->va_uid_uuid
= ip
->meta
.uid
;
341 vap
->va_gid_uuid
= ip
->meta
.gid
;
342 vap
->va_vaflags
= VA_UID_UUID_VALID
| VA_GID_UUID_VALID
|
345 if (__predict_false(spin_access_end(&ip
->cluster_spin
, update
)))
353 hammer2_vop_getattr_lite(struct vop_getattr_lite_args
*ap
)
358 struct vattr_lite
*lvap
;
368 update
= spin_access_start(&ip
->cluster_spin
);
371 vap
->va_fsid
= pmp
->mp
->mnt_stat
.f_fsid
.val
[0];
372 vap
->va_fileid
= ip
->meta
.inum
;
374 lvap
->va_mode
= ip
->meta
.mode
;
375 lvap
->va_nlink
= ip
->meta
.nlinks
;
376 lvap
->va_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
377 lvap
->va_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
382 lvap
->va_size
= ip
->meta
.size
;
384 vap
->va_blocksize
= HAMMER2_PBUFSIZE
;
386 lvap
->va_flags
= ip
->meta
.uflags
;
387 lvap
->va_type
= hammer2_get_vtype(ip
->meta
.type
);
390 vap
->va_uid_uuid
= ip
->meta
.uid
;
391 vap
->va_gid_uuid
= ip
->meta
.gid
;
392 vap
->va_vaflags
= VA_UID_UUID_VALID
| VA_GID_UUID_VALID
|
396 if (__predict_false(spin_access_end(&ip
->cluster_spin
, update
)))
404 hammer2_vop_setattr(struct vop_setattr_args
*ap
)
415 hammer2_update_time(&ctime
);
423 * Normally disallow setattr if there is no space, unless we
424 * are in emergency mode (might be needed to chflags -R noschg
425 * files prior to removal).
427 if ((ip
->pmp
->flags
& HAMMER2_PMPF_EMERG
) == 0 &&
428 hammer2_vfs_enospace(ip
, 0, ap
->a_cred
) > 1) {
432 hammer2_trans_init(ip
->pmp
, 0);
433 hammer2_inode_lock(ip
, 0);
436 if (vap
->va_flags
!= VNOVAL
) {
439 flags
= ip
->meta
.uflags
;
440 error
= vop_helper_setattr_flags(&flags
, vap
->va_flags
,
441 hammer2_to_unix_xid(&ip
->meta
.uid
),
444 if (ip
->meta
.uflags
!= flags
) {
445 hammer2_inode_modify(ip
);
446 hammer2_spin_lock_update(&ip
->cluster_spin
);
447 ip
->meta
.uflags
= flags
;
448 ip
->meta
.ctime
= ctime
;
449 hammer2_spin_unlock_update(&ip
->cluster_spin
);
450 kflags
|= NOTE_ATTRIB
;
452 if (ip
->meta
.uflags
& (IMMUTABLE
| APPEND
)) {
459 if (ip
->meta
.uflags
& (IMMUTABLE
| APPEND
)) {
463 if (vap
->va_uid
!= (uid_t
)VNOVAL
|| vap
->va_gid
!= (gid_t
)VNOVAL
) {
464 mode_t cur_mode
= ip
->meta
.mode
;
465 uid_t cur_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
466 gid_t cur_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
470 error
= vop_helper_chown(ap
->a_vp
, vap
->va_uid
, vap
->va_gid
,
472 &cur_uid
, &cur_gid
, &cur_mode
);
474 hammer2_guid_to_uuid(&uuid_uid
, cur_uid
);
475 hammer2_guid_to_uuid(&uuid_gid
, cur_gid
);
476 if (bcmp(&uuid_uid
, &ip
->meta
.uid
, sizeof(uuid_uid
)) ||
477 bcmp(&uuid_gid
, &ip
->meta
.gid
, sizeof(uuid_gid
)) ||
478 ip
->meta
.mode
!= cur_mode
480 hammer2_inode_modify(ip
);
481 hammer2_spin_lock_update(&ip
->cluster_spin
);
482 ip
->meta
.uid
= uuid_uid
;
483 ip
->meta
.gid
= uuid_gid
;
484 ip
->meta
.mode
= cur_mode
;
485 ip
->meta
.ctime
= ctime
;
486 hammer2_spin_unlock_update(&ip
->cluster_spin
);
488 kflags
|= NOTE_ATTRIB
;
495 if (vap
->va_size
!= VNOVAL
&& ip
->meta
.size
!= vap
->va_size
) {
498 if (vap
->va_size
== ip
->meta
.size
)
500 if (vap
->va_size
< ip
->meta
.size
) {
501 hammer2_mtx_ex(&ip
->truncate_lock
);
502 hammer2_truncate_file(ip
, vap
->va_size
);
503 hammer2_mtx_unlock(&ip
->truncate_lock
);
504 kflags
|= NOTE_WRITE
;
506 hammer2_extend_file(ip
, vap
->va_size
);
507 kflags
|= NOTE_WRITE
| NOTE_EXTEND
;
509 hammer2_inode_modify(ip
);
510 ip
->meta
.mtime
= ctime
;
511 vclrflags(vp
, VLASTWRITETS
);
519 /* atime not supported */
520 if (vap
->va_atime
.tv_sec
!= VNOVAL
) {
521 hammer2_inode_modify(ip
);
522 ip
->meta
.atime
= hammer2_timespec_to_time(&vap
->va_atime
);
523 kflags
|= NOTE_ATTRIB
;
526 if (vap
->va_mode
!= (mode_t
)VNOVAL
) {
527 mode_t cur_mode
= ip
->meta
.mode
;
528 uid_t cur_uid
= hammer2_to_unix_xid(&ip
->meta
.uid
);
529 gid_t cur_gid
= hammer2_to_unix_xid(&ip
->meta
.gid
);
531 error
= vop_helper_chmod(ap
->a_vp
, vap
->va_mode
, ap
->a_cred
,
532 cur_uid
, cur_gid
, &cur_mode
);
534 hammer2_inode_modify(ip
);
535 hammer2_spin_lock_update(&ip
->cluster_spin
);
536 ip
->meta
.mode
= cur_mode
;
537 ip
->meta
.ctime
= ctime
;
538 hammer2_spin_unlock_update(&ip
->cluster_spin
);
539 kflags
|= NOTE_ATTRIB
;
543 if (vap
->va_mtime
.tv_sec
!= VNOVAL
) {
544 hammer2_inode_modify(ip
);
545 ip
->meta
.mtime
= hammer2_timespec_to_time(&vap
->va_mtime
);
546 kflags
|= NOTE_ATTRIB
;
547 vclrflags(vp
, VLASTWRITETS
);
552 * If a truncation occurred we must call chain_sync() now in order
553 * to trim the related data chains, otherwise a later expansion can
556 * If an extend occured that changed the DIRECTDATA state, we must
557 * call inode_chain_sync now in order to prepare the inode's indirect
560 * WARNING! This means we are making an adjustment to the inode's
561 * chain outside of sync/fsync, and not just to inode->meta, which
562 * may result in some consistency issues if a crash were to occur
563 * at just the wrong time.
565 if (ip
->flags
& HAMMER2_INODE_RESIZED
)
566 hammer2_inode_chain_sync(ip
);
571 hammer2_inode_unlock(ip
);
572 hammer2_trans_done(ip
->pmp
, HAMMER2_TRANS_SIDEQ
);
573 hammer2_knote(ip
->vp
, kflags
);
580 hammer2_vop_readdir(struct vop_readdir_args
*ap
)
582 hammer2_xop_readdir_t
*xop
;
583 hammer2_blockref_t bref
;
598 saveoff
= uio
->uio_offset
;
603 * Setup cookies directory entry cookies if requested
605 if (ap
->a_ncookies
) {
606 ncookies
= uio
->uio_resid
/ 16 + 1;
609 cookies
= kmalloc(ncookies
* sizeof(off_t
), M_TEMP
, M_WAITOK
);
616 hammer2_inode_lock(ip
, HAMMER2_RESOLVE_SHARED
);
619 * Handle artificial entries. To ensure that only positive 64 bit
620 * quantities are returned to userland we always strip off bit 63.
621 * The hash code is designed such that codes 0x0000-0x7FFF are not
622 * used, allowing us to use these codes for articial entries.
624 * Entry 0 is used for '.' and entry 1 is used for '..'. Do not
625 * allow '..' to cross the mount point into (e.g.) the super-root.
628 inum
= ip
->meta
.inum
& HAMMER2_DIRHASH_USERMSK
;
629 r
= vop_write_dirent(&error
, uio
, inum
, DT_DIR
, 1, ".");
633 cookies
[cookie_index
] = saveoff
;
636 if (cookie_index
== ncookies
)
641 inum
= ip
->meta
.inum
& HAMMER2_DIRHASH_USERMSK
;
642 if (ip
!= ip
->pmp
->iroot
)
643 inum
= ip
->meta
.iparent
& HAMMER2_DIRHASH_USERMSK
;
644 r
= vop_write_dirent(&error
, uio
, inum
, DT_DIR
, 2, "..");
648 cookies
[cookie_index
] = saveoff
;
651 if (cookie_index
== ncookies
)
655 lkey
= saveoff
| HAMMER2_DIRHASH_VISIBLE
;
656 if (hammer2_debug
& 0x0020)
657 kprintf("readdir: lkey %016jx\n", lkey
);
661 xop
= hammer2_xop_alloc(ip
, 0);
663 hammer2_xop_start(&xop
->head
, &hammer2_readdir_desc
);
666 const hammer2_inode_data_t
*ripdata
;
670 error
= hammer2_xop_collect(&xop
->head
, 0);
671 error
= hammer2_error_to_errno(error
);
675 if (cookie_index
== ncookies
)
677 if (hammer2_debug
& 0x0020)
678 kprintf("cluster chain %p %p\n",
679 xop
->head
.cluster
.focus
,
680 (xop
->head
.cluster
.focus
?
681 xop
->head
.cluster
.focus
->data
: (void *)-1));
682 hammer2_cluster_bref(&xop
->head
.cluster
, &bref
);
684 if (bref
.type
== HAMMER2_BREF_TYPE_INODE
) {
685 ripdata
= &hammer2_xop_gdata(&xop
->head
)->ipdata
;
686 dtype
= hammer2_get_dtype(ripdata
->meta
.type
);
687 saveoff
= bref
.key
& HAMMER2_DIRHASH_USERMSK
;
688 r
= vop_write_dirent(&error
, uio
,
690 HAMMER2_DIRHASH_USERMSK
,
692 ripdata
->meta
.name_len
,
694 hammer2_xop_pdata(&xop
->head
);
698 cookies
[cookie_index
] = saveoff
;
700 } else if (bref
.type
== HAMMER2_BREF_TYPE_DIRENT
) {
703 dtype
= hammer2_get_dtype(bref
.embed
.dirent
.type
);
704 saveoff
= bref
.key
& HAMMER2_DIRHASH_USERMSK
;
705 namlen
= bref
.embed
.dirent
.namlen
;
706 if (namlen
<= sizeof(bref
.check
.buf
)) {
707 dname
= bref
.check
.buf
;
709 dname
= hammer2_xop_gdata(&xop
->head
)->buf
;
711 r
= vop_write_dirent(&error
, uio
,
712 bref
.embed
.dirent
.inum
, dtype
,
714 if (namlen
> sizeof(bref
.check
.buf
))
715 hammer2_xop_pdata(&xop
->head
);
719 cookies
[cookie_index
] = saveoff
;
722 /* XXX chain error */
723 kprintf("bad chain type readdir %d\n", bref
.type
);
726 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
727 if (error
== ENOENT
) {
730 saveoff
= (hammer2_key_t
)-1;
732 saveoff
= bref
.key
& HAMMER2_DIRHASH_USERMSK
;
735 hammer2_inode_unlock(ip
);
737 *ap
->a_eofflag
= eofflag
;
738 if (hammer2_debug
& 0x0020)
739 kprintf("readdir: done at %016jx\n", saveoff
);
740 uio
->uio_offset
= saveoff
& ~HAMMER2_DIRHASH_VISIBLE
;
741 if (error
&& cookie_index
== 0) {
743 kfree(cookies
, M_TEMP
);
745 *ap
->a_cookies
= NULL
;
749 *ap
->a_ncookies
= cookie_index
;
750 *ap
->a_cookies
= cookies
;
757 * hammer2_vop_readlink { vp, uio, cred }
761 hammer2_vop_readlink(struct vop_readlink_args
*ap
)
768 if (vp
->v_type
!= VLNK
)
772 error
= hammer2_read_file(ip
, ap
->a_uio
, 0);
778 hammer2_vop_read(struct vop_read_args
*ap
)
787 * Read operations supported on this vnode?
790 if (vp
->v_type
== VDIR
)
792 if (vp
->v_type
!= VREG
)
802 seqcount
= ap
->a_ioflag
>> IO_SEQSHIFT
;
804 error
= hammer2_read_file(ip
, uio
, seqcount
);
810 hammer2_vop_write(struct vop_write_args
*ap
)
821 * Read operations supported on this vnode?
824 if (vp
->v_type
!= VREG
)
831 ioflag
= ap
->a_ioflag
;
834 if (ip
->pmp
->ronly
|| (ip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
836 switch (hammer2_vfs_enospace(ip
, uio
->uio_resid
, ap
->a_cred
)) {
840 ioflag
|= IO_DIRECT
; /* semi-synchronous */
846 seqcount
= ioflag
>> IO_SEQSHIFT
;
849 * Check resource limit
851 if (uio
->uio_resid
> 0 && (td
= uio
->uio_td
) != NULL
&& td
->td_proc
&&
852 uio
->uio_offset
+ uio
->uio_resid
>
853 td
->td_proc
->p_rlimit
[RLIMIT_FSIZE
].rlim_cur
) {
854 lwpsignal(td
->td_proc
, td
->td_lwp
, SIGXFSZ
);
859 * The transaction interlocks against flush initiations
860 * (note: but will run concurrently with the actual flush).
862 * To avoid deadlocking against the VM system, we must flag any
863 * transaction related to the buffer cache or other direct
864 * VM page manipulation.
866 if (uio
->uio_segflg
== UIO_NOCOPY
) {
867 hammer2_trans_init(ip
->pmp
, HAMMER2_TRANS_BUFCACHE
);
869 hammer2_trans_init(ip
->pmp
, 0);
871 error
= hammer2_write_file(ip
, uio
, ioflag
, seqcount
);
872 if (uio
->uio_segflg
== UIO_NOCOPY
)
873 hammer2_trans_done(ip
->pmp
, HAMMER2_TRANS_BUFCACHE
|
874 HAMMER2_TRANS_SIDEQ
);
876 hammer2_trans_done(ip
->pmp
, HAMMER2_TRANS_SIDEQ
);
882 * Perform read operations on a file or symlink given an UNLOCKED
885 * The passed ip is not locked.
889 hammer2_read_file(hammer2_inode_t
*ip
, struct uio
*uio
, int seqcount
)
900 * WARNING! Assumes that the kernel interlocks size changes at the
903 hammer2_mtx_sh(&ip
->lock
);
904 hammer2_mtx_sh(&ip
->truncate_lock
);
905 size
= ip
->meta
.size
;
906 hammer2_mtx_unlock(&ip
->lock
);
908 while (uio
->uio_resid
> 0 && uio
->uio_offset
< size
) {
915 lblksize
= hammer2_calc_logical(ip
, uio
->uio_offset
,
920 error
= cluster_readx(ip
->vp
, leof
, lbase
, lblksize
,
921 B_NOTMETA
| B_KVABIO
,
926 if (uio
->uio_segflg
== UIO_NOCOPY
) {
927 bp
= getblk(ip
->vp
, lbase
, lblksize
,
928 GETBLK_BHEAVY
| GETBLK_KVABIO
, 0);
929 if (bp
->b_flags
& B_CACHE
) {
932 if (bp
->b_xio
.xio_npages
!= 16)
933 kprintf("NPAGES BAD\n");
934 for (i
= 0; i
< bp
->b_xio
.xio_npages
; ++i
) {
936 m
= bp
->b_xio
.xio_pages
[i
];
937 if (m
== NULL
|| m
->valid
== 0) {
938 kprintf("bp %016jx %016jx pg %d inv",
941 kprintf("m->object %p/%p", m
->object
, ip
->vp
->v_object
);
947 kprintf("b_flags %08x, b_error %d\n", bp
->b_flags
, bp
->b_error
);
951 error
= bread_kvabio(ip
->vp
, lbase
, lblksize
, &bp
);
958 loff
= (int)(uio
->uio_offset
- lbase
);
960 if (n
> uio
->uio_resid
)
962 if (n
> size
- uio
->uio_offset
)
963 n
= (int)(size
- uio
->uio_offset
);
964 bp
->b_flags
|= B_AGE
;
965 uiomovebp(bp
, bp
->b_data
+ loff
, n
, uio
);
968 hammer2_mtx_unlock(&ip
->truncate_lock
);
974 * Write to the file represented by the inode via the logical buffer cache.
975 * The inode may represent a regular file or a symlink.
977 * The inode must not be locked.
981 hammer2_write_file(hammer2_inode_t
*ip
, struct uio
*uio
,
982 int ioflag
, int seqcount
)
984 hammer2_key_t old_eof
;
985 hammer2_key_t new_eof
;
994 * WARNING! Assumes that the kernel interlocks size changes at the
997 hammer2_mtx_ex(&ip
->lock
);
998 hammer2_mtx_sh(&ip
->truncate_lock
);
999 if (ioflag
& IO_APPEND
)
1000 uio
->uio_offset
= ip
->meta
.size
;
1001 old_eof
= ip
->meta
.size
;
1004 * Extend the file if necessary. If the write fails at some point
1005 * we will truncate it back down to cover as much as we were able
1008 * Doing this now makes it easier to calculate buffer sizes in
1015 if (uio
->uio_offset
+ uio
->uio_resid
> old_eof
) {
1016 new_eof
= uio
->uio_offset
+ uio
->uio_resid
;
1018 hammer2_extend_file(ip
, new_eof
);
1019 kflags
|= NOTE_EXTEND
;
1023 hammer2_mtx_unlock(&ip
->lock
);
1028 while (uio
->uio_resid
> 0) {
1029 hammer2_key_t lbase
;
1037 * Don't allow the buffer build to blow out the buffer
1040 if ((ioflag
& IO_RECURSE
) == 0)
1041 bwillwrite(HAMMER2_PBUFSIZE
);
1044 * This nominally tells us how much we can cluster and
1045 * what the logical buffer size needs to be. Currently
1046 * we don't try to cluster the write and just handle one
1049 lblksize
= hammer2_calc_logical(ip
, uio
->uio_offset
,
1051 loff
= (int)(uio
->uio_offset
- lbase
);
1053 KKASSERT(lblksize
<= MAXBSIZE
);
1056 * Calculate bytes to copy this transfer and whether the
1057 * copy completely covers the buffer or not.
1060 n
= lblksize
- loff
;
1061 if (n
> uio
->uio_resid
) {
1063 if (loff
== lbase
&& uio
->uio_offset
+ n
== new_eof
)
1071 if (lbase
>= new_eof
)
1077 if (uio
->uio_segflg
== UIO_NOCOPY
) {
1079 * Issuing a write with the same data backing the
1080 * buffer. Instantiate the buffer to collect the
1081 * backing vm pages, then read-in any missing bits.
1083 * This case is used by vop_stdputpages().
1085 bp
= getblk(ip
->vp
, lbase
, lblksize
,
1086 GETBLK_BHEAVY
| GETBLK_KVABIO
, 0);
1087 if ((bp
->b_flags
& B_CACHE
) == 0) {
1089 error
= bread_kvabio(ip
->vp
, lbase
,
1092 } else if (trivial
) {
1094 * Even though we are entirely overwriting the buffer
1095 * we may still have to zero it out to avoid a
1096 * mmap/write visibility issue.
1098 bp
= getblk(ip
->vp
, lbase
, lblksize
,
1099 GETBLK_BHEAVY
| GETBLK_KVABIO
, 0);
1100 if ((bp
->b_flags
& B_CACHE
) == 0)
1104 * Partial overwrite, read in any missing bits then
1105 * replace the portion being written.
1107 * (The strategy code will detect zero-fill physical
1108 * blocks for this case).
1110 error
= bread_kvabio(ip
->vp
, lbase
, lblksize
, &bp
);
1121 * Ok, copy the data in
1124 error
= uiomovebp(bp
, bp
->b_data
+ loff
, n
, uio
);
1125 kflags
|= NOTE_WRITE
;
1133 * WARNING: Pageout daemon will issue UIO_NOCOPY writes
1134 * with IO_SYNC or IO_ASYNC set. These writes
1135 * must be handled as the pageout daemon expects.
1137 * NOTE! H2 relies on cluster_write() here because it
1138 * cannot preallocate disk blocks at the logical
1139 * level due to not knowing what the compression
1140 * size will be at this time.
1142 * We must use cluster_write() here and we depend
1143 * on the write-behind feature to flush buffers
1144 * appropriately. If we let the buffer daemons do
1145 * it the block allocations will be all over the
1148 if (ioflag
& IO_SYNC
) {
1150 } else if ((ioflag
& IO_DIRECT
) && endofblk
) {
1152 } else if (ioflag
& IO_ASYNC
) {
1154 } else if (ip
->vp
->v_mount
->mnt_flag
& MNT_NOCLUSTERW
) {
1158 bp
->b_flags
|= B_CLUSTEROK
;
1159 cluster_write(bp
, new_eof
, lblksize
, seqcount
);
1161 bp
->b_flags
|= B_CLUSTEROK
;
1168 * Cleanup. If we extended the file EOF but failed to write through
1169 * the entire write is a failure and we have to back-up.
1171 if (error
&& new_eof
!= old_eof
) {
1172 hammer2_mtx_unlock(&ip
->truncate_lock
);
1173 hammer2_mtx_ex(&ip
->lock
); /* note lock order */
1174 hammer2_mtx_ex(&ip
->truncate_lock
); /* note lock order */
1175 hammer2_truncate_file(ip
, old_eof
);
1176 if (ip
->flags
& HAMMER2_INODE_MODIFIED
)
1177 hammer2_inode_chain_sync(ip
);
1178 hammer2_mtx_unlock(&ip
->lock
);
1179 } else if (modified
) {
1180 struct vnode
*vp
= ip
->vp
;
1182 hammer2_mtx_ex(&ip
->lock
);
1183 hammer2_inode_modify(ip
);
1184 if (uio
->uio_segflg
== UIO_NOCOPY
) {
1185 if (vp
->v_flag
& VLASTWRITETS
) {
1187 (unsigned long)vp
->v_lastwrite_ts
.tv_sec
*
1189 vp
->v_lastwrite_ts
.tv_nsec
/ 1000;
1192 hammer2_update_time(&ip
->meta
.mtime
);
1193 vclrflags(vp
, VLASTWRITETS
);
1198 * REMOVED - handled by hammer2_extend_file(). Do not issue
1199 * a chain_sync() outside of a sync/fsync except for DIRECTDATA
1202 * Under normal conditions we only issue a chain_sync if
1203 * the inode's DIRECTDATA state changed.
1205 if (ip
->flags
& HAMMER2_INODE_RESIZED
)
1206 hammer2_inode_chain_sync(ip
);
1208 hammer2_mtx_unlock(&ip
->lock
);
1209 hammer2_knote(ip
->vp
, kflags
);
1211 hammer2_trans_assert_strategy(ip
->pmp
);
1212 hammer2_mtx_unlock(&ip
->truncate_lock
);
1218 * Truncate the size of a file. The inode must be locked.
1220 * We must unconditionally set HAMMER2_INODE_RESIZED to properly
1221 * ensure that any on-media data beyond the new file EOF has been destroyed.
1223 * WARNING: nvtruncbuf() can only be safely called without the inode lock
1224 * held due to the way our write thread works. If the truncation
1225 * occurs in the middle of a buffer, nvtruncbuf() is responsible
1226 * for dirtying that buffer and zeroing out trailing bytes.
1228 * WARNING! Assumes that the kernel interlocks size changes at the
1231 * WARNING! Caller assumes responsibility for removing dead blocks
1232 * if INODE_RESIZED is set.
1236 hammer2_truncate_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
)
1238 hammer2_key_t lbase
;
1241 hammer2_mtx_unlock(&ip
->lock
);
1243 nblksize
= hammer2_calc_logical(ip
, nsize
, &lbase
, NULL
);
1244 nvtruncbuf(ip
->vp
, nsize
,
1245 nblksize
, (int)nsize
& (nblksize
- 1),
1248 hammer2_mtx_ex(&ip
->lock
);
1249 KKASSERT((ip
->flags
& HAMMER2_INODE_RESIZED
) == 0);
1250 ip
->osize
= ip
->meta
.size
;
1251 ip
->meta
.size
= nsize
;
1252 atomic_set_int(&ip
->flags
, HAMMER2_INODE_RESIZED
);
1253 hammer2_inode_modify(ip
);
1257 * Extend the size of a file. The inode must be locked.
1259 * Even though the file size is changing, we do not have to set the
1260 * INODE_RESIZED bit unless the file size crosses the EMBEDDED_BYTES
1261 * boundary. When this occurs a hammer2_inode_chain_sync() is required
1262 * to prepare the inode cluster's indirect block table, otherwise
1263 * async execution of the strategy code will implode on us.
1265 * WARNING! Assumes that the kernel interlocks size changes at the
1268 * WARNING! Caller assumes responsibility for transitioning out
1269 * of the inode DIRECTDATA mode if INODE_RESIZED is set.
1273 hammer2_extend_file(hammer2_inode_t
*ip
, hammer2_key_t nsize
)
1275 hammer2_key_t lbase
;
1276 hammer2_key_t osize
;
1281 KKASSERT((ip
->flags
& HAMMER2_INODE_RESIZED
) == 0);
1282 hammer2_inode_modify(ip
);
1283 osize
= ip
->meta
.size
;
1285 ip
->meta
.size
= nsize
;
1288 * We must issue a chain_sync() when the DIRECTDATA state changes
1289 * to prevent confusion between the flush code and the in-memory
1290 * state. This is not perfect because we are doing it outside of
1291 * a sync/fsync operation, so it might not be fully synchronized
1292 * with the meta-data topology flush.
1294 * We must retain and re-dirty the buffer cache buffer containing
1295 * the direct data so it can be written to a real block. It should
1296 * not be possible for a bread error to occur since the original data
1297 * is extracted from the inode structure directly.
1299 if (osize
<= HAMMER2_EMBEDDED_BYTES
&& nsize
> HAMMER2_EMBEDDED_BYTES
) {
1303 oblksize
= hammer2_calc_logical(ip
, 0, NULL
, NULL
);
1304 error
= bread_kvabio(ip
->vp
, 0, oblksize
, &bp
);
1305 atomic_set_int(&ip
->flags
, HAMMER2_INODE_RESIZED
);
1306 hammer2_inode_chain_sync(ip
);
1314 atomic_set_int(&ip
->flags
, HAMMER2_INODE_RESIZED
);
1315 hammer2_inode_chain_sync(ip
);
1318 hammer2_mtx_unlock(&ip
->lock
);
1320 oblksize
= hammer2_calc_logical(ip
, osize
, &lbase
, NULL
);
1321 nblksize
= hammer2_calc_logical(ip
, nsize
, &lbase
, NULL
);
1327 hammer2_mtx_ex(&ip
->lock
);
1332 hammer2_vop_nresolve(struct vop_nresolve_args
*ap
)
1334 hammer2_xop_nresolve_t
*xop
;
1335 hammer2_inode_t
*ip
;
1336 hammer2_inode_t
*dip
;
1337 struct namecache
*ncp
;
1341 dip
= VTOI(ap
->a_dvp
);
1342 xop
= hammer2_xop_alloc(dip
, 0);
1344 ncp
= ap
->a_nch
->ncp
;
1345 hammer2_xop_setname(&xop
->head
, ncp
->nc_name
, ncp
->nc_nlen
);
1348 * Note: In DragonFly the kernel handles '.' and '..'.
1350 hammer2_inode_lock(dip
, HAMMER2_RESOLVE_SHARED
);
1351 hammer2_xop_start(&xop
->head
, &hammer2_nresolve_desc
);
1353 error
= hammer2_xop_collect(&xop
->head
, 0);
1354 error
= hammer2_error_to_errno(error
);
1358 ip
= hammer2_inode_get(dip
->pmp
, &xop
->head
, -1, -1);
1360 hammer2_inode_unlock(dip
);
1363 * Acquire the related vnode
1365 * NOTE: For error processing, only ENOENT resolves the namecache
1366 * entry to NULL, otherwise we just return the error and
1367 * leave the namecache unresolved.
1369 * WARNING: inode structure is locked exclusively via inode_get
1370 * but chain was locked shared. inode_unlock()
1371 * will handle it properly.
1374 vp
= hammer2_igetv(ip
, &error
); /* error set to UNIX error */
1377 cache_setvp(ap
->a_nch
, vp
);
1378 } else if (error
== ENOENT
) {
1379 cache_setvp(ap
->a_nch
, NULL
);
1381 hammer2_inode_unlock(ip
);
1384 * The vp should not be released until after we've disposed
1385 * of our locks, because it might cause vop_inactive() to
1392 cache_setvp(ap
->a_nch
, NULL
);
1394 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1395 KASSERT(error
|| ap
->a_nch
->ncp
->nc_vp
!= NULL
,
1396 ("resolve error %d/%p ap %p\n",
1397 error
, ap
->a_nch
->ncp
->nc_vp
, ap
));
1404 hammer2_vop_nlookupdotdot(struct vop_nlookupdotdot_args
*ap
)
1406 hammer2_inode_t
*dip
;
1410 dip
= VTOI(ap
->a_dvp
);
1411 inum
= dip
->meta
.iparent
;
1415 error
= hammer2_vfs_vget(ap
->a_dvp
->v_mount
, NULL
,
1425 hammer2_vop_nmkdir(struct vop_nmkdir_args
*ap
)
1427 hammer2_inode_t
*dip
;
1428 hammer2_inode_t
*nip
;
1429 struct namecache
*ncp
;
1435 dip
= VTOI(ap
->a_dvp
);
1436 if (dip
->pmp
->ronly
|| (dip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
1438 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1441 ncp
= ap
->a_nch
->ncp
;
1442 name
= ncp
->nc_name
;
1443 name_len
= ncp
->nc_nlen
;
1445 hammer2_trans_init(dip
->pmp
, 0);
1447 inum
= hammer2_trans_newinum(dip
->pmp
);
1450 * Create the actual inode as a hidden file in the iroot, then
1451 * create the directory entry. The creation of the actual inode
1452 * sets its nlinks to 1 which is the value we desire.
1454 * dip must be locked before nip to avoid deadlock.
1456 hammer2_inode_lock(dip
, 0);
1457 nip
= hammer2_inode_create_normal(dip
, ap
->a_vap
, ap
->a_cred
,
1460 error
= hammer2_error_to_errno(error
);
1462 error
= hammer2_dirent_create(dip
, name
, name_len
,
1463 nip
->meta
.inum
, nip
->meta
.type
);
1464 /* returns UNIX error code */
1468 hammer2_inode_unlink_finisher(nip
, NULL
);
1469 hammer2_inode_unlock(nip
);
1475 * inode_depend() must occur before the igetv() because
1476 * the igetv() can temporarily release the inode lock.
1478 hammer2_inode_depend(dip
, nip
); /* before igetv */
1479 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1480 hammer2_inode_unlock(nip
);
1484 * Update dip's mtime
1486 * We can use a shared inode lock and allow the meta.mtime update
1487 * SMP race. hammer2_inode_modify() is MPSAFE w/a shared lock.
1492 /*hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);*/
1493 hammer2_update_time(&mtime
);
1494 hammer2_inode_modify(dip
);
1495 dip
->meta
.mtime
= mtime
;
1496 /*hammer2_inode_unlock(dip);*/
1498 hammer2_inode_unlock(dip
);
1500 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
1503 cache_setunresolved(ap
->a_nch
);
1504 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1505 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
| NOTE_LINK
);
1512 hammer2_vop_open(struct vop_open_args
*ap
)
1514 return vop_stdopen(ap
);
1518 * hammer2_vop_advlock { vp, id, op, fl, flags }
1522 hammer2_vop_advlock(struct vop_advlock_args
*ap
)
1524 hammer2_inode_t
*ip
= VTOI(ap
->a_vp
);
1527 size
= ip
->meta
.size
;
1528 return (lf_advlock(ap
, &ip
->advlock
, size
));
1533 hammer2_vop_close(struct vop_close_args
*ap
)
1535 return vop_stdclose(ap
);
1539 * hammer2_vop_nlink { nch, dvp, vp, cred }
1541 * Create a hardlink from (vp) to {dvp, nch}.
1545 hammer2_vop_nlink(struct vop_nlink_args
*ap
)
1547 hammer2_inode_t
*tdip
; /* target directory to create link in */
1548 hammer2_inode_t
*ip
; /* inode we are hardlinking to */
1549 struct namecache
*ncp
;
1555 if (ap
->a_dvp
->v_mount
!= ap
->a_vp
->v_mount
)
1558 tdip
= VTOI(ap
->a_dvp
);
1559 if (tdip
->pmp
->ronly
|| (tdip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
1561 if (hammer2_vfs_enospace(tdip
, 0, ap
->a_cred
) > 1)
1564 ncp
= ap
->a_nch
->ncp
;
1565 name
= ncp
->nc_name
;
1566 name_len
= ncp
->nc_nlen
;
1569 * ip represents the file being hardlinked. The file could be a
1570 * normal file or a hardlink target if it has already been hardlinked.
1571 * (with the new semantics, it will almost always be a hardlink
1574 * Bump nlinks and potentially also create or move the hardlink
1575 * target in the parent directory common to (ip) and (tdip). The
1576 * consolidation code can modify ip->cluster. The returned cluster
1579 ip
= VTOI(ap
->a_vp
);
1580 KASSERT(ip
->pmp
, ("ip->pmp is NULL %p %p", ip
, ip
->pmp
));
1581 hammer2_trans_init(ip
->pmp
, 0);
1584 * Target should be an indexed inode or there's no way we will ever
1585 * be able to find it!
1587 KKASSERT((ip
->meta
.name_key
& HAMMER2_DIRHASH_VISIBLE
) == 0);
1592 * Can return NULL and error == EXDEV if the common parent
1593 * crosses a directory with the xlink flag set.
1595 hammer2_inode_lock4(tdip
, ip
, NULL
, NULL
);
1597 hammer2_update_time(&cmtime
);
1600 * Create the directory entry and bump nlinks.
1601 * Also update ip's ctime.
1604 error
= hammer2_dirent_create(tdip
, name
, name_len
,
1605 ip
->meta
.inum
, ip
->meta
.type
);
1606 hammer2_inode_modify(ip
);
1608 ip
->meta
.ctime
= cmtime
;
1612 * Update dip's [cm]time
1614 hammer2_inode_modify(tdip
);
1615 tdip
->meta
.mtime
= cmtime
;
1616 tdip
->meta
.ctime
= cmtime
;
1618 cache_setunresolved(ap
->a_nch
);
1619 cache_setvp(ap
->a_nch
, ap
->a_vp
);
1621 hammer2_inode_unlock(ip
);
1622 hammer2_inode_unlock(tdip
);
1624 hammer2_trans_done(ip
->pmp
, HAMMER2_TRANS_SIDEQ
);
1625 hammer2_knote(ap
->a_vp
, NOTE_LINK
);
1626 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1632 * hammer2_vop_ncreate { nch, dvp, vpp, cred, vap }
1634 * The operating system has already ensured that the directory entry
1635 * does not exist and done all appropriate namespace locking.
1639 hammer2_vop_ncreate(struct vop_ncreate_args
*ap
)
1641 hammer2_inode_t
*dip
;
1642 hammer2_inode_t
*nip
;
1643 struct namecache
*ncp
;
1649 dip
= VTOI(ap
->a_dvp
);
1650 if (dip
->pmp
->ronly
|| (dip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
1652 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1655 ncp
= ap
->a_nch
->ncp
;
1656 name
= ncp
->nc_name
;
1657 name_len
= ncp
->nc_nlen
;
1658 hammer2_trans_init(dip
->pmp
, 0);
1660 inum
= hammer2_trans_newinum(dip
->pmp
);
1663 * Create the actual inode as a hidden file in the iroot, then
1664 * create the directory entry. The creation of the actual inode
1665 * sets its nlinks to 1 which is the value we desire.
1667 * dip must be locked before nip to avoid deadlock.
1669 hammer2_inode_lock(dip
, 0);
1670 nip
= hammer2_inode_create_normal(dip
, ap
->a_vap
, ap
->a_cred
,
1673 error
= hammer2_error_to_errno(error
);
1675 error
= hammer2_dirent_create(dip
, name
, name_len
,
1676 nip
->meta
.inum
, nip
->meta
.type
);
1680 hammer2_inode_unlink_finisher(nip
, NULL
);
1681 hammer2_inode_unlock(nip
);
1686 hammer2_inode_depend(dip
, nip
); /* before igetv */
1687 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1688 hammer2_inode_unlock(nip
);
1692 * Update dip's mtime
1697 /*hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);*/
1698 hammer2_update_time(&mtime
);
1699 hammer2_inode_modify(dip
);
1700 dip
->meta
.mtime
= mtime
;
1701 /*hammer2_inode_unlock(dip);*/
1703 hammer2_inode_unlock(dip
);
1705 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
1708 cache_setunresolved(ap
->a_nch
);
1709 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1710 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1716 * Make a device node (typically a fifo)
1720 hammer2_vop_nmknod(struct vop_nmknod_args
*ap
)
1722 hammer2_inode_t
*dip
;
1723 hammer2_inode_t
*nip
;
1724 struct namecache
*ncp
;
1730 dip
= VTOI(ap
->a_dvp
);
1731 if (dip
->pmp
->ronly
|| (dip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
1733 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1736 ncp
= ap
->a_nch
->ncp
;
1737 name
= ncp
->nc_name
;
1738 name_len
= ncp
->nc_nlen
;
1739 hammer2_trans_init(dip
->pmp
, 0);
1742 * Create the device inode and then create the directory entry.
1744 * dip must be locked before nip to avoid deadlock.
1746 inum
= hammer2_trans_newinum(dip
->pmp
);
1748 hammer2_inode_lock(dip
, 0);
1749 nip
= hammer2_inode_create_normal(dip
, ap
->a_vap
, ap
->a_cred
,
1752 error
= hammer2_error_to_errno(error
);
1754 error
= hammer2_dirent_create(dip
, name
, name_len
,
1755 nip
->meta
.inum
, nip
->meta
.type
);
1759 hammer2_inode_unlink_finisher(nip
, NULL
);
1760 hammer2_inode_unlock(nip
);
1765 hammer2_inode_depend(dip
, nip
); /* before igetv */
1766 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1767 hammer2_inode_unlock(nip
);
1771 * Update dip's mtime
1776 /*hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);*/
1777 hammer2_update_time(&mtime
);
1778 hammer2_inode_modify(dip
);
1779 dip
->meta
.mtime
= mtime
;
1780 /*hammer2_inode_unlock(dip);*/
1782 hammer2_inode_unlock(dip
);
1784 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
1787 cache_setunresolved(ap
->a_nch
);
1788 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1789 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1795 * hammer2_vop_nsymlink { nch, dvp, vpp, cred, vap, target }
1799 hammer2_vop_nsymlink(struct vop_nsymlink_args
*ap
)
1801 hammer2_inode_t
*dip
;
1802 hammer2_inode_t
*nip
;
1803 struct namecache
*ncp
;
1809 dip
= VTOI(ap
->a_dvp
);
1810 if (dip
->pmp
->ronly
|| (dip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
1812 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1815 ncp
= ap
->a_nch
->ncp
;
1816 name
= ncp
->nc_name
;
1817 name_len
= ncp
->nc_nlen
;
1818 hammer2_trans_init(dip
->pmp
, 0);
1820 ap
->a_vap
->va_type
= VLNK
; /* enforce type */
1823 * Create the softlink as an inode and then create the directory
1826 * dip must be locked before nip to avoid deadlock.
1828 inum
= hammer2_trans_newinum(dip
->pmp
);
1830 hammer2_inode_lock(dip
, 0);
1831 nip
= hammer2_inode_create_normal(dip
, ap
->a_vap
, ap
->a_cred
,
1834 error
= hammer2_error_to_errno(error
);
1836 error
= hammer2_dirent_create(dip
, name
, name_len
,
1837 nip
->meta
.inum
, nip
->meta
.type
);
1841 hammer2_inode_unlink_finisher(nip
, NULL
);
1842 hammer2_inode_unlock(nip
);
1846 hammer2_inode_unlock(dip
);
1847 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
1850 hammer2_inode_depend(dip
, nip
); /* before igetv */
1851 *ap
->a_vpp
= hammer2_igetv(nip
, &error
);
1854 * Build the softlink (~like file data) and finalize the namecache.
1861 bytes
= strlen(ap
->a_target
);
1863 hammer2_inode_unlock(nip
);
1864 bzero(&auio
, sizeof(auio
));
1865 bzero(&aiov
, sizeof(aiov
));
1866 auio
.uio_iov
= &aiov
;
1867 auio
.uio_segflg
= UIO_SYSSPACE
;
1868 auio
.uio_rw
= UIO_WRITE
;
1869 auio
.uio_resid
= bytes
;
1870 auio
.uio_iovcnt
= 1;
1871 auio
.uio_td
= curthread
;
1872 aiov
.iov_base
= ap
->a_target
;
1873 aiov
.iov_len
= bytes
;
1874 error
= hammer2_write_file(nip
, &auio
, IO_APPEND
, 0);
1875 /* XXX handle error */
1878 hammer2_inode_unlock(nip
);
1882 * Update dip's mtime
1887 /*hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);*/
1888 hammer2_update_time(&mtime
);
1889 hammer2_inode_modify(dip
);
1890 dip
->meta
.mtime
= mtime
;
1891 /*hammer2_inode_unlock(dip);*/
1893 hammer2_inode_unlock(dip
);
1895 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
1898 * Finalize namecache
1901 cache_setunresolved(ap
->a_nch
);
1902 cache_setvp(ap
->a_nch
, *ap
->a_vpp
);
1903 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
1909 * hammer2_vop_nremove { nch, dvp, cred }
1913 hammer2_vop_nremove(struct vop_nremove_args
*ap
)
1915 hammer2_xop_unlink_t
*xop
;
1916 hammer2_inode_t
*dip
;
1917 hammer2_inode_t
*ip
;
1918 struct vnode
*vprecycle
;
1919 struct namecache
*ncp
;
1922 dip
= VTOI(ap
->a_dvp
);
1923 if (dip
->pmp
->ronly
)
1926 /* allow removals, except user to also bulkfree */
1927 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
1931 ncp
= ap
->a_nch
->ncp
;
1933 if (hammer2_debug_inode
&& dip
->meta
.inum
== hammer2_debug_inode
) {
1934 kprintf("hammer2: attempt to delete inside debug inode: %s\n",
1936 while (hammer2_debug_inode
&&
1937 dip
->meta
.inum
== hammer2_debug_inode
) {
1938 tsleep(&hammer2_debug_inode
, 0, "h2debug", hz
*5);
1942 hammer2_trans_init(dip
->pmp
, 0);
1943 hammer2_inode_lock(dip
, 0);
1946 * The unlink XOP unlinks the path from the directory and
1947 * locates and returns the cluster associated with the real inode.
1948 * We have to handle nlinks here on the frontend.
1950 xop
= hammer2_xop_alloc(dip
, HAMMER2_XOP_MODIFYING
);
1951 hammer2_xop_setname(&xop
->head
, ncp
->nc_name
, ncp
->nc_nlen
);
1954 xop
->dopermanent
= 0;
1955 hammer2_xop_start(&xop
->head
, &hammer2_unlink_desc
);
1958 * Collect the real inode and adjust nlinks, destroy the real
1959 * inode if nlinks transitions to 0 and it was the real inode
1960 * (else it has already been removed).
1962 error
= hammer2_xop_collect(&xop
->head
, 0);
1963 error
= hammer2_error_to_errno(error
);
1967 ip
= hammer2_inode_get(dip
->pmp
, &xop
->head
, -1, -1);
1968 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1970 if (hammer2_debug_inode
&&
1971 ip
->meta
.inum
== hammer2_debug_inode
) {
1972 kprintf("hammer2: attempt to delete debug "
1974 while (hammer2_debug_inode
&&
1975 ip
->meta
.inum
== hammer2_debug_inode
) {
1976 tsleep(&hammer2_debug_inode
, 0,
1980 hammer2_inode_unlink_finisher(ip
, &vprecycle
);
1981 hammer2_inode_depend(dip
, ip
); /* after modified */
1982 hammer2_inode_unlock(ip
);
1985 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
1989 * Update dip's mtime
1994 /*hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);*/
1995 hammer2_update_time(&mtime
);
1996 hammer2_inode_modify(dip
);
1997 dip
->meta
.mtime
= mtime
;
1998 /*hammer2_inode_unlock(dip);*/
2000 hammer2_inode_unlock(dip
);
2002 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
2004 cache_unlink(ap
->a_nch
);
2005 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
);
2008 hammer2_inode_vprecycle(vprecycle
);
2014 * hammer2_vop_nrmdir { nch, dvp, cred }
2018 hammer2_vop_nrmdir(struct vop_nrmdir_args
*ap
)
2020 hammer2_xop_unlink_t
*xop
;
2021 hammer2_inode_t
*dip
;
2022 hammer2_inode_t
*ip
;
2023 struct namecache
*ncp
;
2024 struct vnode
*vprecycle
;
2027 dip
= VTOI(ap
->a_dvp
);
2028 if (dip
->pmp
->ronly
)
2031 /* allow removals, except user to also bulkfree */
2032 if (hammer2_vfs_enospace(dip
, 0, ap
->a_cred
) > 1)
2036 hammer2_trans_init(dip
->pmp
, 0);
2037 hammer2_inode_lock(dip
, 0);
2039 xop
= hammer2_xop_alloc(dip
, HAMMER2_XOP_MODIFYING
);
2041 ncp
= ap
->a_nch
->ncp
;
2042 hammer2_xop_setname(&xop
->head
, ncp
->nc_name
, ncp
->nc_nlen
);
2044 xop
->dopermanent
= 0;
2045 hammer2_xop_start(&xop
->head
, &hammer2_unlink_desc
);
2048 * Collect the real inode and adjust nlinks, destroy the real
2049 * inode if nlinks transitions to 0 and it was the real inode
2050 * (else it has already been removed).
2052 error
= hammer2_xop_collect(&xop
->head
, 0);
2053 error
= hammer2_error_to_errno(error
);
2057 ip
= hammer2_inode_get(dip
->pmp
, &xop
->head
, -1, -1);
2058 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
2060 hammer2_inode_unlink_finisher(ip
, &vprecycle
);
2061 hammer2_inode_depend(dip
, ip
); /* after modified */
2062 hammer2_inode_unlock(ip
);
2065 hammer2_xop_retire(&xop
->head
, HAMMER2_XOPMASK_VOP
);
2069 * Update dip's mtime
2074 /*hammer2_inode_lock(dip, HAMMER2_RESOLVE_SHARED);*/
2075 hammer2_update_time(&mtime
);
2076 hammer2_inode_modify(dip
);
2077 dip
->meta
.mtime
= mtime
;
2078 /*hammer2_inode_unlock(dip);*/
2080 hammer2_inode_unlock(dip
);
2082 hammer2_trans_done(dip
->pmp
, HAMMER2_TRANS_SIDEQ
);
2084 cache_unlink(ap
->a_nch
);
2085 hammer2_knote(ap
->a_dvp
, NOTE_WRITE
| NOTE_LINK
);
2088 hammer2_inode_vprecycle(vprecycle
);
2093 * hammer2_vop_nrename { fnch, tnch, fdvp, tdvp, cred }
2097 hammer2_vop_nrename(struct vop_nrename_args
*ap
)
2099 struct namecache
*fncp
;
2100 struct namecache
*tncp
;
2101 hammer2_inode_t
*fdip
; /* source directory */
2102 hammer2_inode_t
*tdip
; /* target directory */
2103 hammer2_inode_t
*ip
; /* file being renamed */
2104 hammer2_inode_t
*tip
; /* replaced target during rename or NULL */
2105 struct vnode
*vprecycle
;
2115 if (ap
->a_fdvp
->v_mount
!= ap
->a_tdvp
->v_mount
)
2117 if (ap
->a_fdvp
->v_mount
!= ap
->a_fnch
->ncp
->nc_vp
->v_mount
)
2120 fdip
= VTOI(ap
->a_fdvp
); /* source directory */
2121 tdip
= VTOI(ap
->a_tdvp
); /* target directory */
2123 if (fdip
->pmp
->ronly
|| (fdip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
2125 if (hammer2_vfs_enospace(fdip
, 0, ap
->a_cred
) > 1)
2128 fncp
= ap
->a_fnch
->ncp
; /* entry name in source */
2129 fname
= fncp
->nc_name
;
2130 fname_len
= fncp
->nc_nlen
;
2132 tncp
= ap
->a_tnch
->ncp
; /* entry name in target */
2133 tname
= tncp
->nc_name
;
2134 tname_len
= tncp
->nc_nlen
;
2136 hammer2_trans_init(tdip
->pmp
, 0);
2141 ip
= VTOI(fncp
->nc_vp
);
2142 hammer2_inode_ref(ip
); /* extra ref */
2145 * Lookup the target name to determine if a directory entry
2146 * is being overwritten. We only hold related inode locks
2147 * temporarily, the operating system is expected to protect
2148 * against rename races.
2150 tip
= tncp
->nc_vp
? VTOI(tncp
->nc_vp
) : NULL
;
2152 hammer2_inode_ref(tip
); /* extra ref */
2155 * Can return NULL and error == EXDEV if the common parent
2156 * crosses a directory with the xlink flag set.
2158 * For now try to avoid deadlocks with a simple pointer address
2159 * test. (tip) can be NULL.
2163 hammer2_inode_t
*ip1
= fdip
;
2164 hammer2_inode_t
*ip2
= tdip
;
2165 hammer2_inode_t
*ip3
= ip
;
2166 hammer2_inode_t
*ip4
= tip
; /* may be NULL */
2172 if (tip
&& ip
> tip
) {
2176 hammer2_inode_lock4(ip1
, ip2
, ip3
, ip4
);
2180 * Resolve the collision space for (tdip, tname, tname_len)
2182 * tdip must be held exclusively locked to prevent races since
2183 * multiple filenames can end up in the same collision space.
2186 hammer2_xop_scanlhc_t
*sxop
;
2187 hammer2_tid_t lhcbase
;
2189 tlhc
= hammer2_dirhash(tname
, tname_len
);
2191 sxop
= hammer2_xop_alloc(tdip
, HAMMER2_XOP_MODIFYING
);
2193 hammer2_xop_start(&sxop
->head
, &hammer2_scanlhc_desc
);
2194 while ((error
= hammer2_xop_collect(&sxop
->head
, 0)) == 0) {
2195 if (tlhc
!= sxop
->head
.cluster
.focus
->bref
.key
)
2199 error
= hammer2_error_to_errno(error
);
2200 hammer2_xop_retire(&sxop
->head
, HAMMER2_XOPMASK_VOP
);
2203 if (error
!= ENOENT
)
2208 if ((lhcbase
^ tlhc
) & ~HAMMER2_DIRHASH_LOMASK
) {
2215 * Ready to go, issue the rename to the backend. Note that meta-data
2216 * updates to the related inodes occur separately from the rename
2219 * NOTE: While it is not necessary to update ip->meta.name*, doing
2220 * so aids catastrophic recovery and debugging.
2223 hammer2_xop_nrename_t
*xop4
;
2225 xop4
= hammer2_xop_alloc(fdip
, HAMMER2_XOP_MODIFYING
);
2227 xop4
->ip_key
= ip
->meta
.name_key
;
2228 hammer2_xop_setip2(&xop4
->head
, ip
);
2229 hammer2_xop_setip3(&xop4
->head
, tdip
);
2230 if (tip
&& tip
->meta
.type
== HAMMER2_OBJTYPE_DIRECTORY
)
2231 hammer2_xop_setip4(&xop4
->head
, tip
);
2232 hammer2_xop_setname(&xop4
->head
, fname
, fname_len
);
2233 hammer2_xop_setname2(&xop4
->head
, tname
, tname_len
);
2234 hammer2_xop_start(&xop4
->head
, &hammer2_nrename_desc
);
2236 error
= hammer2_xop_collect(&xop4
->head
, 0);
2237 error
= hammer2_error_to_errno(error
);
2238 hammer2_xop_retire(&xop4
->head
, HAMMER2_XOPMASK_VOP
);
2240 if (error
== ENOENT
)
2244 * Update inode meta-data.
2246 * WARNING! The in-memory inode (ip) structure does not
2247 * maintain a copy of the inode's filename buffer.
2250 (ip
->meta
.name_key
& HAMMER2_DIRHASH_VISIBLE
)) {
2251 hammer2_inode_modify(ip
);
2252 ip
->meta
.name_len
= tname_len
;
2253 ip
->meta
.name_key
= tlhc
;
2256 hammer2_inode_modify(ip
);
2257 ip
->meta
.iparent
= tdip
->meta
.inum
;
2265 * If no error, the backend has replaced the target directory entry.
2266 * We must adjust nlinks on the original replace target if it exists.
2269 if (error
== 0 && tip
) {
2270 hammer2_inode_unlink_finisher(tip
, &vprecycle
);
2274 * Update directory mtimes to represent the something changed.
2276 if (update_fdip
|| update_tdip
) {
2279 hammer2_update_time(&mtime
);
2281 hammer2_inode_modify(fdip
);
2282 fdip
->meta
.mtime
= mtime
;
2285 hammer2_inode_modify(tdip
);
2286 tdip
->meta
.mtime
= mtime
;
2290 hammer2_inode_unlock(tip
);
2291 hammer2_inode_drop(tip
);
2293 hammer2_inode_unlock(ip
);
2294 hammer2_inode_unlock(tdip
);
2295 hammer2_inode_unlock(fdip
);
2296 hammer2_inode_drop(ip
);
2297 hammer2_trans_done(tdip
->pmp
, HAMMER2_TRANS_SIDEQ
);
2300 * Issue the namecache update after unlocking all the internal
2301 * hammer2 structures, otherwise we might deadlock.
2303 * WARNING! The target namespace must be updated atomically,
2304 * and we depend on cache_rename() to handle that for
2305 * us. Do not do a separate cache_unlink() because
2306 * that leaves a small window of opportunity for other
2307 * threads to allocate the target namespace before we
2308 * manage to complete our rename.
2310 * WARNING! cache_rename() (and cache_unlink()) will properly
2311 * set VREF_FINALIZE on any attached vnode. Do not
2312 * call cache_setunresolved() manually before-hand as
2313 * this will prevent the flag from being set later via
2314 * cache_rename(). If VREF_FINALIZE is not properly set
2315 * and the inode is no longer in the topology, related
2316 * chains can remain dirty indefinitely.
2318 if (error
== 0 && tip
) {
2319 /*cache_unlink(ap->a_tnch); see above */
2320 /*cache_setunresolved(ap->a_tnch); see above */
2323 cache_rename(ap
->a_fnch
, ap
->a_tnch
);
2324 hammer2_knote(ap
->a_fdvp
, NOTE_WRITE
);
2325 hammer2_knote(ap
->a_tdvp
, NOTE_WRITE
);
2326 hammer2_knote(fncp
->nc_vp
, NOTE_RENAME
);
2329 hammer2_inode_vprecycle(vprecycle
);
2335 * hammer2_vop_ioctl { vp, command, data, fflag, cred }
2339 hammer2_vop_ioctl(struct vop_ioctl_args
*ap
)
2341 hammer2_inode_t
*ip
;
2344 ip
= VTOI(ap
->a_vp
);
2346 error
= hammer2_ioctl(ip
, ap
->a_command
, (void *)ap
->a_data
,
2347 ap
->a_fflag
, ap
->a_cred
);
2353 hammer2_vop_mountctl(struct vop_mountctl_args
*ap
)
2360 case (MOUNTCTL_SET_EXPORT
):
2361 mp
= ap
->a_head
.a_ops
->head
.vv_mount
;
2364 if (ap
->a_ctllen
!= sizeof(struct export_args
))
2367 rc
= vfs_export(mp
, &pmp
->export
,
2368 (const struct export_args
*)ap
->a_ctl
);
2371 rc
= vop_stdmountctl(ap
);
2380 static void filt_hammer2detach(struct knote
*kn
);
2381 static int filt_hammer2read(struct knote
*kn
, long hint
);
2382 static int filt_hammer2write(struct knote
*kn
, long hint
);
2383 static int filt_hammer2vnode(struct knote
*kn
, long hint
);
2385 static struct filterops hammer2read_filtops
=
2386 { FILTEROP_ISFD
| FILTEROP_MPSAFE
,
2387 NULL
, filt_hammer2detach
, filt_hammer2read
};
2388 static struct filterops hammer2write_filtops
=
2389 { FILTEROP_ISFD
| FILTEROP_MPSAFE
,
2390 NULL
, filt_hammer2detach
, filt_hammer2write
};
2391 static struct filterops hammer2vnode_filtops
=
2392 { FILTEROP_ISFD
| FILTEROP_MPSAFE
,
2393 NULL
, filt_hammer2detach
, filt_hammer2vnode
};
2397 hammer2_vop_kqfilter(struct vop_kqfilter_args
*ap
)
2399 struct vnode
*vp
= ap
->a_vp
;
2400 struct knote
*kn
= ap
->a_kn
;
2402 switch (kn
->kn_filter
) {
2404 kn
->kn_fop
= &hammer2read_filtops
;
2407 kn
->kn_fop
= &hammer2write_filtops
;
2410 kn
->kn_fop
= &hammer2vnode_filtops
;
2413 return (EOPNOTSUPP
);
2416 kn
->kn_hook
= (caddr_t
)vp
;
2418 knote_insert(&vp
->v_pollinfo
.vpi_kqinfo
.ki_note
, kn
);
2424 filt_hammer2detach(struct knote
*kn
)
2426 struct vnode
*vp
= (void *)kn
->kn_hook
;
2428 knote_remove(&vp
->v_pollinfo
.vpi_kqinfo
.ki_note
, kn
);
2432 filt_hammer2read(struct knote
*kn
, long hint
)
2434 struct vnode
*vp
= (void *)kn
->kn_hook
;
2435 hammer2_inode_t
*ip
= VTOI(vp
);
2438 if (hint
== NOTE_REVOKE
) {
2439 kn
->kn_flags
|= (EV_EOF
| EV_NODATA
| EV_ONESHOT
);
2442 off
= ip
->meta
.size
- kn
->kn_fp
->f_offset
;
2443 kn
->kn_data
= (off
< INTPTR_MAX
) ? off
: INTPTR_MAX
;
2444 if (kn
->kn_sfflags
& NOTE_OLDAPI
)
2446 return (kn
->kn_data
!= 0);
2451 filt_hammer2write(struct knote
*kn
, long hint
)
2453 if (hint
== NOTE_REVOKE
)
2454 kn
->kn_flags
|= (EV_EOF
| EV_NODATA
| EV_ONESHOT
);
2460 filt_hammer2vnode(struct knote
*kn
, long hint
)
2462 if (kn
->kn_sfflags
& hint
)
2463 kn
->kn_fflags
|= hint
;
2464 if (hint
== NOTE_REVOKE
) {
2465 kn
->kn_flags
|= (EV_EOF
| EV_NODATA
);
2468 return (kn
->kn_fflags
!= 0);
2476 hammer2_vop_markatime(struct vop_markatime_args
*ap
)
2478 hammer2_inode_t
*ip
;
2484 if (ip
->pmp
->ronly
|| (ip
->pmp
->flags
& HAMMER2_PMPF_EMERG
))
2491 hammer2_vop_fifokqfilter(struct vop_kqfilter_args
*ap
)
2495 error
= VOCALL(&fifo_vnode_vops
, &ap
->a_head
);
2497 error
= hammer2_vop_kqfilter(ap
);
2504 struct vop_ops hammer2_vnode_vops
= {
2505 .vop_default
= vop_defaultop
,
2506 .vop_fsync
= hammer2_vop_fsync
,
2507 .vop_getpages
= vop_stdgetpages
,
2508 .vop_putpages
= vop_stdputpages
,
2509 .vop_access
= hammer2_vop_access
,
2510 .vop_advlock
= hammer2_vop_advlock
,
2511 .vop_close
= hammer2_vop_close
,
2512 .vop_nlink
= hammer2_vop_nlink
,
2513 .vop_ncreate
= hammer2_vop_ncreate
,
2514 .vop_nsymlink
= hammer2_vop_nsymlink
,
2515 .vop_nremove
= hammer2_vop_nremove
,
2516 .vop_nrmdir
= hammer2_vop_nrmdir
,
2517 .vop_nrename
= hammer2_vop_nrename
,
2518 .vop_getattr
= hammer2_vop_getattr
,
2519 .vop_getattr_lite
= hammer2_vop_getattr_lite
,
2520 .vop_setattr
= hammer2_vop_setattr
,
2521 .vop_readdir
= hammer2_vop_readdir
,
2522 .vop_readlink
= hammer2_vop_readlink
,
2523 .vop_read
= hammer2_vop_read
,
2524 .vop_write
= hammer2_vop_write
,
2525 .vop_open
= hammer2_vop_open
,
2526 .vop_inactive
= hammer2_vop_inactive
,
2527 .vop_reclaim
= hammer2_vop_reclaim
,
2528 .vop_nresolve
= hammer2_vop_nresolve
,
2529 .vop_nlookupdotdot
= hammer2_vop_nlookupdotdot
,
2530 .vop_nmkdir
= hammer2_vop_nmkdir
,
2531 .vop_nmknod
= hammer2_vop_nmknod
,
2532 .vop_ioctl
= hammer2_vop_ioctl
,
2533 .vop_mountctl
= hammer2_vop_mountctl
,
2534 .vop_bmap
= hammer2_vop_bmap
,
2535 .vop_strategy
= hammer2_vop_strategy
,
2536 .vop_kqfilter
= hammer2_vop_kqfilter
2539 struct vop_ops hammer2_spec_vops
= {
2540 .vop_default
= vop_defaultop
,
2541 .vop_fsync
= hammer2_vop_fsync
,
2542 .vop_read
= vop_stdnoread
,
2543 .vop_write
= vop_stdnowrite
,
2544 .vop_access
= hammer2_vop_access
,
2545 .vop_close
= hammer2_vop_close
,
2546 .vop_markatime
= hammer2_vop_markatime
,
2547 .vop_getattr
= hammer2_vop_getattr
,
2548 .vop_inactive
= hammer2_vop_inactive
,
2549 .vop_reclaim
= hammer2_vop_reclaim
,
2550 .vop_setattr
= hammer2_vop_setattr
2553 struct vop_ops hammer2_fifo_vops
= {
2554 .vop_default
= fifo_vnoperate
,
2555 .vop_fsync
= hammer2_vop_fsync
,
2557 .vop_read
= hammer2_vop_fiforead
,
2558 .vop_write
= hammer2_vop_fifowrite
,
2560 .vop_access
= hammer2_vop_access
,
2562 .vop_close
= hammer2_vop_fifoclose
,
2564 .vop_markatime
= hammer2_vop_markatime
,
2565 .vop_getattr
= hammer2_vop_getattr
,
2566 .vop_inactive
= hammer2_vop_inactive
,
2567 .vop_reclaim
= hammer2_vop_reclaim
,
2568 .vop_setattr
= hammer2_vop_setattr
,
2569 .vop_kqfilter
= hammer2_vop_fifokqfilter