Skip to content

Commit 91557b0

Browse files
committed
Add timeout for nfs mount within kdumpctl & mkdumprd
In kdumpctl and mkdumprd, for nfs dump target, cmd mount will be used to mount nfs dump target to local directory. However there is no time limit for mount, and it may take a long time for mount to finish, no matter success or fail, when network connection is unstable. E.g we can emulate the package loss using the following command: $ tc qdisc add dev tun0 root handle 1: prio $ tc qdisc add dev tun0 parent 1:3 handle 30: netem delay 2000ms 1000ms loss 80% $ tc filter add dev tun0 protocol ip parent 1:0 prio 3 u32 match ip dst <nfs_server_ip> flowid 1:3 This will emulate 80% network package loss to <nfs_server_ip>, then we invoke nfs mount: $ time mount -t nfs <nfs_server_ip>:<nfs_dir> /mnt real 354m56.200s user 0m0.003s sys 0m0.013s $ mount | grep nfs <nfs_server_ip>:<nfs_dir> on /mnt type nfs4 (...) As we can see, though mount succeeded finally, it took near 6h to finish. The long time waiting makes no sense and should be ended as early, so user can check network issues and retry. This issue also noticed in QE testing, because for beaker test tasks, if one task doesn't finish within a specific time period, the task will be killed and fail. We'd better set a timeout limit for nfs mount, in order to prevent it from connecting to nfs server timelessly. This patch will set timeout duration as 5min for kdumpctl, and 10min for mkdumprd, as I think they are enough for normal cases as well as bail out as early if network do encounter problems. Signed-off-by: Tao Liu <[email protected]>
1 parent c08d151 commit 91557b0

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

kdumpctl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,17 +2065,21 @@ set_vmcore_creation_status()
20652065
fetch_status()
20662066
{
20672067
local _test_id="$1" _mnt
2068-
local _status
2068+
local _status _timeout_cmd
20692069

20702070
is_raw_dump_target && return 2
20712071

20722072
_status="${OPT[path]}/kdump-test-$_test_id/vmcore-creation.status"
20732073

20742074
if is_nfs_dump_target || is_local_target; then
20752075
_mnt=$(get_mntpoint_from_target "${OPT[_target]}")
2076+
if is_nfs_dump_target; then
2077+
_timeout_cmd="timeout --preserve-status 5m"
2078+
fi
2079+
20762080
if [[ -z $_mnt ]] || ! is_mounted "$_mnt"; then
20772081
mkdir -p "$TMPMNT"
2078-
mount "${OPT[_target]}" "$TMPMNT" -t "${OPT[_fstype]}" -o defaults ||
2082+
$_timeout_cmd mount "${OPT[_target]}" "$TMPMNT" -t "${OPT[_fstype]}" -o defaults ||
20792083
{
20802084
dwarn "Failed to mount ${OPT[_target]}" && return 2
20812085
}

mkdumprd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ mount_failure()
208208
msg="$msg for kdump preflight check."
209209

210210
if [[ $_fstype == "nfs" ]]; then
211-
msg="$msg Please make sure nfs-utils has been installed."
211+
msg="$msg Please make sure nfs-utils has been installed, and nfs server is accessible."
212212
fi
213213

214214
perror_exit "$msg"
@@ -217,7 +217,7 @@ mount_failure()
217217
check_user_configured_target()
218218
{
219219
local _target=$1 _cfg_fs_type=$2 _mounted
220-
local _mnt _opt _fstype
220+
local _mnt _opt _fstype _timeout_cmd
221221

222222
_mnt=$(get_mntpoint_from_target "$_target")
223223
_opt=$(get_mntopt_from_target "$_target")
@@ -235,12 +235,16 @@ check_user_configured_target()
235235
_fstype="$_cfg_fs_type"
236236
fi
237237

238+
if [[ $_fstype == "nfs"* ]]; then
239+
_timeout_cmd="timeout --preserve-status 10m"
240+
fi
241+
238242
# For noauto mount, mount it inplace with default value.
239243
# Else use the temporary target directory
240244
if [[ -n $_mnt ]]; then
241245
if ! is_mounted "$_mnt"; then
242246
if [[ $_opt == *",noauto"* ]]; then
243-
mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype"
247+
$_timeout_cmd mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype"
244248
_mounted=$_mnt
245249
else
246250
perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
@@ -249,7 +253,7 @@ check_user_configured_target()
249253
else
250254
_mnt=$MKDUMPRD_TMPMNT
251255
mkdir -p "$_mnt"
252-
mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype"
256+
$_timeout_cmd mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype"
253257
_mounted=$_mnt
254258
fi
255259

0 commit comments

Comments
 (0)