Skip to content

Commit

Permalink
git subrepo pull --force sys/contrib/subrepo-openzfs
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "sys/contrib/subrepo-openzfs"
  merged:   "256817ec444a"
upstream:
  origin:   "https://github.com/CTSRD-CHERI/zfs.git"
  branch:   "cheri-hybrid"
  commit:   "256817ec444a"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
  • Loading branch information
bsdjhb committed Mar 12, 2024
1 parent 0b9521a commit e184e3d
Show file tree
Hide file tree
Showing 21 changed files with 581 additions and 17 deletions.
4 changes: 2 additions & 2 deletions sys/contrib/subrepo-openzfs/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/CTSRD-CHERI/zfs.git
branch = cheri-hybrid
commit = 3f36e91fa8d5269772a9813a1d26e711a378b747
parent = 91348b413355aa92802a5f94b84a7229030910e1
commit = 256817ec444af1bf0846397835e955e8418a3b73
parent = 0b9521aeecf670e0fda710dc5e8aaf1d98e60f11
method = merge
cmdver = 0.4.3
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Bad SCSI disks can often "disappear and reappear" causing all sorts of chaos
# as they flip between FAULTED and ONLINE. If
# ZED_POWER_OFF_ENCLOUSRE_SLOT_ON_FAULT is set in zed.rc, and the disk gets
# ZED_POWER_OFF_ENCLOSURE_SLOT_ON_FAULT is set in zed.rc, and the disk gets
# FAULTED, then power down the slot via sysfs:
#
# /sys/class/enclosure/<enclosure>/<slot>/power_status
Expand All @@ -19,7 +19,7 @@
# Exit codes:
# 0: slot successfully powered off
# 1: enclosure not available
# 2: ZED_POWER_OFF_ENCLOUSRE_SLOT_ON_FAULT disabled
# 2: ZED_POWER_OFF_ENCLOSURE_SLOT_ON_FAULT disabled
# 3: vdev was not FAULTED
# 4: The enclosure sysfs path passed from ZFS does not exist
# 5: Enclosure slot didn't actually turn off after we told it to
Expand All @@ -32,7 +32,7 @@ if [ ! -d /sys/class/enclosure ] ; then
exit 1
fi

if [ "${ZED_POWER_OFF_ENCLOUSRE_SLOT_ON_FAULT}" != "1" ] ; then
if [ "${ZED_POWER_OFF_ENCLOSURE_SLOT_ON_FAULT}" != "1" ] ; then
exit 2
fi

Expand Down
2 changes: 1 addition & 1 deletion sys/contrib/subrepo-openzfs/cmd/zed/zed.d/zed.rc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event"
# Power off the drive's slot in the enclosure if it becomes FAULTED. This can
# help silence misbehaving drives. This assumes your drive enclosure fully
# supports slot power control via sysfs.
#ZED_POWER_OFF_ENCLOUSRE_SLOT_ON_FAULT=1
#ZED_POWER_OFF_ENCLOSURE_SLOT_ON_FAULT=1

##
# Ntfy topic
Expand Down
1 change: 1 addition & 0 deletions sys/contrib/subrepo-openzfs/include/sys/dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ extern "C" {
* dbuf_states_t (see comment on dn_dbufs in dnode.h).
*/
typedef enum dbuf_states {
DB_MARKER = -2,
DB_SEARCH = -1,
DB_UNCACHED,
DB_FILL,
Expand Down
20 changes: 16 additions & 4 deletions sys/contrib/subrepo-openzfs/module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,6 @@ dbuf_unoverride(dbuf_dirty_record_t *dr)
dmu_buf_impl_t *db = dr->dr_dbuf;
blkptr_t *bp = &dr->dt.dl.dr_overridden_by;
uint64_t txg = dr->dr_txg;
boolean_t release;

ASSERT(MUTEX_HELD(&db->db_mtx));
/*
Expand All @@ -1940,7 +1939,10 @@ dbuf_unoverride(dbuf_dirty_record_t *dr)
if (!BP_IS_HOLE(bp) && !dr->dt.dl.dr_nopwrite)
zio_free(db->db_objset->os_spa, txg, bp);

release = !dr->dt.dl.dr_brtwrite;
if (dr->dt.dl.dr_brtwrite) {
ASSERT0P(dr->dt.dl.dr_data);
dr->dt.dl.dr_data = db->db_buf;
}
dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;
dr->dt.dl.dr_nopwrite = B_FALSE;
dr->dt.dl.dr_brtwrite = B_FALSE;
Expand All @@ -1954,7 +1956,7 @@ dbuf_unoverride(dbuf_dirty_record_t *dr)
* the buf thawed to save the effort of freezing &
* immediately re-thawing it.
*/
if (release)
if (dr->dt.dl.dr_data)
arc_release(dr->dt.dl.dr_data, db);
}

Expand Down Expand Up @@ -2945,7 +2947,8 @@ dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx)
while (db->db_state == DB_READ || db->db_state == DB_FILL)
cv_wait(&db->db_changed, &db->db_mtx);

