MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sa_byteswap

Function sa_byteswap

freebsd/contrib/openzfs/module/zfs/sa.c:1232–1271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1230}
1231
1232static void
1233sa_byteswap(sa_handle_t *hdl, sa_buf_type_t buftype)
1234{
1235 sa_hdr_phys_t *sa_hdr_phys = SA_GET_HDR(hdl, buftype);
1236 dmu_buf_impl_t *db;
1237 int num_lengths = 1;
1238 int i;
1239 sa_os_t *sa __maybe_unused = hdl->sa_os->os_sa;
1240
1241 ASSERT(MUTEX_HELD(&sa->sa_lock));
1242 if (sa_hdr_phys->sa_magic == SA_MAGIC)
1243 return;
1244
1245 db = SA_GET_DB(hdl, buftype);
1246
1247 if (buftype == SA_SPILL) {
1248 arc_release(db->db_buf, NULL);
1249 arc_buf_thaw(db->db_buf);
1250 }
1251
1252 sa_hdr_phys->sa_magic = BSWAP_32(sa_hdr_phys->sa_magic);
1253 sa_hdr_phys->sa_layout_info = BSWAP_16(sa_hdr_phys->sa_layout_info);
1254
1255 /*
1256 * Determine number of variable lengths in header
1257 * The standard 8 byte header has one for free and a
1258 * 16 byte header would have 4 + 1;
1259 */
1260 if (SA_HDR_SIZE(sa_hdr_phys) > 8)
1261 num_lengths += (SA_HDR_SIZE(sa_hdr_phys) - 8) >> 1;
1262 for (i = 0; i != num_lengths; i++)
1263 sa_hdr_phys->sa_lengths[i] =
1264 BSWAP_16(sa_hdr_phys->sa_lengths[i]);
1265
1266 sa_attr_iter(hdl->sa_os, sa_hdr_phys, DMU_OT_SA,
1267 sa_byteswap_cb, NULL, hdl);
1268
1269 if (buftype == SA_SPILL)
1270 arc_buf_freeze(((dmu_buf_impl_t *)hdl->sa_spill)->db_buf);
1271}
1272
1273static int
1274sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype)

Callers 1

sa_build_indexFunction · 0.85

Calls 4

arc_releaseFunction · 0.85
arc_buf_thawFunction · 0.85
sa_attr_iterFunction · 0.85
arc_buf_freezeFunction · 0.85

Tested by

no test coverage detected