Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp101913rdb; Wed, 21 Feb 2024 19:19:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXYaow3gdIhAEw6OburBq9Pq4LqtSVxHXM+wQY0FkOXzal59+cV0yNl9gduiPT7YkoupG2p1CvWTugn/9RpyLbxFMKK0NdWRIyGZcCocg== X-Google-Smtp-Source: AGHT+IEbVaXCFLFrqeepLzBnLC/RuMwRHuUjNeDdTtiMkydu61DD0TCQcgJg4iF3Dab2XADxjd96 X-Received: by 2002:a05:622a:15c2:b0:42d:fb39:deee with SMTP id d2-20020a05622a15c200b0042dfb39deeemr16581097qty.31.1708571996447; Wed, 21 Feb 2024 19:19:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708571996; cv=pass; d=google.com; s=arc-20160816; b=mmoSRavT20un3JqCQ9KSov9J3NcwOQp5v+01tKJCUyDNXGtFlEHdvE3j8RqP39rXjq TghW3qbao+NpWpav/zDUXZ3X8DUv2k78XlYux5aHk2LHHH2GNAH1UCqzORSme2fDgmaj m5W9EJGdEYO3It2nG+1d3QOO0wfN1mkbGAy/RfPb7LdGovOm4IXPOuJ1Bgszae48w4oM ampFduOLFOT9SgLRPZ6epQe53s6XgvOEmwBL4ZXJwXZs/NnTevvSZt05otneIyNuxyhD Z44Vhfm57E6/8GtRNWlehg5/QGgxpLgG/6WmWtwJSAZE3zNob2IstoHQW4L7lTbGVgDM yuWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=V9/JqdFP6+H5ZwF5GLxGFsL2hRG+X43V/o/Ie5ISJlI=; fh=lGromeZQ/Q/pC8M+hGgxKxkYB8ykyKM0BEpcgnYKLHc=; b=UAq5Ay3K/Exrcy2VBedzzmLfmED4/U+ppb3Nyt+PJ0Hk0DkcIvB7ius4aqIQ0+F9zc +Z07cW+3ML/RhcnzByz9Uc1zaQQK5eRSeCzCmuJcqwuRYNTwa7RdvWtiSH1hnbQJJUBp nebLVw2NmtAtnf2WplY3C49qyXwxuACX/P/RTeeUQrOBX5Acu1NP+kLlbat4PdNqCw3B HwhELtxVJ7LQ69uSdf/+d3PNCQA/UlCw3bZovrjzD0/+qo76+3GoVZSimK+ZjqzDws61 1FgOxYgwRlZN5vcj20Lg1/KW7up9GQXw+RvREnE6UEjvOGbGqveWIzcCIzro8wybJ4A6 c5gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=w7PD8r1N; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-75842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r14-20020ac867ce000000b0042e4c2f9486si445159qtp.690.2024.02.21.19.19.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 19:19:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=w7PD8r1N; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-75842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 360C01C2196B for ; Thu, 22 Feb 2024 03:19:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 618421754F; Thu, 22 Feb 2024 03:19:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="w7PD8r1N" Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BE67156E4; Thu, 22 Feb 2024 03:19:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708571986; cv=none; b=iuLBS5m7GYZ9qzrU+U5Zj8cBZ0ftzpvktRvG3f2qaYjFWjDYjiiuVvViEmOcxYhVtzK6pCG0V5ImKAm7Ek79qQE2YqrGIPR9RTb0WOAZHJymby5Z095SZMEG2DMEbk9rFWKnHF5mA3LM//tQvzypUuedeJzmjpeSvqAGsUEgfXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708571986; c=relaxed/simple; bh=ZR4uoLQTiEOwo3CnieSljcC/pC2fqYtStebX1jAXWJA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eSCR4ac1oDWsSFnQvbxgfxc4Posn7XLEuw/nLLU6r88kMHXooeTE+tkXTonpVUx5TVndC47aVNKbnC1xmIedInLdTJYoldQKzsUEIgbuJKh7tpFBA8F+DE/alVmwwHLGGmuYKRxTE1TTpaYZ6/WK4x00wEUHSebZ2rqjcqfLIlk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=w7PD8r1N; arc=none smtp.client-ip=115.124.30.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708571981; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=V9/JqdFP6+H5ZwF5GLxGFsL2hRG+X43V/o/Ie5ISJlI=; b=w7PD8r1NPQ2OClkdgI7DKPnp8Of/q/UEv9hYF3u3DZjeKfgslGyn+f5a1phMX83XibkpD2+8jOU4Doox+YtB3uIt1ct38PlNHQlASziveVFTUucvoEx/9l6kfum10V3+jJMX0cD2/2TX6n4Mnr0RR8WgK25UlIF0hU9Y6RQLgy0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0W1.d02z_1708571979; Received: from 30.221.147.146(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0W1.d02z_1708571979) by smtp.aliyun-inc.com; Thu, 22 Feb 2024 11:19:40 +0800 Message-ID: <27a77b2a-ad9c-4247-9ddb-61fdf5bb3891@linux.alibaba.com> Date: Thu, 22 Feb 2024 11:19:38 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] erofs: fix refcount on the metabuf used for inode lookup Content-Language: en-US To: Sandeep Dhavale , Gao Xiang , Chao Yu , Yue Hu Cc: quic_wenjieli@quicinc.com, stable@vger.kernel.org, kernel-team@android.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20240221210348.3667795-1-dhavale@google.com> From: Jingbo Xu In-Reply-To: <20240221210348.3667795-1-dhavale@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/22/24 5:03 AM, Sandeep Dhavale wrote: > In erofs_find_target_block() when erofs_dirnamecmp() returns 0, > we do not assign the target metabuf. This causes the caller > erofs_namei()'s erofs_put_metabuf() at the end to be not effective > leaving the refcount on the page. > As the page from metabuf (buf->page) is never put, such page cannot be > migrated or reclaimed. Fix it now by putting the metabuf from > previous loop and assigning the current metabuf to target before > returning so caller erofs_namei() can do the final put as it was > intended. > > Fixes: 500edd095648 ("erofs: use meta buffers for inode lookup") > Cc: stable@vger.kernel.org > Signed-off-by: Sandeep Dhavale LGTM. Reviewed-by: Jingbo Xu > --- > Changes since v1 > - Rearrange the cases as suggested by Gao so there is less duplication > of the code and it is more readable > > fs/erofs/namei.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/fs/erofs/namei.c b/fs/erofs/namei.c > index d4f631d39f0f..f0110a78acb2 100644 > --- a/fs/erofs/namei.c > +++ b/fs/erofs/namei.c > @@ -130,24 +130,24 @@ static void *erofs_find_target_block(struct erofs_buf *target, > /* string comparison without already matched prefix */ > diff = erofs_dirnamecmp(name, &dname, &matched); > > - if (!diff) { > - *_ndirents = 0; > - goto out; > - } else if (diff > 0) { > - head = mid + 1; > - startprfx = matched; > - > - if (!IS_ERR(candidate)) > - erofs_put_metabuf(target); > - *target = buf; > - candidate = de; > - *_ndirents = ndirents; > - } else { > + if (diff < 0) { > erofs_put_metabuf(&buf); > - > back = mid - 1; > endprfx = matched; > + continue; > + } > + > + if (!IS_ERR(candidate)) > + erofs_put_metabuf(target); > + *target = buf; > + if (!diff) { > + *_ndirents = 0; > + return de; > } > + head = mid + 1; > + startprfx = matched; > + candidate = de; > + *_ndirents = ndirents; > continue; > } > out: /* free if the candidate is valid */ -- Thanks, Jingbo