ASSERT(db->db_state == DB_CACHED || db->db_state == DB_UNCACHED);
ASSERT(db->db_state == DB_CACHED || db->db_state == DB_UNCACHED ||
db->db_state == DB_NOFILL);

if (db->db_state == DB_CACHED &&
zfs_refcount_count(&db->db_holds) - 1 > db->db_dirtycnt) {
Expand Down Expand Up @@ -2982,6 +2985,15 @@ dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx)
arc_buf_destroy(db->db_buf, db);
}
db->db_buf = NULL;
} else if (db->db_state == DB_NOFILL) {
/*
* We will be completely replacing the cloned block. In case
* it was cloned in this transaction group, let's undirty the
* pending clone and mark the block as uncached. This will be
* as if the clone was never done.
*/
VERIFY(!dbuf_undirty(db, tx));
db->db_state = DB_UNCACHED;
}
ASSERT(db->db_buf == NULL);
dbuf_set_data(db, buf);
Expand Down
2 changes: 1 addition & 1 deletion sys/contrib/subrepo-openzfs/module/zfs/dmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,9 +1501,9 @@ dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset, arc_buf_t *buf,
rw_enter(&dn->dn_struct_rwlock, RW_READER);
blkid = dbuf_whichblock(dn, 0, offset);
db = dbuf_hold(dn, blkid, FTAG);
rw_exit(&dn->dn_struct_rwlock);
if (db == NULL)
return (SET_ERROR(EIO));
rw_exit(&dn->dn_struct_rwlock);

/*
* We can only assign if the offset is aligned and the arc buf is the
Expand Down
8 changes: 8 additions & 0 deletions sys/contrib/subrepo-openzfs/module/zfs/dnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ dbuf_compare(const void *x1, const void *x2)
if (likely(cmp))
return (cmp);

if (d1->db_state == DB_MARKER) {
ASSERT3S(d2->db_state, !=, DB_MARKER);
return (TREE_PCMP(d1->db_parent, d2));
} else if (d2->db_state == DB_MARKER) {
ASSERT3S(d1->db_state, !=, DB_MARKER);
return (TREE_PCMP(d1, d2->db_parent));
}

if (d1->db_state == DB_SEARCH) {
ASSERT3S(d2->db_state, !=, DB_SEARCH);
return (-1);
Expand Down
9 changes: 8 additions & 1 deletion sys/contrib/subrepo-openzfs/module/zfs/dnode_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,14 @@ dnode_evict_dbufs(dnode_t *dn)
zfs_refcount_is_zero(&db->db_holds)) {
db_marker->db_level = db->db_level;
db_marker->db_blkid = db->db_blkid;
db_marker->db_state = DB_SEARCH;
/*
* Insert a MARKER node with the same level and blkid.
* And to resolve any ties in dbuf_compare() use the
* pointer of the dbuf that we are evicting. Pass the
* address in db_parent.
*/
db_marker->db_state = DB_MARKER;
db_marker->db_parent = (void *)((uintptr_t)db - 1);
avl_insert_here(&dn->dn_dbufs, db_marker, db,
AVL_BEFORE);

