Gentoo Archives: gentoo-commits

From: "Richard Yao (ryao)" <ryao@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-fs/zfs/files: zfs-0.6.0_rc9-range-lock-caller-allocate.patch
Date: Mon, 25 Jun 2012 00:51:01
Message-Id: 20120625005051.811CA2004C@flycatcher.gentoo.org
1 ryao 12/06/25 00:50:51
2
3 Added: zfs-0.6.0_rc9-range-lock-caller-allocate.patch
4 Log:
5 Fix swap deadlock involving zfs_range_lock() and zvols
6
7 (Portage version: 2.1.10.49/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 sys-fs/zfs/files/zfs-0.6.0_rc9-range-lock-caller-allocate.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs/files/zfs-0.6.0_rc9-range-lock-caller-allocate.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-fs/zfs/files/zfs-0.6.0_rc9-range-lock-caller-allocate.patch?rev=1.1&content-type=text/plain
14
15 Index: zfs-0.6.0_rc9-range-lock-caller-allocate.patch
16 ===================================================================
17 commit 59c247716c71837b0071fb933f731e7b82c98dd8
18 Author: Gunnar Beutner <gunnar@×××××××.name>
19 Date: Mon Jun 18 11:44:34 2012 -0400
20
21 Fix znode corruption when using xattr=sa.
22
23 Using a separate SA handle (rather than zp->z_sa_hdl) to update
24 attributes corrupts the znode's mode flags (and possibly other
25 attributes as well).
26
27 This patch changes the zfs_sa_get_xattr/zfs_sa_set_xattr functions
28 so that they use zp->z_sa_hdl.
29
30 Signed-off-by: Richard Yao <ryao@×××××××××××××.edu>
31
32 diff --git a/module/zfs/zfs_sa.c b/module/zfs/zfs_sa.c
33 index f35f6f6..7f14706 100644
34 --- a/module/zfs/zfs_sa.c
35 +++ b/module/zfs/zfs_sa.c
36 @@ -188,7 +188,6 @@ int
37 zfs_sa_get_xattr(znode_t *zp)
38 {
39 zfs_sb_t *zsb = ZTOZSB(zp);
40 - sa_handle_t *sa;
41 char *obj;
42 int size;
43 int error;
44 @@ -197,14 +196,8 @@ zfs_sa_get_xattr(znode_t *zp)
45 ASSERT(!zp->z_xattr_cached);
46 ASSERT(zp->z_is_sa);
47
48 - error = sa_handle_get(zsb->z_os, zp->z_id, NULL, SA_HDL_PRIVATE, &sa);
49 - if (error)
50 - return (error);
51 -
52 - error = sa_size(sa, SA_ZPL_DXATTR(zsb), &size);
53 + error = sa_size(zp->z_sa_hdl, SA_ZPL_DXATTR(zsb), &size);
54 if (error) {
55 - sa_handle_destroy(sa);
56 -
57 if (error == ENOENT)
58 return nvlist_alloc(&zp->z_xattr_cached,
59 NV_UNIQUE_NAME, KM_SLEEP);
60 @@ -212,14 +205,13 @@ zfs_sa_get_xattr(znode_t *zp)
61 return (error);
62 }
63
64 - obj = sa_spill_alloc(KM_SLEEP);
65 + obj = kmem_alloc(size, KM_SLEEP);
66
67 - error = sa_lookup(sa, SA_ZPL_DXATTR(zsb), obj, size);
68 + error = sa_lookup(zp->z_sa_hdl, SA_ZPL_DXATTR(zsb), obj, size);
69 if (error == 0)
70 error = nvlist_unpack(obj, size, &zp->z_xattr_cached, KM_SLEEP);
71
72 - sa_spill_free(obj);
73 - sa_handle_destroy(sa);
74 + kmem_free(obj, size);
75
76 return (error);
77 }
78 @@ -228,7 +220,6 @@ int
79 zfs_sa_set_xattr(znode_t *zp)
80 {
81 zfs_sb_t *zsb = ZTOZSB(zp);
82 - sa_handle_t *sa;
83 dmu_tx_t *tx;
84 char *obj;
85 size_t size;
86 @@ -242,44 +233,27 @@ zfs_sa_set_xattr(znode_t *zp)
87 if (error)
88 goto out;
89
90 - obj = sa_spill_alloc(KM_SLEEP);
91 + obj = kmem_alloc(size, KM_SLEEP);
92
93 error = nvlist_pack(zp->z_xattr_cached, &obj, &size,
94 NV_ENCODE_XDR, KM_SLEEP);
95 if (error)
96 - goto out_free;
97 -
98 - /*
99 - * A private SA handle must be used to ensure we can drop the hold
100 - * on the spill block prior to calling dmu_tx_commit(). If we call
101 - * dmu_tx_commit() before sa_handle_destroy(), then our hold will
102 - * trigger a copy of the buffer at txg sync time. This is done to
103 - * prevent data from leaking in to the syncing txg. As a result
104 - * the original dirty spill block will be remain dirty in the arc
105 - * while the copy is written and laundered.
106 - */
107 - error = sa_handle_get(zsb->z_os, zp->z_id, NULL, SA_HDL_PRIVATE, &sa);
108 - if (error)
109 - goto out_free;
110 + goto out;
111
112 tx = dmu_tx_create(zsb->z_os);
113 dmu_tx_hold_sa_create(tx, size);
114 - dmu_tx_hold_sa(tx, sa, B_TRUE);
115 + dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_TRUE);
116
117 error = dmu_tx_assign(tx, TXG_WAIT);
118 if (error) {
119 dmu_tx_abort(tx);
120 - sa_handle_destroy(sa);
121 } else {
122 - error = sa_update(sa, SA_ZPL_DXATTR(zsb), obj, size, tx);
123 - sa_handle_destroy(sa);
124 - if (error)
125 - dmu_tx_abort(tx);
126 - else
127 - dmu_tx_commit(tx);
128 + VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_DXATTR(zsb), obj,
129 + size, tx));
130 + dmu_tx_commit(tx);
131 }
132 -out_free:
133 - sa_spill_free(obj);
134 +
135 + kmem_free(obj, size);
136 out:
137 return (error);
138 }