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

Function ztest_get_data

freebsd/contrib/openzfs/cmd/ztest/ztest.c:2274–2359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2272}
2273
2274static int
2275ztest_get_data(void *arg, lr_write_t *lr, char *buf, struct lwb *lwb,
2276 zio_t *zio)
2277{
2278 ztest_ds_t *zd = arg;
2279 objset_t *os = zd->zd_os;
2280 uint64_t object = lr->lr_foid;
2281 uint64_t offset = lr->lr_offset;
2282 uint64_t size = lr->lr_length;
2283 uint64_t txg = lr->lr_common.lrc_txg;
2284 uint64_t crtxg;
2285 dmu_object_info_t doi;
2286 dmu_buf_t *db;
2287 zgd_t *zgd;
2288 int error;
2289
2290 ASSERT3P(lwb, !=, NULL);
2291 ASSERT3P(zio, !=, NULL);
2292 ASSERT3U(size, !=, 0);
2293
2294 ztest_object_lock(zd, object, RL_READER);
2295 error = dmu_bonus_hold(os, object, FTAG, &db);
2296 if (error) {
2297 ztest_object_unlock(zd, object);
2298 return (error);
2299 }
2300
2301 crtxg = ztest_bt_bonus(db)->bt_crtxg;
2302
2303 if (crtxg == 0 || crtxg > txg) {
2304 dmu_buf_rele(db, FTAG);
2305 ztest_object_unlock(zd, object);
2306 return (ENOENT);
2307 }
2308
2309 dmu_object_info_from_db(db, &doi);
2310 dmu_buf_rele(db, FTAG);
2311 db = NULL;
2312
2313 zgd = umem_zalloc(sizeof (*zgd), UMEM_NOFAIL);
2314 zgd->zgd_lwb = lwb;
2315 zgd->zgd_private = zd;
2316
2317 if (buf != NULL) { /* immediate write */
2318 zgd->zgd_lr = (struct zfs_locked_range *)ztest_range_lock(zd,
2319 object, offset, size, RL_READER);
2320
2321 error = dmu_read(os, object, offset, size, buf,
2322 DMU_READ_NO_PREFETCH);
2323 ASSERT(error == 0);
2324 } else {
2325 size = doi.doi_data_block_size;
2326 if (ISP2(size)) {
2327 offset = P2ALIGN(offset, size);
2328 } else {
2329 ASSERT(offset < size);
2330 offset = 0;
2331 }

Callers

nothing calls this directly

Calls 12

ztest_object_lockFunction · 0.85
dmu_bonus_holdFunction · 0.85
ztest_object_unlockFunction · 0.85
ztest_bt_bonusFunction · 0.85
dmu_buf_releFunction · 0.85
dmu_object_info_from_dbFunction · 0.85
umem_zallocFunction · 0.85
ztest_range_lockFunction · 0.85
dmu_readFunction · 0.85
dmu_buf_holdFunction · 0.85
dmu_syncFunction · 0.85
ztest_get_doneFunction · 0.85

Tested by

no test coverage detected