Skip to content

Commit

Permalink
Notable upstream pull request merges:
Browse files Browse the repository at this point in the history
 #15539 687e4d7 Extend import_progress kstat with a notes field
 #15544 c7b6119 Allow block cloning across encrypted datasets
 #15553 adcea23 ZIO: Add overflow checks for linear buffers
 #15593 5f2700e zpool: flush output before sleeping
 #15609 3e4bef5 Only provide execvpe(3) when needed
 #15610 735ba3a Use uint64_t instead of u_int64_t
 #15612 bcd83cc ZIL: Remove TX_CLONE_RANGE replay for ZVOLs
 #15617 55b764e ZIL: Do not clone blocks from the future
 #15623 727497c module/icp/asm-arm/sha2: enable non-SIMD asm kernels
                  on armv5/6
 #15625 9743d09 BRT: Limit brt_vdev_dump() to only one vdev
 #15629 f9765b1 zdb: Dump encrypted write and clone ZIL records
 #15634 2aa3a48 ZIL: Remove 128K into 2x68K LWB split optimization
 #15639 1165623 FreeBSD: Ensure that zfs_getattr() initializes the
                  va_rdev field
 #15647 4836d29 zfs_refcount_remove: explictly ignore returns
 #15649 f0cb648 setproctitle: fix ununitialised variable
 #15650 450f2d0 import: ignore return on hostid lookups

Obtained from:	OpenZFS
OpenZFS commit:	450f2d0
  • Loading branch information
mmatuska committed Dec 8, 2023
2 parents 1f36ca5 + 450f2d0 commit 3494f7c
Show file tree
Hide file tree
Showing 42 changed files with 885 additions and 209 deletions.
60 changes: 58 additions & 2 deletions sys/contrib/openzfs/cmd/zdb/zdb_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, const void *arg)
(u_longlong_t)lr->lr_foid, (u_longlong_t)lr->lr_offset,
(u_longlong_t)lr->lr_length);

if (txtype == TX_WRITE2 || verbose < 5)
if (txtype == TX_WRITE2 || verbose < 4)
return;

if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
Expand All @@ -178,6 +178,8 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, const void *arg)
"will claim" : "won't claim");
print_log_bp(bp, tab_prefix);

if (verbose < 5)
return;
if (BP_IS_HOLE(bp)) {
(void) printf("\t\t\tLSIZE 0x%llx\n",
(u_longlong_t)BP_GET_LSIZE(bp));
Expand All @@ -202,6 +204,9 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, const void *arg)
if (error)
goto out;
} else {
if (verbose < 5)
return;

/* data is stored after the end of the lr_write record */
data = abd_alloc(lr->lr_length, B_FALSE);
abd_copy_from_buf(data, lr + 1, lr->lr_length);
Expand All @@ -217,6 +222,28 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, const void *arg)
abd_free(data);
}

static void
zil_prt_rec_write_enc(zilog_t *zilog, int txtype, const void *arg)
{
(void) txtype;
const lr_write_t *lr = arg;
const blkptr_t *bp = &lr->lr_blkptr;
int verbose = MAX(dump_opt['d'], dump_opt['i']);

(void) printf("%s(encrypted)\n", tab_prefix);

if (verbose < 4)
return;

if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
(void) printf("%shas blkptr, %s\n", tab_prefix,
!BP_IS_HOLE(bp) &&
bp->blk_birth >= spa_min_claim_txg(zilog->zl_spa) ?
"will claim" : "won't claim");
print_log_bp(bp, tab_prefix);
}
}

