| 1985 | } |
| 1986 | |
| 1987 | static int |
| 1988 | ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap) |
| 1989 | { |
| 1990 | ztest_ds_t *zd = arg1; |
| 1991 | lr_write_t *lr = arg2; |
| 1992 | objset_t *os = zd->zd_os; |
| 1993 | void *data = lr + 1; /* data follows lr */ |
| 1994 | uint64_t offset, length; |
| 1995 | ztest_block_tag_t *bt = data; |
| 1996 | ztest_block_tag_t *bbt; |
| 1997 | uint64_t gen, txg, lrtxg, crtxg; |
| 1998 | dmu_object_info_t doi; |
| 1999 | dmu_tx_t *tx; |
| 2000 | dmu_buf_t *db; |
| 2001 | arc_buf_t *abuf = NULL; |
| 2002 | rl_t *rl; |
| 2003 | |
| 2004 | if (byteswap) |
| 2005 | byteswap_uint64_array(lr, sizeof (*lr)); |
| 2006 | |
| 2007 | offset = lr->lr_offset; |
| 2008 | length = lr->lr_length; |
| 2009 | |
| 2010 | /* If it's a dmu_sync() block, write the whole block */ |
| 2011 | if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) { |
| 2012 | uint64_t blocksize = BP_GET_LSIZE(&lr->lr_blkptr); |
| 2013 | if (length < blocksize) { |
| 2014 | offset -= offset % blocksize; |
| 2015 | length = blocksize; |
| 2016 | } |
| 2017 | } |
| 2018 | |
| 2019 | if (bt->bt_magic == BSWAP_64(BT_MAGIC)) |
| 2020 | byteswap_uint64_array(bt, sizeof (*bt)); |
| 2021 | |
| 2022 | if (bt->bt_magic != BT_MAGIC) |
| 2023 | bt = NULL; |
| 2024 | |
| 2025 | ztest_object_lock(zd, lr->lr_foid, RL_READER); |
| 2026 | rl = ztest_range_lock(zd, lr->lr_foid, offset, length, RL_WRITER); |
| 2027 | |
| 2028 | VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); |
| 2029 | |
| 2030 | dmu_object_info_from_db(db, &doi); |
| 2031 | |
| 2032 | bbt = ztest_bt_bonus(db); |
| 2033 | ASSERT3U(bbt->bt_magic, ==, BT_MAGIC); |
| 2034 | gen = bbt->bt_gen; |
| 2035 | crtxg = bbt->bt_crtxg; |
| 2036 | lrtxg = lr->lr_common.lrc_txg; |
| 2037 | |
| 2038 | tx = dmu_tx_create(os); |
| 2039 | |
| 2040 | dmu_tx_hold_write(tx, lr->lr_foid, offset, length); |
| 2041 | |
| 2042 | if (ztest_random(8) == 0 && length == doi.doi_data_block_size && |
| 2043 | P2PHASE(offset, length) == 0) |
| 2044 | abuf = dmu_request_arcbuf(db, length); |
no test coverage detected