1 |
ryao 13/05/28 13:08:52 |
2 |
|
3 |
Added: zfs-kmod-0.6.1-fix-xattr-behavior-2.patch |
4 |
zfs-kmod-0.6.1-fix-zvol-initialization.patch |
5 |
zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch |
6 |
zfs-kmod-0.6.1-fix-getdents.patch |
7 |
zfs-kmod-0.6.1-fix-xattr-behavior-1.patch |
8 |
Log: |
9 |
Backport important fixes from upstream HEAD; also includes important zvol initialization fixes (by me) that were sent upstream |
10 |
|
11 |
(Portage version: 2.2.0_alpha176/cvs/Linux x86_64, signed Manifest commit with key 0xBEE84C64) |
12 |
|
13 |
Revision Changes Path |
14 |
1.1 sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch |
15 |
|
16 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch?rev=1.1&view=markup |
17 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch?rev=1.1&content-type=text/plain |
18 |
|
19 |
Index: zfs-kmod-0.6.1-fix-xattr-behavior-2.patch |
20 |
=================================================================== |
21 |
From 0377189b884fab7db02a95088e05712c7cf336f7 Mon Sep 17 00:00:00 2001 |
22 |
From: Brian Behlendorf <behlendorf1@××××.gov> |
23 |
Date: Wed, 8 May 2013 09:20:04 -0700 |
24 |
Subject: [PATCH] Only check directory xattr on ENOENT |
25 |
|
26 |
When SA xattrs are enabled only fallback to checking the directory |
27 |
xattrs when the name is not found as a SA xattr. Otherwise, the SA |
28 |
error which should be returned to the caller is overwritten by the |
29 |
directory xattr errors. Positive return values indicating success |
30 |
will also be immediately returned. |
31 |
|
32 |
In the case of #1437 the ERANGE error was being correctly returned |
33 |
by zpl_xattr_get_sa() only to be overridden with ENOENT which was |
34 |
returned by the subsequent unnessisary call to zpl_xattr_get_dir(). |
35 |
|
36 |
Signed-off-by: Brian Behlendorf <behlendorf1@××××.gov> |
37 |
Closes #1437 |
38 |
--- |
39 |
module/zfs/zpl_xattr.c | 2 +- |
40 |
1 file changed, 1 insertion(+), 1 deletion(-) |
41 |
|
42 |
diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c |
43 |
index a7e38e6..eb2c00d 100644 |
44 |
--- a/module/zfs/zpl_xattr.c |
45 |
+++ b/module/zfs/zpl_xattr.c |
46 |
@@ -288,7 +288,7 @@ |
47 |
|
48 |
if (zsb->z_use_sa && zp->z_is_sa) { |
49 |
error = zpl_xattr_get_sa(ip, name, value, size); |
50 |
- if (error >= 0) |
51 |
+ if (error != -ENOENT) |
52 |
goto out; |
53 |
} |
54 |
|
55 |
-- |
56 |
1.8.1.6 |
57 |
|
58 |
|
59 |
|
60 |
|
61 |
1.1 sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-zvol-initialization.patch |
62 |
|
63 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-zvol-initialization.patch?rev=1.1&view=markup |
64 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-zvol-initialization.patch?rev=1.1&content-type=text/plain |
65 |
|
66 |
Index: zfs-kmod-0.6.1-fix-zvol-initialization.patch |
67 |
=================================================================== |
68 |
diff --git a/module/zfs/spa.c b/module/zfs/spa.c |
69 |
index 82ee445..eaf05b9 100644 |
70 |
--- a/module/zfs/spa.c |
71 |
+++ b/module/zfs/spa.c |
72 |
@@ -64,6 +64,7 @@ |
73 |
#include <sys/zfs_ioctl.h> |
74 |
#include <sys/dsl_scan.h> |
75 |
#include <sys/zfeature.h> |
76 |
+#include <sys/zvol.h> |
77 |
|
78 |
#ifdef _KERNEL |
79 |
#include <sys/bootprops.h> |
80 |
@@ -2856,6 +2857,7 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, |
81 |
spa_load_state_t state = SPA_LOAD_OPEN; |
82 |
int error; |
83 |
int locked = B_FALSE; |
84 |
+ int firstopen = B_FALSE; |
85 |
|
86 |
*spapp = NULL; |
87 |
|
88 |
@@ -2879,6 +2881,8 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, |
89 |
if (spa->spa_state == POOL_STATE_UNINITIALIZED) { |
90 |
zpool_rewind_policy_t policy; |
91 |
|
92 |
+ firstopen = B_TRUE; |
93 |
+ |
94 |
zpool_get_rewind_policy(nvpolicy ? nvpolicy : spa->spa_config, |
95 |
&policy); |
96 |
if (policy.zrp_request & ZPOOL_DO_REWIND) |
97 |
@@ -2953,6 +2957,11 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, |
98 |
mutex_exit(&spa_namespace_lock); |
99 |
} |
100 |
|
101 |
+#ifdef _KERNEL |
102 |
+ if (firstopen) |
103 |
+ zvol_create_minors(spa->spa_name); |
104 |
+#endif |
105 |
+ |
106 |
*spapp = spa; |
107 |
|
108 |
return (0); |
109 |
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c |
110 |
index b41eeb2..f9387a7 100644 |
111 |
--- a/module/zfs/zvol.c |
112 |
+++ b/module/zfs/zvol.c |
113 |
@@ -1217,6 +1217,8 @@ zvol_alloc(dev_t dev, const char *name) |
114 |
if (zv == NULL) |
115 |
goto out; |
116 |
|
117 |
+ spin_lock_init(&zv->zv_lock); |
118 |
+ |
119 |
zv->zv_queue = blk_init_queue(zvol_request, &zv->zv_lock); |
120 |
if (zv->zv_queue == NULL) |
121 |
goto out_kmem; |
122 |
@@ -1250,7 +1252,6 @@ zvol_alloc(dev_t dev, const char *name) |
123 |
sizeof (rl_t), offsetof(rl_t, r_node)); |
124 |
zv->zv_znode.z_is_zvol = TRUE; |
125 |
|
126 |
- spin_lock_init(&zv->zv_lock); |
127 |
list_link_init(&zv->zv_next); |
128 |
|
129 |
zv->zv_disk->major = zvol_major; |
130 |
@@ -1563,36 +1564,40 @@ zvol_init(void) |
131 |
{ |
132 |
int error; |
133 |
|
134 |
+ list_create(&zvol_state_list, sizeof (zvol_state_t), |
135 |
+ offsetof(zvol_state_t, zv_next)); |
136 |
+ mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); |
137 |
+ |
138 |
zvol_taskq = taskq_create(ZVOL_DRIVER, zvol_threads, maxclsyspri, |
139 |
zvol_threads, INT_MAX, TASKQ_PREPOPULATE); |
140 |
if (zvol_taskq == NULL) { |
141 |
printk(KERN_INFO "ZFS: taskq_create() failed\n"); |
142 |
- return (-ENOMEM); |
143 |
+ error = -ENOMEM; |
144 |
+ goto out1; |
145 |
} |
146 |
|
147 |
error = register_blkdev(zvol_major, ZVOL_DRIVER); |
148 |
if (error) { |
149 |
printk(KERN_INFO "ZFS: register_blkdev() failed %d\n", error); |
150 |
- taskq_destroy(zvol_taskq); |
151 |
- return (error); |
152 |
+ goto out2; |
153 |
} |
154 |
|
155 |
blk_register_region(MKDEV(zvol_major, 0), 1UL << MINORBITS, |
156 |
THIS_MODULE, zvol_probe, NULL, NULL); |
157 |
|
158 |
- mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); |
159 |
- list_create(&zvol_state_list, sizeof (zvol_state_t), |
160 |
- offsetof(zvol_state_t, zv_next)); |
161 |
- |
162 |
- (void) zvol_create_minors(NULL); |
163 |
- |
164 |
return (0); |
165 |
+ |
166 |
+out2: |
167 |
+ taskq_destroy(zvol_taskq); |
168 |
+out1: |
169 |
+ mutex_destroy(&zvol_state_lock); |
170 |
+ list_destroy(&zvol_state_list); |
171 |
+ return (error); |
172 |
} |
173 |
|
174 |
void |
175 |
zvol_fini(void) |
176 |
{ |
177 |
- zvol_remove_minors(NULL); |
178 |
blk_unregister_region(MKDEV(zvol_major, 0), 1UL << MINORBITS); |
179 |
unregister_blkdev(zvol_major, ZVOL_DRIVER); |
180 |
taskq_destroy(zvol_taskq); |
181 |
|
182 |
|
183 |
|
184 |
1.1 sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch |
185 |
|
186 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch?rev=1.1&view=markup |
187 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch?rev=1.1&content-type=text/plain |
188 |
|
189 |
Index: zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch |
190 |
=================================================================== |
191 |
From 57f5a2008e2e6acf58934cf43c5fdca0faffa73e Mon Sep 17 00:00:00 2001 |
192 |
From: Brian Behlendorf <behlendorf1@××××.gov> |
193 |
Date: Thu, 25 Apr 2013 16:29:22 -0700 |
194 |
Subject: [PATCH] Fix txg_quiesce thread deadlock |
195 |
|
196 |
A deadlock was accidentally introduced by commit e95853a which |
197 |
can occur when the system is under memory pressure. What happens |
198 |
is that while the txg_quiesce thread is holding the tx->tx_cpu |
199 |
locks it enters memory reclaim. In the context of this memory |
200 |
reclaim it then issues synchronous I/O to a ZVOL swap device. |
201 |
Because the txg_quiesce thread is holding the tx->tx_cpu locks |
202 |
a new txg cannot be opened to handle the I/O. Deadlock. |
203 |
|
204 |
The fix is straight forward. Move the memory allocation outside |
205 |
the critical region where the tx->tx_cpu locks are held. And for |
206 |
good measure change the offending allocation to KM_PUSHPAGE to |
207 |
ensure it never attempts to issue I/O during reclaim. |
208 |
|
209 |
Signed-off-by: Brian Behlendorf <behlendorf1@××××.gov> |
210 |
Issue #1274 |
211 |
--- |
212 |
module/zfs/dsl_pool.c | 2 +- |
213 |
module/zfs/txg.c | 14 +++++++------- |
214 |
2 files changed, 8 insertions(+), 8 deletions(-) |
215 |
|
216 |
diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c |
217 |
index 704f034..771b265 100644 |
218 |
--- a/module/zfs/dsl_pool.c |
219 |
+++ b/module/zfs/dsl_pool.c |
220 |
@@ -143,7 +143,7 @@ |
221 |
{ |
222 |
txg_history_t *th, *rm; |
223 |
|
224 |
- th = kmem_zalloc(sizeof(txg_history_t), KM_SLEEP); |
225 |
+ th = kmem_zalloc(sizeof(txg_history_t), KM_PUSHPAGE); |
226 |
mutex_init(&th->th_lock, NULL, MUTEX_DEFAULT, NULL); |
227 |
th->th_kstat.txg = txg; |
228 |
th->th_kstat.state = TXG_STATE_OPEN; |
229 |
diff --git a/module/zfs/txg.c b/module/zfs/txg.c |
230 |
index c7c3df3..7c820af 100644 |
231 |
--- a/module/zfs/txg.c |
232 |
+++ b/module/zfs/txg.c |
233 |
@@ -367,6 +367,13 @@ |
234 |
tx->tx_open_txg++; |
235 |
|
236 |
/* |
237 |
+ * Now that we've incremented tx_open_txg, we can let threads |
238 |
+ * enter the next transaction group. |
239 |
+ */ |
240 |
+ for (c = 0; c < max_ncpus; c++) |
241 |
+ mutex_exit(&tx->tx_cpu[c].tc_lock); |
242 |
+ |
243 |
+ /* |
244 |
* Measure how long the txg was open and replace the kstat. |
245 |
*/ |
246 |
th = dsl_pool_txg_history_get(dp, txg); |
247 |
@@ -376,13 +383,6 @@ |
248 |
dsl_pool_txg_history_add(dp, tx->tx_open_txg); |
249 |
|
250 |
/* |
251 |
- * Now that we've incremented tx_open_txg, we can let threads |
252 |
- * enter the next transaction group. |
253 |
- */ |
254 |
- for (c = 0; c < max_ncpus; c++) |
255 |
- mutex_exit(&tx->tx_cpu[c].tc_lock); |
256 |
- |
257 |
- /* |
258 |
* Quiesce the transaction group by waiting for everyone to txg_exit(). |
259 |
*/ |
260 |
start = gethrtime(); |
261 |
-- |
262 |
1.8.1.6 |
263 |
|
264 |
|
265 |
|
266 |
|
267 |
1.1 sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-getdents.patch |
268 |
|
269 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-getdents.patch?rev=1.1&view=markup |
270 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-getdents.patch?rev=1.1&content-type=text/plain |
271 |
|
272 |
Index: zfs-kmod-0.6.1-fix-getdents.patch |
273 |
=================================================================== |
274 |
From 8f1e11b6105bf46a4258958eb3dcae2ab21ed8b2 Mon Sep 17 00:00:00 2001 |
275 |
From: Caleb James DeLisle <calebdelisle@×××××××.com> |
276 |
Date: Tue, 16 Apr 2013 05:23:39 -0400 |
277 |
Subject: [PATCH] Remove .readdir from zpl_file_operations table |
278 |
|
279 |
The zpl_readdir() function shouldn't be registered as part of |
280 |
the zpl_file_operations table, it must only be part of the |
281 |
zpl_dir_file_operations table. By removing this callback |
282 |
the VFS will now correctly return ENOTDIR when calling |
283 |
getdents() on a file. |
284 |
|
285 |
Signed-off-by: Brian Behlendorf <behlendorf1@××××.gov> |
286 |
Closes #1404 |
287 |
--- |
288 |
module/zfs/zpl_file.c | 1 - |
289 |
1 file changed, 1 deletion(-) |
290 |
|
291 |
diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c |
292 |
index 9c27b7f..db6a72c 100644 |
293 |
--- a/module/zfs/zpl_file.c |
294 |
+++ b/module/zfs/zpl_file.c |
295 |
@@ -446,7 +446,6 @@ |
296 |
.llseek = generic_file_llseek, |
297 |
.read = zpl_read, |
298 |
.write = zpl_write, |
299 |
- .readdir = zpl_readdir, |
300 |
.mmap = zpl_mmap, |
301 |
.fsync = zpl_fsync, |
302 |
#ifdef HAVE_FILE_FALLOCATE |
303 |
-- |
304 |
1.8.1.6 |
305 |
|
306 |
|
307 |
|
308 |
|
309 |
1.1 sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch |
310 |
|
311 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch?rev=1.1&view=markup |
312 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch?rev=1.1&content-type=text/plain |
313 |
|
314 |
Index: zfs-kmod-0.6.1-fix-xattr-behavior-1.patch |
315 |
=================================================================== |
316 |
From f706421173c571371afff5e2a2ee0784c5e3f95d Mon Sep 17 00:00:00 2001 |
317 |
From: Brian Behlendorf <behlendorf1@××××.gov> |
318 |
Date: Wed, 17 Apr 2013 13:07:36 -0700 |
319 |
Subject: [PATCH] Correctly return ERANGE in getxattr(2) |
320 |
|
321 |
According to the getxattr(2) man page the ERANGE errno should be |
322 |
returned when the size of the value buffer is to small to hold the |
323 |
result. Prior to this patch the implementation would just truncate |
324 |
the value to size bytes. |
325 |
|
326 |
Signed-off-by: Brian Behlendorf <behlendorf1@××××.gov> |
327 |
Closes #1408 |
328 |
--- |
329 |
module/zfs/zpl_xattr.c | 12 ++++++++++-- |
330 |
1 file changed, 10 insertions(+), 2 deletions(-) |
331 |
|
332 |
diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c |
333 |
index c03764f..a7e38e6 100644 |
334 |
--- a/module/zfs/zpl_xattr.c |
335 |
+++ b/module/zfs/zpl_xattr.c |
336 |
@@ -225,6 +225,11 @@ |
337 |
goto out; |
338 |
} |
339 |
|
340 |
+ if (size < i_size_read(xip)) { |
341 |
+ error = -ERANGE; |
342 |
+ goto out; |
343 |
+ } |
344 |
+ |
345 |
error = zpl_read_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr); |
346 |
out: |
347 |
if (xip) |
348 |
@@ -263,9 +268,12 @@ |
349 |
if (!size) |
350 |
return (nv_size); |
351 |
|
352 |
- memcpy(value, nv_value, MIN(size, nv_size)); |
353 |
+ if (size < nv_size) |
354 |
+ return (-ERANGE); |
355 |
+ |
356 |
+ memcpy(value, nv_value, nv_size); |
357 |
|
358 |
- return (MIN(size, nv_size)); |
359 |
+ return (nv_size); |
360 |
} |
361 |
|
362 |
static int |
363 |
-- |
364 |
1.8.1.6 |