]>
Commit | Line | Data |
---|---|---|
19953df1 TL |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Antonio Russo <aerusso@aerusso.net> | |
3 | Date: Tue, 22 Jun 2021 22:39:15 -0600 | |
4 | Subject: [PATCH] Revert Consolidate arc_buf allocation checks | |
5 | ||
6 | This reverts commit 13fac09868b4e4e08cc3ef7b937ac277c1c407b1. | |
7 | ||
8 | Per the discussion in #11531, the reverted commit---which intended only | |
9 | to be a cleanup commit---introduced a subtle, unintended change in | |
10 | behavior. | |
11 | ||
12 | Care was taken to partially revert and then reapply 10b3c7f5e4 | |
13 | which would otherwise have caused a conflict. These changes were | |
14 | squashed in to this commit. | |
15 | ||
16 | Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
17 | Suggested-by: @chrisrd | |
18 | Suggested-by: robn@despairlabs.com | |
19 | Signed-off-by: Antonio Russo <aerusso@aerusso.net> | |
20 | Closes #11531 | |
21 | Closes #12227 | |
22 | (cherry picked from commit c01032417f655555b29f4e67c187e0622d587c8d) | |
23 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> | |
24 | --- | |
25 | module/zfs/dbuf.c | 121 +++++++++++++++++++++++++++++----------------- | |
26 | 1 file changed, 77 insertions(+), 44 deletions(-) | |
27 | ||
28 | diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c | |
29 | index 7d817320a..844f69367 100644 | |
30 | --- a/module/zfs/dbuf.c | |
31 | +++ b/module/zfs/dbuf.c | |
32 | @@ -1090,42 +1090,6 @@ dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf) | |
33 | db->db.db_data = buf->b_data; | |
34 | } | |
35 | ||
36 | -static arc_buf_t * | |
37 | -dbuf_alloc_arcbuf_from_arcbuf(dmu_buf_impl_t *db, arc_buf_t *data) | |
38 | -{ | |
39 | - objset_t *os = db->db_objset; | |
40 | - spa_t *spa = os->os_spa; | |
41 | - arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); | |
42 | - enum zio_compress compress_type; | |
43 | - uint8_t complevel; | |
44 | - int psize, lsize; | |
45 | - | |
46 | - psize = arc_buf_size(data); | |
47 | - lsize = arc_buf_lsize(data); | |
48 | - compress_type = arc_get_compression(data); | |
49 | - complevel = arc_get_complevel(data); | |
50 | - | |
51 | - if (arc_is_encrypted(data)) { | |
52 | - boolean_t byteorder; | |
53 | - uint8_t salt[ZIO_DATA_SALT_LEN]; | |
54 | - uint8_t iv[ZIO_DATA_IV_LEN]; | |
55 | - uint8_t mac[ZIO_DATA_MAC_LEN]; | |
56 | - dnode_t *dn = DB_DNODE(db); | |
57 | - | |
58 | - arc_get_raw_params(data, &byteorder, salt, iv, mac); | |
59 | - data = arc_alloc_raw_buf(spa, db, dmu_objset_id(os), | |
60 | - byteorder, salt, iv, mac, dn->dn_type, psize, lsize, | |
61 | - compress_type, complevel); | |
62 | - } else if (compress_type != ZIO_COMPRESS_OFF) { | |
63 | - ASSERT3U(type, ==, ARC_BUFC_DATA); | |
64 | - data = arc_alloc_compressed_buf(spa, db, | |
65 | - psize, lsize, compress_type, complevel); | |
66 | - } else { | |
67 | - data = arc_alloc_buf(spa, db, type, psize); | |
68 | - } | |
69 | - return (data); | |
70 | -} | |
71 | - | |
72 | static arc_buf_t * | |
73 | dbuf_alloc_arcbuf(dmu_buf_impl_t *db) | |
74 | { | |
75 | @@ -1575,9 +1539,35 @@ dbuf_fix_old_data(dmu_buf_impl_t *db, uint64_t txg) | |
76 | arc_space_consume(bonuslen, ARC_SPACE_BONUS); | |
77 | bcopy(db->db.db_data, dr->dt.dl.dr_data, bonuslen); | |
78 | } else if (zfs_refcount_count(&db->db_holds) > db->db_dirtycnt) { | |
79 | - arc_buf_t *buf = dbuf_alloc_arcbuf_from_arcbuf(db, db->db_buf); | |
80 | - dr->dt.dl.dr_data = buf; | |
81 | - bcopy(db->db.db_data, buf->b_data, arc_buf_size(buf)); | |
82 | + dnode_t *dn = DB_DNODE(db); | |
83 | + int size = arc_buf_size(db->db_buf); | |
84 | + arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); | |
85 | + spa_t *spa = db->db_objset->os_spa; | |
86 | + enum zio_compress compress_type = | |
87 | + arc_get_compression(db->db_buf); | |
88 | + uint8_t complevel = arc_get_complevel(db->db_buf); | |
89 | + | |
90 | + if (arc_is_encrypted(db->db_buf)) { | |
91 | + boolean_t byteorder; | |
92 | + uint8_t salt[ZIO_DATA_SALT_LEN]; | |
93 | + uint8_t iv[ZIO_DATA_IV_LEN]; | |
94 | + uint8_t mac[ZIO_DATA_MAC_LEN]; | |
95 | + | |
96 | + arc_get_raw_params(db->db_buf, &byteorder, salt, | |
97 | + iv, mac); | |
98 | + dr->dt.dl.dr_data = arc_alloc_raw_buf(spa, db, | |
99 | + dmu_objset_id(dn->dn_objset), byteorder, salt, iv, | |
100 | + mac, dn->dn_type, size, arc_buf_lsize(db->db_buf), | |
101 | + compress_type, complevel); | |
102 | + } else if (compress_type != ZIO_COMPRESS_OFF) { | |
103 | + ASSERT3U(type, ==, ARC_BUFC_DATA); | |
104 | + dr->dt.dl.dr_data = arc_alloc_compressed_buf(spa, db, | |
105 | + size, arc_buf_lsize(db->db_buf), compress_type, | |
106 | + complevel); | |
107 | + } else { | |
108 | + dr->dt.dl.dr_data = arc_alloc_buf(spa, db, type, size); | |
109 | + } | |
110 | + bcopy(db->db.db_data, dr->dt.dl.dr_data->b_data, size); | |
111 | } else { | |
112 | db->db_buf = NULL; | |
113 | dbuf_clear_data(db); | |
114 | @@ -3280,10 +3270,30 @@ noinline static void | |
115 | dbuf_hold_copy(dnode_t *dn, dmu_buf_impl_t *db) | |
116 | { | |
117 | dbuf_dirty_record_t *dr = db->db_data_pending; | |
118 | - arc_buf_t *newdata, *data = dr->dt.dl.dr_data; | |
119 | + arc_buf_t *data = dr->dt.dl.dr_data; | |
120 | + enum zio_compress compress_type = arc_get_compression(data); | |
121 | + uint8_t complevel = arc_get_complevel(data); | |
122 | + | |
123 | + if (arc_is_encrypted(data)) { | |
124 | + boolean_t byteorder; | |
125 | + uint8_t salt[ZIO_DATA_SALT_LEN]; | |
126 | + uint8_t iv[ZIO_DATA_IV_LEN]; | |
127 | + uint8_t mac[ZIO_DATA_MAC_LEN]; | |
128 | + | |
129 | + arc_get_raw_params(data, &byteorder, salt, iv, mac); | |
130 | + dbuf_set_data(db, arc_alloc_raw_buf(dn->dn_objset->os_spa, db, | |
131 | + dmu_objset_id(dn->dn_objset), byteorder, salt, iv, mac, | |
132 | + dn->dn_type, arc_buf_size(data), arc_buf_lsize(data), | |
133 | + compress_type, complevel)); | |
134 | + } else if (compress_type != ZIO_COMPRESS_OFF) { | |
135 | + dbuf_set_data(db, arc_alloc_compressed_buf( | |
136 | + dn->dn_objset->os_spa, db, arc_buf_size(data), | |
137 | + arc_buf_lsize(data), compress_type, complevel)); | |
138 | + } else { | |
139 | + dbuf_set_data(db, arc_alloc_buf(dn->dn_objset->os_spa, db, | |
140 | + DBUF_GET_BUFC_TYPE(db), db->db.db_size)); | |
141 | + } | |
142 | ||
143 | - newdata = dbuf_alloc_arcbuf_from_arcbuf(db, data); | |
144 | - dbuf_set_data(db, newdata); | |
145 | rw_enter(&db->db_rwlock, RW_WRITER); | |
146 | bcopy(data->b_data, db->db.db_data, arc_buf_size(data)); | |
147 | rw_exit(&db->db_rwlock); | |
148 | @@ -4067,8 +4077,31 @@ dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx) | |
149 | * objects only modified in the syncing context (e.g. | |
150 | * DNONE_DNODE blocks). | |
151 | */ | |
152 | - *datap = dbuf_alloc_arcbuf_from_arcbuf(db, db->db_buf); | |
153 | - bcopy(db->db.db_data, (*datap)->b_data, arc_buf_size(*datap)); | |
154 | + int psize = arc_buf_size(*datap); | |
155 | + int lsize = arc_buf_lsize(*datap); | |
156 | + arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db); | |
157 | + enum zio_compress compress_type = arc_get_compression(*datap); | |
158 | + uint8_t complevel = arc_get_complevel(*datap); | |
159 | + | |
160 | + if (arc_is_encrypted(*datap)) { | |
161 | + boolean_t byteorder; | |
162 | + uint8_t salt[ZIO_DATA_SALT_LEN]; | |
163 | + uint8_t iv[ZIO_DATA_IV_LEN]; | |
164 | + uint8_t mac[ZIO_DATA_MAC_LEN]; | |
165 | + | |
166 | + arc_get_raw_params(*datap, &byteorder, salt, iv, mac); | |
167 | + *datap = arc_alloc_raw_buf(os->os_spa, db, | |
168 | + dmu_objset_id(os), byteorder, salt, iv, mac, | |
169 | + dn->dn_type, psize, lsize, compress_type, | |
170 | + complevel); | |
171 | + } else if (compress_type != ZIO_COMPRESS_OFF) { | |
172 | + ASSERT3U(type, ==, ARC_BUFC_DATA); | |
173 | + *datap = arc_alloc_compressed_buf(os->os_spa, db, | |
174 | + psize, lsize, compress_type, complevel); | |
175 | + } else { | |
176 | + *datap = arc_alloc_buf(os->os_spa, db, type, psize); | |
177 | + } | |
178 | + bcopy(db->db.db_data, (*datap)->b_data, psize); | |
179 | } | |
180 | db->db_data_pending = dr; | |
181 |