author | Mark Shellenbaum <Mark.Shellenbaum@Sun.COM> |
Tue, 16 Mar 2010 09:43:38 -0600 | |
changeset 11935 | 538c866aaac6 |
parent 11249 | 6c30f7dfc97b |
child 12050 | 5879aa161e65 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
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. |
|
12 |
* |
|
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] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
22 |
* Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
4144
068f395736ad
6465105 ZFS does not update timestamps upon the creat() of an existing file
peteh
parents:
4105
diff
changeset
|
26 |
/* Portions Copyright 2007 Jeremy Teo */ |
068f395736ad
6465105 ZFS does not update timestamps upon the creat() of an existing file
peteh
parents:
4105
diff
changeset
|
27 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
28 |
#ifdef _KERNEL |
789 | 29 |
#include <sys/types.h> |
30 |
#include <sys/param.h> |
|
31 |
#include <sys/time.h> |
|
32 |
#include <sys/systm.h> |
|
33 |
#include <sys/sysmacros.h> |
|
34 |
#include <sys/resource.h> |
|
35 |
#include <sys/mntent.h> |
|
1816
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
36 |
#include <sys/mkdev.h> |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
37 |
#include <sys/u8_textprep.h> |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
5844
diff
changeset
|
38 |
#include <sys/dsl_dataset.h> |
789 | 39 |
#include <sys/vfs.h> |
3898
c788126f2a20
PSARC/2007/124 Strong Type-Checking for VFS Operation Registration Mechanism
rsb
parents:
3897
diff
changeset
|
40 |
#include <sys/vfs_opreg.h> |
789 | 41 |
#include <sys/vnode.h> |
42 |
#include <sys/file.h> |
|
43 |
#include <sys/kmem.h> |
|
44 |
#include <sys/errno.h> |
|
45 |
#include <sys/unistd.h> |
|
46 |
#include <sys/mode.h> |
|
47 |
#include <sys/atomic.h> |
|
48 |
#include <vm/pvn.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> |
|
1669 | 53 |
#include <sys/zfs_rlock.h> |
5331 | 54 |
#include <sys/zfs_fuid.h> |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
55 |
#include <sys/dnode.h> |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
56 |
#include <sys/fs/zfs.h> |
5331 | 57 |
#include <sys/kidmap.h> |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
58 |
#endif /* _KERNEL */ |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
59 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
60 |
#include <sys/dmu.h> |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
61 |
#include <sys/refcount.h> |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
62 |
#include <sys/stat.h> |
789 | 63 |
#include <sys/zap.h> |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
64 |
#include <sys/zfs_znode.h> |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
65 |
#include <sys/sa.h> |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
66 |
#include <sys/zfs_sa.h> |
789 | 67 |
|
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
68 |
#include "zfs_prop.h" |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
69 |
#include "zfs_comutil.h" |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
70 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
71 |
/* |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
72 |
* Define ZNODE_STATS to turn on statistic gathering. By default, it is only |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
73 |
* turned on when DEBUG is also defined. |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
74 |
*/ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
75 |
#ifdef DEBUG |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
76 |
#define ZNODE_STATS |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
77 |
#endif /* DEBUG */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
78 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
79 |
#ifdef ZNODE_STATS |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
80 |
#define ZNODE_STAT_ADD(stat) ((stat)++) |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
81 |
#else |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
82 |
#define ZNODE_STAT_ADD(stat) /* nothing */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
83 |
#endif /* ZNODE_STATS */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
84 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
85 |
#define POINTER_IS_VALID(p) (!((uintptr_t)(p) & 0x3)) |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
86 |
#define POINTER_INVALIDATE(pp) (*(pp) = (void *)((uintptr_t)(*(pp)) | 0x1)) |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
87 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
88 |
/* |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
89 |
* Functions needed for userland (ie: libzpool) are not put under |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
90 |
* #ifdef_KERNEL; the rest of the functions have dependencies |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
91 |
* (such as VFS logic) that will not compile easily in userland. |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
92 |
*/ |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
93 |
#ifdef _KERNEL |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
94 |
/* |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
95 |
* Needed to close a small window in zfs_znode_move() that allows the zfsvfs to |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
96 |
* be freed before it can be safely accessed. |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
97 |
*/ |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
98 |
krwlock_t zfsvfs_lock; |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
99 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
100 |
static kmem_cache_t *znode_cache = NULL; |
789 | 101 |
|
102 |
/*ARGSUSED*/ |
|
103 |
static void |
|
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
104 |
znode_evict_error(dmu_buf_t *dbuf, void *user_ptr) |
789 | 105 |
{ |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
106 |
/* |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
107 |
* We should never drop all dbuf refs without first clearing |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
108 |
* the eviction callback. |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
109 |
*/ |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
110 |
panic("evicting znode %p\n", user_ptr); |
789 | 111 |
} |
112 |
||
113 |
/*ARGSUSED*/ |
|
114 |
static int |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
115 |
zfs_znode_cache_constructor(void *buf, void *arg, int kmflags) |
789 | 116 |
{ |
117 |
znode_t *zp = buf; |
|
118 |
||
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
119 |
ASSERT(!POINTER_IS_VALID(zp->z_zfsvfs)); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
120 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
121 |
zp->z_vnode = vn_alloc(kmflags); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
122 |
if (zp->z_vnode == NULL) { |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
123 |
return (-1); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
124 |
} |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
125 |
ZTOV(zp)->v_data = zp; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
126 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
127 |
list_link_init(&zp->z_link_node); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
128 |
|
789 | 129 |
mutex_init(&zp->z_lock, NULL, MUTEX_DEFAULT, NULL); |
1669 | 130 |
rw_init(&zp->z_parent_lock, NULL, RW_DEFAULT, NULL); |
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3461
diff
changeset
|
131 |
rw_init(&zp->z_name_lock, NULL, RW_DEFAULT, NULL); |
789 | 132 |
mutex_init(&zp->z_acl_lock, NULL, MUTEX_DEFAULT, NULL); |
1669 | 133 |
|
134 |
mutex_init(&zp->z_range_lock, NULL, MUTEX_DEFAULT, NULL); |
|
135 |
avl_create(&zp->z_range_avl, zfs_range_compare, |
|
136 |
sizeof (rl_t), offsetof(rl_t, r_node)); |
|
137 |
||
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
138 |
zp->z_dirlocks = NULL; |
9981
b4907297e740
6775100 stat() performance on files on zfs should be improved
Tim Haley <Tim.Haley@Sun.COM>
parents:
9788
diff
changeset
|
139 |
zp->z_acl_cached = NULL; |
789 | 140 |
return (0); |
141 |
} |
|
142 |
||
143 |
/*ARGSUSED*/ |
|
144 |
static void |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
145 |
zfs_znode_cache_destructor(void *buf, void *arg) |
789 | 146 |
{ |
147 |
znode_t *zp = buf; |
|
148 |
||
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
149 |
ASSERT(!POINTER_IS_VALID(zp->z_zfsvfs)); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
150 |
ASSERT(ZTOV(zp)->v_data == zp); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
151 |
vn_free(ZTOV(zp)); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
152 |
ASSERT(!list_link_active(&zp->z_link_node)); |
789 | 153 |
mutex_destroy(&zp->z_lock); |
1669 | 154 |
rw_destroy(&zp->z_parent_lock); |
3897
278bade789ba
6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents:
3461
diff
changeset
|
155 |
rw_destroy(&zp->z_name_lock); |
789 | 156 |
mutex_destroy(&zp->z_acl_lock); |
1669 | 157 |
avl_destroy(&zp->z_range_avl); |
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4577
diff
changeset
|
158 |
mutex_destroy(&zp->z_range_lock); |
789 | 159 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
160 |
ASSERT(zp->z_dirlocks == NULL); |
10143
d2d432dfe597
6857433 memory leaks found at: zfs_acl_alloc/zfs_acl_node_alloc
Tim Haley <Tim.Haley@Sun.COM>
parents:
9981
diff
changeset
|
161 |
ASSERT(zp->z_acl_cached == NULL); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
162 |
} |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
163 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
164 |
#ifdef ZNODE_STATS |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
165 |
static struct { |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
166 |
uint64_t zms_zfsvfs_invalid; |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
167 |
uint64_t zms_zfsvfs_recheck1; |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
168 |
uint64_t zms_zfsvfs_unmounted; |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
169 |
uint64_t zms_zfsvfs_recheck2; |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
170 |
uint64_t zms_obj_held; |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
171 |
uint64_t zms_vnode_locked; |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
172 |
uint64_t zms_not_only_dnlc; |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
173 |
} znode_move_stats; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
174 |
#endif /* ZNODE_STATS */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
175 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
176 |
static void |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
177 |
zfs_znode_move_impl(znode_t *ozp, znode_t *nzp) |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
178 |
{ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
179 |
vnode_t *vp; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
180 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
181 |
/* Copy fields. */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
182 |
nzp->z_zfsvfs = ozp->z_zfsvfs; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
183 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
184 |
/* Swap vnodes. */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
185 |
vp = nzp->z_vnode; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
186 |
nzp->z_vnode = ozp->z_vnode; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
187 |
ozp->z_vnode = vp; /* let destructor free the overwritten vnode */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
188 |
ZTOV(ozp)->v_data = ozp; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
189 |
ZTOV(nzp)->v_data = nzp; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
190 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
191 |
nzp->z_id = ozp->z_id; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
192 |
ASSERT(ozp->z_dirlocks == NULL); /* znode not in use */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
193 |
ASSERT(avl_numnodes(&ozp->z_range_avl) == 0); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
194 |
nzp->z_unlinked = ozp->z_unlinked; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
195 |
nzp->z_atime_dirty = ozp->z_atime_dirty; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
196 |
nzp->z_zn_prefetch = ozp->z_zn_prefetch; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
197 |
nzp->z_blksz = ozp->z_blksz; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
198 |
nzp->z_seq = ozp->z_seq; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
199 |
nzp->z_mapcnt = ozp->z_mapcnt; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
200 |
nzp->z_last_itx = ozp->z_last_itx; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
201 |
nzp->z_gen = ozp->z_gen; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
202 |
nzp->z_sync_cnt = ozp->z_sync_cnt; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
203 |
nzp->z_is_sa = ozp->z_is_sa; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
204 |
nzp->z_sa_hdl = ozp->z_sa_hdl; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
205 |
bcopy(ozp->z_atime, nzp->z_atime, sizeof (uint64_t) * 2); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
206 |
nzp->z_links = ozp->z_links; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
207 |
nzp->z_size = ozp->z_size; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
208 |
nzp->z_pflags = ozp->z_pflags; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
209 |
nzp->z_uid = ozp->z_uid; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
210 |
nzp->z_gid = ozp->z_gid; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
211 |
nzp->z_mode = ozp->z_mode; |
10250
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
212 |
|
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
213 |
/* |
10269
2788675568fd
6868276 zfs_rezget() can be hazardous when znode has a cached ACL
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10250
diff
changeset
|
214 |
* Since this is just an idle znode and kmem is already dealing with |
2788675568fd
6868276 zfs_rezget() can be hazardous when znode has a cached ACL
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10250
diff
changeset
|
215 |
* memory pressure, release any cached ACL. |
10250
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
216 |
*/ |
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
217 |
if (ozp->z_acl_cached) { |
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
218 |
zfs_acl_free(ozp->z_acl_cached); |
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
219 |
ozp->z_acl_cached = NULL; |
b179ceb34b62
6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e (#pf Page fault)
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10143
diff
changeset
|
220 |
} |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
221 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
222 |
sa_set_userp(nzp->z_sa_hdl, nzp); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
223 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
224 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
225 |
* Invalidate the original znode by clearing fields that provide a |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
226 |
* pointer back to the znode. Set the low bit of the vfs pointer to |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
227 |
* ensure that zfs_znode_move() recognizes the znode as invalid in any |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
228 |
* subsequent callback. |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
229 |
*/ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
230 |
ozp->z_sa_hdl = NULL; |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
231 |
POINTER_INVALIDATE(&ozp->z_zfsvfs); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
232 |
} |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
233 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
234 |
/*ARGSUSED*/ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
235 |
static kmem_cbrc_t |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
236 |
zfs_znode_move(void *buf, void *newbuf, size_t size, void *arg) |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
237 |
{ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
238 |
znode_t *ozp = buf, *nzp = newbuf; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
239 |
zfsvfs_t *zfsvfs; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
240 |
vnode_t *vp; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
241 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
242 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
243 |
* The znode is on the file system's list of known znodes if the vfs |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
244 |
* pointer is valid. We set the low bit of the vfs pointer when freeing |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
245 |
* the znode to invalidate it, and the memory patterns written by kmem |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
246 |
* (baddcafe and deadbeef) set at least one of the two low bits. A newly |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
247 |
* created znode sets the vfs pointer last of all to indicate that the |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
248 |
* znode is known and in a valid state to be moved by this function. |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
249 |
*/ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
250 |
zfsvfs = ozp->z_zfsvfs; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
251 |
if (!POINTER_IS_VALID(zfsvfs)) { |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
252 |
ZNODE_STAT_ADD(znode_move_stats.zms_zfsvfs_invalid); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
253 |
return (KMEM_CBRC_DONT_KNOW); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
254 |
} |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
255 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
256 |
/* |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
257 |
* Close a small window in which it's possible that the filesystem could |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
258 |
* be unmounted and freed, and zfsvfs, though valid in the previous |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
259 |
* statement, could point to unrelated memory by the time we try to |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
260 |
* prevent the filesystem from being unmounted. |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
261 |
*/ |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
262 |
rw_enter(&zfsvfs_lock, RW_WRITER); |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
263 |
if (zfsvfs != ozp->z_zfsvfs) { |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
264 |
rw_exit(&zfsvfs_lock); |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
265 |
ZNODE_STAT_ADD(znode_move_stats.zms_zfsvfs_recheck1); |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
266 |
return (KMEM_CBRC_DONT_KNOW); |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
267 |
} |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
268 |
|
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
269 |
/* |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
270 |
* If the znode is still valid, then so is the file system. We know that |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
271 |
* no valid file system can be freed while we hold zfsvfs_lock, so we |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
272 |
* can safely ensure that the filesystem is not and will not be |
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
273 |
* unmounted. The next statement is equivalent to ZFS_ENTER(). |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
274 |
*/ |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
275 |
rrw_enter(&zfsvfs->z_teardown_lock, RW_READER, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
276 |
if (zfsvfs->z_unmounted) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
277 |
ZFS_EXIT(zfsvfs); |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
278 |
rw_exit(&zfsvfs_lock); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
279 |
ZNODE_STAT_ADD(znode_move_stats.zms_zfsvfs_unmounted); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
280 |
return (KMEM_CBRC_DONT_KNOW); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
281 |
} |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
282 |
rw_exit(&zfsvfs_lock); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
283 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
284 |
mutex_enter(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
285 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
286 |
* Recheck the vfs pointer in case the znode was removed just before |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
287 |
* acquiring the lock. |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
288 |
*/ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
289 |
if (zfsvfs != ozp->z_zfsvfs) { |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
290 |
mutex_exit(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
291 |
ZFS_EXIT(zfsvfs); |
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
292 |
ZNODE_STAT_ADD(znode_move_stats.zms_zfsvfs_recheck2); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
293 |
return (KMEM_CBRC_DONT_KNOW); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
294 |
} |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
295 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
296 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
297 |
* At this point we know that as long as we hold z_znodes_lock, the |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
298 |
* znode cannot be freed and fields within the znode can be safely |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
299 |
* accessed. Now, prevent a race with zfs_zget(). |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
300 |
*/ |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
301 |
if (ZFS_OBJ_HOLD_TRYENTER(zfsvfs, ozp->z_id) == 0) { |
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
302 |
mutex_exit(&zfsvfs->z_znodes_lock); |
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
303 |
ZFS_EXIT(zfsvfs); |
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
304 |
ZNODE_STAT_ADD(znode_move_stats.zms_obj_held); |
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
305 |
return (KMEM_CBRC_LATER); |
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
306 |
} |
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
307 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
308 |
vp = ZTOV(ozp); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
309 |
if (mutex_tryenter(&vp->v_lock) == 0) { |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
310 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, ozp->z_id); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
311 |
mutex_exit(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
312 |
ZFS_EXIT(zfsvfs); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
313 |
ZNODE_STAT_ADD(znode_move_stats.zms_vnode_locked); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
314 |
return (KMEM_CBRC_LATER); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
315 |
} |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
316 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
317 |
/* Only move znodes that are referenced _only_ by the DNLC. */ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
318 |
if (vp->v_count != 1 || !vn_in_dnlc(vp)) { |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
319 |
mutex_exit(&vp->v_lock); |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
320 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, ozp->z_id); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
321 |
mutex_exit(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
322 |
ZFS_EXIT(zfsvfs); |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
323 |
ZNODE_STAT_ADD(znode_move_stats.zms_not_only_dnlc); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
324 |
return (KMEM_CBRC_LATER); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
325 |
} |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
326 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
327 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
328 |
* The znode is known and in a valid state to move. We're holding the |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
329 |
* locks needed to execute the critical section. |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
330 |
*/ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
331 |
zfs_znode_move_impl(ozp, nzp); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
332 |
mutex_exit(&vp->v_lock); |
7579
c91803605019
6744863 race between zfs_znode_move() and zfs_zget()
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
7240
diff
changeset
|
333 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, ozp->z_id); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
334 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
335 |
list_link_replace(&ozp->z_link_node, &nzp->z_link_node); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
336 |
mutex_exit(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
337 |
ZFS_EXIT(zfsvfs); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
338 |
|
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
339 |
return (KMEM_CBRC_YES); |
789 | 340 |
} |
341 |
||
342 |
void |
|
343 |
zfs_znode_init(void) |
|
344 |
{ |
|
345 |
/* |
|
346 |
* Initialize zcache |
|
347 |
*/ |
|
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
348 |
rw_init(&zfsvfs_lock, NULL, RW_DEFAULT, NULL); |
789 | 349 |
ASSERT(znode_cache == NULL); |
350 |
znode_cache = kmem_cache_create("zfs_znode_cache", |
|
351 |
sizeof (znode_t), 0, zfs_znode_cache_constructor, |
|
352 |
zfs_znode_cache_destructor, NULL, NULL, NULL, 0); |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
353 |
kmem_cache_set_move(znode_cache, zfs_znode_move); |
789 | 354 |
} |
355 |
||
356 |
void |
|
357 |
zfs_znode_fini(void) |
|
358 |
{ |
|
359 |
/* |
|
360 |
* Cleanup vfs & vnode ops |
|
361 |
*/ |
|
362 |
zfs_remove_op_tables(); |
|
363 |
||
364 |
/* |
|
365 |
* Cleanup zcache |
|
366 |
*/ |
|
367 |
if (znode_cache) |
|
368 |
kmem_cache_destroy(znode_cache); |
|
369 |
znode_cache = NULL; |
|
9788
f660bc44f2e8
6843700 zfs_znode_move() does not ensure valid file system pointer
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
9396
diff
changeset
|
370 |
rw_destroy(&zfsvfs_lock); |
789 | 371 |
} |
372 |
||
373 |
struct vnodeops *zfs_dvnodeops; |
|
374 |
struct vnodeops *zfs_fvnodeops; |
|
375 |
struct vnodeops *zfs_symvnodeops; |
|
376 |
struct vnodeops *zfs_xdvnodeops; |
|
377 |
struct vnodeops *zfs_evnodeops; |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
378 |
struct vnodeops *zfs_sharevnodeops; |
789 | 379 |
|
380 |
void |
|
381 |
zfs_remove_op_tables() |
|
382 |
{ |
|
383 |
/* |
|
384 |
* Remove vfs ops |
|
385 |
*/ |
|
386 |
ASSERT(zfsfstype); |
|
387 |
(void) vfs_freevfsops_by_type(zfsfstype); |
|
388 |
zfsfstype = 0; |
|
389 |
||
390 |
/* |
|
391 |
* Remove vnode ops |
|
392 |
*/ |
|
393 |
if (zfs_dvnodeops) |
|
394 |
vn_freevnodeops(zfs_dvnodeops); |
|
395 |
if (zfs_fvnodeops) |
|
396 |
vn_freevnodeops(zfs_fvnodeops); |
|
397 |
if (zfs_symvnodeops) |
|
398 |
vn_freevnodeops(zfs_symvnodeops); |
|
399 |
if (zfs_xdvnodeops) |
|
400 |
vn_freevnodeops(zfs_xdvnodeops); |
|
401 |
if (zfs_evnodeops) |
|
402 |
vn_freevnodeops(zfs_evnodeops); |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
403 |
if (zfs_sharevnodeops) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
404 |
vn_freevnodeops(zfs_sharevnodeops); |
789 | 405 |
|
406 |
zfs_dvnodeops = NULL; |
|
407 |
zfs_fvnodeops = NULL; |
|
408 |
zfs_symvnodeops = NULL; |
|
409 |
zfs_xdvnodeops = NULL; |
|
410 |
zfs_evnodeops = NULL; |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
411 |
zfs_sharevnodeops = NULL; |
789 | 412 |
} |
413 |
||
414 |
extern const fs_operation_def_t zfs_dvnodeops_template[]; |
|
415 |
extern const fs_operation_def_t zfs_fvnodeops_template[]; |
|
416 |
extern const fs_operation_def_t zfs_xdvnodeops_template[]; |
|
417 |
extern const fs_operation_def_t zfs_symvnodeops_template[]; |
|
418 |
extern const fs_operation_def_t zfs_evnodeops_template[]; |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
419 |
extern const fs_operation_def_t zfs_sharevnodeops_template[]; |
789 | 420 |
|
421 |
int |
|
422 |
zfs_create_op_tables() |
|
423 |
{ |
|
424 |
int error; |
|
425 |
||
426 |
/* |
|
427 |
* zfs_dvnodeops can be set if mod_remove() calls mod_installfs() |
|
428 |
* due to a failure to remove the the 2nd modlinkage (zfs_modldrv). |
|
429 |
* In this case we just return as the ops vectors are already set up. |
|
430 |
*/ |
|
431 |
if (zfs_dvnodeops) |
|
432 |
return (0); |
|
433 |
||
434 |
error = vn_make_ops(MNTTYPE_ZFS, zfs_dvnodeops_template, |
|
435 |
&zfs_dvnodeops); |
|
436 |
if (error) |
|
437 |
return (error); |
|
438 |
||
439 |
error = vn_make_ops(MNTTYPE_ZFS, zfs_fvnodeops_template, |
|
440 |
&zfs_fvnodeops); |
|
441 |
if (error) |
|
442 |
return (error); |
|
443 |
||
444 |
error = vn_make_ops(MNTTYPE_ZFS, zfs_symvnodeops_template, |
|
445 |
&zfs_symvnodeops); |
|
446 |
if (error) |
|
447 |
return (error); |
|
448 |
||
449 |
error = vn_make_ops(MNTTYPE_ZFS, zfs_xdvnodeops_template, |
|
450 |
&zfs_xdvnodeops); |
|
451 |
if (error) |
|
452 |
return (error); |
|
453 |
||
454 |
error = vn_make_ops(MNTTYPE_ZFS, zfs_evnodeops_template, |
|
455 |
&zfs_evnodeops); |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
456 |
if (error) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
457 |
return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
458 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
459 |
error = vn_make_ops(MNTTYPE_ZFS, zfs_sharevnodeops_template, |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
460 |
&zfs_sharevnodeops); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
461 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
462 |
return (error); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
463 |
} |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
464 |
|
9030
243fd360d81f
6815893 hang mounting a dataset after booting into a new boot environment
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
8845
diff
changeset
|
465 |
int |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
466 |
zfs_create_share_dir(zfsvfs_t *zfsvfs, dmu_tx_t *tx) |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
467 |
{ |
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
468 |
zfs_acl_ids_t acl_ids; |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
469 |
vattr_t vattr; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
470 |
znode_t *sharezp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
471 |
vnode_t *vp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
472 |
znode_t *zp; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
473 |
int error; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
474 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
475 |
vattr.va_mask = AT_MODE|AT_UID|AT_GID|AT_TYPE; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
476 |
vattr.va_type = VDIR; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
477 |
vattr.va_mode = S_IFDIR|0555; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
478 |
vattr.va_uid = crgetuid(kcred); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
479 |
vattr.va_gid = crgetgid(kcred); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
480 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
481 |
sharezp = kmem_cache_alloc(znode_cache, KM_SLEEP); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
482 |
sharezp->z_unlinked = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
483 |
sharezp->z_atime_dirty = 0; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
484 |
sharezp->z_zfsvfs = zfsvfs; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
485 |
sharezp->z_is_sa = zfsvfs->z_use_sa; |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
486 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
487 |
vp = ZTOV(sharezp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
488 |
vn_reinit(vp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
489 |
vp->v_type = VDIR; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
490 |
|
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
491 |
VERIFY(0 == zfs_acl_ids_create(sharezp, IS_ROOT_NODE, &vattr, |
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
492 |
kcred, NULL, &acl_ids)); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
493 |
zfs_mknode(sharezp, &vattr, tx, kcred, IS_ROOT_NODE, &zp, &acl_ids); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
494 |
ASSERT3P(zp, ==, sharezp); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
495 |
ASSERT(!vn_in_dnlc(ZTOV(sharezp))); /* not valid to move */ |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
496 |
POINTER_INVALIDATE(&sharezp->z_zfsvfs); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
497 |
error = zap_add(zfsvfs->z_os, MASTER_NODE_OBJ, |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
498 |
ZFS_SHARES_DIR, 8, 1, &sharezp->z_id, tx); |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
499 |
zfsvfs->z_shares_dir = sharezp->z_id; |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
500 |
|
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
501 |
zfs_acl_ids_free(&acl_ids); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
502 |
ZTOV(sharezp)->v_count = 0; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
503 |
sa_handle_destroy(sharezp->z_sa_hdl); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
504 |
kmem_cache_free(znode_cache, sharezp); |
789 | 505 |
|
506 |
return (error); |
|
507 |
} |
|
508 |
||
509 |
/* |
|
1816
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
510 |
* define a couple of values we need available |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
511 |
* for both 64 and 32 bit environments. |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
512 |
*/ |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
513 |
#ifndef NBITSMINOR64 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
514 |
#define NBITSMINOR64 32 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
515 |
#endif |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
516 |
#ifndef MAXMAJ64 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
517 |
#define MAXMAJ64 0xffffffffUL |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
518 |
#endif |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
519 |
#ifndef MAXMIN64 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
520 |
#define MAXMIN64 0xffffffffUL |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
521 |
#endif |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
522 |
|
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
523 |
/* |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
524 |
* Create special expldev for ZFS private use. |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
525 |
* Can't use standard expldev since it doesn't do |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
526 |
* what we want. The standard expldev() takes a |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
527 |
* dev32_t in LP64 and expands it to a long dev_t. |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
528 |
* We need an interface that takes a dev32_t in ILP32 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
529 |
* and expands it to a long dev_t. |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
530 |
*/ |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
531 |
static uint64_t |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
532 |
zfs_expldev(dev_t dev) |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
533 |
{ |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
534 |
#ifndef _LP64 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
535 |
major_t major = (major_t)dev >> NBITSMINOR32 & MAXMAJ32; |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
536 |
return (((uint64_t)major << NBITSMINOR64) | |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
537 |
((minor_t)dev & MAXMIN32)); |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
538 |
#else |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
539 |
return (dev); |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
540 |
#endif |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
541 |
} |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
542 |
|
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
543 |
/* |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
544 |
* Special cmpldev for ZFS private use. |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
545 |
* Can't use standard cmpldev since it takes |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
546 |
* a long dev_t and compresses it to dev32_t in |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
547 |
* LP64. We need to do a compaction of a long dev_t |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
548 |
* to a dev32_t in ILP32. |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
549 |
*/ |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
550 |
dev_t |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
551 |
zfs_cmpldev(uint64_t dev) |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
552 |
{ |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
553 |
#ifndef _LP64 |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
554 |
minor_t minor = (minor_t)dev & MAXMIN64; |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
555 |
major_t major = (major_t)(dev >> NBITSMINOR64) & MAXMAJ64; |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
556 |
|
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
557 |
if (major > MAXMAJ32 || minor > MAXMIN32) |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
558 |
return (NODEV32); |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
559 |
|
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
560 |
return (((dev32_t)major << NBITSMINOR32) | minor); |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
561 |
#else |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
562 |
return (dev); |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
563 |
#endif |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
564 |
} |
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
565 |
|
5446 | 566 |
static void |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
567 |
zfs_znode_sa_init(zfsvfs_t *zfsvfs, znode_t *zp, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
568 |
dmu_buf_t *db, dmu_object_type_t obj_type, sa_handle_t *sa_hdl) |
5446 | 569 |
{ |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
570 |
ASSERT(!POINTER_IS_VALID(zp->z_zfsvfs) || (zfsvfs == zp->z_zfsvfs)); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
571 |
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zfsvfs, zp->z_id))); |
5446 | 572 |
|
573 |
mutex_enter(&zp->z_lock); |
|
574 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
575 |
ASSERT(zp->z_sa_hdl == NULL); |
10269
2788675568fd
6868276 zfs_rezget() can be hazardous when znode has a cached ACL
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10250
diff
changeset
|
576 |
ASSERT(zp->z_acl_cached == NULL); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
577 |
if (sa_hdl == NULL) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
578 |
VERIFY(0 == sa_handle_get_from_db(zfsvfs->z_os, db, zp, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
579 |
SA_HDL_SHARED, &zp->z_sa_hdl)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
580 |
} else { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
581 |
zp->z_sa_hdl = sa_hdl; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
582 |
sa_set_userp(sa_hdl, zp); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
583 |
} |
5446 | 584 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
585 |
zp->z_is_sa = (obj_type == DMU_OT_SA) ? B_TRUE : B_FALSE; |
5446 | 586 |
|
587 |
/* |
|
588 |
* Slap on VROOT if we are the root znode |
|
589 |
*/ |
|
590 |
if (zp->z_id == zfsvfs->z_root) |
|
591 |
ZTOV(zp)->v_flag |= VROOT; |
|
592 |
||
593 |
mutex_exit(&zp->z_lock); |
|
594 |
vn_exists(ZTOV(zp)); |
|
595 |
} |
|
596 |
||
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
597 |
void |
5446 | 598 |
zfs_znode_dmu_fini(znode_t *zp) |
599 |
{ |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
600 |
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zp->z_zfsvfs, zp->z_id)) || |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
601 |
zp->z_unlinked || |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
602 |
RW_WRITE_HELD(&zp->z_zfsvfs->z_teardown_inactive_lock)); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
603 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
604 |
sa_handle_destroy(zp->z_sa_hdl); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
605 |
zp->z_sa_hdl = NULL; |
5446 | 606 |
} |
607 |
||
1816
8c14b56c8515
6408482 64-bit system can't read some 32-bit dev_ts created on zfs
marks
parents:
1760
diff
changeset
|
608 |
/* |
789 | 609 |
* Construct a new znode/vnode and intialize. |
610 |
* |
|
611 |
* This does not do a call to dmu_set_user() that is |
|
612 |
* up to the caller to do, in case you don't want to |
|
613 |
* return the znode |
|
614 |
*/ |
|
1544 | 615 |
static znode_t * |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
616 |
zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
617 |
dmu_object_type_t obj_type, sa_handle_t *hdl) |
789 | 618 |
{ |
619 |
znode_t *zp; |
|
620 |
vnode_t *vp; |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
621 |
uint64_t mode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
622 |
uint64_t parent; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
623 |
uint64_t uid, gid; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
624 |
sa_bulk_attr_t bulk[9]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
625 |
int count = 0; |
789 | 626 |
|
627 |
zp = kmem_cache_alloc(znode_cache, KM_SLEEP); |
|
628 |
||
629 |
ASSERT(zp->z_dirlocks == NULL); |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
630 |
ASSERT(!POINTER_IS_VALID(zp->z_zfsvfs)); |
789 | 631 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
632 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
633 |
* Defer setting z_zfsvfs until the znode is ready to be a candidate for |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
634 |
* the zfs_znode_move() callback. |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
635 |
*/ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
636 |
zp->z_sa_hdl = NULL; |
3461 | 637 |
zp->z_unlinked = 0; |
789 | 638 |
zp->z_atime_dirty = 0; |
639 |
zp->z_mapcnt = 0; |
|
640 |
zp->z_last_itx = 0; |
|
5446 | 641 |
zp->z_id = db->db_object; |
789 | 642 |
zp->z_blksz = blksz; |
643 |
zp->z_seq = 0x7A4653; |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2885
diff
changeset
|
644 |
zp->z_sync_cnt = 0; |
5446 | 645 |
|
646 |
vp = ZTOV(zp); |
|
647 |
vn_reinit(vp); |
|
648 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
649 |
zfs_znode_sa_init(zfsvfs, zp, db, obj_type, hdl); |
5446 | 650 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
651 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
652 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GEN(zfsvfs), NULL, &zp->z_gen, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
653 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_SIZE(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
654 |
&zp->z_size, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
655 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_LINKS(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
656 |
&zp->z_links, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
657 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
658 |
&zp->z_pflags, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
659 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_PARENT(zfsvfs), NULL, &parent, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
660 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
661 |
&zp->z_atime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
662 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
663 |
&uid, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
664 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
665 |
&gid, 8); |
789 | 666 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
667 |
if (sa_bulk_lookup(zp->z_sa_hdl, bulk, count) != 0 || zp->z_gen == 0) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
668 |
if (hdl == NULL) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
669 |
sa_handle_destroy(zp->z_sa_hdl); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
670 |
kmem_cache_free(znode_cache, zp); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
671 |
return (NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
672 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
673 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
674 |
zp->z_uid = zfs_fuid_map_id(zfsvfs, uid, CRED(), ZFS_OWNER); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
675 |
zp->z_gid = zfs_fuid_map_id(zfsvfs, gid, CRED(), ZFS_GROUP); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
676 |
zp->z_mode = mode; |
789 | 677 |
vp->v_vfsp = zfsvfs->z_parent->z_vfs; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
678 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
679 |
vp->v_type = IFTOVT((mode_t)mode); |
789 | 680 |
|
681 |
switch (vp->v_type) { |
|
682 |
case VDIR: |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
683 |
if (zp->z_pflags & ZFS_XATTR) { |
789 | 684 |
vn_setops(vp, zfs_xdvnodeops); |
685 |
vp->v_flag |= V_XATTRDIR; |
|
5446 | 686 |
} else { |
789 | 687 |
vn_setops(vp, zfs_dvnodeops); |
5446 | 688 |
} |
869
dc133b87dfb3
6297285 znode prefetching in zfs_readdir causes 5x performance degradation for 'ls'
perrin
parents:
789
diff
changeset
|
689 |
zp->z_zn_prefetch = B_TRUE; /* z_prefetch default is enabled */ |
789 | 690 |
break; |
691 |
case VBLK: |
|
692 |
case VCHR: |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
693 |
{ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
694 |
uint64_t rdev; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
695 |
VERIFY(sa_lookup(zp->z_sa_hdl, SA_ZPL_RDEV(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
696 |
&rdev, sizeof (rdev)) == 0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
697 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
698 |
vp->v_rdev = zfs_cmpldev(rdev); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
699 |
} |
789 | 700 |
/*FALLTHROUGH*/ |
701 |
case VFIFO: |
|
702 |
case VSOCK: |
|
703 |
case VDOOR: |
|
704 |
vn_setops(vp, zfs_fvnodeops); |
|
705 |
break; |
|
706 |
case VREG: |
|
707 |
vp->v_flag |= VMODSORT; |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
708 |
if (parent == zfsvfs->z_shares_dir) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
709 |
ASSERT(uid == 0 && gid == 0); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
710 |
vn_setops(vp, zfs_sharevnodeops); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
711 |
} else { |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
712 |
vn_setops(vp, zfs_fvnodeops); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
713 |
} |
789 | 714 |
break; |
715 |
case VLNK: |
|
716 |
vn_setops(vp, zfs_symvnodeops); |
|
717 |
break; |
|
718 |
default: |
|
719 |
vn_setops(vp, zfs_evnodeops); |
|
720 |
break; |
|
721 |
} |
|
722 |
||
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
723 |
mutex_enter(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
724 |
list_insert_tail(&zfsvfs->z_all_znodes, zp); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
725 |
membar_producer(); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
726 |
/* |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
727 |
* Everything else must be valid before assigning z_zfsvfs makes the |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
728 |
* znode eligible for zfs_znode_move(). |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
729 |
*/ |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
730 |
zp->z_zfsvfs = zfsvfs; |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
731 |
mutex_exit(&zfsvfs->z_znodes_lock); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
732 |
|
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
733 |
VFS_HOLD(zfsvfs->z_vfs); |
789 | 734 |
return (zp); |
735 |
} |
|
736 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
737 |
static uint64_t empty_xattr; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
738 |
static uint64_t pad[4]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
739 |
static zfs_acl_phys_t acl_phys; |
789 | 740 |
/* |
741 |
* Create a new DMU object to hold a zfs znode. |
|
742 |
* |
|
743 |
* IN: dzp - parent directory for new znode |
|
744 |
* vap - file attributes for new znode |
|
745 |
* tx - dmu transaction id for zap operations |
|
746 |
* cr - credentials of caller |
|
747 |
* flag - flags: |
|
748 |
* IS_ROOT_NODE - new object will be root |
|
749 |
* IS_XATTR - new object is an attribute |
|
5331 | 750 |
* bonuslen - length of bonus buffer |
751 |
* setaclp - File/Dir initial ACL |
|
752 |
* fuidp - Tracks fuid allocation. |
|
789 | 753 |
* |
5446 | 754 |
* OUT: zpp - allocated znode |
789 | 755 |
* |
756 |
*/ |
|
757 |
void |
|
5446 | 758 |
zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
759 |
uint_t flag, znode_t **zpp, zfs_acl_ids_t *acl_ids) |
789 | 760 |
{ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
761 |
uint64_t crtime[2], atime[2], mtime[2], ctime[2]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
762 |
uint64_t mode, size, links, parent, pflags; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
763 |
uint64_t dzp_pflags = 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
764 |
uint64_t rdev = 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
765 |
zfsvfs_t *zfsvfs = dzp->z_zfsvfs; |
5446 | 766 |
dmu_buf_t *db; |
789 | 767 |
timestruc_t now; |
5446 | 768 |
uint64_t gen, obj; |
789 | 769 |
int err; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
770 |
int bonuslen; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
771 |
sa_handle_t *sa_hdl; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
772 |
dmu_object_type_t obj_type; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
773 |
sa_bulk_attr_t sa_attrs[ZPL_END]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
774 |
int cnt = 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
775 |
zfs_acl_locator_cb_t locate = { 0 }; |
789 | 776 |
|
777 |
ASSERT(vap && (vap->va_mask & (AT_TYPE|AT_MODE)) == (AT_TYPE|AT_MODE)); |
|
778 |
||
8227 | 779 |
if (zfsvfs->z_replay) { |
5446 | 780 |
obj = vap->va_nodeid; |
789 | 781 |
now = vap->va_ctime; /* see zfs_replay_create() */ |
782 |
gen = vap->va_nblocks; /* ditto */ |
|
783 |
} else { |
|
5446 | 784 |
obj = 0; |
789 | 785 |
gethrestime(&now); |
786 |
gen = dmu_tx_get_txg(tx); |
|
787 |
} |
|
788 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
789 |
obj_type = zfsvfs->z_use_sa ? DMU_OT_SA : DMU_OT_ZNODE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
790 |
bonuslen = (obj_type == DMU_OT_SA) ? |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
791 |
DN_MAX_BONUSLEN : ZFS_OLD_ZNODE_PHYS_SIZE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
792 |
|
789 | 793 |
/* |
794 |
* Create a new DMU object. |
|
795 |
*/ |
|
1544 | 796 |
/* |
797 |
* There's currently no mechanism for pre-reading the blocks that will |
|
798 |
* be to needed allocate a new object, so we accept the small chance |
|
799 |
* that there will be an i/o error and we will fail one of the |
|
800 |
* assertions below. |
|
801 |
*/ |
|
789 | 802 |
if (vap->va_type == VDIR) { |
11249
6c30f7dfc97b
6906110 bad trap panic in zil_replay_log_record
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10938
diff
changeset
|
803 |
if (zfsvfs->z_replay) { |
5446 | 804 |
err = zap_create_claim_norm(zfsvfs->z_os, obj, |
5331 | 805 |
zfsvfs->z_norm, DMU_OT_DIRECTORY_CONTENTS, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
806 |
obj_type, bonuslen, tx); |
789 | 807 |
ASSERT3U(err, ==, 0); |
808 |
} else { |
|
5446 | 809 |
obj = zap_create_norm(zfsvfs->z_os, |
5331 | 810 |
zfsvfs->z_norm, DMU_OT_DIRECTORY_CONTENTS, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
811 |
obj_type, bonuslen, tx); |
789 | 812 |
} |
813 |
} else { |
|
11249
6c30f7dfc97b
6906110 bad trap panic in zil_replay_log_record
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10938
diff
changeset
|
814 |
if (zfsvfs->z_replay) { |
5446 | 815 |
err = dmu_object_claim(zfsvfs->z_os, obj, |
789 | 816 |
DMU_OT_PLAIN_FILE_CONTENTS, 0, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
817 |
obj_type, bonuslen, tx); |
789 | 818 |
ASSERT3U(err, ==, 0); |
819 |
} else { |
|
5446 | 820 |
obj = dmu_object_alloc(zfsvfs->z_os, |
789 | 821 |
DMU_OT_PLAIN_FILE_CONTENTS, 0, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
822 |
obj_type, bonuslen, tx); |
789 | 823 |
} |
824 |
} |
|
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
825 |
|
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
826 |
ZFS_OBJ_HOLD_ENTER(zfsvfs, obj); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
827 |
VERIFY(0 == sa_buf_hold(zfsvfs->z_os, obj, NULL, &db)); |
789 | 828 |
|
829 |
/* |
|
830 |
* If this is the root, fix up the half-initialized parent pointer |
|
831 |
* to reference the just-allocated physical data area. |
|
832 |
*/ |
|
833 |
if (flag & IS_ROOT_NODE) { |
|
5446 | 834 |
dzp->z_id = obj; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
835 |
} else { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
836 |
dzp_pflags = dzp->z_pflags; |
789 | 837 |
} |
838 |
||
839 |
/* |
|
840 |
* If parent is an xattr, so am I. |
|
841 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
842 |
if (dzp_pflags & ZFS_XATTR) { |
789 | 843 |
flag |= IS_XATTR; |
844 |
} |
|
845 |
||
5331 | 846 |
if (zfsvfs->z_use_fuids) |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
847 |
pflags = ZFS_ARCHIVE | ZFS_AV_MODIFIED; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
848 |
else |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
849 |
pflags = 0; |
5331 | 850 |
|
789 | 851 |
if (vap->va_type == VDIR) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
852 |
size = 2; /* contents ("." and "..") */ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
853 |
links = (flag & (IS_ROOT_NODE | IS_XATTR)) ? 2 : 1; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
854 |
} else { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
855 |
size = links = 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
856 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
857 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
858 |
if (vap->va_type == VBLK || vap->va_type == VCHR) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
859 |
rdev = zfs_expldev(vap->va_rdev); |
789 | 860 |
} |
861 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
862 |
parent = dzp->z_id; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
863 |
mode = acl_ids->z_mode; |
789 | 864 |
if (flag & IS_XATTR) |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
865 |
pflags |= ZFS_XATTR; |
789 | 866 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
867 |
/* |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
868 |
* No execs denied will be deterimed when zfs_mode_compute() is called. |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
869 |
*/ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
870 |
pflags |= acl_ids->z_aclp->z_hints & |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
871 |
(ZFS_ACL_TRIVIAL|ZFS_INHERIT_ACE|ZFS_ACL_AUTO_INHERIT| |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
872 |
ZFS_ACL_DEFAULTED|ZFS_ACL_PROTECTED); |
789 | 873 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
874 |
ZFS_TIME_ENCODE(&now, crtime); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
875 |
ZFS_TIME_ENCODE(&now, ctime); |
789 | 876 |
|
877 |
if (vap->va_mask & AT_ATIME) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
878 |
ZFS_TIME_ENCODE(&vap->va_atime, atime); |
789 | 879 |
} else { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
880 |
ZFS_TIME_ENCODE(&now, atime); |
789 | 881 |
} |
882 |
||
883 |
if (vap->va_mask & AT_MTIME) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
884 |
ZFS_TIME_ENCODE(&vap->va_mtime, mtime); |
789 | 885 |
} else { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
886 |
ZFS_TIME_ENCODE(&now, mtime); |
789 | 887 |
} |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
888 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
889 |
/* Now add in all of the "SA" attributes */ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
890 |
VERIFY(0 == sa_handle_get_from_db(zfsvfs->z_os, db, NULL, SA_HDL_SHARED, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
891 |
&sa_hdl)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
892 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
893 |
/* |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
894 |
* Setup the array of attributes to be replaced/set on the new file |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
895 |
* |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
896 |
* order for DMU_OT_ZNODE is critical since it needs to be constructed |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
897 |
* in the old znode_phys_t format. Don't change this ordering |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
898 |
*/ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
899 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
900 |
if (obj_type == DMU_OT_ZNODE) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
901 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_ATIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
902 |
NULL, &atime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
903 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_MTIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
904 |
NULL, &mtime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
905 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_CTIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
906 |
NULL, &ctime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
907 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_CRTIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
908 |
NULL, &crtime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
909 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_GEN(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
910 |
NULL, &gen, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
911 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_MODE(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
912 |
NULL, &mode, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
913 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_SIZE(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
914 |
NULL, &size, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
915 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_PARENT(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
916 |
NULL, &parent, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
917 |
} else { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
918 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_MODE(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
919 |
NULL, &mode, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
920 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_SIZE(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
921 |
NULL, &size, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
922 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_GEN(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
923 |
NULL, &gen, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
924 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_UID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
925 |
&acl_ids->z_fuid, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
926 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_GID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
927 |
&acl_ids->z_fgid, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
928 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_PARENT(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
929 |
NULL, &parent, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
930 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_FLAGS(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
931 |
NULL, &pflags, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
932 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_ATIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
933 |
NULL, &atime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
934 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_MTIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
935 |
NULL, &mtime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
936 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_CTIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
937 |
NULL, &ctime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
938 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_CRTIME(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
939 |
NULL, &crtime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
940 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
941 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
942 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_LINKS(zfsvfs), NULL, &links, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
943 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
944 |
if (obj_type == DMU_OT_ZNODE) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
945 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_XATTR(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
946 |
&empty_xattr, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
947 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
948 |
if (obj_type == DMU_OT_ZNODE || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
949 |
(vap->va_type == VBLK || vap->va_type == VCHR)) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
950 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_RDEV(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
951 |
NULL, &rdev, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
952 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
953 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
954 |
if (obj_type == DMU_OT_ZNODE) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
955 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_FLAGS(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
956 |
NULL, &pflags, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
957 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_UID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
958 |
&acl_ids->z_fuid, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
959 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_GID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
960 |
&acl_ids->z_fgid, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
961 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_PAD(zfsvfs), NULL, pad, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
962 |
sizeof (uint64_t) * 4); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
963 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_ZNODE_ACL(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
964 |
&acl_phys, sizeof (zfs_acl_phys_t)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
965 |
} else if (acl_ids->z_aclp->z_version >= ZFS_ACL_VERSION_FUID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
966 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_DACL_COUNT(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
967 |
&acl_ids->z_aclp->z_acl_count, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
968 |
locate.cb_aclp = acl_ids->z_aclp; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
969 |
SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_DACL_ACES(zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
970 |
zfs_acl_data_locator, &locate, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
971 |
acl_ids->z_aclp->z_acl_bytes); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
972 |
mode = zfs_mode_compute(mode, acl_ids->z_aclp, &pflags); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
973 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
974 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
975 |
VERIFY(sa_replace_all_by_template(sa_hdl, sa_attrs, cnt, tx) == 0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
976 |
|
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
977 |
if (!(flag & IS_ROOT_NODE)) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
978 |
*zpp = zfs_znode_alloc(zfsvfs, db, 0, obj_type, sa_hdl); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
979 |
ASSERT(*zpp != NULL); |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
980 |
} else { |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
981 |
/* |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
982 |
* If we are creating the root node, the "parent" we |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
983 |
* passed in is the znode for the root. |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
984 |
*/ |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
985 |
*zpp = dzp; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
986 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
987 |
(*zpp)->z_sa_hdl = sa_hdl; |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
988 |
} |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
989 |
|
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
990 |
if (vap->va_mask & AT_XVATTR) |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
991 |
zfs_xvattr_set(*zpp, (xvattr_t *)vap, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
992 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
993 |
(*zpp)->z_pflags = pflags; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
994 |
(*zpp)->z_mode = mode; |
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
995 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
996 |
if (obj_type == DMU_OT_ZNODE || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
997 |
acl_ids->z_aclp->z_version < ZFS_ACL_VERSION_FUID) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
998 |
err = zfs_aclset_common(*zpp, acl_ids->z_aclp, cr, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
999 |
ASSERT3P(err, ==, 0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1000 |
} |
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1001 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj); |
789 | 1002 |
} |
1003 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1004 |
/* |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1005 |
* zfs_xvattr_set only updates the in-core attributes |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1006 |
* it is assumed the caller will be doing an sa_bulk_update |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1007 |
* to push the changes out |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1008 |
*/ |
5331 | 1009 |
void |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1010 |
zfs_xvattr_set(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx) |
5331 | 1011 |
{ |
1012 |
xoptattr_t *xoap; |
|
1013 |
||
1014 |
xoap = xva_getxoptattr(xvap); |
|
1015 |
ASSERT(xoap); |
|
1016 |
||
1017 |
if (XVA_ISSET_REQ(xvap, XAT_CREATETIME)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1018 |
uint64_t times[2]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1019 |
ZFS_TIME_ENCODE(&xoap->xoa_createtime, times); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1020 |
(void) sa_update(zp->z_sa_hdl, SA_ZPL_CRTIME(zp->z_zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1021 |
×, sizeof (times), tx); |
5331 | 1022 |
XVA_SET_RTN(xvap, XAT_CREATETIME); |
1023 |
} |
|
1024 |
if (XVA_ISSET_REQ(xvap, XAT_READONLY)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1025 |
ZFS_ATTR_SET(zp, ZFS_READONLY, xoap->xoa_readonly, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1026 |
zp->z_pflags, tx); |
5331 | 1027 |
XVA_SET_RTN(xvap, XAT_READONLY); |
1028 |
} |
|
1029 |
if (XVA_ISSET_REQ(xvap, XAT_HIDDEN)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1030 |
ZFS_ATTR_SET(zp, ZFS_HIDDEN, xoap->xoa_hidden, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1031 |
zp->z_pflags, tx); |
5331 | 1032 |
XVA_SET_RTN(xvap, XAT_HIDDEN); |
1033 |
} |
|
1034 |
if (XVA_ISSET_REQ(xvap, XAT_SYSTEM)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1035 |
ZFS_ATTR_SET(zp, ZFS_SYSTEM, xoap->xoa_system, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1036 |
zp->z_pflags, tx); |
5331 | 1037 |
XVA_SET_RTN(xvap, XAT_SYSTEM); |
1038 |
} |
|
1039 |
if (XVA_ISSET_REQ(xvap, XAT_ARCHIVE)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1040 |
ZFS_ATTR_SET(zp, ZFS_ARCHIVE, xoap->xoa_archive, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1041 |
zp->z_pflags, tx); |
5331 | 1042 |
XVA_SET_RTN(xvap, XAT_ARCHIVE); |
1043 |
} |
|
1044 |
if (XVA_ISSET_REQ(xvap, XAT_IMMUTABLE)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1045 |
ZFS_ATTR_SET(zp, ZFS_IMMUTABLE, xoap->xoa_immutable, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1046 |
zp->z_pflags, tx); |
5331 | 1047 |
XVA_SET_RTN(xvap, XAT_IMMUTABLE); |
1048 |
} |
|
1049 |
if (XVA_ISSET_REQ(xvap, XAT_NOUNLINK)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1050 |
ZFS_ATTR_SET(zp, ZFS_NOUNLINK, xoap->xoa_nounlink, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1051 |
zp->z_pflags, tx); |
5331 | 1052 |
XVA_SET_RTN(xvap, XAT_NOUNLINK); |
1053 |
} |
|
1054 |
if (XVA_ISSET_REQ(xvap, XAT_APPENDONLY)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1055 |
ZFS_ATTR_SET(zp, ZFS_APPENDONLY, xoap->xoa_appendonly, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1056 |
zp->z_pflags, tx); |
5331 | 1057 |
XVA_SET_RTN(xvap, XAT_APPENDONLY); |
1058 |
} |
|
1059 |
if (XVA_ISSET_REQ(xvap, XAT_NODUMP)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1060 |
ZFS_ATTR_SET(zp, ZFS_NODUMP, xoap->xoa_nodump, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1061 |
zp->z_pflags, tx); |
5331 | 1062 |
XVA_SET_RTN(xvap, XAT_NODUMP); |
1063 |
} |
|
1064 |
if (XVA_ISSET_REQ(xvap, XAT_OPAQUE)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1065 |
ZFS_ATTR_SET(zp, ZFS_OPAQUE, xoap->xoa_opaque, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1066 |
zp->z_pflags, tx); |
5331 | 1067 |
XVA_SET_RTN(xvap, XAT_OPAQUE); |
1068 |
} |
|
1069 |
if (XVA_ISSET_REQ(xvap, XAT_AV_QUARANTINED)) { |
|
1070 |
ZFS_ATTR_SET(zp, ZFS_AV_QUARANTINED, |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1071 |
xoap->xoa_av_quarantined, zp->z_pflags, tx); |
5331 | 1072 |
XVA_SET_RTN(xvap, XAT_AV_QUARANTINED); |
1073 |
} |
|
1074 |
if (XVA_ISSET_REQ(xvap, XAT_AV_MODIFIED)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1075 |
ZFS_ATTR_SET(zp, ZFS_AV_MODIFIED, xoap->xoa_av_modified, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1076 |
zp->z_pflags, tx); |
5331 | 1077 |
XVA_SET_RTN(xvap, XAT_AV_MODIFIED); |
1078 |
} |
|
1079 |
if (XVA_ISSET_REQ(xvap, XAT_AV_SCANSTAMP)) { |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1080 |
zfs_sa_set_scanstamp(zp, xvap, tx); |
5331 | 1081 |
XVA_SET_RTN(xvap, XAT_AV_SCANSTAMP); |
1082 |
} |
|
10793
34709091de6d
6886081 Solaris needs reparse point support (PSARC 2009/387)
Dai Ngo <dai.ngo@sun.com>
parents:
10269
diff
changeset
|
1083 |
if (XVA_ISSET_REQ(xvap, XAT_REPARSE)) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1084 |
ZFS_ATTR_SET(zp, ZFS_REPARSE, xoap->xoa_reparse, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1085 |
zp->z_pflags, tx); |
10793
34709091de6d
6886081 Solaris needs reparse point support (PSARC 2009/387)
Dai Ngo <dai.ngo@sun.com>
parents:
10269
diff
changeset
|
1086 |
XVA_SET_RTN(xvap, XAT_REPARSE); |
34709091de6d
6886081 Solaris needs reparse point support (PSARC 2009/387)
Dai Ngo <dai.ngo@sun.com>
parents:
10269
diff
changeset
|
1087 |
} |
5331 | 1088 |
} |
1089 |
||
789 | 1090 |
int |
1091 |
zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp) |
|
1092 |
{ |
|
1093 |
dmu_object_info_t doi; |
|
1094 |
dmu_buf_t *db; |
|
1095 |
znode_t *zp; |
|
1544 | 1096 |
int err; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1097 |
sa_handle_t *hdl; |
789 | 1098 |
|
1099 |
*zpp = NULL; |
|
1100 |
||
1101 |
ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num); |
|
1102 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1103 |
err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db); |
1544 | 1104 |
if (err) { |
789 | 1105 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
1544 | 1106 |
return (err); |
789 | 1107 |
} |
1108 |
||
1109 |
dmu_object_info_from_db(db, &doi); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1110 |
if (doi.doi_bonus_type != DMU_OT_SA && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1111 |
(doi.doi_bonus_type != DMU_OT_ZNODE || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1112 |
(doi.doi_bonus_type == DMU_OT_ZNODE && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1113 |
doi.doi_bonus_size < sizeof (znode_phys_t)))) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1114 |
sa_buf_rele(db, NULL); |
789 | 1115 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
1116 |
return (EINVAL); |
|
1117 |
} |
|
1118 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1119 |
hdl = dmu_buf_get_user(db); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1120 |
if (hdl != NULL) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1121 |
zp = sa_get_userdata(hdl); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1122 |
|
789 | 1123 |
|
5446 | 1124 |
/* |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1125 |
* Since "SA" does immediate eviction we |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1126 |
* should never find a sa handle that doesn't |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1127 |
* know about the znode. |
5446 | 1128 |
*/ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1129 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1130 |
ASSERT3P(zp, !=, NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1131 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1132 |
mutex_enter(&zp->z_lock); |
789 | 1133 |
ASSERT3U(zp->z_id, ==, obj_num); |
3461 | 1134 |
if (zp->z_unlinked) { |
5446 | 1135 |
err = ENOENT; |
789 | 1136 |
} else { |
5446 | 1137 |
VN_HOLD(ZTOV(zp)); |
1138 |
*zpp = zp; |
|
1139 |
err = 0; |
|
789 | 1140 |
} |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1141 |
sa_buf_rele(db, NULL); |
789 | 1142 |
mutex_exit(&zp->z_lock); |
1544 | 1143 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
5446 | 1144 |
return (err); |
789 | 1145 |
} |
1146 |
||
1147 |
/* |
|
1148 |
* Not found create new znode/vnode |
|
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1149 |
* but only if file exists. |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1150 |
* |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1151 |
* There is a small window where zfs_vget() could |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1152 |
* find this object while a file create is still in |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1153 |
* progress. This is checked for in zfs_znode_alloc() |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1154 |
* |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1155 |
* if zfs_znode_alloc() fails it will drop the hold on the |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1156 |
* bonus buffer. |
789 | 1157 |
*/ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1158 |
zp = zfs_znode_alloc(zfsvfs, db, doi.doi_data_block_size, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1159 |
doi.doi_bonus_type, NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1160 |
if (zp == NULL) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1161 |
err = ENOENT; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1162 |
} else { |
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1163 |
*zpp = zp; |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1164 |
} |
1544 | 1165 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1166 |
return (err); |
789 | 1167 |
} |
1168 |
||
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1169 |
int |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1170 |
zfs_rezget(znode_t *zp) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1171 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1172 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1173 |
dmu_object_info_t doi; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1174 |
dmu_buf_t *db; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1175 |
uint64_t obj_num = zp->z_id; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1176 |
uint64_t mode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1177 |
uint64_t uid, gid; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1178 |
sa_bulk_attr_t bulk[8]; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1179 |
int err; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1180 |
int count = 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1181 |
uint64_t gen; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1182 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1183 |
ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1184 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1185 |
mutex_enter(&zp->z_acl_lock); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1186 |
if (zp->z_acl_cached) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1187 |
zfs_acl_free(zp->z_acl_cached); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1188 |
zp->z_acl_cached = NULL; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1189 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1190 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1191 |
mutex_exit(&zp->z_acl_lock); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1192 |
ASSERT(zp->z_sa_hdl == NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1193 |
err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1194 |
if (err) { |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1195 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1196 |
return (err); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1197 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1198 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1199 |
dmu_object_info_from_db(db, &doi); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1200 |
if (doi.doi_bonus_type != DMU_OT_SA && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1201 |
(doi.doi_bonus_type != DMU_OT_ZNODE || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1202 |
(doi.doi_bonus_type == DMU_OT_ZNODE && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1203 |
doi.doi_bonus_size < sizeof (znode_phys_t)))) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1204 |
sa_buf_rele(db, NULL); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1205 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1206 |
return (EINVAL); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1207 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1208 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1209 |
zfs_znode_sa_init(zfsvfs, zp, db, doi.doi_bonus_type, NULL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1210 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1211 |
/* reload cached values */ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1212 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GEN(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1213 |
&gen, sizeof (gen)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1214 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_SIZE(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1215 |
&zp->z_size, sizeof (zp->z_size)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1216 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_LINKS(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1217 |
&zp->z_links, sizeof (zp->z_links)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1218 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1219 |
&zp->z_pflags, sizeof (zp->z_pflags)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1220 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1221 |
&zp->z_atime, sizeof (zp->z_atime)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1222 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_UID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1223 |
&uid, sizeof (uid)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1224 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_GID(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1225 |
&gid, sizeof (gid)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1226 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1227 |
&mode, sizeof (mode)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1228 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1229 |
zp->z_mode = mode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1230 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1231 |
if (sa_bulk_lookup(zp->z_sa_hdl, bulk, count)) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1232 |
zfs_znode_dmu_fini(zp); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1233 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1234 |
return (EIO); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1235 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1236 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1237 |
if (gen != zp->z_gen) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1238 |
zfs_znode_dmu_fini(zp); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1239 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1240 |
return (EIO); |
10269
2788675568fd
6868276 zfs_rezget() can be hazardous when znode has a cached ACL
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10250
diff
changeset
|
1241 |
} |
2788675568fd
6868276 zfs_rezget() can be hazardous when znode has a cached ACL
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10250
diff
changeset
|
1242 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1243 |
zp->z_uid = zfs_fuid_map_id(zfsvfs, uid, CRED(), ZFS_OWNER); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1244 |
zp->z_gid = zfs_fuid_map_id(zfsvfs, gid, CRED(), ZFS_GROUP); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1245 |
zp->z_unlinked = (zp->z_links == 0); |
5844
51eed00be2b0
6649002 panic "accessing past end of object" after online recv/rollback
ek110237
parents:
5745
diff
changeset
|
1246 |
zp->z_blksz = doi.doi_data_block_size; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1247 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1248 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1249 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1250 |
return (0); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1251 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4831
diff
changeset
|
1252 |
|
789 | 1253 |
void |
1254 |
zfs_znode_delete(znode_t *zp, dmu_tx_t *tx) |
|
1255 |
{ |
|
1256 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
|
6992 | 1257 |
objset_t *os = zfsvfs->z_os; |
5446 | 1258 |
uint64_t obj = zp->z_id; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1259 |
uint64_t acl_obj = ZFS_EXTERNAL_ACL(zp); |
789 | 1260 |
|
5446 | 1261 |
ZFS_OBJ_HOLD_ENTER(zfsvfs, obj); |
6992 | 1262 |
if (acl_obj) |
1263 |
VERIFY(0 == dmu_object_free(os, acl_obj, tx)); |
|
1264 |
VERIFY(0 == dmu_object_free(os, obj, tx)); |
|
5446 | 1265 |
zfs_znode_dmu_fini(zp); |
1266 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj); |
|
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1267 |
zfs_znode_free(zp); |
789 | 1268 |
} |
1269 |
||
1270 |
void |
|
1271 |
zfs_zinactive(znode_t *zp) |
|
1272 |
{ |
|
1273 |
vnode_t *vp = ZTOV(zp); |
|
1274 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
|
1275 |
uint64_t z_id = zp->z_id; |
|
1276 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1277 |
ASSERT(zp->z_sa_hdl); |
789 | 1278 |
|
1279 |
/* |
|
1280 |
* Don't allow a zfs_zget() while were trying to release this znode |
|
1281 |
*/ |
|
1282 |
ZFS_OBJ_HOLD_ENTER(zfsvfs, z_id); |
|
1283 |
||
1284 |
mutex_enter(&zp->z_lock); |
|
1285 |
mutex_enter(&vp->v_lock); |
|
1286 |
vp->v_count--; |
|
1287 |
if (vp->v_count > 0 || vn_has_cached_data(vp)) { |
|
1288 |
/* |
|
1289 |
* If the hold count is greater than zero, somebody has |
|
1290 |
* obtained a new reference on this znode while we were |
|
1291 |
* processing it here, so we are done. If we still have |
|
1292 |
* mapped pages then we are also done, since we don't |
|
1293 |
* want to inactivate the znode until the pages get pushed. |
|
1294 |
* |
|
1295 |
* XXX - if vn_has_cached_data(vp) is true, but count == 0, |
|
1296 |
* this seems like it would leave the znode hanging with |
|
1297 |
* no chance to go inactive... |
|
1298 |
*/ |
|
1299 |
mutex_exit(&vp->v_lock); |
|
1300 |
mutex_exit(&zp->z_lock); |
|
1301 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, z_id); |
|
1302 |
return; |
|
1303 |
} |
|
1304 |
mutex_exit(&vp->v_lock); |
|
1305 |
||
1306 |
/* |
|
1307 |
* If this was the last reference to a file with no links, |
|
1308 |
* remove the file from the file system. |
|
1309 |
*/ |
|
3461 | 1310 |
if (zp->z_unlinked) { |
789 | 1311 |
mutex_exit(&zp->z_lock); |
1312 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, z_id); |
|
3461 | 1313 |
zfs_rmnode(zp); |
789 | 1314 |
return; |
1315 |
} |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1316 |
|
789 | 1317 |
mutex_exit(&zp->z_lock); |
5446 | 1318 |
zfs_znode_dmu_fini(zp); |
789 | 1319 |
ZFS_OBJ_HOLD_EXIT(zfsvfs, z_id); |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1320 |
zfs_znode_free(zp); |
789 | 1321 |
} |
1322 |
||
1323 |
void |
|
1324 |
zfs_znode_free(znode_t *zp) |
|
1325 |
{ |
|
1326 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
|
1327 |
||
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1328 |
vn_invalid(ZTOV(zp)); |
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1329 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1330 |
ASSERT(ZTOV(zp)->v_count == 0); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1331 |
|
789 | 1332 |
mutex_enter(&zfsvfs->z_znodes_lock); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1333 |
POINTER_INVALIDATE(&zp->z_zfsvfs); |
789 | 1334 |
list_remove(&zfsvfs->z_all_znodes, zp); |
1335 |
mutex_exit(&zfsvfs->z_znodes_lock); |
|
1336 |
||
9981
b4907297e740
6775100 stat() performance on files on zfs should be improved
Tim Haley <Tim.Haley@Sun.COM>
parents:
9788
diff
changeset
|
1337 |
if (zp->z_acl_cached) { |
b4907297e740
6775100 stat() performance on files on zfs should be improved
Tim Haley <Tim.Haley@Sun.COM>
parents:
9788
diff
changeset
|
1338 |
zfs_acl_free(zp->z_acl_cached); |
b4907297e740
6775100 stat() performance on files on zfs should be improved
Tim Haley <Tim.Haley@Sun.COM>
parents:
9788
diff
changeset
|
1339 |
zp->z_acl_cached = NULL; |
b4907297e740
6775100 stat() performance on files on zfs should be improved
Tim Haley <Tim.Haley@Sun.COM>
parents:
9788
diff
changeset
|
1340 |
} |
b4907297e740
6775100 stat() performance on files on zfs should be improved
Tim Haley <Tim.Haley@Sun.COM>
parents:
9788
diff
changeset
|
1341 |
|
789 | 1342 |
kmem_cache_free(znode_cache, zp); |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1343 |
|
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1344 |
VFS_RELE(zfsvfs->z_vfs); |
789 | 1345 |
} |
1346 |
||
1347 |
void |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1348 |
zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2], |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1349 |
uint64_t ctime[2], boolean_t have_tx) |
789 | 1350 |
{ |
1351 |
timestruc_t now; |
|
1352 |
||
1353 |
gethrestime(&now); |
|
1354 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1355 |
if (have_tx) { /* will sa_bulk_update happen really soon? */ |
789 | 1356 |
zp->z_atime_dirty = 0; |
1357 |
zp->z_seq++; |
|
1358 |
} else { |
|
1359 |
zp->z_atime_dirty = 1; |
|
1360 |
} |
|
1361 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1362 |
if (flag & AT_ATIME) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1363 |
ZFS_TIME_ENCODE(&now, zp->z_atime); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1364 |
} |
789 | 1365 |
|
5331 | 1366 |
if (flag & AT_MTIME) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1367 |
ZFS_TIME_ENCODE(&now, mtime); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1368 |
if (zp->z_zfsvfs->z_use_fuids) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1369 |
zp->z_pflags |= (ZFS_ARCHIVE | |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1370 |
ZFS_AV_MODIFIED); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1371 |
} |
5331 | 1372 |
} |
789 | 1373 |
|
5331 | 1374 |
if (flag & AT_CTIME) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1375 |
ZFS_TIME_ENCODE(&now, ctime); |
5331 | 1376 |
if (zp->z_zfsvfs->z_use_fuids) |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1377 |
zp->z_pflags |= ZFS_ARCHIVE; |
5331 | 1378 |
} |
789 | 1379 |
} |
1380 |
||
1381 |
/* |
|
1669 | 1382 |
* Grow the block size for a file. |
789 | 1383 |
* |
1384 |
* IN: zp - znode of file to free data in. |
|
1385 |
* size - requested block size |
|
1386 |
* tx - open transaction. |
|
1387 |
* |
|
1388 |
* NOTE: this function assumes that the znode is write locked. |
|
1389 |
*/ |
|
1669 | 1390 |
void |
789 | 1391 |
zfs_grow_blocksize(znode_t *zp, uint64_t size, dmu_tx_t *tx) |
1392 |
{ |
|
1393 |
int error; |
|
1394 |
u_longlong_t dummy; |
|
1395 |
||
1396 |
if (size <= zp->z_blksz) |
|
1669 | 1397 |
return; |
789 | 1398 |
/* |
1399 |
* If the file size is already greater than the current blocksize, |
|
1400 |
* we will not grow. If there is more than one block in a file, |
|
1401 |
* the blocksize cannot change. |
|
1402 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1403 |
if (zp->z_blksz && zp->z_size > zp->z_blksz) |
1669 | 1404 |
return; |
789 | 1405 |
|
1406 |
error = dmu_object_set_blocksize(zp->z_zfsvfs->z_os, zp->z_id, |
|
1407 |
size, 0, tx); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1408 |
|
789 | 1409 |
if (error == ENOTSUP) |
1669 | 1410 |
return; |
789 | 1411 |
ASSERT3U(error, ==, 0); |
1412 |
||
1413 |
/* What blocksize did we actually get? */ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1414 |
dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &zp->z_blksz, &dummy); |
789 | 1415 |
} |
1416 |
||
1417 |
/* |
|
1418 |
* This is a dummy interface used when pvn_vplist_dirty() should *not* |
|
1419 |
* be calling back into the fs for a putpage(). E.g.: when truncating |
|
1420 |
* a file, the pages being "thrown away* don't need to be written out. |
|
1421 |
*/ |
|
1422 |
/* ARGSUSED */ |
|
1423 |
static int |
|
1424 |
zfs_no_putpage(vnode_t *vp, page_t *pp, u_offset_t *offp, size_t *lenp, |
|
1425 |
int flags, cred_t *cr) |
|
1426 |
{ |
|
1427 |
ASSERT(0); |
|
1428 |
return (0); |
|
1429 |
} |
|
1430 |
||
1431 |
/* |
|
6992 | 1432 |
* Increase the file length |
789 | 1433 |
* |
1434 |
* IN: zp - znode of file to free data in. |
|
6992 | 1435 |
* end - new end-of-file |
789 | 1436 |
* |
1437 |
* RETURN: 0 if success |
|
1438 |
* error code if failure |
|
1439 |
*/ |
|
6992 | 1440 |
static int |
1441 |
zfs_extend(znode_t *zp, uint64_t end) |
|
789 | 1442 |
{ |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1443 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
6992 | 1444 |
dmu_tx_t *tx; |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1445 |
rl_t *rl; |
6992 | 1446 |
uint64_t newblksz; |
1669 | 1447 |
int error; |
789 | 1448 |
|
1449 |
/* |
|
6992 | 1450 |
* We will change zp_size, lock the whole file. |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1451 |
*/ |
6992 | 1452 |
rl = zfs_range_lock(zp, 0, UINT64_MAX, RL_WRITER); |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1453 |
|
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1454 |
/* |
789 | 1455 |
* Nothing to do if file already at desired length. |
1456 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1457 |
if (end <= zp->z_size) { |
2237 | 1458 |
zfs_range_unlock(rl); |
789 | 1459 |
return (0); |
1460 |
} |
|
6992 | 1461 |
top: |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1462 |
tx = dmu_tx_create(zfsvfs->z_os); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1463 |
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1464 |
zfs_sa_upgrade_txholds(tx, zp); |
6992 | 1465 |
if (end > zp->z_blksz && |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1466 |
(!ISP2(zp->z_blksz) || zp->z_blksz < zfsvfs->z_max_blksz)) { |
789 | 1467 |
/* |
1468 |
* We are growing the file past the current block size. |
|
1469 |
*/ |
|
1470 |
if (zp->z_blksz > zp->z_zfsvfs->z_max_blksz) { |
|
1471 |
ASSERT(!ISP2(zp->z_blksz)); |
|
6992 | 1472 |
newblksz = MIN(end, SPA_MAXBLOCKSIZE); |
789 | 1473 |
} else { |
6992 | 1474 |
newblksz = MIN(end, zp->z_zfsvfs->z_max_blksz); |
789 | 1475 |
} |
6992 | 1476 |
dmu_tx_hold_write(tx, zp->z_id, 0, newblksz); |
1477 |
} else { |
|
1478 |
newblksz = 0; |
|
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1479 |
} |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1480 |
|
8227 | 1481 |
error = dmu_tx_assign(tx, TXG_NOWAIT); |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1482 |
if (error) { |
8227 | 1483 |
if (error == ERESTART) { |
2113
0510bb40c993
6430121 3-way deadlock involving tc_lock within zfs
ahrens
parents:
1936
diff
changeset
|
1484 |
dmu_tx_wait(tx); |
6992 | 1485 |
dmu_tx_abort(tx); |
1486 |
goto top; |
|
1487 |
} |
|
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1488 |
dmu_tx_abort(tx); |
2237 | 1489 |
zfs_range_unlock(rl); |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1490 |
return (error); |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1491 |
} |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1492 |
|
6992 | 1493 |
if (newblksz) |
1494 |
zfs_grow_blocksize(zp, newblksz, tx); |
|
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1495 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1496 |
zp->z_size = end; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1497 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1498 |
VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_SIZE(zp->z_zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1499 |
&zp->z_size, sizeof (zp->z_size), tx)); |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1500 |
|
2237 | 1501 |
zfs_range_unlock(rl); |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1502 |
|
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1503 |
dmu_tx_commit(tx); |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1504 |
|
6992 | 1505 |
return (0); |
1506 |
} |
|
1507 |
||
1508 |
/* |
|
1509 |
* Free space in a file. |
|
1510 |
* |
|
1511 |
* IN: zp - znode of file to free data in. |
|
1512 |
* off - start of section to free. |
|
1513 |
* len - length of section to free. |
|
1514 |
* |
|
1515 |
* RETURN: 0 if success |
|
1516 |
* error code if failure |
|
1517 |
*/ |
|
1518 |
static int |
|
1519 |
zfs_free_range(znode_t *zp, uint64_t off, uint64_t len) |
|
1520 |
{ |
|
1521 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
|
1522 |
rl_t *rl; |
|
1523 |
int error; |
|
1524 |
||
1525 |
/* |
|
1526 |
* Lock the range being freed. |
|
1527 |
*/ |
|
1528 |
rl = zfs_range_lock(zp, off, len, RL_WRITER); |
|
1529 |
||
1530 |
/* |
|
1531 |
* Nothing to do if file already at desired length. |
|
1532 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1533 |
if (off >= zp->z_size) { |
6992 | 1534 |
zfs_range_unlock(rl); |
1535 |
return (0); |
|
1536 |
} |
|
1537 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1538 |
if (off + len > zp->z_size) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1539 |
len = zp->z_size - off; |
6992 | 1540 |
|
1541 |
error = dmu_free_long_range(zfsvfs->z_os, zp->z_id, off, len); |
|
1542 |
||
1543 |
zfs_range_unlock(rl); |
|
1544 |
||
1545 |
return (error); |
|
1546 |
} |
|
1547 |
||
1548 |
/* |
|
1549 |
* Truncate a file |
|
1550 |
* |
|
1551 |
* IN: zp - znode of file to free data in. |
|
1552 |
* end - new end-of-file. |
|
1553 |
* |
|
1554 |
* RETURN: 0 if success |
|
1555 |
* error code if failure |
|
1556 |
*/ |
|
1557 |
static int |
|
1558 |
zfs_trunc(znode_t *zp, uint64_t end) |
|
1559 |
{ |
|
1560 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
|
1561 |
vnode_t *vp = ZTOV(zp); |
|
1562 |
dmu_tx_t *tx; |
|
1563 |
rl_t *rl; |
|
1564 |
int error; |
|
1565 |
||
1566 |
/* |
|
1567 |
* We will change zp_size, lock the whole file. |
|
1568 |
*/ |
|
1569 |
rl = zfs_range_lock(zp, 0, UINT64_MAX, RL_WRITER); |
|
1570 |
||
1571 |
/* |
|
1572 |
* Nothing to do if file already at desired length. |
|
1573 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1574 |
if (end >= zp->z_size) { |
6992 | 1575 |
zfs_range_unlock(rl); |
1576 |
return (0); |
|
1577 |
} |
|
1578 |
||
1579 |
error = dmu_free_long_range(zfsvfs->z_os, zp->z_id, end, -1); |
|
1580 |
if (error) { |
|
1581 |
zfs_range_unlock(rl); |
|
1582 |
return (error); |
|
1583 |
} |
|
1584 |
top: |
|
1585 |
tx = dmu_tx_create(zfsvfs->z_os); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1586 |
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1587 |
zfs_sa_upgrade_txholds(tx, zp); |
8227 | 1588 |
error = dmu_tx_assign(tx, TXG_NOWAIT); |
6992 | 1589 |
if (error) { |
8227 | 1590 |
if (error == ERESTART) { |
6992 | 1591 |
dmu_tx_wait(tx); |
1592 |
dmu_tx_abort(tx); |
|
1593 |
goto top; |
|
1594 |
} |
|
1595 |
dmu_tx_abort(tx); |
|
1596 |
zfs_range_unlock(rl); |
|
1597 |
return (error); |
|
1598 |
} |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1599 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1600 |
zp->z_size = end; |
6992 | 1601 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1602 |
VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_SIZE(zp->z_zfsvfs), |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1603 |
&zp->z_size, sizeof (zp->z_size), tx)); |
6992 | 1604 |
|
1605 |
dmu_tx_commit(tx); |
|
1606 |
||
789 | 1607 |
/* |
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1608 |
* Clear any mapped pages in the truncated region. This has to |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1609 |
* happen outside of the transaction to avoid the possibility of |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1610 |
* a deadlock with someone trying to push a page that we are |
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1611 |
* about to invalidate. |
789 | 1612 |
*/ |
6992 | 1613 |
if (vn_has_cached_data(vp)) { |
789 | 1614 |
page_t *pp; |
6992 | 1615 |
uint64_t start = end & PAGEMASK; |
1616 |
int poff = end & PAGEOFFSET; |
|
789 | 1617 |
|
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1618 |
if (poff != 0 && (pp = page_lookup(vp, start, SE_SHARED))) { |
789 | 1619 |
/* |
1620 |
* We need to zero a partial page. |
|
1621 |
*/ |
|
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1622 |
pagezero(pp, poff, PAGESIZE - poff); |
789 | 1623 |
start += PAGESIZE; |
1624 |
page_unlock(pp); |
|
1625 |
} |
|
1626 |
error = pvn_vplist_dirty(vp, start, zfs_no_putpage, |
|
1878
c22df0f5603f
6413573 deadlock between fsflush() and zfs_create()
maybee
parents:
1816
diff
changeset
|
1627 |
B_INVAL | B_TRUNC, NULL); |
789 | 1628 |
ASSERT(error == 0); |
1629 |
} |
|
8636
7e4ce9158df3
6551866 deadlock between zfs_write(), zfs_freesp(), and zfs_putapage()
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8227
diff
changeset
|
1630 |
|
7e4ce9158df3
6551866 deadlock between zfs_write(), zfs_freesp(), and zfs_putapage()
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8227
diff
changeset
|
1631 |
zfs_range_unlock(rl); |
789 | 1632 |
|
1633 |
return (0); |
|
1634 |
} |
|
1635 |
||
6992 | 1636 |
/* |
1637 |
* Free space in a file |
|
1638 |
* |
|
1639 |
* IN: zp - znode of file to free data in. |
|
1640 |
* off - start of range |
|
1641 |
* len - end of range (0 => EOF) |
|
1642 |
* flag - current file open mode flags. |
|
1643 |
* log - TRUE if this action should be logged |
|
1644 |
* |
|
1645 |
* RETURN: 0 if success |
|
1646 |
* error code if failure |
|
1647 |
*/ |
|
1648 |
int |
|
1649 |
zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log) |
|
1650 |
{ |
|
1651 |
vnode_t *vp = ZTOV(zp); |
|
1652 |
dmu_tx_t *tx; |
|
1653 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
|
1654 |
zilog_t *zilog = zfsvfs->z_log; |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1655 |
uint64_t mode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1656 |
uint64_t mtime[2], ctime[2]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1657 |
sa_bulk_attr_t bulk[2]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1658 |
int count = 0; |
6992 | 1659 |
int error; |
1660 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1661 |
if ((error = sa_lookup(zp->z_sa_hdl, SA_ZPL_MODE(zfsvfs), &mode, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1662 |
sizeof (mode))) != 0) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1663 |
return (error); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1664 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1665 |
if (off > zp->z_size) { |
6992 | 1666 |
error = zfs_extend(zp, off+len); |
1667 |
if (error == 0 && log) |
|
1668 |
goto log; |
|
1669 |
else |
|
1670 |
return (error); |
|
1671 |
} |
|
1672 |
||
1673 |
/* |
|
1674 |
* Check for any locks in the region to be freed. |
|
1675 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1676 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1677 |
if (MANDLOCK(vp, (mode_t)mode)) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1678 |
uint64_t length = (len ? len : zp->z_size - off); |
6992 | 1679 |
if (error = chklock(vp, FWRITE, off, length, flag, NULL)) |
1680 |
return (error); |
|
1681 |
} |
|
1682 |
||
1683 |
if (len == 0) { |
|
1684 |
error = zfs_trunc(zp, off); |
|
1685 |
} else { |
|
1686 |
if ((error = zfs_free_range(zp, off, len)) == 0 && |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1687 |
off + len > zp->z_size) |
6992 | 1688 |
error = zfs_extend(zp, off+len); |
1689 |
} |
|
1690 |
if (error || !log) |
|
1691 |
return (error); |
|
1692 |
log: |
|
1693 |
tx = dmu_tx_create(zfsvfs->z_os); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1694 |
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1695 |
zfs_sa_upgrade_txholds(tx, zp); |
8227 | 1696 |
error = dmu_tx_assign(tx, TXG_NOWAIT); |
6992 | 1697 |
if (error) { |
8227 | 1698 |
if (error == ERESTART) { |
6992 | 1699 |
dmu_tx_wait(tx); |
1700 |
dmu_tx_abort(tx); |
|
1701 |
goto log; |
|
1702 |
} |
|
1703 |
dmu_tx_abort(tx); |
|
1704 |
return (error); |
|
1705 |
} |
|
1706 |
||
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1707 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, mtime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1708 |
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, ctime, 16); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1709 |
zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime, B_TRUE); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1710 |
error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1711 |
ASSERT(error == 0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1712 |
|
6992 | 1713 |
zfs_log_truncate(zilog, tx, TX_TRUNCATE, zp, off, len); |
1714 |
||
1715 |
dmu_tx_commit(tx); |
|
1716 |
return (0); |
|
1717 |
} |
|
1718 |
||
789 | 1719 |
void |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1720 |
zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) |
789 | 1721 |
{ |
1722 |
zfsvfs_t zfsvfs; |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1723 |
uint64_t moid, obj, sa_obj, version; |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1724 |
uint64_t sense = ZFS_CASE_SENSITIVE; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1725 |
uint64_t norm = 0; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1726 |
nvpair_t *elem; |
789 | 1727 |
int error; |
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1728 |
int i; |
789 | 1729 |
znode_t *rootzp = NULL; |
1730 |
vnode_t *vp; |
|
1731 |
vattr_t vattr; |
|
5446 | 1732 |
znode_t *zp; |
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
1733 |
zfs_acl_ids_t acl_ids; |
789 | 1734 |
|
1735 |
/* |
|
1736 |
* First attempt to create master node. |
|
1737 |
*/ |
|
1544 | 1738 |
/* |
1739 |
* In an empty objset, there are no blocks to read and thus |
|
1740 |
* there can be no i/o errors (which we assert below). |
|
1741 |
*/ |
|
789 | 1742 |
moid = MASTER_NODE_OBJ; |
1743 |
error = zap_create_claim(os, moid, DMU_OT_MASTER_NODE, |
|
1744 |
DMU_OT_NONE, 0, tx); |
|
1745 |
ASSERT(error == 0); |
|
1746 |
||
1747 |
/* |
|
1748 |
* Set starting attributes. |
|
1749 |
*/ |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1750 |
version = zfs_zpl_version_map(spa_version(dmu_objset_spa(os))); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1751 |
elem = NULL; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1752 |
while ((elem = nvlist_next_nvpair(zplprops, elem)) != NULL) { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1753 |
/* For the moment we expect all zpl props to be uint64_ts */ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1754 |
uint64_t val; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1755 |
char *name; |
789 | 1756 |
|
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1757 |
ASSERT(nvpair_type(elem) == DATA_TYPE_UINT64); |
5520
70184f49637e
6633610 cannot successfully 'zpool create' on non-debug bits after 6622831
timh
parents:
5498
diff
changeset
|
1758 |
VERIFY(nvpair_value_uint64(elem, &val) == 0); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1759 |
name = nvpair_name(elem); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1760 |
if (strcmp(name, zfs_prop_to_name(ZFS_PROP_VERSION)) == 0) { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
1761 |
if (val < version) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
1762 |
version = val; |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1763 |
} else { |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1764 |
error = zap_update(os, moid, name, 8, 1, &val, tx); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1765 |
} |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1766 |
ASSERT(error == 0); |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1767 |
if (strcmp(name, zfs_prop_to_name(ZFS_PROP_NORMALIZE)) == 0) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1768 |
norm = val; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1769 |
else if (strcmp(name, zfs_prop_to_name(ZFS_PROP_CASE)) == 0) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1770 |
sense = val; |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1771 |
} |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1772 |
ASSERT(version != 0); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
1773 |
error = zap_update(os, moid, ZPL_VERSION_STR, 8, 1, &version, tx); |
789 | 1774 |
|
1775 |
/* |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1776 |
* Create zap object used for SA attribute registration |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1777 |
*/ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1778 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1779 |
if (version >= ZPL_VERSION_SA) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1780 |
sa_obj = zap_create(os, DMU_OT_SA_MASTER_NODE, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1781 |
DMU_OT_NONE, 0, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1782 |
error = zap_add(os, moid, ZFS_SA_ATTRS, 8, 1, &sa_obj, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1783 |
ASSERT(error == 0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1784 |
} else { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1785 |
sa_obj = 0; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1786 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1787 |
/* |
789 | 1788 |
* Create a delete queue. |
1789 |
*/ |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
1790 |
obj = zap_create(os, DMU_OT_UNLINKED_SET, DMU_OT_NONE, 0, tx); |
789 | 1791 |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9179
diff
changeset
|
1792 |
error = zap_add(os, moid, ZFS_UNLINKED_SET, 8, 1, &obj, tx); |
789 | 1793 |
ASSERT(error == 0); |
1794 |
||
1795 |
/* |
|
1796 |
* Create root znode. Create minimal znode/vnode/zfsvfs |
|
1797 |
* to allow zfs_mknode to work. |
|
1798 |
*/ |
|
1799 |
vattr.va_mask = AT_MODE|AT_UID|AT_GID|AT_TYPE; |
|
1800 |
vattr.va_type = VDIR; |
|
1801 |
vattr.va_mode = S_IFDIR|0755; |
|
4543 | 1802 |
vattr.va_uid = crgetuid(cr); |
1803 |
vattr.va_gid = crgetgid(cr); |
|
789 | 1804 |
|
1805 |
rootzp = kmem_cache_alloc(znode_cache, KM_SLEEP); |
|
3461 | 1806 |
rootzp->z_unlinked = 0; |
789 | 1807 |
rootzp->z_atime_dirty = 0; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1808 |
rootzp->z_is_sa = USE_SA(version, os); |
789 | 1809 |
|
1810 |
vp = ZTOV(rootzp); |
|
1811 |
vn_reinit(vp); |
|
1812 |
vp->v_type = VDIR; |
|
1813 |
||
1814 |
bzero(&zfsvfs, sizeof (zfsvfs_t)); |
|
1815 |
||
1816 |
zfsvfs.z_os = os; |
|
1817 |
zfsvfs.z_parent = &zfsvfs; |
|
5331 | 1818 |
zfsvfs.z_version = version; |
1819 |
zfsvfs.z_use_fuids = USE_FUIDS(version, os); |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1820 |
zfsvfs.z_use_sa = USE_SA(version, os); |
5331 | 1821 |
zfsvfs.z_norm = norm; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1822 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1823 |
zfsvfs.z_attr_table = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1824 |
|
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1825 |
/* |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1826 |
* Fold case on file systems that are always or sometimes case |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1827 |
* insensitive. |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1828 |
*/ |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1829 |
if (sense == ZFS_CASE_INSENSITIVE || sense == ZFS_CASE_MIXED) |
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5446
diff
changeset
|
1830 |
zfsvfs.z_norm |= U8_TEXTPREP_TOUPPER; |
789 | 1831 |
|
1832 |
mutex_init(&zfsvfs.z_znodes_lock, NULL, MUTEX_DEFAULT, NULL); |
|
1833 |
list_create(&zfsvfs.z_all_znodes, sizeof (znode_t), |
|
1834 |
offsetof(znode_t, z_link_node)); |
|
1835 |
||
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1836 |
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++) |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1837 |
mutex_init(&zfsvfs.z_hold_mtx[i], NULL, MUTEX_DEFAULT, NULL); |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1838 |
|
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1839 |
ASSERT(!POINTER_IS_VALID(rootzp->z_zfsvfs)); |
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1840 |
rootzp->z_zfsvfs = &zfsvfs; |
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
1841 |
VERIFY(0 == zfs_acl_ids_create(rootzp, IS_ROOT_NODE, &vattr, |
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
1842 |
cr, NULL, &acl_ids)); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1843 |
zfs_mknode(rootzp, &vattr, tx, cr, IS_ROOT_NODE, &zp, &acl_ids); |
5642
504c84876fda
6513209 Destroying pools under stress caused a hang in arc_flush
maybee
parents:
5520
diff
changeset
|
1844 |
ASSERT3P(zp, ==, rootzp); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1845 |
ASSERT(!vn_in_dnlc(ZTOV(rootzp))); /* not valid to move */ |
5446 | 1846 |
error = zap_add(os, moid, ZFS_ROOT_OBJ, 8, 1, &rootzp->z_id, tx); |
789 | 1847 |
ASSERT(error == 0); |
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
1848 |
zfs_acl_ids_free(&acl_ids); |
6712
79afecec3f3c
6554564 slab allocator cannot release slabs with lonely buffers
tomee
parents:
6492
diff
changeset
|
1849 |
POINTER_INVALIDATE(&rootzp->z_zfsvfs); |
789 | 1850 |
|
1851 |
ZTOV(rootzp)->v_count = 0; |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1852 |
sa_handle_destroy(rootzp->z_sa_hdl); |
789 | 1853 |
kmem_cache_free(znode_cache, rootzp); |
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1854 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1855 |
/* |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1856 |
* Create shares directory |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1857 |
*/ |
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1858 |
|
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1859 |
error = zfs_create_share_dir(&zfsvfs, tx); |
9179
d8fbd96b79b3
6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
9030
diff
changeset
|
1860 |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8636
diff
changeset
|
1861 |
ASSERT(error == 0); |
10938
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1862 |
|
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1863 |
for (i = 0; i != ZFS_OBJ_MTX_SZ; i++) |
270624bd70f1
6895088 panic: existing znode ffffff84e4747da0 for dbuf ffffff8271678e18
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10793
diff
changeset
|
1864 |
mutex_destroy(&zfsvfs.z_hold_mtx[i]); |
789 | 1865 |
} |
5331 | 1866 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1867 |
#endif /* _KERNEL */ |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1868 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1869 |
/* |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1870 |
* Given an object number, return its parent object number and whether |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1871 |
* or not the object is an extended attribute directory. |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1872 |
*/ |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1873 |
static int |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1874 |
zfs_obj_to_pobj(objset_t *osp, uint64_t obj, uint64_t *pobjp, int *is_xattrdir, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1875 |
sa_attr_type_t *sa_table) |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1876 |
{ |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1877 |
dmu_buf_t *db; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1878 |
dmu_object_info_t doi; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1879 |
int error; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1880 |
uint64_t parent; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1881 |
uint64_t pflags; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1882 |
uint64_t mode; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1883 |
sa_bulk_attr_t bulk[3]; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1884 |
sa_handle_t *hdl; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1885 |
int count = 0; |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1886 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1887 |
if ((error = sa_buf_hold(osp, obj, FTAG, &db)) != 0) |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1888 |
return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1889 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1890 |
dmu_object_info_from_db(db, &doi); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1891 |
if ((doi.doi_bonus_type != DMU_OT_SA && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1892 |
doi.doi_bonus_type != DMU_OT_ZNODE) || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1893 |
doi.doi_bonus_type == DMU_OT_ZNODE && |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1894 |
doi.doi_bonus_size < sizeof (znode_phys_t)) { |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1895 |
sa_buf_rele(db, FTAG); |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1896 |
return (EINVAL); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1897 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1898 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1899 |
if ((error = sa_handle_get(osp, obj, NULL, SA_HDL_PRIVATE, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1900 |
&hdl)) != 0) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1901 |
sa_buf_rele(db, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1902 |
return (error); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1903 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1904 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1905 |
SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_PARENT], |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1906 |
NULL, &parent, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1907 |
SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_FLAGS], NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1908 |
&pflags, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1909 |
SA_ADD_BULK_ATTR(bulk, count, sa_table[ZPL_MODE], NULL, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1910 |
&mode, 8); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1911 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1912 |
if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1913 |
sa_buf_rele(db, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1914 |
sa_handle_destroy(hdl); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1915 |
return (error); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1916 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1917 |
*pobjp = parent; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1918 |
*is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1919 |
sa_handle_destroy(hdl); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1920 |
sa_buf_rele(db, FTAG); |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1921 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1922 |
return (0); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1923 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1924 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1925 |
int |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1926 |
zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len) |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1927 |
{ |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1928 |
char *path = buf + len - 1; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1929 |
sa_attr_type_t *sa_table; |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1930 |
int error; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1931 |
uint64_t sa_obj = 0; |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1932 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1933 |
*path = '\0'; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1934 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1935 |
error = zap_lookup(osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1936 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1937 |
if (error != 0 && error != ENOENT) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1938 |
return (error); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1939 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1940 |
sa_table = sa_setup(osp, sa_obj, zfs_attr_table, ZPL_END); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1941 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1942 |
for (;;) { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1943 |
uint64_t pobj; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1944 |
char component[MAXNAMELEN + 2]; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1945 |
size_t complen; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1946 |
int is_xattrdir; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1947 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1948 |
if ((error = zfs_obj_to_pobj(osp, obj, &pobj, |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1949 |
&is_xattrdir, sa_table)) != 0) |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1950 |
break; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1951 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1952 |
if (pobj == obj) { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1953 |
if (path[0] != '/') |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1954 |
*--path = '/'; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1955 |
break; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1956 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1957 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1958 |
component[0] = '/'; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1959 |
if (is_xattrdir) { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1960 |
(void) sprintf(component + 1, "<xattrdir>"); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1961 |
} else { |
4577 | 1962 |
error = zap_value_search(osp, pobj, obj, |
1963 |
ZFS_DIRENT_OBJ(-1ULL), component + 1); |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1964 |
if (error != 0) |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1965 |
break; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1966 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1967 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1968 |
complen = strlen(component); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1969 |
path -= complen; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1970 |
ASSERT(path >= buf); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1971 |
bcopy(component, path, complen); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1972 |
obj = pobj; |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1973 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1974 |
|
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1975 |
if (error == 0) |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1976 |
(void) memmove(buf, path, buf + len - path); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11249
diff
changeset
|
1977 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1978 |
return (error); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3063
diff
changeset
|
1979 |
} |