mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Update pin_user_pages() calls for Direct I/O
Originally #16856 updated Linux Direct I/O requests to use the new pin_user_pages API. However, it was an oversight that this PR only handled iov_iter's of type ITER_IOVEC and ITER_UBUF. Other iov_iter types may try and use the pin_user_pages API if it is available. This can lead to panics as the iov_iter is not being iterated over correctly in zfs_uio_pin_user_pages(). Unfortunately, generic iov_iter API's that call pin_user_page_fast() are protected as GPL only. Rather than update zfs_uio_pin_user_pages() to account for all iov_iter types, we can simply just call zfs_uio_get_dio_page_iov_iter() if the iov_iter type is not ITER_IOVEC or ITER_UBUF. zfs_uio_get_dio_page_iov_iter() calls the iov_iter_get_pages() calls that can handle any iov_iter type. In the future it might be worth using the exposed iov_iter iterator functions that are included in the header iov_iter.h since v6.7. These functions allow for any iov_iter type to be iterated over and advanced while applying a step function during iteration. This could possibly be leveraged in zfs_uio_pin_user_pages(). A new ZFS test case was added to test that a ITER_BVEC is handled correctly using this new code path. This test case was provided though issue #16956. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ameer Hamza <ahamza@ixsystems.com> Signed-off-by: Brian Atkinson <batkinson@lanl.gov> Closes #16956 Closes #17006
This commit is contained in:
@@ -103,7 +103,7 @@ tests = ['devices_001_pos', 'devices_002_neg', 'devices_003_pos']
|
||||
tags = ['functional', 'devices']
|
||||
|
||||
[tests/functional/direct:Linux]
|
||||
tests = ['dio_write_verify']
|
||||
tests = ['dio_loopback_dev', 'dio_write_verify']
|
||||
tags = ['functional', 'direct']
|
||||
|
||||
[tests/functional/events:Linux]
|
||||
|
||||
@@ -1476,6 +1476,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/direct/dio_dedup.ksh \
|
||||
functional/direct/dio_encryption.ksh \
|
||||
functional/direct/dio_grow_block.ksh \
|
||||
functional/direct/dio_loopback_dev.ksh \
|
||||
functional/direct/dio_max_recordsize.ksh \
|
||||
functional/direct/dio_mixed.ksh \
|
||||
functional/direct/dio_mmap.ksh \
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/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
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2025 by Triad National Security, LLC.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/direct/dio.cfg
|
||||
. $STF_SUITE/tests/functional/direct/dio.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Verify Direct I/O reads work with loopback devices using direct=always.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create raidz zpool.
|
||||
# 2. Create dataset with the direct dataset property set to always.
|
||||
# 3. Create an empty file in dataset and setup loop device on it.
|
||||
# 4. Read from loopback device.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
if [[ -n $lofidev ]]; then
|
||||
losetup -d $lofidev
|
||||
fi
|
||||
dio_cleanup
|
||||
}
|
||||
|
||||
log_assert "Verify loopback devices with Direct I/O."
|
||||
|
||||
if ! is_linux; then
|
||||
log_unsupported "This is just a check for Linux Direct I/O"
|
||||
fi
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
# Create zpool
|
||||
log_must truncate -s $MINVDEVSIZE $DIO_VDEVS
|
||||
log_must create_pool $TESTPOOL1 "raidz" $DIO_VDEVS
|
||||
|
||||
# Creating dataset with direct=always
|
||||
log_must eval "zfs create -o direct=always $TESTPOOL1/$TESTFS1"
|
||||
mntpt=$(get_prop mountpoint $TESTPOOL1/$TESTFS1)
|
||||
|
||||
# Getting a loopback device
|
||||
lofidev=$(losetup -f)
|
||||
|
||||
# Create loopback device
|
||||
log_must truncate -s 1M "$mntpt/temp_file"
|
||||
log_must losetup $lofidev "$mntpt/temp_file"
|
||||
|
||||
# Read from looback device to make sure Direct I/O works with loopback device
|
||||
log_must dd if=$lofidev of=/dev/null count=1 bs=4k
|
||||
|
||||
log_pass "Verified loopback devices for Direct I/O."
|
||||
Reference in New Issue
Block a user