Expand Down
2 changes: 1 addition & 1 deletion sys/contrib/subrepo-openzfs/tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ tests = ['compress_001_pos', 'compress_002_pos', 'compress_003_pos',
tags = ['functional', 'compression']

[tests/functional/cp_files]
tests = ['cp_files_001_pos']
tests = ['cp_files_001_pos', 'cp_stress']
tags = ['functional', 'cp_files']

[tests/functional/crtime]
Expand Down
3 changes: 2 additions & 1 deletion sys/contrib/subrepo-openzfs/tests/runfiles/linux.run
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ tests = ['block_cloning_copyfilerange', 'block_cloning_copyfilerange_partial',
'block_cloning_disabled_ficlonerange',
'block_cloning_copyfilerange_cross_dataset',
'block_cloning_cross_enc_dataset',
'block_cloning_copyfilerange_fallback_same_txg']
'block_cloning_copyfilerange_fallback_same_txg',
'block_cloning_replay', 'block_cloning_replay_encrypted']
tags = ['functional', 'block_cloning']

[tests/functional/chattr:Linux]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ elif sys.platform.startswith('linux'):
['SKIP', cfr_reason],
'block_cloning/block_cloning_copyfilerange_fallback':
['SKIP', cfr_reason],
'block_cloning/block_cloning_replay':
['SKIP', cfr_reason],
'block_cloning/block_cloning_replay_encrypted':
['SKIP', cfr_reason],
'block_cloning/block_cloning_copyfilerange_cross_dataset':
['SKIP', cfr_cross_reason],
'block_cloning/block_cloning_copyfilerange_fallback_same_txg':
Expand All @@ -309,7 +313,6 @@ elif sys.platform.startswith('linux'):
['SKIP', cfr_cross_reason],
})


# Not all Github actions runners have scsi_debug module, so we may skip
# some tests which use it.
if os.environ.get('CI') == 'true':
Expand Down
3 changes: 3 additions & 0 deletions sys/contrib/subrepo-openzfs/tests/zfs-tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ scripts_zfs_tests_functional_hkdf_PROGRAMS = %D%/tests/functional/hkdf/hkdf_test
%C%_tests_functional_hkdf_hkdf_test_LDADD = \
libzpool.la

scripts_zfs_tests_functional_cp_filesdir = $(datadir)/$(PACKAGE)/zfs-tests/tests/functional/cp_files
scripts_zfs_tests_functional_cp_files_PROGRAMS = %D%/tests/functional/cp_files/seekflood

if BUILD_LINUX
scripts_zfs_tests_functional_tmpfiledir = $(datadir)/$(PACKAGE)/zfs-tests/tests/functional/tmpfile
scripts_zfs_tests_functional_tmpfile_PROGRAMS = \
Expand Down
4 changes: 4 additions & 0 deletions sys/contrib/subrepo-openzfs/tests/zfs-tests/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/block_cloning/block_cloning_ficlonerange.ksh \
functional/block_cloning/block_cloning_ficlonerange_partial.ksh \
functional/block_cloning/block_cloning_cross_enc_dataset.ksh \
functional/block_cloning/block_cloning_replay.ksh \
functional/block_cloning/block_cloning_replay_encrypted.ksh \
functional/bootfs/bootfs_001_pos.ksh \
functional/bootfs/bootfs_002_neg.ksh \
functional/bootfs/bootfs_003_pos.ksh \
Expand Down Expand Up @@ -1185,6 +1187,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/cli_root/zpool_import/zpool_import_missing_002_pos.ksh \
functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh \
functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh \
functional/cli_root/zpool_import/zpool_import_status.ksh \
functional/cli_root/zpool_initialize/cleanup.ksh \
functional/cli_root/zpool_initialize/zpool_initialize_attach_detach_add_remove.ksh \
functional/cli_root/zpool_initialize/zpool_initialize_fault_export_import_online.ksh \
Expand Down Expand Up @@ -1438,6 +1441,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/compression/setup.ksh \
functional/cp_files/cleanup.ksh \
functional/cp_files/cp_files_001_pos.ksh \
functional/cp_files/cp_stress.ksh \
functional/cp_files/setup.ksh \
functional/crtime/cleanup.ksh \
functional/crtime/crtime_001_pos.ksh \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ function get_same_blocks
awk '/ L0 / { print l++ " " $3 " " $7 }' > $zdbout.a
zdb $KEY -vvvvv $3 -O $4 | \
awk '/ L0 / { print l++ " " $3 " " $7 }' > $zdbout.b
echo $(sort $zdbout.a $zdbout.b | uniq -d | cut -f1 -d' ')
echo $(sort -n $zdbout.a $zdbout.b | uniq -d | cut -f1 -d' ')
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or https://opensource.org/licenses/CDDL-1.0.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/block_cloning/block_cloning.kshlib

