From patchwork Fri Sep 25 12:58:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Bruce Fields" X-Patchwork-Id: 11799721 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22AF0112C for ; Fri, 25 Sep 2020 12:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E516D2072E for ; Fri, 25 Sep 2020 12:58:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fieldses.org header.i=@fieldses.org header.b="b1ab3B9j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728951AbgIYM6P (ORCPT ); Fri, 25 Sep 2020 08:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728935AbgIYM6P (ORCPT ); Fri, 25 Sep 2020 08:58:15 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E033DC0613CE for ; Fri, 25 Sep 2020 05:58:14 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id C5766448D; Fri, 25 Sep 2020 08:58:13 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org C5766448D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1601038693; bh=gCCJxb/0DquHJNEPu1djqUX+jjr0NPycxUSjLaHNxjM=; h=Date:To:Subject:From:From; b=b1ab3B9j3hPkibXoPduB4XawuyqtaAN0LGOroFcSeSglKlZOruGPep868YPiUz5w9 FoeKv4Ytp4Xpjk0O+d3V22zKhwRYi+iwlq9GWEmVVeeb+2v3pkFlx6ucZtt9pJZSgn QOgsv4FiZhaQcC+1LkWiZM1SU0GVZYSvhWYjrvy0= Date: Fri, 25 Sep 2020 08:58:13 -0400 To: linux-nfs@vger.kernel.org Subject: [PATCH] sunrpc: simplify do_cache_clean Message-ID: <20200925125813.GA1096@fieldses.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" Is it just me, or is the logic written in a slightly convoluted way? I find it a little easier to read this way. Signed-off-by: J. Bruce Fields --- net/sunrpc/cache.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 9e68e443f497..2990a7ab9e2a 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -498,16 +498,17 @@ static int cache_clean(void) */ static void do_cache_clean(struct work_struct *work) { - int delay = 5; - if (cache_clean() == -1) - delay = round_jiffies_relative(30*HZ); + int delay; if (list_empty(&cache_list)) - delay = 0; + return; + + if (cache_clean() == -1) + delay = round_jiffies_relative(30*HZ); + else + delay = 5; - if (delay) - queue_delayed_work(system_power_efficient_wq, - &cache_cleaner, delay); + queue_delayed_work(system_power_efficient_wq, &cache_cleaner, delay); }