From 6ca2fb6623cb3113bfed525ec398f8323ba33147 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 24 Oct 2017 02:25:42 +0000 Subject: [PATCH] Treat a 'current' value of 0 as unlimited as a failsfe. When limiting I/O, a value of 0 makes no sense as a limit. No progress can be made. Trade the possibility that someone might be doing something clever to achieve ultra-low I/O limits vs the damage of not ever making progress on an I/O in favor of making progress. Now the machine won't be useless if this accidentally gets requested. Sponsored by: Netflix --- sys/cam/cam_iosched.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index b733978016f5..c42594e22da7 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -457,9 +457,10 @@ cam_iosched_iops_caniop(struct iop_stats *ios, struct bio *bp) /* * So if we have any more IOPs left, allow it, - * otherwise wait. + * otherwise wait. If current iops is 0, treat that + * as unlimited as a failsafe. */ - if (ios->l_value1 <= 0) + if (ios->current > 0 && ios->l_value1 <= 0) return EAGAIN; return 0; } @@ -525,8 +526,11 @@ cam_iosched_bw_caniop(struct iop_stats *ios, struct bio *bp) * what we let through this quantum (to prevent the * starvation), at the cost of getting a little less * next quantum. + * + * Also note that if the current limit is <= 0, + * we treat it as unlimited as a failsafe. */ - if (ios->l_value1 <= 0) + if (ios->current > 0 && ios->l_value1 <= 0) return EAGAIN;