static void
zil_prt_rec_truncate(zilog_t *zilog, int txtype, const void *arg)
{
Expand Down Expand Up @@ -312,11 +339,34 @@ zil_prt_rec_clone_range(zilog_t *zilog, int txtype, const void *arg)
{
(void) zilog, (void) txtype;
const lr_clone_range_t *lr = arg;
int verbose = MAX(dump_opt['d'], dump_opt['i']);

(void) printf("%sfoid %llu, offset %llx, length %llx, blksize %llx\n",
tab_prefix, (u_longlong_t)lr->lr_foid, (u_longlong_t)lr->lr_offset,
(u_longlong_t)lr->lr_length, (u_longlong_t)lr->lr_blksz);

if (verbose < 4)
return;

for (unsigned int i = 0; i < lr->lr_nbps; i++) {
(void) printf("%s[%u/%llu] ", tab_prefix, i + 1,
(u_longlong_t)lr->lr_nbps);
print_log_bp(&lr->lr_bps[i], "");
}
}

static void
zil_prt_rec_clone_range_enc(zilog_t *zilog, int txtype, const void *arg)
{
(void) zilog, (void) txtype;
const lr_clone_range_t *lr = arg;
int verbose = MAX(dump_opt['d'], dump_opt['i']);

(void) printf("%s(encrypted)\n", tab_prefix);

if (verbose < 4)
return;

for (unsigned int i = 0; i < lr->lr_nbps; i++) {
(void) printf("%s[%u/%llu] ", tab_prefix, i + 1,
(u_longlong_t)lr->lr_nbps);
Expand All @@ -327,6 +377,7 @@ zil_prt_rec_clone_range(zilog_t *zilog, int txtype, const void *arg)
typedef void (*zil_prt_rec_func_t)(zilog_t *, int, const void *);
typedef struct zil_rec_info {
zil_prt_rec_func_t zri_print;
zil_prt_rec_func_t zri_print_enc;
const char *zri_name;
uint64_t zri_count;
} zil_rec_info_t;
Expand All @@ -341,7 +392,9 @@ static zil_rec_info_t zil_rec_info[TX_MAX_TYPE] = {
{.zri_print = zil_prt_rec_remove, .zri_name = "TX_RMDIR "},
{.zri_print = zil_prt_rec_link, .zri_name = "TX_LINK "},
{.zri_print = zil_prt_rec_rename, .zri_name = "TX_RENAME "},
{.zri_print = zil_prt_rec_write, .zri_name = "TX_WRITE "},
{.zri_print = zil_prt_rec_write,
.zri_print_enc = zil_prt_rec_write_enc,
.zri_name = "TX_WRITE "},
{.zri_print = zil_prt_rec_truncate, .zri_name = "TX_TRUNCATE "},
{.zri_print = zil_prt_rec_setattr, .zri_name = "TX_SETATTR "},
{.zri_print = zil_prt_rec_acl, .zri_name = "TX_ACL_V0 "},
Expand All @@ -358,6 +411,7 @@ static zil_rec_info_t zil_rec_info[TX_MAX_TYPE] = {
{.zri_print = zil_prt_rec_rename, .zri_name = "TX_RENAME_EXCHANGE "},
{.zri_print = zil_prt_rec_rename, .zri_name = "TX_RENAME_WHITEOUT "},
{.zri_print = zil_prt_rec_clone_range,
.zri_print_enc = zil_prt_rec_clone_range_enc,
.zri_name = "TX_CLONE_RANGE "},
};

Expand All @@ -384,6 +438,8 @@ print_log_record(zilog_t *zilog, const lr_t *lr, void *arg, uint64_t claim_txg)
if (txtype && verbose >= 3) {
if (!zilog->zl_os->os_encrypted) {
zil_rec_info[txtype].zri_print(zilog, txtype, lr);
} else if (zil_rec_info[txtype].zri_print_enc) {
zil_rec_info[txtype].zri_print_enc(zilog, txtype, lr);
} else {
(void) printf("%s(encrypted)\n", tab_prefix);
}
Expand Down
98 changes: 98 additions & 0 deletions sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ zed_notify()
[ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
[ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))

zed_notify_ntfy "${subject}" "${pathname}"; rv=$?
[ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
[ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))

[ "${num_success}" -gt 0 ] && return 0
[ "${num_failure}" -gt 0 ] && return 1
return 2
Expand Down Expand Up @@ -527,6 +531,100 @@ zed_notify_pushover()
}


# zed_notify_ntfy (subject, pathname)
#
# Send a notification via Ntfy.sh <https://ntfy.sh/>.
# The ntfy topic (ZED_NTFY_TOPIC) identifies the topic that the notification
# will be sent to Ntfy.sh server. The ntfy url (ZED_NTFY_URL) defines the
# self-hosted or provided hosted ntfy service location. The ntfy access token
# <https://docs.ntfy.sh/publish/#access-tokens> (ZED_NTFY_ACCESS_TOKEN) reprsents an
# access token that could be used if a topic is read/write protected. If a
# topic can be written to publicaly, a ZED_NTFY_ACCESS_TOKEN is not required.
#
# Requires curl and sed executables to be installed in the standard PATH.
#
# References
# https://docs.ntfy.sh
#
# Arguments
# subject: notification subject
# pathname: pathname containing the notification message (OPTIONAL)
#
# Globals
# ZED_NTFY_TOPIC
# ZED_NTFY_ACCESS_TOKEN (OPTIONAL)
# ZED_NTFY_URL
#
# Return
# 0: notification sent
# 1: notification failed
# 2: not configured
#
zed_notify_ntfy()
{
local subject="$1"
local pathname="${2:-"/dev/null"}"
local msg_body
local msg_out
local msg_err

[ -n "${ZED_NTFY_TOPIC}" ] || return 2
local url="${ZED_NTFY_URL:-"https://ntfy.sh"}/${ZED_NTFY_TOPIC}"

if [ ! -r "${pathname}" ]; then
zed_log_err "ntfy cannot read \"${pathname}\""
return 1
fi

zed_check_cmd "curl" "sed" || return 1

# Read the message body in.
#
msg_body="$(cat "${pathname}")"

if [ -z "${msg_body}" ]
then
msg_body=$subject
subject=""
fi

# Send the POST request and check for errors.
#
if [ -n "${ZED_NTFY_ACCESS_TOKEN}" ]; then
msg_out="$( \
curl \
-u ":${ZED_NTFY_ACCESS_TOKEN}" \
-H "Title: ${subject}" \
-d "${msg_body}" \
-H "Priority: high" \
"${url}" \
2>/dev/null \
)"; rv=$?
else
msg_out="$( \
curl \
-H "Title: ${subject}" \
-d "${msg_body}" \
-H "Priority: high" \
"${url}" \
2>/dev/null \
)"; rv=$?
fi
if [ "${rv}" -ne 0 ]; then
zed_log_err "curl exit=${rv}"
return 1
fi
msg_err="$(echo "${msg_out}" \
| sed -n -e 's/.*"errors" *:.*\[\(.*\)\].*/\1/p')"
if [ -n "${msg_err}" ]; then
zed_log_err "ntfy \"${msg_err}"\"
return 1
fi
return 0
}



# zed_rate_limit (tag, [interval])
#
# Check whether an event of a given type [tag] has already occurred within the
Expand Down
22 changes: 22 additions & 0 deletions sys/contrib/openzfs/cmd/zed/zed.d/zed.rc
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,25 @@ ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event"
# help silence misbehaving drives. This assumes your drive enclosure fully
# supports slot power control via sysfs.
#ZED_POWER_OFF_ENCLOUSRE_SLOT_ON_FAULT=1

##
# Ntfy topic
# This defines which topic will receive the ntfy notification.
# <https://docs.ntfy.sh/publish/>
# Disabled by default; uncomment to enable.
#ZED_NTFY_TOPIC=""

##
# Ntfy access token (optional for public topics)
# This defines an access token which can be used
# to allow you to authenticate when sending to topics
# <https://docs.ntfy.sh/publish/#access-tokens>
# Disabled by default; uncomment to enable.
#ZED_NTFY_ACCESS_TOKEN=""

##
# Ntfy Service URL
# This defines which service the ntfy call will be directed toward
# <https://docs.ntfy.sh/install/>
# https://ntfy.sh by default; uncomment to enable an alternative service url.
#ZED_NTFY_URL="https://ntfy.sh"
14 changes: 7 additions & 7 deletions sys/contrib/openzfs/cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3132,7 +3132,8 @@ zfs_force_import_required(nvlist_t *config)
* local hostid.
*/
if (nvlist_lookup_uint64(nvinfo, ZPOOL_CONFIG_HOSTID, &hostid) != 0)
nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID, &hostid);
(void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID,
&hostid);

if (state != POOL_STATE_EXPORTED && hostid != get_system_hostid())
return (B_TRUE);
Expand Down Expand Up @@ -5950,6 +5951,7 @@ zpool_do_iostat(int argc, char **argv)
print_iostat_header(&cb);

if (skip) {
(void) fflush(stdout);
(void) fsleep(interval);
continue;
}
Expand Down Expand Up @@ -5980,18 +5982,13 @@ zpool_do_iostat(int argc, char **argv)

}

/*
* Flush the output so that redirection to a file isn't buffered
* indefinitely.
*/
(void) fflush(stdout);

if (interval == 0)
break;

if (count != 0 && --count == 0)
break;

(void) fflush(stdout);
(void) fsleep(interval);
}

Expand Down Expand Up @@ -6514,6 +6511,8 @@ zpool_do_list(int argc, char **argv)
break;

pool_list_free(list);

(void) fflush(stdout);
(void) fsleep(interval);
}

