Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6004743iob; Tue, 10 May 2022 08:19:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmS0+hoaEY+pd8P4rNPGduTC6HTDCswAvsho7/LvJ+W5zYexvublDMWqdhspUYriCKY4v4 X-Received: by 2002:a17:90b:4d09:b0:1dc:5fb0:a8ce with SMTP id mw9-20020a17090b4d0900b001dc5fb0a8cemr447364pjb.187.1652195965025; Tue, 10 May 2022 08:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652195965; cv=none; d=google.com; s=arc-20160816; b=afP8IJ8G5ant0UUtm5hqGhGaiBSAYOQ72u4PQmFQ3hc9n69AsrLSGlWgn5cZr/GL7K 5YNYhMz/dFK8LiqqAGZrUkfbYghHWasz33wDVpmwSxEZjKia412xerBALCs0H9o46mMs mI82zHo4b5lUwLD5+/aI/RBjQdofj2TQWMS1CCLxeOAcgBQYYaTKRf6acoMI0KwhwkJ7 jjJUOiVQGIPL1wj0FxIgeObeEIxueGMDDekWLpbdu7Yee8Y7G7hOfY5MOlcFb74gYDtF InRa1CU8xBZMO7WSTrkHaK7GYEZiq1usaoKhVVmJerUZyD6niRVA4q6Cn2/VGxeUnO0u RseA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=lbzQNHvRgmAKJHhChSsDKGEqh0+N/1gADq6UqyTU0po=; b=yFTVfS134fqLH+jf95vctKZKIMVVyk6ABxTRs7o7jtF7jor7kfHKslSu96m4ot0HbF 3EO42EZIeaSFE3k1GEdKAGHBQtsm9Uvc+BItu5OvGc4Y+sTILPiDTEAc+dLhojr7Ki45 5IV0792qf4wfdjFLSO36xdtbavvX8nePbikLrm4LX3odO4/TigK1eMeimhLCLOgS9QPy UqHWwNDGy8DahrdCTmU+cy97gvnHGP69piV+H74YajGNOVeMBhfg+SyTjMrEvB2vn/Qz k+e9fcwpg0DgjboLzK+mUeS0rpT8hqBxDuCv07heyZNk02GKcax5imMhVyodmuUMI3P3 ka0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FXV8fqvd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a17090274c500b00156fceb78f1si3322200plt.318.2022.05.10.08.19.10; Tue, 10 May 2022 08:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@redhat.com header.s=mimecast20190719 header.b=FXV8fqvd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240820AbiEJM5b (ORCPT + 99 others); Tue, 10 May 2022 08:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238553AbiEJM53 (ORCPT ); Tue, 10 May 2022 08:57:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 74ED4201336 for ; Tue, 10 May 2022 05:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652187211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lbzQNHvRgmAKJHhChSsDKGEqh0+N/1gADq6UqyTU0po=; b=FXV8fqvdcGNsx72PqNVMwpWgYUqpb6xsgh+VpFtu5xZyO+dbaPfxkvdu9ZESwumy0/3rCv Tdii/t2ObRAFVYX5ViwucDikUEYRcui+X1RgE7kcReVWvg8tG+s4LYb8AVlivQbE3cTQXM qXq4/GANgrW03tT4R96rjKOTAlX9dj0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-UjOvT2dzP5K19VuLQAl7qQ-1; Tue, 10 May 2022 08:53:29 -0400 X-MC-Unique: UjOvT2dzP5K19VuLQAl7qQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E2431C08979; Tue, 10 May 2022 12:53:22 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.37.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73CDB40CFD74; Tue, 10 May 2022 12:53:19 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20220509074028.74954-4-jefflexu@linux.alibaba.com> References: <20220509074028.74954-4-jefflexu@linux.alibaba.com> <20220509074028.74954-1-jefflexu@linux.alibaba.com> To: Jeffle Xu Cc: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, willy@infradead.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org, luodaowen.backend@bytedance.com, tianzichen@kuaishou.com, yinxin.x@bytedance.com, zhangjiachen.jaycee@bytedance.com, zhujia.zj@bytedance.com Subject: Re: [PATCH v11 03/22] cachefiles: unbind cachefiles gracefully in on-demand mode MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3509260.1652187198.1@warthog.procyon.org.uk> Date: Tue, 10 May 2022 13:53:18 +0100 Message-ID: <3509261.1652187198@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,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-kernel@vger.kernel.org Jeffle Xu wrote: > Add a refcount to avoid the deadlock in on-demand read mode. The > on-demand read mode will pin the corresponding cachefiles object for > each anonymous fd. The cachefiles object is unpinned when the anonymous > fd gets closed. When the user daemon exits and the fd of > "/dev/cachefiles" device node gets closed, it will wait for all > cahcefiles objects getting withdrawn. Then if there's any anonymous fd > getting closed after the fd of the device node, the user daemon will > hang forever, waiting for all objects getting withdrawn. > > To fix this, add a refcount indicating if there's any object pinned by > anonymous fds. The cachefiles cache gets unbound and withdrawn when the > refcount is decreased to 0. It won't change the behaviour of the > original mode, in which case the cachefiles cache gets unbound and > withdrawn as long as the fd of the device node gets closed. > > Signed-off-by: Jeffle Xu Acked-by: David Howells