Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1498781iog; Thu, 16 Jun 2022 07:36:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpbe64vuEZafgbL5+94DoGshsO2EbIVwynileuUBe279rwaxdzMr6dqWftAAFCTfPvr2QF X-Received: by 2002:a17:902:ea0f:b0:164:1a71:bef1 with SMTP id s15-20020a170902ea0f00b001641a71bef1mr4724367plg.52.1655390180998; Thu, 16 Jun 2022 07:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655390180; cv=none; d=google.com; s=arc-20160816; b=T3lW2FkH8tOf+g4ZHkuZ4AM9rk0nrV1W1VfLEJMfibQMurAnbRV/RwKAHLz2j0ckpd kzUe2cnOQWoAatQwwFwtrG0j/rD04c8okQZOSkG1o7P+MqYAvf5kLo7/yyl+TiDEQeo5 7YziH7NEEB2g8R5miXjiGNTLjU/WLZuLp6NafSuQFYz34QP9DyOKvbWiHLwGz7Yiu+rQ ZLpwU81vlap9BEYlrbNTq5SHG3cyaVbxScbAKm19jeWagBoMFWlmwO+VZy+VQ4wWHEFY Il+ZR/bjEUzUDjNKG7PmhGfLRZmyPLQX8vj+LytO5cYxB8zCa9E9NUhn86rR/JYxGl/Z aHzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=J62eWHBm1JNFoiDxH6Ar0/JBxBaKgKeGtVLTQNkH49I=; b=sVBxCh0JH9TTMU61BHZJaQwu1KWeSwSoYRS+zPJaCV7qGZ3v6ldKz6pDrZqopkBXO3 83uej392XYf16vVLrkDI7iY1P7AqfocuFEOIkUAbbXimjajWUVyezv6AtaWis8panXCs V2eqaZF3GiOaJnRWQO+ryKer+QUvP2Z0a0GBDfgoUKRflKS/j62zZxv3Zi8avaEnsWZQ sx3QqYnu8MPZDtib1Ddj7lngwR44EE8bXnbuRSMhecTf4KG7AkuH5wuUlmfDeBxZS5/s yDINx7kJwNA81pP6bdwek17q59SKUa1JjBftqZHwZ71cY5jMDfbLN3m9W2scdnTUt69E otsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NLfnQFzK; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 62-20020a17090a09c400b001d996a5c5e4si751026pjo.128.2022.06.16.07.35.53; Thu, 16 Jun 2022 07:36:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NLfnQFzK; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232827AbiFPOWU (ORCPT + 99 others); Thu, 16 Jun 2022 10:22:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232449AbiFPOWT (ORCPT ); Thu, 16 Jun 2022 10:22:19 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCB793B3EF; Thu, 16 Jun 2022 07:22:18 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id s37so1632173pfg.11; Thu, 16 Jun 2022 07:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J62eWHBm1JNFoiDxH6Ar0/JBxBaKgKeGtVLTQNkH49I=; b=NLfnQFzKtXZv8Xorzfs04lnAbj9Va00oDN4lA0sXxpAr4eDOsOV9DkyjjI6LXPDOtY XKn2wZo6Hc++qO8K/hHcQnepVHHNUmYVHMNevAlnSY0gwYHNrIx0O4hgZEt9ptlwULTg tuT5MQRW8uPE/Z21D4uTRowc+lqd3VZmnM23CRUhANvGK3AuxX7IMd1MIU6c3Q6bMZmj qGh6Km0oL1uhvWtxByAMmi0AaXfNJkoC2tUlQBE6Tdb+bMGdclAdEldiHSDgK6MCK8yp uXYhEBMKykHZ1QOCx5nX82smkQsaIpLp2QEbKwcW2tm3DEmKYXDMyl+2f+oMDfV39GiG b8bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J62eWHBm1JNFoiDxH6Ar0/JBxBaKgKeGtVLTQNkH49I=; b=grJ4izg4vM1W6DPbjOIHGeA76BoKUbHEQtAl8PCqc1qKW9Pp3IhF4ukeA+JdrmBgH3 s5ei81QgezzkaSjNRNgbJkEYkOZwxRZgvs0aY5PeE0KssNy+rAtBv217sBDxSW/WBZQi MQ8ja7V+aOZcltMsm/5AK+us2HZXbEvMfnL9UTkOPwMdXPcXTB4Onw90XIagSrxkpWEG dsXWBfHCAtC4nFkQbakR7UpY8Vl8I73sELGL0nUhYsWB0EbJLRdFTlynjW5I6Cv/ZJ1b WoiCufMy6QsQfwxP8bvNCw7yVTK2cYSmArmai0LrwgXOImhlHlTh+ofYejaIfdGeeGsq EGLQ== X-Gm-Message-State: AJIora+Ovx4Fv5pckN2O3FgH+nmMElc+HPY/AyZ/kEc1F+QpH6UlhRNK hP8NCCVOkMUcPD+qjPXazXGe3v2aI7M= X-Received: by 2002:aa7:8e0b:0:b0:50d:6d7f:54d with SMTP id c11-20020aa78e0b000000b0050d6d7f054dmr5159906pfr.29.1655389337977; Thu, 16 Jun 2022 07:22:17 -0700 (PDT) Received: from localhost ([2406:7400:63:5d34:e6c2:4c64:12ae:aa11]) by smtp.gmail.com with ESMTPSA id jd12-20020a170903260c00b001640ab19773sm1728312plb.58.2022.06.16.07.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 07:22:17 -0700 (PDT) Date: Thu, 16 Jun 2022 19:52:12 +0530 From: Ritesh Harjani To: Jan Kara Cc: Ted Tso , linux-ext4@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 01/10] mbcache: Don't reclaim used entries Message-ID: <20220616142212.do5hdazjkuq5ayar@riteshh-domain> References: <20220614124146.21594-1-jack@suse.cz> <20220614160603.20566-1-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220614160603.20566-1-jack@suse.cz> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 22/06/14 06:05PM, Jan Kara wrote: > Do not reclaim entries that are currently used by somebody from a > shrinker. Firstly, these entries are likely useful. Secondly, we will > need to keep such entries to protect pending increment of xattr block > refcount. Trying to review the patch series to best of my knowledge, so kindly excuse my silly queries along the way. > > CC: stable@vger.kernel.org > Fixes: 82939d7999df ("ext4: convert to mbcache2") > Signed-off-by: Jan Kara > --- > fs/mbcache.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/fs/mbcache.c b/fs/mbcache.c > index 97c54d3a2227..cfc28129fb6f 100644 > --- a/fs/mbcache.c > +++ b/fs/mbcache.c > @@ -288,7 +288,7 @@ static unsigned long mb_cache_shrink(struct mb_cache *cache, > while (nr_to_scan-- && !list_empty(&cache->c_list)) { > entry = list_first_entry(&cache->c_list, > struct mb_cache_entry, e_list); > - if (entry->e_referenced) { > + if (entry->e_referenced || atomic_read(&entry->e_refcnt) > 2) { Sure, yes, the above "||" conditions looks good. i.e. if the refcnt is above 2, then we should move the entry to the tail of LRU. Because that means that there is another user of this entry which might have incremented the refcnt. > entry->e_referenced = 0; > list_move_tail(&entry->e_list, &cache->c_list); > continue; > @@ -302,6 +302,14 @@ static unsigned long mb_cache_shrink(struct mb_cache *cache, > spin_unlock(&cache->c_list_lock); > head = mb_cache_entry_head(cache, entry->e_key); > hlist_bl_lock(head); > + /* Now a reliable check if the entry didn't get used... */ But not sure why this is more reliable? Anytime we add or remove the entry, we first always do the list operation and then increment or decrement the refcnt "atomically". So could you please help in understanding why will this be more reliable? -ritesh > + if (atomic_read(&entry->e_refcnt) > 2) { > + hlist_bl_unlock(head); > + spin_lock(&cache->c_list_lock); > + list_add_tail(&entry->e_list, &cache->c_list); > + cache->c_entry_count++; > + continue; > + } > if (!hlist_bl_unhashed(&entry->e_hash_list)) { > hlist_bl_del_init(&entry->e_hash_list); > atomic_dec(&entry->e_refcnt); > -- > 2.35.3 >