Expand Down Expand Up @@ -9094,6 +9093,7 @@ zpool_do_status(int argc, char **argv)
if (count != 0 && --count == 0)
break;

(void) fflush(stdout);
(void) fsleep(interval);
}

Expand Down
5 changes: 3 additions & 2 deletions sys/contrib/openzfs/config/kernel-flush_dcache_page.m4
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
dnl #
dnl # Starting from Linux 5.13, flush_dcache_page() becomes an inline
dnl # function and may indirectly referencing GPL-only cpu_feature_keys on
dnl # powerpc
dnl # function and may indirectly referencing GPL-only symbols:
dnl # on powerpc: cpu_feature_keys
dnl # on riscv: PageHuge (added from 6.2)
dnl #

dnl #
Expand Down
6 changes: 6 additions & 0 deletions sys/contrib/openzfs/config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
;;
riscv*)
ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
;;
esac
AC_MSG_CHECKING([for available kernel interfaces])
Expand Down Expand Up @@ -310,6 +313,9 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_CPU_HAS_FEATURE
ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
;;
riscv*)
ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
;;
esac
])

Expand Down
2 changes: 1 addition & 1 deletion sys/contrib/openzfs/config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV
ZFS_AC_CONFIG_USER_ZFSEXEC
AC_CHECK_FUNCS([issetugid mlockall strlcat strlcpy])
AC_CHECK_FUNCS([execvpe issetugid mlockall strlcat strlcpy])
AC_SUBST(RM)
])
4 changes: 1 addition & 3 deletions sys/contrib/openzfs/include/os/freebsd/spl/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/

#ifndef _OPENSOLARIS_SYS_TIME_H_
Expand Down Expand Up @@ -91,6 +89,6 @@ gethrtime(void)
{
struct timespec ts;
clock_gettime(CLOCK_UPTIME, &ts);
return (((u_int64_t)ts.tv_sec) * NANOSEC + ts.tv_nsec);
return (((uint64_t)ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
#endif /* !_OPENSOLARIS_SYS_TIME_H_ */
Loading

0 comments on commit 3494f7c

Please sign in to comment.