Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1903940rwl; Thu, 6 Apr 2023 03:04:16 -0700 (PDT) X-Google-Smtp-Source: AKy350bnIk+5/111v9eAywaEDRk8BLnqwabBW/Igk/gqtagOIXvbbZhutiSQF8gbOFl67qaY1K7P X-Received: by 2002:a62:1705:0:b0:62d:c382:1384 with SMTP id 5-20020a621705000000b0062dc3821384mr6136081pfx.5.1680775456647; Thu, 06 Apr 2023 03:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680775456; cv=none; d=google.com; s=arc-20160816; b=NtfjL+0hlyg5tf/ZvKOSxxU2nrGUIJh7jlJ9y1bVs7lK/DCtkxlk4FFgYboARqGZ81 Mh2RSYbeJ5CMlL4YxMoSqNrStvYVaO0Bgtuf1i8Wv8A227Yj9e6Pyf9+jboPHXu8p18v oW25kwb9aFGKANUWFtigAG0LUn1FeyYMedOTqQ67jboFlkA9tM7dBTmtJySS8gCJGfue ocOHMH3JEtDJ7/Ve1+xp7l23k3L0XXVSlqey8YwdGVcnSvRCs6nArZS5ZzrEMHUsswsk GrdvByA0FTlqdEkd9zKEgBXSMDCJ/RL+FdXQaq6kijA8RYyRaTp+0HPrFPrNP+usECGJ /pNw== 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=nCOAWP3Xq3SdDEBQjDYeqCMyjLT01aV2FZjw5ujT9Ds=; b=n8MBAgcV8SmVJwrajECteK7dNqQKB47TepAQjWMPPYlhDZipsvZjvLf+u2Ts0l4c75 wCaBDQA3Lpz3d48SJ6mULJe2Xp0k0MIbOxMynf4qMdiSWQ64J4nA8bjyhRV3mUfjwFsg pGY4qm1mzw1FRAdm+Iz4tXgxCFM7eilqjOB6FDz2ira9i0AC+u+SfRhy88Qt8W6gj2Xj RlRGiT5fDUQPvuV6YzLdFiKTIU5tog2yKRwAblCs/7XpisCvPCGJ7l2WFaVpZb/d1Sg8 RD36kzsAW777NfDCA59ZW8OF0YE1n2OVsFqXrK8etoic1LfwVbbIwC2rLlY8yxXt3LG8 RnAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Wqx/xHpw"; 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 a14-20020aa795ae000000b005a8adc698casi1049774pfk.189.2023.04.06.03.04.04; Thu, 06 Apr 2023 03:04:16 -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="Wqx/xHpw"; 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 S236218AbjDFKDq (ORCPT + 99 others); Thu, 6 Apr 2023 06:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236860AbjDFKD1 (ORCPT ); Thu, 6 Apr 2023 06:03:27 -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 9AA7D83D0; Thu, 6 Apr 2023 03:03:12 -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 249D16288B; Thu, 6 Apr 2023 10:03:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C9BDC433D2; Thu, 6 Apr 2023 10:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1680775391; bh=Q91LeGfazZCcvmkNSKQDh2S2zJ4XUfMbkzSQcwu2+kQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wqx/xHpwzEgloQBD/CkbVAJsa84OKnowPu4b4Yi11M5ANZ6Wm5L3VLKJ+2JdWegoj rF+9HKby+OQju13wlpp3kQ3yNagJHvqu9xAhdqLV4YS4tySFKDnQZJG+XsYj67nkLk m7h0DVt/xIgASFFVk3MQNgxNFR7Bd8kZmpsVokXc= Date: Thu, 6 Apr 2023 12:03:08 +0200 From: Greg KH To: Yangtao Li Cc: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com, damien.lemoal@opensource.wdc.com, naohiro.aota@wdc.com, jth@kernel.org, rafael@kernel.org, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 2/3] erofs: convert to use kobject_is_added() Message-ID: <2023040635-duty-overblown-7b4d@gregkh> References: <20230406093056.33916-1-frank.li@vivo.com> <20230406093056.33916-2-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230406093056.33916-2-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 05:30:55PM +0800, Yangtao Li wrote: > Use kobject_is_added() instead of directly accessing the internal > variables of kobject. BTW kill kobject_del() directly, because > kobject_put() actually covers kobject removal automatically. > > Signed-off-by: Yangtao Li > --- > fs/erofs/sysfs.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c > index 435e515c0792..daac23e32026 100644 > --- a/fs/erofs/sysfs.c > +++ b/fs/erofs/sysfs.c > @@ -240,8 +240,7 @@ void erofs_unregister_sysfs(struct super_block *sb) > { > struct erofs_sb_info *sbi = EROFS_SB(sb); > > - if (sbi->s_kobj.state_in_sysfs) { > - kobject_del(&sbi->s_kobj); > + if (kobject_is_added(&sbi->s_kobj)) { I do not understand why this check is even needed, I do not think it should be there at all as obviously the kobject was registered if it now needs to not be registered. 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. kobjects were not designed to be "used raw" like this, ideally they would be wrapped in a subsystem that makes them easier to be used (like the driver model), but filesystems decided to use them and that usage just grew over the years. That's evolution for you... thanks, greg k-h