staging/lustre/lnet: Don't call roundup_pow_of_two on zero in LNetEQAlloc
authorOleg Drokin <green@linuxhacker.ru>
Sat, 6 Feb 2016 07:12:12 +0000 (02:12 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Feb 2016 01:34:58 +0000 (17:34 -0800)
roundup_pow_of_two return when called on a zero argument is
undefined, so don't call it like that.

This fixes a problem introduced by commit 322489d9d551
("staging/lustre: Use roundup_pow_of_two() in LNetEQAlloc()")
since 0 is a valid count parameter for LNetEQAlloc. Also manifesting
itself as an annoying kernel warning:
LNet: 3486:0:(lib-eq.c:85:LNetEQAlloc()) EQ callback is guaranteed to get every event, do you still want to set eqcount 1 for polling event which will have locking overhead? Please contact with developer to confirm

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
CC: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/lnet/lib-eq.c

index 64f94a69008142d98ebb8b8b644112098103be8e..bfbc3136fd3bb4ea81499210edb93fec9dcb0c1c 100644 (file)
@@ -79,7 +79,8 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
         * overflow, they don't skip entries, so the queue has the same
         * apparent capacity at all times */
 
-       count = roundup_pow_of_two(count);
+       if (count)
+               count = roundup_pow_of_two(count);
 
        if (callback != LNET_EQ_HANDLER_NONE && count != 0)
                CWARN("EQ callback is guaranteed to get every event, do you still want to set eqcount %d for polling event which will have locking overhead? Please contact with developer to confirm\n", count);