4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
26 /* Portions Copyright 2007 Jeremy Teo */
29 #include <sys/types.h>
30 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/sysmacros.h>
34 #include <sys/resource.h>
35 #include <sys/mntent.h>
36 #include <sys/mkdev.h>
37 #include <sys/u8_textprep.h>
38 #include <sys/dsl_dataset.h>
40 #include <sys/vfs_opreg.h>
41 #include <sys/vnode.h>
44 #include <sys/errno.h>
45 #include <sys/unistd.h>
47 #include <sys/atomic.h>
49 #include "fs/fs_subr.h"
50 #include <sys/zfs_dir.h>
51 #include <sys/zfs_acl.h>
52 #include <sys/zfs_ioctl.h>
53 #include <sys/zfs_rlock.h>
54 #include <sys/zfs_fuid.h>
55 #include <sys/zfs_vnops.h>
56 #include <sys/zfs_ctldir.h>
57 #include <sys/dnode.h>
58 #include <sys/fs/zfs.h>
59 #include <sys/kidmap.h>
64 #include <sys/dmu_objset.h>
65 #include <sys/refcount.h>
68 #include <sys/zfs_znode.h>
70 #include <sys/zfs_sa.h>
71 #include <sys/zfs_stat.h>
74 #include "zfs_comutil.h"
77 * Define ZNODE_STATS to turn on statistic gathering. By default, it is only
78 * turned on when DEBUG is also defined.
85 #define ZNODE_STAT_ADD(stat) ((stat)++)
87 #define ZNODE_STAT_ADD(stat) /* nothing */
88 #endif /* ZNODE_STATS */
91 * Functions needed for userland (ie: libzpool) are not put under
92 * #ifdef_KERNEL; the rest of the functions have dependencies
93 * (such as VFS logic) that will not compile easily in userland.
97 static kmem_cache_t
*znode_cache
= NULL
;
98 static kmem_cache_t
*znode_hold_cache
= NULL
;
99 unsigned int zfs_object_mutex_size
= ZFS_OBJ_MTX_SZ
;
103 zfs_znode_cache_constructor(void *buf
, void *arg
, int kmflags
)
107 inode_init_once(ZTOI(zp
));
108 list_link_init(&zp
->z_link_node
);
110 mutex_init(&zp
->z_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
111 rw_init(&zp
->z_parent_lock
, NULL
, RW_DEFAULT
, NULL
);
112 rw_init(&zp
->z_name_lock
, NULL
, RW_NOLOCKDEP
, NULL
);
113 mutex_init(&zp
->z_acl_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
114 rw_init(&zp
->z_xattr_lock
, NULL
, RW_DEFAULT
, NULL
);
116 mutex_init(&zp
->z_range_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
117 avl_create(&zp
->z_range_avl
, zfs_range_compare
,
118 sizeof (rl_t
), offsetof(rl_t
, r_node
));
120 zp
->z_dirlocks
= NULL
;
121 zp
->z_acl_cached
= NULL
;
122 zp
->z_xattr_cached
= NULL
;
123 zp
->z_xattr_parent
= NULL
;
130 zfs_znode_cache_destructor(void *buf
, void *arg
)
134 ASSERT(!list_link_active(&zp
->z_link_node
));
135 mutex_destroy(&zp
->z_lock
);
136 rw_destroy(&zp
->z_parent_lock
);
137 rw_destroy(&zp
->z_name_lock
);
138 mutex_destroy(&zp
->z_acl_lock
);
139 rw_destroy(&zp
->z_xattr_lock
);
140 avl_destroy(&zp
->z_range_avl
);
141 mutex_destroy(&zp
->z_range_lock
);
143 ASSERT(zp
->z_dirlocks
== NULL
);
144 ASSERT(zp
->z_acl_cached
== NULL
);
145 ASSERT(zp
->z_xattr_cached
== NULL
);
146 ASSERT(zp
->z_xattr_parent
== NULL
);
150 zfs_znode_hold_cache_constructor(void *buf
, void *arg
, int kmflags
)
152 znode_hold_t
*zh
= buf
;
154 mutex_init(&zh
->zh_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
155 refcount_create(&zh
->zh_refcount
);
156 zh
->zh_obj
= ZFS_NO_OBJECT
;
162 zfs_znode_hold_cache_destructor(void *buf
, void *arg
)
164 znode_hold_t
*zh
= buf
;
166 mutex_destroy(&zh
->zh_lock
);
167 refcount_destroy(&zh
->zh_refcount
);
174 * Initialize zcache. The KMC_SLAB hint is used in order that it be
175 * backed by kmalloc() when on the Linux slab in order that any
176 * wait_on_bit() operations on the related inode operate properly.
178 ASSERT(znode_cache
== NULL
);
179 znode_cache
= kmem_cache_create("zfs_znode_cache",
180 sizeof (znode_t
), 0, zfs_znode_cache_constructor
,
181 zfs_znode_cache_destructor
, NULL
, NULL
, NULL
, KMC_SLAB
);
183 ASSERT(znode_hold_cache
== NULL
);
184 znode_hold_cache
= kmem_cache_create("zfs_znode_hold_cache",
185 sizeof (znode_hold_t
), 0, zfs_znode_hold_cache_constructor
,
186 zfs_znode_hold_cache_destructor
, NULL
, NULL
, NULL
, 0);
196 kmem_cache_destroy(znode_cache
);
199 if (znode_hold_cache
)
200 kmem_cache_destroy(znode_hold_cache
);
201 znode_hold_cache
= NULL
;
205 * The zfs_znode_hold_enter() / zfs_znode_hold_exit() functions are used to
206 * serialize access to a znode and its SA buffer while the object is being
207 * created or destroyed. This kind of locking would normally reside in the
208 * znode itself but in this case that's impossible because the znode and SA
209 * buffer may not yet exist. Therefore the locking is handled externally
210 * with an array of mutexs and AVLs trees which contain per-object locks.
212 * In zfs_znode_hold_enter() a per-object lock is created as needed, inserted
213 * in to the correct AVL tree and finally the per-object lock is held. In
214 * zfs_znode_hold_exit() the process is reversed. The per-object lock is
215 * released, removed from the AVL tree and destroyed if there are no waiters.
217 * This scheme has two important properties:
219 * 1) No memory allocations are performed while holding one of the z_hold_locks.
220 * This ensures evict(), which can be called from direct memory reclaim, will
221 * never block waiting on a z_hold_locks which just happens to have hashed
224 * 2) All locks used to serialize access to an object are per-object and never
225 * shared. This minimizes lock contention without creating a large number
226 * of dedicated locks.
228 * On the downside it does require znode_lock_t structures to be frequently
229 * allocated and freed. However, because these are backed by a kmem cache
230 * and very short lived this cost is minimal.
233 zfs_znode_hold_compare(const void *a
, const void *b
)
235 const znode_hold_t
*zh_a
= a
;
236 const znode_hold_t
*zh_b
= b
;
238 if (zh_a
->zh_obj
< zh_b
->zh_obj
)
240 else if (zh_a
->zh_obj
> zh_b
->zh_obj
)
247 zfs_znode_held(zfs_sb_t
*zsb
, uint64_t obj
)
249 znode_hold_t
*zh
, search
;
250 int i
= ZFS_OBJ_HASH(zsb
, obj
);
255 mutex_enter(&zsb
->z_hold_locks
[i
]);
256 zh
= avl_find(&zsb
->z_hold_trees
[i
], &search
, NULL
);
257 held
= (zh
&& MUTEX_HELD(&zh
->zh_lock
)) ? B_TRUE
: B_FALSE
;
258 mutex_exit(&zsb
->z_hold_locks
[i
]);
263 static znode_hold_t
*
264 zfs_znode_hold_enter(zfs_sb_t
*zsb
, uint64_t obj
)
266 znode_hold_t
*zh
, *zh_new
, search
;
267 int i
= ZFS_OBJ_HASH(zsb
, obj
);
268 boolean_t found
= B_FALSE
;
270 zh_new
= kmem_cache_alloc(znode_hold_cache
, KM_SLEEP
);
271 zh_new
->zh_obj
= obj
;
274 mutex_enter(&zsb
->z_hold_locks
[i
]);
275 zh
= avl_find(&zsb
->z_hold_trees
[i
], &search
, NULL
);
276 if (likely(zh
== NULL
)) {
278 avl_add(&zsb
->z_hold_trees
[i
], zh
);
280 ASSERT3U(zh
->zh_obj
, ==, obj
);
283 refcount_add(&zh
->zh_refcount
, NULL
);
284 mutex_exit(&zsb
->z_hold_locks
[i
]);
287 kmem_cache_free(znode_hold_cache
, zh_new
);
289 ASSERT(MUTEX_NOT_HELD(&zh
->zh_lock
));
290 ASSERT3S(refcount_count(&zh
->zh_refcount
), >, 0);
291 mutex_enter(&zh
->zh_lock
);
297 zfs_znode_hold_exit(zfs_sb_t
*zsb
, znode_hold_t
*zh
)
299 int i
= ZFS_OBJ_HASH(zsb
, zh
->zh_obj
);
300 boolean_t remove
= B_FALSE
;
302 ASSERT(zfs_znode_held(zsb
, zh
->zh_obj
));
303 ASSERT3S(refcount_count(&zh
->zh_refcount
), >, 0);
304 mutex_exit(&zh
->zh_lock
);
306 mutex_enter(&zsb
->z_hold_locks
[i
]);
307 if (refcount_remove(&zh
->zh_refcount
, NULL
) == 0) {
308 avl_remove(&zsb
->z_hold_trees
[i
], zh
);
311 mutex_exit(&zsb
->z_hold_locks
[i
]);
313 if (remove
== B_TRUE
)
314 kmem_cache_free(znode_hold_cache
, zh
);
318 zfs_create_share_dir(zfs_sb_t
*zsb
, dmu_tx_t
*tx
)
320 #ifdef HAVE_SMB_SHARE
321 zfs_acl_ids_t acl_ids
;
328 vattr
.va_mask
= AT_MODE
|AT_UID
|AT_GID
|AT_TYPE
;
329 vattr
.va_mode
= S_IFDIR
| 0555;
330 vattr
.va_uid
= crgetuid(kcred
);
331 vattr
.va_gid
= crgetgid(kcred
);
333 sharezp
= kmem_cache_alloc(znode_cache
, KM_SLEEP
);
334 sharezp
->z_moved
= 0;
335 sharezp
->z_unlinked
= 0;
336 sharezp
->z_atime_dirty
= 0;
337 sharezp
->z_zfsvfs
= zfsvfs
;
338 sharezp
->z_is_sa
= zfsvfs
->z_use_sa
;
344 VERIFY(0 == zfs_acl_ids_create(sharezp
, IS_ROOT_NODE
, &vattr
,
345 kcred
, NULL
, &acl_ids
));
346 zfs_mknode(sharezp
, &vattr
, tx
, kcred
, IS_ROOT_NODE
, &zp
, &acl_ids
);
347 ASSERT3P(zp
, ==, sharezp
);
348 ASSERT(!vn_in_dnlc(ZTOV(sharezp
))); /* not valid to move */
349 POINTER_INVALIDATE(&sharezp
->z_zfsvfs
);
350 error
= zap_add(zfsvfs
->z_os
, MASTER_NODE_OBJ
,
351 ZFS_SHARES_DIR
, 8, 1, &sharezp
->z_id
, tx
);
352 zfsvfs
->z_shares_dir
= sharezp
->z_id
;
354 zfs_acl_ids_free(&acl_ids
);
355 // ZTOV(sharezp)->v_count = 0;
356 sa_handle_destroy(sharezp
->z_sa_hdl
);
357 kmem_cache_free(znode_cache
, sharezp
);
362 #endif /* HAVE_SMB_SHARE */
366 zfs_znode_sa_init(zfs_sb_t
*zsb
, znode_t
*zp
,
367 dmu_buf_t
*db
, dmu_object_type_t obj_type
, sa_handle_t
*sa_hdl
)
369 ASSERT(zfs_znode_held(zsb
, zp
->z_id
));
371 mutex_enter(&zp
->z_lock
);
373 ASSERT(zp
->z_sa_hdl
== NULL
);
374 ASSERT(zp
->z_acl_cached
== NULL
);
375 if (sa_hdl
== NULL
) {
376 VERIFY(0 == sa_handle_get_from_db(zsb
->z_os
, db
, zp
,
377 SA_HDL_SHARED
, &zp
->z_sa_hdl
));
379 zp
->z_sa_hdl
= sa_hdl
;
380 sa_set_userp(sa_hdl
, zp
);
383 zp
->z_is_sa
= (obj_type
== DMU_OT_SA
) ? B_TRUE
: B_FALSE
;
385 mutex_exit(&zp
->z_lock
);
389 zfs_znode_dmu_fini(znode_t
*zp
)
391 ASSERT(zfs_znode_held(ZTOZSB(zp
), zp
->z_id
) || zp
->z_unlinked
||
392 RW_WRITE_HELD(&ZTOZSB(zp
)->z_teardown_inactive_lock
));
394 sa_handle_destroy(zp
->z_sa_hdl
);
399 * Called by new_inode() to allocate a new inode.
402 zfs_inode_alloc(struct super_block
*sb
, struct inode
**ip
)
406 zp
= kmem_cache_alloc(znode_cache
, KM_SLEEP
);
413 * Called in multiple places when an inode should be destroyed.
416 zfs_inode_destroy(struct inode
*ip
)
418 znode_t
*zp
= ITOZ(ip
);
419 zfs_sb_t
*zsb
= ZTOZSB(zp
);
421 mutex_enter(&zsb
->z_znodes_lock
);
422 if (list_link_active(&zp
->z_link_node
)) {
423 list_remove(&zsb
->z_all_znodes
, zp
);
426 mutex_exit(&zsb
->z_znodes_lock
);
428 if (zp
->z_acl_cached
) {
429 zfs_acl_free(zp
->z_acl_cached
);
430 zp
->z_acl_cached
= NULL
;
433 if (zp
->z_xattr_cached
) {
434 nvlist_free(zp
->z_xattr_cached
);
435 zp
->z_xattr_cached
= NULL
;
438 if (zp
->z_xattr_parent
) {
439 zfs_iput_async(ZTOI(zp
->z_xattr_parent
));
440 zp
->z_xattr_parent
= NULL
;
443 kmem_cache_free(znode_cache
, zp
);
447 zfs_inode_set_ops(zfs_sb_t
*zsb
, struct inode
*ip
)
451 switch (ip
->i_mode
& S_IFMT
) {
453 ip
->i_op
= &zpl_inode_operations
;
454 ip
->i_fop
= &zpl_file_operations
;
455 ip
->i_mapping
->a_ops
= &zpl_address_space_operations
;
459 ip
->i_op
= &zpl_dir_inode_operations
;
460 ip
->i_fop
= &zpl_dir_file_operations
;
461 ITOZ(ip
)->z_zn_prefetch
= B_TRUE
;
465 ip
->i_op
= &zpl_symlink_inode_operations
;
469 * rdev is only stored in a SA only for device files.
473 sa_lookup(ITOZ(ip
)->z_sa_hdl
, SA_ZPL_RDEV(zsb
), &rdev
,
478 init_special_inode(ip
, ip
->i_mode
, rdev
);
479 ip
->i_op
= &zpl_special_inode_operations
;
483 zfs_panic_recover("inode %llu has invalid mode: 0x%x\n",
484 (u_longlong_t
)ip
->i_ino
, ip
->i_mode
);
486 /* Assume the inode is a file and attempt to continue */
487 ip
->i_mode
= S_IFREG
| 0644;
488 ip
->i_op
= &zpl_inode_operations
;
489 ip
->i_fop
= &zpl_file_operations
;
490 ip
->i_mapping
->a_ops
= &zpl_address_space_operations
;
496 zfs_set_inode_flags(znode_t
*zp
, struct inode
*ip
)
499 * Linux and Solaris have different sets of file attributes, so we
500 * restrict this conversion to the intersection of the two.
503 if (zp
->z_pflags
& ZFS_IMMUTABLE
)
504 ip
->i_flags
|= S_IMMUTABLE
;
506 ip
->i_flags
&= ~S_IMMUTABLE
;
508 if (zp
->z_pflags
& ZFS_APPENDONLY
)
509 ip
->i_flags
|= S_APPEND
;
511 ip
->i_flags
&= ~S_APPEND
;
515 * Update the embedded inode given the znode. We should work toward
516 * eliminating this function as soon as possible by removing values
517 * which are duplicated between the znode and inode. If the generic
518 * inode has the correct field it should be used, and the ZFS code
519 * updated to access the inode. This can be done incrementally.
522 zfs_inode_update_impl(znode_t
*zp
, boolean_t
new)
527 u_longlong_t i_blocks
;
528 uint64_t atime
[2], mtime
[2], ctime
[2];
534 /* Skip .zfs control nodes which do not exist on disk. */
535 if (zfsctl_is_node(ip
))
538 sa_lookup(zp
->z_sa_hdl
, SA_ZPL_ATIME(zsb
), &atime
, 16);
539 sa_lookup(zp
->z_sa_hdl
, SA_ZPL_MTIME(zsb
), &mtime
, 16);
540 sa_lookup(zp
->z_sa_hdl
, SA_ZPL_CTIME(zsb
), &ctime
, 16);
542 dmu_object_size_from_db(sa_get_db(zp
->z_sa_hdl
), &blksize
, &i_blocks
);
544 spin_lock(&ip
->i_lock
);
545 ip
->i_uid
= SUID_TO_KUID(zp
->z_uid
);
546 ip
->i_gid
= SGID_TO_KGID(zp
->z_gid
);
547 set_nlink(ip
, zp
->z_links
);
548 ip
->i_mode
= zp
->z_mode
;
549 zfs_set_inode_flags(zp
, ip
);
550 ip
->i_blkbits
= SPA_MINBLOCKSHIFT
;
551 ip
->i_blocks
= i_blocks
;
554 * Only read atime from SA if we are newly created inode (or rezget),
555 * otherwise i_atime might be dirty.
558 ZFS_TIME_DECODE(&ip
->i_atime
, atime
);
559 ZFS_TIME_DECODE(&ip
->i_mtime
, mtime
);
560 ZFS_TIME_DECODE(&ip
->i_ctime
, ctime
);
562 i_size_write(ip
, zp
->z_size
);
563 spin_unlock(&ip
->i_lock
);
567 zfs_inode_update_new(znode_t
*zp
)
569 zfs_inode_update_impl(zp
, B_TRUE
);
573 zfs_inode_update(znode_t
*zp
)
575 zfs_inode_update_impl(zp
, B_FALSE
);
579 * Construct a znode+inode and initialize.
581 * This does not do a call to dmu_set_user() that is
582 * up to the caller to do, in case you don't want to
586 zfs_znode_alloc(zfs_sb_t
*zsb
, dmu_buf_t
*db
, int blksz
,
587 dmu_object_type_t obj_type
, uint64_t obj
, sa_handle_t
*hdl
,
594 sa_bulk_attr_t bulk
[8];
599 ip
= new_inode(zsb
->z_sb
);
604 ASSERT(zp
->z_dirlocks
== NULL
);
605 ASSERT3P(zp
->z_acl_cached
, ==, NULL
);
606 ASSERT3P(zp
->z_xattr_cached
, ==, NULL
);
607 ASSERT3P(zp
->z_xattr_parent
, ==, NULL
);
611 zp
->z_atime_dirty
= 0;
613 zp
->z_id
= db
->db_object
;
615 zp
->z_seq
= 0x7A4653;
617 zp
->z_is_zvol
= B_FALSE
;
618 zp
->z_is_mapped
= B_FALSE
;
619 zp
->z_is_ctldir
= B_FALSE
;
620 zp
->z_is_stale
= B_FALSE
;
622 zfs_znode_sa_init(zsb
, zp
, db
, obj_type
, hdl
);
624 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_MODE(zsb
), NULL
, &mode
, 8);
625 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_GEN(zsb
), NULL
,
626 &ip
->i_generation
, 8);
627 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_SIZE(zsb
), NULL
, &zp
->z_size
, 8);
628 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_LINKS(zsb
), NULL
, &zp
->z_links
, 8);
629 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_FLAGS(zsb
), NULL
,
631 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_PARENT(zsb
), NULL
,
633 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_UID(zsb
), NULL
, &zp
->z_uid
, 8);
634 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_GID(zsb
), NULL
, &zp
->z_gid
, 8);
636 if (sa_bulk_lookup(zp
->z_sa_hdl
, bulk
, count
) != 0 ||
637 ip
->i_generation
== 0) {
640 sa_handle_destroy(zp
->z_sa_hdl
);
648 * xattr znodes hold a reference on their unique parent
650 if (dip
&& zp
->z_pflags
& ZFS_XATTR
) {
652 zp
->z_xattr_parent
= ITOZ(dip
);
656 zfs_inode_update_new(zp
);
657 zfs_inode_set_ops(zsb
, ip
);
660 * The only way insert_inode_locked() can fail is if the ip->i_ino
661 * number is already hashed for this super block. This can never
662 * happen because the inode numbers map 1:1 with the object numbers.
664 * The one exception is rolling back a mounted file system, but in
665 * this case all the active inode are unhashed during the rollback.
667 VERIFY3S(insert_inode_locked(ip
), ==, 0);
669 mutex_enter(&zsb
->z_znodes_lock
);
670 list_insert_tail(&zsb
->z_all_znodes
, zp
);
673 mutex_exit(&zsb
->z_znodes_lock
);
675 unlock_new_inode(ip
);
684 * Safely mark an inode dirty. Inodes which are part of a read-only
685 * file system or snapshot may not be dirtied.
688 zfs_mark_inode_dirty(struct inode
*ip
)
690 zfs_sb_t
*zsb
= ITOZSB(ip
);
692 if (zfs_is_readonly(zsb
) || dmu_objset_is_snapshot(zsb
->z_os
))
695 mark_inode_dirty(ip
);
698 static uint64_t empty_xattr
;
699 static uint64_t pad
[4];
700 static zfs_acl_phys_t acl_phys
;
702 * Create a new DMU object to hold a zfs znode.
704 * IN: dzp - parent directory for new znode
705 * vap - file attributes for new znode
706 * tx - dmu transaction id for zap operations
707 * cr - credentials of caller
709 * IS_ROOT_NODE - new object will be root
710 * IS_XATTR - new object is an attribute
711 * bonuslen - length of bonus buffer
712 * setaclp - File/Dir initial ACL
713 * fuidp - Tracks fuid allocation.
715 * OUT: zpp - allocated znode
719 zfs_mknode(znode_t
*dzp
, vattr_t
*vap
, dmu_tx_t
*tx
, cred_t
*cr
,
720 uint_t flag
, znode_t
**zpp
, zfs_acl_ids_t
*acl_ids
)
722 uint64_t crtime
[2], atime
[2], mtime
[2], ctime
[2];
723 uint64_t mode
, size
, links
, parent
, pflags
;
724 uint64_t dzp_pflags
= 0;
726 zfs_sb_t
*zsb
= ZTOZSB(dzp
);
732 dmu_object_type_t obj_type
;
733 sa_bulk_attr_t
*sa_attrs
;
735 zfs_acl_locator_cb_t locate
= { 0 };
739 obj
= vap
->va_nodeid
;
740 now
= vap
->va_ctime
; /* see zfs_replay_create() */
741 gen
= vap
->va_nblocks
; /* ditto */
745 gen
= dmu_tx_get_txg(tx
);
748 obj_type
= zsb
->z_use_sa
? DMU_OT_SA
: DMU_OT_ZNODE
;
749 bonuslen
= (obj_type
== DMU_OT_SA
) ?
750 DN_MAX_BONUSLEN
: ZFS_OLD_ZNODE_PHYS_SIZE
;
753 * Create a new DMU object.
756 * There's currently no mechanism for pre-reading the blocks that will
757 * be needed to allocate a new object, so we accept the small chance
758 * that there will be an i/o error and we will fail one of the
761 if (S_ISDIR(vap
->va_mode
)) {
763 VERIFY0(zap_create_claim_norm(zsb
->z_os
, obj
,
764 zsb
->z_norm
, DMU_OT_DIRECTORY_CONTENTS
,
765 obj_type
, bonuslen
, tx
));
767 obj
= zap_create_norm(zsb
->z_os
,
768 zsb
->z_norm
, DMU_OT_DIRECTORY_CONTENTS
,
769 obj_type
, bonuslen
, tx
);
773 VERIFY0(dmu_object_claim(zsb
->z_os
, obj
,
774 DMU_OT_PLAIN_FILE_CONTENTS
, 0,
775 obj_type
, bonuslen
, tx
));
777 obj
= dmu_object_alloc(zsb
->z_os
,
778 DMU_OT_PLAIN_FILE_CONTENTS
, 0,
779 obj_type
, bonuslen
, tx
);
783 zh
= zfs_znode_hold_enter(zsb
, obj
);
784 VERIFY(0 == sa_buf_hold(zsb
->z_os
, obj
, NULL
, &db
));
787 * If this is the root, fix up the half-initialized parent pointer
788 * to reference the just-allocated physical data area.
790 if (flag
& IS_ROOT_NODE
) {
793 dzp_pflags
= dzp
->z_pflags
;
797 * If parent is an xattr, so am I.
799 if (dzp_pflags
& ZFS_XATTR
) {
803 if (zsb
->z_use_fuids
)
804 pflags
= ZFS_ARCHIVE
| ZFS_AV_MODIFIED
;
808 if (S_ISDIR(vap
->va_mode
)) {
809 size
= 2; /* contents ("." and "..") */
810 links
= (flag
& (IS_ROOT_NODE
| IS_XATTR
)) ? 2 : 1;
815 if (S_ISBLK(vap
->va_mode
) || S_ISCHR(vap
->va_mode
))
819 mode
= acl_ids
->z_mode
;
824 * No execs denied will be deterimed when zfs_mode_compute() is called.
826 pflags
|= acl_ids
->z_aclp
->z_hints
&
827 (ZFS_ACL_TRIVIAL
|ZFS_INHERIT_ACE
|ZFS_ACL_AUTO_INHERIT
|
828 ZFS_ACL_DEFAULTED
|ZFS_ACL_PROTECTED
);
830 ZFS_TIME_ENCODE(&now
, crtime
);
831 ZFS_TIME_ENCODE(&now
, ctime
);
833 if (vap
->va_mask
& ATTR_ATIME
) {
834 ZFS_TIME_ENCODE(&vap
->va_atime
, atime
);
836 ZFS_TIME_ENCODE(&now
, atime
);
839 if (vap
->va_mask
& ATTR_MTIME
) {
840 ZFS_TIME_ENCODE(&vap
->va_mtime
, mtime
);
842 ZFS_TIME_ENCODE(&now
, mtime
);
845 /* Now add in all of the "SA" attributes */
846 VERIFY(0 == sa_handle_get_from_db(zsb
->z_os
, db
, NULL
, SA_HDL_SHARED
,
850 * Setup the array of attributes to be replaced/set on the new file
852 * order for DMU_OT_ZNODE is critical since it needs to be constructed
853 * in the old znode_phys_t format. Don't change this ordering
855 sa_attrs
= kmem_alloc(sizeof (sa_bulk_attr_t
) * ZPL_END
, KM_SLEEP
);
857 if (obj_type
== DMU_OT_ZNODE
) {
858 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_ATIME(zsb
),
860 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_MTIME(zsb
),
862 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_CTIME(zsb
),
864 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_CRTIME(zsb
),
866 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_GEN(zsb
),
868 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_MODE(zsb
),
870 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_SIZE(zsb
),
872 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_PARENT(zsb
),
875 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_MODE(zsb
),
877 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_SIZE(zsb
),
879 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_GEN(zsb
),
881 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_UID(zsb
),
882 NULL
, &acl_ids
->z_fuid
, 8);
883 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_GID(zsb
),
884 NULL
, &acl_ids
->z_fgid
, 8);
885 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_PARENT(zsb
),
887 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_FLAGS(zsb
),
889 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_ATIME(zsb
),
891 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_MTIME(zsb
),
893 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_CTIME(zsb
),
895 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_CRTIME(zsb
),
899 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_LINKS(zsb
), NULL
, &links
, 8);
901 if (obj_type
== DMU_OT_ZNODE
) {
902 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_XATTR(zsb
), NULL
,
905 if (obj_type
== DMU_OT_ZNODE
||
906 (S_ISBLK(vap
->va_mode
) || S_ISCHR(vap
->va_mode
))) {
907 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_RDEV(zsb
),
910 if (obj_type
== DMU_OT_ZNODE
) {
911 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_FLAGS(zsb
),
913 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_UID(zsb
), NULL
,
914 &acl_ids
->z_fuid
, 8);
915 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_GID(zsb
), NULL
,
916 &acl_ids
->z_fgid
, 8);
917 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_PAD(zsb
), NULL
, pad
,
918 sizeof (uint64_t) * 4);
919 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_ZNODE_ACL(zsb
), NULL
,
920 &acl_phys
, sizeof (zfs_acl_phys_t
));
921 } else if (acl_ids
->z_aclp
->z_version
>= ZFS_ACL_VERSION_FUID
) {
922 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_DACL_COUNT(zsb
), NULL
,
923 &acl_ids
->z_aclp
->z_acl_count
, 8);
924 locate
.cb_aclp
= acl_ids
->z_aclp
;
925 SA_ADD_BULK_ATTR(sa_attrs
, cnt
, SA_ZPL_DACL_ACES(zsb
),
926 zfs_acl_data_locator
, &locate
,
927 acl_ids
->z_aclp
->z_acl_bytes
);
928 mode
= zfs_mode_compute(mode
, acl_ids
->z_aclp
, &pflags
,
929 acl_ids
->z_fuid
, acl_ids
->z_fgid
);
932 VERIFY(sa_replace_all_by_template(sa_hdl
, sa_attrs
, cnt
, tx
) == 0);
934 if (!(flag
& IS_ROOT_NODE
)) {
935 *zpp
= zfs_znode_alloc(zsb
, db
, 0, obj_type
, obj
, sa_hdl
,
937 VERIFY(*zpp
!= NULL
);
941 * If we are creating the root node, the "parent" we
942 * passed in is the znode for the root.
946 (*zpp
)->z_sa_hdl
= sa_hdl
;
949 (*zpp
)->z_pflags
= pflags
;
950 (*zpp
)->z_mode
= mode
;
952 if (obj_type
== DMU_OT_ZNODE
||
953 acl_ids
->z_aclp
->z_version
< ZFS_ACL_VERSION_FUID
) {
954 VERIFY0(zfs_aclset_common(*zpp
, acl_ids
->z_aclp
, cr
, tx
));
956 kmem_free(sa_attrs
, sizeof (sa_bulk_attr_t
) * ZPL_END
);
957 zfs_znode_hold_exit(zsb
, zh
);
961 * Update in-core attributes. It is assumed the caller will be doing an
962 * sa_bulk_update to push the changes out.
965 zfs_xvattr_set(znode_t
*zp
, xvattr_t
*xvap
, dmu_tx_t
*tx
)
969 xoap
= xva_getxoptattr(xvap
);
972 if (XVA_ISSET_REQ(xvap
, XAT_CREATETIME
)) {
974 ZFS_TIME_ENCODE(&xoap
->xoa_createtime
, times
);
975 (void) sa_update(zp
->z_sa_hdl
, SA_ZPL_CRTIME(ZTOZSB(zp
)),
976 ×
, sizeof (times
), tx
);
977 XVA_SET_RTN(xvap
, XAT_CREATETIME
);
979 if (XVA_ISSET_REQ(xvap
, XAT_READONLY
)) {
980 ZFS_ATTR_SET(zp
, ZFS_READONLY
, xoap
->xoa_readonly
,
982 XVA_SET_RTN(xvap
, XAT_READONLY
);
984 if (XVA_ISSET_REQ(xvap
, XAT_HIDDEN
)) {
985 ZFS_ATTR_SET(zp
, ZFS_HIDDEN
, xoap
->xoa_hidden
,
987 XVA_SET_RTN(xvap
, XAT_HIDDEN
);
989 if (XVA_ISSET_REQ(xvap
, XAT_SYSTEM
)) {
990 ZFS_ATTR_SET(zp
, ZFS_SYSTEM
, xoap
->xoa_system
,
992 XVA_SET_RTN(xvap
, XAT_SYSTEM
);
994 if (XVA_ISSET_REQ(xvap
, XAT_ARCHIVE
)) {
995 ZFS_ATTR_SET(zp
, ZFS_ARCHIVE
, xoap
->xoa_archive
,
997 XVA_SET_RTN(xvap
, XAT_ARCHIVE
);
999 if (XVA_ISSET_REQ(xvap
, XAT_IMMUTABLE
)) {
1000 ZFS_ATTR_SET(zp
, ZFS_IMMUTABLE
, xoap
->xoa_immutable
,
1002 XVA_SET_RTN(xvap
, XAT_IMMUTABLE
);
1004 if (XVA_ISSET_REQ(xvap
, XAT_NOUNLINK
)) {
1005 ZFS_ATTR_SET(zp
, ZFS_NOUNLINK
, xoap
->xoa_nounlink
,
1007 XVA_SET_RTN(xvap
, XAT_NOUNLINK
);
1009 if (XVA_ISSET_REQ(xvap
, XAT_APPENDONLY
)) {
1010 ZFS_ATTR_SET(zp
, ZFS_APPENDONLY
, xoap
->xoa_appendonly
,
1012 XVA_SET_RTN(xvap
, XAT_APPENDONLY
);
1014 if (XVA_ISSET_REQ(xvap
, XAT_NODUMP
)) {
1015 ZFS_ATTR_SET(zp
, ZFS_NODUMP
, xoap
->xoa_nodump
,
1017 XVA_SET_RTN(xvap
, XAT_NODUMP
);
1019 if (XVA_ISSET_REQ(xvap
, XAT_OPAQUE
)) {
1020 ZFS_ATTR_SET(zp
, ZFS_OPAQUE
, xoap
->xoa_opaque
,
1022 XVA_SET_RTN(xvap
, XAT_OPAQUE
);
1024 if (XVA_ISSET_REQ(xvap
, XAT_AV_QUARANTINED
)) {
1025 ZFS_ATTR_SET(zp
, ZFS_AV_QUARANTINED
,
1026 xoap
->xoa_av_quarantined
, zp
->z_pflags
, tx
);
1027 XVA_SET_RTN(xvap
, XAT_AV_QUARANTINED
);
1029 if (XVA_ISSET_REQ(xvap
, XAT_AV_MODIFIED
)) {
1030 ZFS_ATTR_SET(zp
, ZFS_AV_MODIFIED
, xoap
->xoa_av_modified
,
1032 XVA_SET_RTN(xvap
, XAT_AV_MODIFIED
);
1034 if (XVA_ISSET_REQ(xvap
, XAT_AV_SCANSTAMP
)) {
1035 zfs_sa_set_scanstamp(zp
, xvap
, tx
);
1036 XVA_SET_RTN(xvap
, XAT_AV_SCANSTAMP
);
1038 if (XVA_ISSET_REQ(xvap
, XAT_REPARSE
)) {
1039 ZFS_ATTR_SET(zp
, ZFS_REPARSE
, xoap
->xoa_reparse
,
1041 XVA_SET_RTN(xvap
, XAT_REPARSE
);
1043 if (XVA_ISSET_REQ(xvap
, XAT_OFFLINE
)) {
1044 ZFS_ATTR_SET(zp
, ZFS_OFFLINE
, xoap
->xoa_offline
,
1046 XVA_SET_RTN(xvap
, XAT_OFFLINE
);
1048 if (XVA_ISSET_REQ(xvap
, XAT_SPARSE
)) {
1049 ZFS_ATTR_SET(zp
, ZFS_SPARSE
, xoap
->xoa_sparse
,
1051 XVA_SET_RTN(xvap
, XAT_SPARSE
);
1056 zfs_zget(zfs_sb_t
*zsb
, uint64_t obj_num
, znode_t
**zpp
)
1058 dmu_object_info_t doi
;
1068 zh
= zfs_znode_hold_enter(zsb
, obj_num
);
1070 err
= sa_buf_hold(zsb
->z_os
, obj_num
, NULL
, &db
);
1072 zfs_znode_hold_exit(zsb
, zh
);
1076 dmu_object_info_from_db(db
, &doi
);
1077 if (doi
.doi_bonus_type
!= DMU_OT_SA
&&
1078 (doi
.doi_bonus_type
!= DMU_OT_ZNODE
||
1079 (doi
.doi_bonus_type
== DMU_OT_ZNODE
&&
1080 doi
.doi_bonus_size
< sizeof (znode_phys_t
)))) {
1081 sa_buf_rele(db
, NULL
);
1082 zfs_znode_hold_exit(zsb
, zh
);
1083 return (SET_ERROR(EINVAL
));
1086 hdl
= dmu_buf_get_user(db
);
1088 zp
= sa_get_userdata(hdl
);
1092 * Since "SA" does immediate eviction we
1093 * should never find a sa handle that doesn't
1094 * know about the znode.
1097 ASSERT3P(zp
, !=, NULL
);
1099 mutex_enter(&zp
->z_lock
);
1100 ASSERT3U(zp
->z_id
, ==, obj_num
);
1101 if (zp
->z_unlinked
) {
1102 err
= SET_ERROR(ENOENT
);
1105 * If igrab() returns NULL the VFS has independently
1106 * determined the inode should be evicted and has
1107 * called iput_final() to start the eviction process.
1108 * The SA handle is still valid but because the VFS
1109 * requires that the eviction succeed we must drop
1110 * our locks and references to allow the eviction to
1111 * complete. The zfs_zget() may then be retried.
1113 * This unlikely case could be optimized by registering
1114 * a sops->drop_inode() callback. The callback would
1115 * need to detect the active SA hold thereby informing
1116 * the VFS that this inode should not be evicted.
1118 if (igrab(ZTOI(zp
)) == NULL
) {
1119 mutex_exit(&zp
->z_lock
);
1120 sa_buf_rele(db
, NULL
);
1121 zfs_znode_hold_exit(zsb
, zh
);
1122 /* inode might need this to finish evict */
1129 mutex_exit(&zp
->z_lock
);
1130 sa_buf_rele(db
, NULL
);
1131 zfs_znode_hold_exit(zsb
, zh
);
1136 * Not found create new znode/vnode but only if file exists.
1138 * There is a small window where zfs_vget() could
1139 * find this object while a file create is still in
1140 * progress. This is checked for in zfs_znode_alloc()
1142 * if zfs_znode_alloc() fails it will drop the hold on the
1145 zp
= zfs_znode_alloc(zsb
, db
, doi
.doi_data_block_size
,
1146 doi
.doi_bonus_type
, obj_num
, NULL
, NULL
);
1148 err
= SET_ERROR(ENOENT
);
1152 zfs_znode_hold_exit(zsb
, zh
);
1157 zfs_rezget(znode_t
*zp
)
1159 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1160 dmu_object_info_t doi
;
1162 uint64_t obj_num
= zp
->z_id
;
1164 sa_bulk_attr_t bulk
[7];
1170 zh
= zfs_znode_hold_enter(zsb
, obj_num
);
1172 mutex_enter(&zp
->z_acl_lock
);
1173 if (zp
->z_acl_cached
) {
1174 zfs_acl_free(zp
->z_acl_cached
);
1175 zp
->z_acl_cached
= NULL
;
1177 mutex_exit(&zp
->z_acl_lock
);
1179 rw_enter(&zp
->z_xattr_lock
, RW_WRITER
);
1180 if (zp
->z_xattr_cached
) {
1181 nvlist_free(zp
->z_xattr_cached
);
1182 zp
->z_xattr_cached
= NULL
;
1185 if (zp
->z_xattr_parent
) {
1186 zfs_iput_async(ZTOI(zp
->z_xattr_parent
));
1187 zp
->z_xattr_parent
= NULL
;
1189 rw_exit(&zp
->z_xattr_lock
);
1191 ASSERT(zp
->z_sa_hdl
== NULL
);
1192 err
= sa_buf_hold(zsb
->z_os
, obj_num
, NULL
, &db
);
1194 zfs_znode_hold_exit(zsb
, zh
);
1198 dmu_object_info_from_db(db
, &doi
);
1199 if (doi
.doi_bonus_type
!= DMU_OT_SA
&&
1200 (doi
.doi_bonus_type
!= DMU_OT_ZNODE
||
1201 (doi
.doi_bonus_type
== DMU_OT_ZNODE
&&
1202 doi
.doi_bonus_size
< sizeof (znode_phys_t
)))) {
1203 sa_buf_rele(db
, NULL
);
1204 zfs_znode_hold_exit(zsb
, zh
);
1205 return (SET_ERROR(EINVAL
));
1208 zfs_znode_sa_init(zsb
, zp
, db
, doi
.doi_bonus_type
, NULL
);
1210 /* reload cached values */
1211 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_GEN(zsb
), NULL
,
1212 &gen
, sizeof (gen
));
1213 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_SIZE(zsb
), NULL
,
1214 &zp
->z_size
, sizeof (zp
->z_size
));
1215 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_LINKS(zsb
), NULL
,
1216 &zp
->z_links
, sizeof (zp
->z_links
));
1217 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_FLAGS(zsb
), NULL
,
1218 &zp
->z_pflags
, sizeof (zp
->z_pflags
));
1219 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_UID(zsb
), NULL
,
1220 &zp
->z_uid
, sizeof (zp
->z_uid
));
1221 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_GID(zsb
), NULL
,
1222 &zp
->z_gid
, sizeof (zp
->z_gid
));
1223 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_MODE(zsb
), NULL
,
1224 &mode
, sizeof (mode
));
1226 if (sa_bulk_lookup(zp
->z_sa_hdl
, bulk
, count
)) {
1227 zfs_znode_dmu_fini(zp
);
1228 zfs_znode_hold_exit(zsb
, zh
);
1229 return (SET_ERROR(EIO
));
1234 if (gen
!= ZTOI(zp
)->i_generation
) {
1235 zfs_znode_dmu_fini(zp
);
1236 zfs_znode_hold_exit(zsb
, zh
);
1237 return (SET_ERROR(EIO
));
1240 zp
->z_unlinked
= (zp
->z_links
== 0);
1241 zp
->z_blksz
= doi
.doi_data_block_size
;
1242 zp
->z_atime_dirty
= 0;
1243 zfs_inode_update_new(zp
);
1245 zfs_znode_hold_exit(zsb
, zh
);
1251 zfs_znode_delete(znode_t
*zp
, dmu_tx_t
*tx
)
1253 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1254 objset_t
*os
= zsb
->z_os
;
1255 uint64_t obj
= zp
->z_id
;
1256 uint64_t acl_obj
= zfs_external_acl(zp
);
1259 zh
= zfs_znode_hold_enter(zsb
, obj
);
1261 VERIFY(!zp
->z_is_sa
);
1262 VERIFY(0 == dmu_object_free(os
, acl_obj
, tx
));
1264 VERIFY(0 == dmu_object_free(os
, obj
, tx
));
1265 zfs_znode_dmu_fini(zp
);
1266 zfs_znode_hold_exit(zsb
, zh
);
1270 zfs_zinactive(znode_t
*zp
)
1272 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1273 uint64_t z_id
= zp
->z_id
;
1276 ASSERT(zp
->z_sa_hdl
);
1279 * Don't allow a zfs_zget() while were trying to release this znode.
1281 zh
= zfs_znode_hold_enter(zsb
, z_id
);
1283 mutex_enter(&zp
->z_lock
);
1286 * If this was the last reference to a file with no links,
1287 * remove the file from the file system.
1289 if (zp
->z_unlinked
) {
1290 mutex_exit(&zp
->z_lock
);
1291 zfs_znode_hold_exit(zsb
, zh
);
1296 mutex_exit(&zp
->z_lock
);
1297 zfs_znode_dmu_fini(zp
);
1299 zfs_znode_hold_exit(zsb
, zh
);
1303 zfs_compare_timespec(struct timespec
*t1
, struct timespec
*t2
)
1305 if (t1
->tv_sec
< t2
->tv_sec
)
1308 if (t1
->tv_sec
> t2
->tv_sec
)
1311 return (t1
->tv_nsec
- t2
->tv_nsec
);
1315 * Prepare to update znode time stamps.
1317 * IN: zp - znode requiring timestamp update
1318 * flag - ATTR_MTIME, ATTR_CTIME flags
1324 * Note: We don't update atime here, because we rely on Linux VFS to do
1328 zfs_tstamp_update_setup(znode_t
*zp
, uint_t flag
, uint64_t mtime
[2],
1337 if (flag
& ATTR_MTIME
) {
1338 ZFS_TIME_ENCODE(&now
, mtime
);
1339 if (ZTOZSB(zp
)->z_use_fuids
) {
1340 zp
->z_pflags
|= (ZFS_ARCHIVE
|
1345 if (flag
& ATTR_CTIME
) {
1346 ZFS_TIME_ENCODE(&now
, ctime
);
1347 if (ZTOZSB(zp
)->z_use_fuids
)
1348 zp
->z_pflags
|= ZFS_ARCHIVE
;
1353 * Grow the block size for a file.
1355 * IN: zp - znode of file to free data in.
1356 * size - requested block size
1357 * tx - open transaction.
1359 * NOTE: this function assumes that the znode is write locked.
1362 zfs_grow_blocksize(znode_t
*zp
, uint64_t size
, dmu_tx_t
*tx
)
1367 if (size
<= zp
->z_blksz
)
1370 * If the file size is already greater than the current blocksize,
1371 * we will not grow. If there is more than one block in a file,
1372 * the blocksize cannot change.
1374 if (zp
->z_blksz
&& zp
->z_size
> zp
->z_blksz
)
1377 error
= dmu_object_set_blocksize(ZTOZSB(zp
)->z_os
, zp
->z_id
,
1380 if (error
== ENOTSUP
)
1384 /* What blocksize did we actually get? */
1385 dmu_object_size_from_db(sa_get_db(zp
->z_sa_hdl
), &zp
->z_blksz
, &dummy
);
1389 * Increase the file length
1391 * IN: zp - znode of file to free data in.
1392 * end - new end-of-file
1394 * RETURN: 0 on success, error code on failure
1397 zfs_extend(znode_t
*zp
, uint64_t end
)
1399 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1406 * We will change zp_size, lock the whole file.
1408 rl
= zfs_range_lock(zp
, 0, UINT64_MAX
, RL_WRITER
);
1411 * Nothing to do if file already at desired length.
1413 if (end
<= zp
->z_size
) {
1414 zfs_range_unlock(rl
);
1417 tx
= dmu_tx_create(zsb
->z_os
);
1418 dmu_tx_hold_sa(tx
, zp
->z_sa_hdl
, B_FALSE
);
1419 zfs_sa_upgrade_txholds(tx
, zp
);
1420 if (end
> zp
->z_blksz
&&
1421 (!ISP2(zp
->z_blksz
) || zp
->z_blksz
< zsb
->z_max_blksz
)) {
1423 * We are growing the file past the current block size.
1425 if (zp
->z_blksz
> ZTOZSB(zp
)->z_max_blksz
) {
1427 * File's blocksize is already larger than the
1428 * "recordsize" property. Only let it grow to
1429 * the next power of 2.
1431 ASSERT(!ISP2(zp
->z_blksz
));
1432 newblksz
= MIN(end
, 1 << highbit64(zp
->z_blksz
));
1434 newblksz
= MIN(end
, ZTOZSB(zp
)->z_max_blksz
);
1436 dmu_tx_hold_write(tx
, zp
->z_id
, 0, newblksz
);
1441 error
= dmu_tx_assign(tx
, TXG_WAIT
);
1444 zfs_range_unlock(rl
);
1449 zfs_grow_blocksize(zp
, newblksz
, tx
);
1453 VERIFY(0 == sa_update(zp
->z_sa_hdl
, SA_ZPL_SIZE(ZTOZSB(zp
)),
1454 &zp
->z_size
, sizeof (zp
->z_size
), tx
));
1456 zfs_range_unlock(rl
);
1464 * zfs_zero_partial_page - Modeled after update_pages() but
1465 * with different arguments and semantics for use by zfs_freesp().
1467 * Zeroes a piece of a single page cache entry for zp at offset
1468 * start and length len.
1470 * Caller must acquire a range lock on the file for the region
1471 * being zeroed in order that the ARC and page cache stay in sync.
1474 zfs_zero_partial_page(znode_t
*zp
, uint64_t start
, uint64_t len
)
1476 struct address_space
*mp
= ZTOI(zp
)->i_mapping
;
1481 ASSERT((start
& PAGE_MASK
) == ((start
+ len
- 1) & PAGE_MASK
));
1483 off
= start
& (PAGE_SIZE
- 1);
1486 pp
= find_lock_page(mp
, start
>> PAGE_SHIFT
);
1488 if (mapping_writably_mapped(mp
))
1489 flush_dcache_page(pp
);
1492 bzero(pb
+ off
, len
);
1495 if (mapping_writably_mapped(mp
))
1496 flush_dcache_page(pp
);
1498 mark_page_accessed(pp
);
1499 SetPageUptodate(pp
);
1507 * Free space in a file.
1509 * IN: zp - znode of file to free data in.
1510 * off - start of section to free.
1511 * len - length of section to free.
1513 * RETURN: 0 on success, error code on failure
1516 zfs_free_range(znode_t
*zp
, uint64_t off
, uint64_t len
)
1518 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1523 * Lock the range being freed.
1525 rl
= zfs_range_lock(zp
, off
, len
, RL_WRITER
);
1528 * Nothing to do if file already at desired length.
1530 if (off
>= zp
->z_size
) {
1531 zfs_range_unlock(rl
);
1535 if (off
+ len
> zp
->z_size
)
1536 len
= zp
->z_size
- off
;
1538 error
= dmu_free_long_range(zsb
->z_os
, zp
->z_id
, off
, len
);
1541 * Zero partial page cache entries. This must be done under a
1542 * range lock in order to keep the ARC and page cache in sync.
1544 if (zp
->z_is_mapped
) {
1545 loff_t first_page
, last_page
, page_len
;
1546 loff_t first_page_offset
, last_page_offset
;
1548 /* first possible full page in hole */
1549 first_page
= (off
+ PAGE_SIZE
- 1) >> PAGE_SHIFT
;
1550 /* last page of hole */
1551 last_page
= (off
+ len
) >> PAGE_SHIFT
;
1553 /* offset of first_page */
1554 first_page_offset
= first_page
<< PAGE_SHIFT
;
1555 /* offset of last_page */
1556 last_page_offset
= last_page
<< PAGE_SHIFT
;
1558 /* truncate whole pages */
1559 if (last_page_offset
> first_page_offset
) {
1560 truncate_inode_pages_range(ZTOI(zp
)->i_mapping
,
1561 first_page_offset
, last_page_offset
- 1);
1564 /* truncate sub-page ranges */
1565 if (first_page
> last_page
) {
1566 /* entire punched area within a single page */
1567 zfs_zero_partial_page(zp
, off
, len
);
1569 /* beginning of punched area at the end of a page */
1570 page_len
= first_page_offset
- off
;
1572 zfs_zero_partial_page(zp
, off
, page_len
);
1574 /* end of punched area at the beginning of a page */
1575 page_len
= off
+ len
- last_page_offset
;
1577 zfs_zero_partial_page(zp
, last_page_offset
,
1581 zfs_range_unlock(rl
);
1589 * IN: zp - znode of file to free data in.
1590 * end - new end-of-file.
1592 * RETURN: 0 on success, error code on failure
1595 zfs_trunc(znode_t
*zp
, uint64_t end
)
1597 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1601 sa_bulk_attr_t bulk
[2];
1605 * We will change zp_size, lock the whole file.
1607 rl
= zfs_range_lock(zp
, 0, UINT64_MAX
, RL_WRITER
);
1610 * Nothing to do if file already at desired length.
1612 if (end
>= zp
->z_size
) {
1613 zfs_range_unlock(rl
);
1617 error
= dmu_free_long_range(zsb
->z_os
, zp
->z_id
, end
, -1);
1619 zfs_range_unlock(rl
);
1622 tx
= dmu_tx_create(zsb
->z_os
);
1623 dmu_tx_hold_sa(tx
, zp
->z_sa_hdl
, B_FALSE
);
1624 zfs_sa_upgrade_txholds(tx
, zp
);
1625 dmu_tx_mark_netfree(tx
);
1626 error
= dmu_tx_assign(tx
, TXG_WAIT
);
1629 zfs_range_unlock(rl
);
1634 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_SIZE(zsb
),
1635 NULL
, &zp
->z_size
, sizeof (zp
->z_size
));
1638 zp
->z_pflags
&= ~ZFS_SPARSE
;
1639 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_FLAGS(zsb
),
1640 NULL
, &zp
->z_pflags
, 8);
1642 VERIFY(sa_bulk_update(zp
->z_sa_hdl
, bulk
, count
, tx
) == 0);
1646 zfs_range_unlock(rl
);
1652 * Free space in a file
1654 * IN: zp - znode of file to free data in.
1655 * off - start of range
1656 * len - end of range (0 => EOF)
1657 * flag - current file open mode flags.
1658 * log - TRUE if this action should be logged
1660 * RETURN: 0 on success, error code on failure
1663 zfs_freesp(znode_t
*zp
, uint64_t off
, uint64_t len
, int flag
, boolean_t log
)
1666 zfs_sb_t
*zsb
= ZTOZSB(zp
);
1667 zilog_t
*zilog
= zsb
->z_log
;
1669 uint64_t mtime
[2], ctime
[2];
1670 sa_bulk_attr_t bulk
[3];
1674 if ((error
= sa_lookup(zp
->z_sa_hdl
, SA_ZPL_MODE(zsb
), &mode
,
1675 sizeof (mode
))) != 0)
1678 if (off
> zp
->z_size
) {
1679 error
= zfs_extend(zp
, off
+len
);
1680 if (error
== 0 && log
)
1686 error
= zfs_trunc(zp
, off
);
1688 if ((error
= zfs_free_range(zp
, off
, len
)) == 0 &&
1689 off
+ len
> zp
->z_size
)
1690 error
= zfs_extend(zp
, off
+len
);
1695 tx
= dmu_tx_create(zsb
->z_os
);
1696 dmu_tx_hold_sa(tx
, zp
->z_sa_hdl
, B_FALSE
);
1697 zfs_sa_upgrade_txholds(tx
, zp
);
1698 error
= dmu_tx_assign(tx
, TXG_WAIT
);
1704 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_MTIME(zsb
), NULL
, mtime
, 16);
1705 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_CTIME(zsb
), NULL
, ctime
, 16);
1706 SA_ADD_BULK_ATTR(bulk
, count
, SA_ZPL_FLAGS(zsb
),
1707 NULL
, &zp
->z_pflags
, 8);
1708 zfs_tstamp_update_setup(zp
, CONTENT_MODIFIED
, mtime
, ctime
);
1709 error
= sa_bulk_update(zp
->z_sa_hdl
, bulk
, count
, tx
);
1712 zfs_log_truncate(zilog
, tx
, TX_TRUNCATE
, zp
, off
, len
);
1716 zfs_inode_update(zp
);
1721 * Truncate the page cache - for file truncate operations, use
1722 * the purpose-built API for truncations. For punching operations,
1723 * the truncation is handled under a range lock in zfs_free_range.
1726 truncate_setsize(ZTOI(zp
), off
);
1731 zfs_create_fs(objset_t
*os
, cred_t
*cr
, nvlist_t
*zplprops
, dmu_tx_t
*tx
)
1733 struct super_block
*sb
;
1735 uint64_t moid
, obj
, sa_obj
, version
;
1736 uint64_t sense
= ZFS_CASE_SENSITIVE
;
1742 znode_t
*rootzp
= NULL
;
1745 zfs_acl_ids_t acl_ids
;
1748 * First attempt to create master node.
1751 * In an empty objset, there are no blocks to read and thus
1752 * there can be no i/o errors (which we assert below).
1754 moid
= MASTER_NODE_OBJ
;
1755 error
= zap_create_claim(os
, moid
, DMU_OT_MASTER_NODE
,
1756 DMU_OT_NONE
, 0, tx
);
1760 * Set starting attributes.
1762 version
= zfs_zpl_version_map(spa_version(dmu_objset_spa(os
)));
1764 while ((elem
= nvlist_next_nvpair(zplprops
, elem
)) != NULL
) {
1765 /* For the moment we expect all zpl props to be uint64_ts */
1769 ASSERT(nvpair_type(elem
) == DATA_TYPE_UINT64
);
1770 VERIFY(nvpair_value_uint64(elem
, &val
) == 0);
1771 name
= nvpair_name(elem
);
1772 if (strcmp(name
, zfs_prop_to_name(ZFS_PROP_VERSION
)) == 0) {
1776 error
= zap_update(os
, moid
, name
, 8, 1, &val
, tx
);
1779 if (strcmp(name
, zfs_prop_to_name(ZFS_PROP_NORMALIZE
)) == 0)
1781 else if (strcmp(name
, zfs_prop_to_name(ZFS_PROP_CASE
)) == 0)
1784 ASSERT(version
!= 0);
1785 error
= zap_update(os
, moid
, ZPL_VERSION_STR
, 8, 1, &version
, tx
);
1788 * Create zap object used for SA attribute registration
1791 if (version
>= ZPL_VERSION_SA
) {
1792 sa_obj
= zap_create(os
, DMU_OT_SA_MASTER_NODE
,
1793 DMU_OT_NONE
, 0, tx
);
1794 error
= zap_add(os
, moid
, ZFS_SA_ATTRS
, 8, 1, &sa_obj
, tx
);
1800 * Create a delete queue.
1802 obj
= zap_create(os
, DMU_OT_UNLINKED_SET
, DMU_OT_NONE
, 0, tx
);
1804 error
= zap_add(os
, moid
, ZFS_UNLINKED_SET
, 8, 1, &obj
, tx
);
1808 * Create root znode. Create minimal znode/inode/zsb/sb
1809 * to allow zfs_mknode to work.
1811 vattr
.va_mask
= ATTR_MODE
|ATTR_UID
|ATTR_GID
;
1812 vattr
.va_mode
= S_IFDIR
|0755;
1813 vattr
.va_uid
= crgetuid(cr
);
1814 vattr
.va_gid
= crgetgid(cr
);
1816 rootzp
= kmem_cache_alloc(znode_cache
, KM_SLEEP
);
1817 rootzp
->z_moved
= 0;
1818 rootzp
->z_unlinked
= 0;
1819 rootzp
->z_atime_dirty
= 0;
1820 rootzp
->z_is_sa
= USE_SA(version
, os
);
1822 zsb
= kmem_zalloc(sizeof (zfs_sb_t
), KM_SLEEP
);
1824 zsb
->z_parent
= zsb
;
1825 zsb
->z_version
= version
;
1826 zsb
->z_use_fuids
= USE_FUIDS(version
, os
);
1827 zsb
->z_use_sa
= USE_SA(version
, os
);
1830 sb
= kmem_zalloc(sizeof (struct super_block
), KM_SLEEP
);
1831 sb
->s_fs_info
= zsb
;
1833 ZTOI(rootzp
)->i_sb
= sb
;
1835 error
= sa_setup(os
, sa_obj
, zfs_attr_table
, ZPL_END
,
1836 &zsb
->z_attr_table
);
1841 * Fold case on file systems that are always or sometimes case
1844 if (sense
== ZFS_CASE_INSENSITIVE
|| sense
== ZFS_CASE_MIXED
)
1845 zsb
->z_norm
|= U8_TEXTPREP_TOUPPER
;
1847 mutex_init(&zsb
->z_znodes_lock
, NULL
, MUTEX_DEFAULT
, NULL
);
1848 list_create(&zsb
->z_all_znodes
, sizeof (znode_t
),
1849 offsetof(znode_t
, z_link_node
));
1851 size
= MIN(1 << (highbit64(zfs_object_mutex_size
)-1), ZFS_OBJ_MTX_MAX
);
1852 zsb
->z_hold_size
= size
;
1853 zsb
->z_hold_trees
= vmem_zalloc(sizeof (avl_tree_t
) * size
, KM_SLEEP
);
1854 zsb
->z_hold_locks
= vmem_zalloc(sizeof (kmutex_t
) * size
, KM_SLEEP
);
1855 for (i
= 0; i
!= size
; i
++) {
1856 avl_create(&zsb
->z_hold_trees
[i
], zfs_znode_hold_compare
,
1857 sizeof (znode_hold_t
), offsetof(znode_hold_t
, zh_node
));
1858 mutex_init(&zsb
->z_hold_locks
[i
], NULL
, MUTEX_DEFAULT
, NULL
);
1861 VERIFY(0 == zfs_acl_ids_create(rootzp
, IS_ROOT_NODE
, &vattr
,
1862 cr
, NULL
, &acl_ids
));
1863 zfs_mknode(rootzp
, &vattr
, tx
, cr
, IS_ROOT_NODE
, &zp
, &acl_ids
);
1864 ASSERT3P(zp
, ==, rootzp
);
1865 error
= zap_add(os
, moid
, ZFS_ROOT_OBJ
, 8, 1, &rootzp
->z_id
, tx
);
1867 zfs_acl_ids_free(&acl_ids
);
1869 atomic_set(&ZTOI(rootzp
)->i_count
, 0);
1870 sa_handle_destroy(rootzp
->z_sa_hdl
);
1871 kmem_cache_free(znode_cache
, rootzp
);
1874 * Create shares directory
1876 error
= zfs_create_share_dir(zsb
, tx
);
1879 for (i
= 0; i
!= size
; i
++) {
1880 avl_destroy(&zsb
->z_hold_trees
[i
]);
1881 mutex_destroy(&zsb
->z_hold_locks
[i
]);
1884 vmem_free(zsb
->z_hold_trees
, sizeof (avl_tree_t
) * size
);
1885 vmem_free(zsb
->z_hold_locks
, sizeof (kmutex_t
) * size
);
1886 kmem_free(sb
, sizeof (struct super_block
));
1887 kmem_free(zsb
, sizeof (zfs_sb_t
));
1889 #endif /* _KERNEL */
1892 zfs_sa_setup(objset_t
*osp
, sa_attr_type_t
**sa_table
)
1894 uint64_t sa_obj
= 0;
1897 error
= zap_lookup(osp
, MASTER_NODE_OBJ
, ZFS_SA_ATTRS
, 8, 1, &sa_obj
);
1898 if (error
!= 0 && error
!= ENOENT
)
1901 error
= sa_setup(osp
, sa_obj
, zfs_attr_table
, ZPL_END
, sa_table
);
1906 zfs_grab_sa_handle(objset_t
*osp
, uint64_t obj
, sa_handle_t
**hdlp
,
1907 dmu_buf_t
**db
, void *tag
)
1909 dmu_object_info_t doi
;
1912 if ((error
= sa_buf_hold(osp
, obj
, tag
, db
)) != 0)
1915 dmu_object_info_from_db(*db
, &doi
);
1916 if ((doi
.doi_bonus_type
!= DMU_OT_SA
&&
1917 doi
.doi_bonus_type
!= DMU_OT_ZNODE
) ||
1918 (doi
.doi_bonus_type
== DMU_OT_ZNODE
&&
1919 doi
.doi_bonus_size
< sizeof (znode_phys_t
))) {
1920 sa_buf_rele(*db
, tag
);
1921 return (SET_ERROR(ENOTSUP
));
1924 error
= sa_handle_get(osp
, obj
, NULL
, SA_HDL_PRIVATE
, hdlp
);
1926 sa_buf_rele(*db
, tag
);
1934 zfs_release_sa_handle(sa_handle_t
*hdl
, dmu_buf_t
*db
, void *tag
)
1936 sa_handle_destroy(hdl
);
1937 sa_buf_rele(db
, tag
);
1941 * Given an object number, return its parent object number and whether
1942 * or not the object is an extended attribute directory.
1945 zfs_obj_to_pobj(objset_t
*osp
, sa_handle_t
*hdl
, sa_attr_type_t
*sa_table
,
1946 uint64_t *pobjp
, int *is_xattrdir
)
1951 uint64_t parent_mode
;
1952 sa_bulk_attr_t bulk
[3];
1953 sa_handle_t
*sa_hdl
;
1958 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_PARENT
], NULL
,
1959 &parent
, sizeof (parent
));
1960 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_FLAGS
], NULL
,
1961 &pflags
, sizeof (pflags
));
1962 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_MODE
], NULL
,
1963 &mode
, sizeof (mode
));
1965 if ((error
= sa_bulk_lookup(hdl
, bulk
, count
)) != 0)
1969 * When a link is removed its parent pointer is not changed and will
1970 * be invalid. There are two cases where a link is removed but the
1971 * file stays around, when it goes to the delete queue and when there
1972 * are additional links.
1974 error
= zfs_grab_sa_handle(osp
, parent
, &sa_hdl
, &sa_db
, FTAG
);
1978 error
= sa_lookup(sa_hdl
, ZPL_MODE
, &parent_mode
, sizeof (parent_mode
));
1979 zfs_release_sa_handle(sa_hdl
, sa_db
, FTAG
);
1983 *is_xattrdir
= ((pflags
& ZFS_XATTR
) != 0) && S_ISDIR(mode
);
1986 * Extended attributes can be applied to files, directories, etc.
1987 * Otherwise the parent must be a directory.
1989 if (!*is_xattrdir
&& !S_ISDIR(parent_mode
))
1998 * Given an object number, return some zpl level statistics
2001 zfs_obj_to_stats_impl(sa_handle_t
*hdl
, sa_attr_type_t
*sa_table
,
2004 sa_bulk_attr_t bulk
[4];
2007 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_MODE
], NULL
,
2008 &sb
->zs_mode
, sizeof (sb
->zs_mode
));
2009 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_GEN
], NULL
,
2010 &sb
->zs_gen
, sizeof (sb
->zs_gen
));
2011 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_LINKS
], NULL
,
2012 &sb
->zs_links
, sizeof (sb
->zs_links
));
2013 SA_ADD_BULK_ATTR(bulk
, count
, sa_table
[ZPL_CTIME
], NULL
,
2014 &sb
->zs_ctime
, sizeof (sb
->zs_ctime
));
2016 return (sa_bulk_lookup(hdl
, bulk
, count
));
2020 zfs_obj_to_path_impl(objset_t
*osp
, uint64_t obj
, sa_handle_t
*hdl
,
2021 sa_attr_type_t
*sa_table
, char *buf
, int len
)
2023 sa_handle_t
*sa_hdl
;
2024 sa_handle_t
*prevhdl
= NULL
;
2025 dmu_buf_t
*prevdb
= NULL
;
2026 dmu_buf_t
*sa_db
= NULL
;
2027 char *path
= buf
+ len
- 1;
2035 char component
[MAXNAMELEN
+ 2];
2037 int is_xattrdir
= 0;
2040 zfs_release_sa_handle(prevhdl
, prevdb
, FTAG
);
2042 if ((error
= zfs_obj_to_pobj(osp
, sa_hdl
, sa_table
, &pobj
,
2043 &is_xattrdir
)) != 0)
2054 (void) sprintf(component
+ 1, "<xattrdir>");
2056 error
= zap_value_search(osp
, pobj
, obj
,
2057 ZFS_DIRENT_OBJ(-1ULL), component
+ 1);
2062 complen
= strlen(component
);
2064 ASSERT(path
>= buf
);
2065 bcopy(component
, path
, complen
);
2068 if (sa_hdl
!= hdl
) {
2072 error
= zfs_grab_sa_handle(osp
, obj
, &sa_hdl
, &sa_db
, FTAG
);
2080 if (sa_hdl
!= NULL
&& sa_hdl
!= hdl
) {
2081 ASSERT(sa_db
!= NULL
);
2082 zfs_release_sa_handle(sa_hdl
, sa_db
, FTAG
);
2086 (void) memmove(buf
, path
, buf
+ len
- path
);
2092 zfs_obj_to_path(objset_t
*osp
, uint64_t obj
, char *buf
, int len
)
2094 sa_attr_type_t
*sa_table
;
2099 error
= zfs_sa_setup(osp
, &sa_table
);
2103 error
= zfs_grab_sa_handle(osp
, obj
, &hdl
, &db
, FTAG
);
2107 error
= zfs_obj_to_path_impl(osp
, obj
, hdl
, sa_table
, buf
, len
);
2109 zfs_release_sa_handle(hdl
, db
, FTAG
);
2114 zfs_obj_to_stats(objset_t
*osp
, uint64_t obj
, zfs_stat_t
*sb
,
2117 char *path
= buf
+ len
- 1;
2118 sa_attr_type_t
*sa_table
;
2125 error
= zfs_sa_setup(osp
, &sa_table
);
2129 error
= zfs_grab_sa_handle(osp
, obj
, &hdl
, &db
, FTAG
);
2133 error
= zfs_obj_to_stats_impl(hdl
, sa_table
, sb
);
2135 zfs_release_sa_handle(hdl
, db
, FTAG
);
2139 error
= zfs_obj_to_path_impl(osp
, obj
, hdl
, sa_table
, buf
, len
);
2141 zfs_release_sa_handle(hdl
, db
, FTAG
);
2145 #if defined(_KERNEL) && defined(HAVE_SPL)
2146 EXPORT_SYMBOL(zfs_create_fs
);
2147 EXPORT_SYMBOL(zfs_obj_to_path
);
2149 module_param(zfs_object_mutex_size
, uint
, 0644);
2150 MODULE_PARM_DESC(zfs_object_mutex_size
, "Size of znode hold array");