Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2244068rwl; Thu, 6 Apr 2023 07:43:05 -0700 (PDT) X-Google-Smtp-Source: AKy350aMJzYjCAqDi1YtNgEVlMVABcFdmrR1xf2JolIWuw67AwhCGhBaUBC33tZieAGRLXlN+g6Z X-Received: by 2002:a05:6402:8c4:b0:4fb:98e2:3df8 with SMTP id d4-20020a05640208c400b004fb98e23df8mr5574739edz.27.1680792184982; Thu, 06 Apr 2023 07:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680792184; cv=none; d=google.com; s=arc-20160816; b=iClBx1MD6bnaSQxBNWQkRSLeqBqreqbQ5v05S4wAXtOC2nXAgwMtclZyHnpfXH72hv YDExUet20xnXYHhPrv7BiO0tQ+TISZRNd4IEE2jo5jN7Es51gXjje2vmdHaQ5SX5f8Fa wWY4glmCQrBODffGQZTssZUC2lK09M/MQRMgNoAQb8UDFzxoYj1N/AEs17giZG12MXs6 mXIzyn16qCN5VY9SEvyiFPM51DPrKB2nx8jdfa1hC2ZAvnvtVIappDVZV5DIYq6VZjqS Cm47IALBZO+LBFon+oWWm0CroOjhtxckHvt8pRgDoKltfhMs0w/sR/tUhkuL9qzXVZmY yd9Q== 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=jwOo+1NvOW53Uw+rD16JFExQocRSz8CsTcA/hgXASnY=; b=rxuaA3UFBhqrMoSns9ztyQtF7up4ON79keShqJsoUZY8EymackWN+rDVRbgkR+Br+r plfNpRVywyl3Eh4s+AVOO/zH103kmhvfMOtF0vSQZYE6h2/luy/22Bosz3J4tj5jk5BI MO8e5K/fND9QT3UUcmiO8pKSJ/+klE7i9wLJ8QO0jDUEC3z8Sxlc76wqcSbrg+mtdemo US7ksV208598FpORB9+kvbYtdqt3Y6gVW0VR0FxC8+cBoXpkJYEvt/H4NssZjFuXqgyh E+qh9y49iGDzR/eRgzhp5+rsN/YVmfKV7eCt9Hf6o47vdFKlI2MQ20XGOFJBOtzVHPoF nIog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kIoXODhP; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by7-20020a0564021b0700b004aadaa706ecsi1296790edb.169.2023.04.06.07.42.39; Thu, 06 Apr 2023 07:43:04 -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=@linuxfoundation.org header.s=korg header.b=kIoXODhP; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239241AbjDFOgA (ORCPT + 99 others); Thu, 6 Apr 2023 10:36:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239226AbjDFOfp (ORCPT ); Thu, 6 Apr 2023 10:35:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DD4CA13; Thu, 6 Apr 2023 07:33:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2C9E7648A1; Thu, 6 Apr 2023 14:31:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12E1AC4339C; Thu, 6 Apr 2023 14:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1680791487; bh=XeI9KfiYdDhLQo7ETsetlFQttpL3vF0ZQRlL4DrjO94=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kIoXODhPxDBIJeLdJ53pjgicprZj+Q4MZ9pJlpKxGHW//XKTtdP3WoW0DpEm1ZgMJ mjc5yPJj26Xm03Kdfrc+NQfnVusWWRsJ25te7hsy2Q/Lwt+8qdqKX5cRBTQErBDdhx 14GL7sjuTczZYdD73fKJ+57w5AfueFBtoY8hSByo= Date: Thu, 6 Apr 2023 16:31:24 +0200 From: Greg KH To: Yangtao Li Cc: chao@kernel.org, damien.lemoal@opensource.wdc.com, huyue2@coolpad.com, jefflexu@linux.alibaba.com, jth@kernel.org, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, naohiro.aota@wdc.com, rafael@kernel.org, xiang@kernel.org Subject: Re: [PATCH 2/3] erofs: convert to use kobject_is_added() Message-ID: <2023040602-stack-overture-d418@gregkh> References: <2023040635-duty-overblown-7b4d@gregkh> <20230406120716.80980-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230406120716.80980-1-frank.li@vivo.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On Thu, Apr 06, 2023 at 08:07:16PM +0800, Yangtao Li wrote: > > Meta-comment, we need to come up with a "filesystem kobject type" to get > > rid of lots of the boilerplate filesystem kobject logic as it's > > duplicated in every filesystem in tiny different ways and lots of times > > (like here), it's wrong. > > Can we add the following structure? > > struct filesystem_kobject { > struct kobject kobject; > struct completion unregister; > }; Ah, no, I see the problem. The filesystem authors are treating the kobject NOT as the thing that handles the lifespan of the structure it is embedded in, but rather as something else (i.e. a convient place to put filesystem information to userspace.) That isn't going to work, and as proof of that, the release callback should be a simple call to kfree(), NOT as a completion notification which then something else will go off and free the memory here. That implies that there are multiple reference counting structures happening on the same structure, which is not ok. Either we let the kobject code properly handle the lifespan of the structure, OR we pull it out of the structure and just let it hang off as a separate structure (i.e. a pointer to something else.) As the superblock lifespan rules ALREADY control the reference counting logic of the filesystem superblock structure, let's stick with that and just tack-on the kobject as a separate structure entirely. Does that make sense? Let me do a quick pass at this for zonefs as that's pretty simple to show you what I mean... thanks, greg k-h