Received: by 10.223.185.116 with SMTP id b49csp6427020wrg; Wed, 28 Feb 2018 09:12:59 -0800 (PST) X-Google-Smtp-Source: AH8x2249JSnw0uuMVcwAMZsOmPllzK0PxgOQc2d+ERZ72iq675+4wh0I1egGg7Ws398pc9Tpj4nV X-Received: by 10.99.123.74 with SMTP id k10mr14873995pgn.217.1519837978917; Wed, 28 Feb 2018 09:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519837978; cv=none; d=google.com; s=arc-20160816; b=zrGFMmk92VuU3940C5d1gCpD1im12zas/EIdLQZWlpF9zPO/yJwzn5+GYshAUuoOPq 3oBUqZul7ZC7bO2uIMBkeydanbTnU0sbSHUu67xfzmWApVKtji/UaeQuA0Re+W8Q92TR gDISPs7iCEo1qU4y4BNDjlFjeWiNZni71P0Qb6BoEJNM/KR5b6CW8VHh0qWKNG0zzDtC wBimyMxbumTFHe6k2T1nxdMWPzOWGd3NdZNg1H16uh4PF7fcm+bxi5ON4ocYVjtSftrO mNv5a+HFwpu7bZStVFp8rEATrGHw29tVscK3zGfVi4xAX1O2ZYEQPaPKuWsWTrdR6I5a G7Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eICM9IxNFHK0nhJTyjdYUQYA9nWUYOcsisJnKPeHYZo=; b=Wn7TzMEBeThcv5UrGWC3Vs5Pgf7rbuDZomRCnSffT9ESjrOHBkIRXFOynWqDsMO1s/ 6g5JNNKwGy546BE/NaJ/wgbTJFTltmeWLTZxkeYmGFn3IEUUe2J+iuzjKNvKKj2v4OuG Mzl0qpBF0n2vangUnttb/8br4y4rqOTNQ7sAaSVtyGkw+zeZ4QFwEi5SCk0efOjswPNU l//lqzRo7i5R1FyiwKnfNd9s8xHMqPLeL3W+SdmU7w02K7O6ac5wbu6Zb03DaiIM7uOu ++/CaF/0k5CEfvioDQNeMCFtl6fIJ7CfMCQ+4Gz/22f3IMRdctOufAL9PAhaDsyPdy/6 3sdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si1207713pgn.366.2018.02.28.09.12.43; Wed, 28 Feb 2018 09:12:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933739AbeB1RLu (ORCPT + 99 others); Wed, 28 Feb 2018 12:11:50 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46928 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933179AbeB1Pty (ORCPT ); Wed, 28 Feb 2018 10:49:54 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D12918D6EF; Wed, 28 Feb 2018 15:49:53 +0000 (UTC) Received: from dhcp-26-154.brq.redhat.com (dhcp-27-188.brq.redhat.com [10.34.27.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A0972156601; Wed, 28 Feb 2018 15:49:52 +0000 (UTC) From: Vratislav Bendel To: linux-xfs@vger.kernel.org, "Darrick J . Wong" Cc: Brian Foster , linux-kernel@vger.kernel.org Subject: [PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic Date: Wed, 28 Feb 2018 16:49:51 +0100 Message-Id: <20180228154951.31714-1-vbendel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 28 Feb 2018 15:49:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 28 Feb 2018 15:49:53 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vbendel@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function xfs_buftarg_isolate() used by xfs buffer schrinkers to determine whether a buffer should be isolated and disposed from LRU list, has inverted logic. Excerpt from xfs_buftarg_isolate(): /* * Decrement the b_lru_ref count unless the value is already * zero. If the value is already zero, we need to reclaim the * buffer, otherwise it gets another trip through the LRU. */ if (!atomic_add_unless(&bp->b_lru_ref, -1, 0)) { spin_unlock(&bp->b_lock); return LRU_ROTATE; } However, as per documentation, atomic_add_unless() returns _zero_ if the atomic value was originally equal to the specified *unsless* value. Ultimately causing a xfs_buffer with ->b_lru_ref == 0, to take another trip around LRU, while isolating buffers with non-zero b_lru_ref. Signed-off-by: Vratislav Bendel CC: Brian Foster --- fs/xfs/xfs_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index d1da2ee9e6db..ac669a10c62f 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1708,7 +1708,7 @@ xfs_buftarg_isolate( * zero. If the value is already zero, we need to reclaim the * buffer, otherwise it gets another trip through the LRU. */ - if (!atomic_add_unless(&bp->b_lru_ref, -1, 0)) { + if (atomic_add_unless(&bp->b_lru_ref, -1, 0)) { spin_unlock(&bp->b_lock); return LRU_ROTATE; } -- 2.14.3