#
# DESCRIPTION:
# Verify slogs are replayed correctly for cloned files. This
# test is ported from slog_replay tests for block cloning.
#
# STRATEGY:
# 1. Create an empty file system (TESTFS)
# 2. Create regular files and sync
# 3. Freeze TESTFS
# 4. Clone the file
# 5. Unmount filesystem
# <At this stage TESTFS is frozen, the intent log contains a
# complete set of deltas to replay it>
# 6. Remount TESTFS <which replays the intent log>
# 7. Compare clone file with the original file
#

verify_runnable "global"

if [[ $(linux_version) -lt $(linux_version "4.5") ]]; then
log_unsupported "copy_file_range not available before Linux 4.5"
fi

export VDIR=$TEST_BASE_DIR/disk-bclone
export VDEV="$VDIR/a $VDIR/b $VDIR/c"
export LDEV="$VDIR/e $VDIR/f"
log_must rm -rf $VDIR
log_must mkdir -p $VDIR
log_must truncate -s $MINVDEVSIZE $VDEV $LDEV

claim="The slogs are replayed correctly for cloned files."

log_assert $claim

function cleanup
{
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
rm -rf $TESTDIR $VDIR $VDIR2
}

log_onexit cleanup

#
# 1. Create an empty file system (TESTFS)
#
log_must zpool create -o feature@block_cloning=enabled $TESTPOOL $VDEV \
log mirror $LDEV
log_must zfs create $TESTPOOL/$TESTFS

#
# 2. TX_WRITE: Create two files and sync txg
#
log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS/file1 \
oflag=sync bs=128k count=4
log_must zfs set recordsize=16K $TESTPOOL/$TESTFS
log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS/file2 \
oflag=sync bs=16K count=2048
sync_pool $TESTPOOL

#
# 3. Checkpoint for ZIL Replay
#
log_must zpool freeze $TESTPOOL

#
# 4. TX_CLONE_RANGE: Clone the file
#
log_must clonefile -c /$TESTPOOL/$TESTFS/file1 /$TESTPOOL/$TESTFS/clone1
log_must clonefile -c /$TESTPOOL/$TESTFS/file2 /$TESTPOOL/$TESTFS/clone2

#
# 5. Unmount filesystem and export the pool
#
# At this stage TESTFS is frozen, the intent log contains a complete set
# of deltas to replay for clone files.
#
log_must zfs unmount /$TESTPOOL/$TESTFS

log_note "Verify transactions to replay:"
log_must zdb -iv $TESTPOOL/$TESTFS

log_must zpool export $TESTPOOL

#
# 6. Remount TESTFS <which replays the intent log>
#
# Import the pool to unfreeze it and claim log blocks. It has to be
# `zpool import -f` because we can't write a frozen pool's labels!
#
log_must zpool import -f -d $VDIR $TESTPOOL

#
# 7. Compare clone file with the original file
#
log_must have_same_content /$TESTPOOL/$TESTFS/file1 /$TESTPOOL/$TESTFS/clone1
log_must have_same_content /$TESTPOOL/$TESTFS/file2 /$TESTPOOL/$TESTFS/clone2

typeset blocks=$(get_same_blocks $TESTPOOL/$TESTFS file1 \
$TESTPOOL/$TESTFS clone1)
log_must [ "$blocks" = "0 1 2 3" ]

typeset blocks=$(get_same_blocks $TESTPOOL/$TESTFS file2 \
$TESTPOOL/$TESTFS clone2)
log_must [ "$blocks" = "$(seq -s " " 0 2047)" ]

log_pass $claim
Loading

0 comments on commit e184e3d

Please sign in to comment.