forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update pin_user_pages() calls for Direct I/O
Originally openzfs#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 openzfs#16956. Signed-off-by: Brian Atkinson <batkinson@lanl.gov> Closes openzfs#16956
- Loading branch information
1 parent
3420571
commit e46af9b
Showing
6 changed files
with
157 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
tests/zfs-tests/tests/functional/direct/dio_loopback_dev.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |