Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp104670lqf; Fri, 26 Apr 2024 00:30:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0EICiHXz7i53soG0qPlLpAqzrEFAkA5/lG34IdyghqO8+6dFj9DlZDuL5uLZ23vYCVawVa155wPxoK9jp8vL+wynbR2ON5KzqytShlw== X-Google-Smtp-Source: AGHT+IETZilIeR28VjCtkM2hXcRWFNa7LUUq2PtJ3lEU+BouuVSR26S4jQRAWo9v9EkYbpLvD53R X-Received: by 2002:a05:622a:2a05:b0:434:ff21:c2a with SMTP id hc5-20020a05622a2a0500b00434ff210c2amr1869560qtb.51.1714116654532; Fri, 26 Apr 2024 00:30:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714116654; cv=pass; d=google.com; s=arc-20160816; b=HtO2lKq9TfypvrxzUJX+it9TPU4bS7nP7X0vmAv9A/Eg2pNgIJEVJVb0w5COX7fG4z 3Dn0GCWvC3kvMCazEUmNYUE9skmkdAGy0RwIg5fXaYbTipZhOUnc9ywWPtpzdFb5hx9A bk7Pv70J8L1h3lUiIY/H/UG7B55MABkG6DFgyeFGytP9iOXO/VZa74Kz7Kg5dcnxXQVG IVhSrMyT5fTBU/TVIbLRwVjH3UN5dyxej/TMiiCfv4+Ff2cOyM4Tf3qO0nsMdvLR+f97 ub0OM08Ruw10yzorr9vKp5dfXCenD8A/xpVJgbkLzJ1e3CSU9SqRhV+fhSulOxTomkg7 8RWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DQ6r3w+I+fAoQSvNF+oOUgR+CEx6NZvzg3R1b8bRtHg=; fh=uRRo/bsVkkMz4T1a2t0y0xSNbzWg22XBPvnHoLuz/8k=; b=fqu1eGeXNwdHkM58aWeMTDDrIhm7/2KZjBupc1WZhaEkIeYinzwni2X3aIF2fXsjXB 3jEy0MOF37UFAgsZmo+CO1wYoAopnCiAGe9AqYksDAmGFMSxgWqr/cN4Zh+OD7FQrTTI qYf+MtdsZjLaq9Buf+K+HY3wNScDmN2SGuggpzxUzjh7M0fP/F6GTsvUfYytROXuAw+b Epha2EGowvuECiapvuerCkqa4LbLS/h6LMQnFKVLpJT6Da8pPSr4kZqpyz1ZgtxCZrjz zcPCAto57PtJYuykQZeVtk4OsQuL/7urhiOW+aFbOiH7QBo6m7i96NBmOhpdiqcH0lHJ 7X0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vVEXqZHW; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-159632-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o17-20020a05622a009100b0043a7075c988si1170054qtw.8.2024.04.26.00.30.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 00:30:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159632-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.dev header.s=key1 header.b=vVEXqZHW; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-159632-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 436001C22078 for ; Fri, 26 Apr 2024 07:30:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84B9813C3D2; Fri, 26 Apr 2024 07:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vVEXqZHW" Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (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 1696C13BC2B for ; Fri, 26 Apr 2024 07:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714116648; cv=none; b=dJ2UmpTvTSceJ/prlE+LR4MVXRdC7q+harS4kdjMqZDsRak4RNMrIPT19PFEk2rOKZQWMA59L8mgfjKm+px26rNJ73+nAznV6iCJkvWf7zq/voWyVoj7+UL3yTZMC56eyhmIuiOwsZy+DEvfedI/u8KwNjZ7R431qACXFKs0Nk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714116648; c=relaxed/simple; bh=l5QiBjcOva5LgsCUWVhPHkGb5Db5ByV+PGZtR5LTWAU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=C4N864gqs7395QZQkQMtrUPk1Xbk4JaLDwl13QSDFpb/7r0ughkxG72d78yWhaysoU+lga6TzeDcHK/7/3tNjInXD72/fT23+85CSGWQrpg/vtb21jLuU3MgdNX1MpNfud1FVK0DJQWcnQ4CwuWtJHWICFqJYBNcFz3rDDZaaTE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vVEXqZHW; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714116642; 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: content-transfer-encoding:content-transfer-encoding; bh=DQ6r3w+I+fAoQSvNF+oOUgR+CEx6NZvzg3R1b8bRtHg=; b=vVEXqZHWZBWkca8nXxKhI3kfdyqVrZe51H0CXsqaXqAu2wrZY8E2oprdFcwXAYmPksFtrN 3fGrsh5ssjLG70trE6v4YTYCDZYN89NJoas3PIKu6wlhcKn/4S4gHp23HN69VxE1ozI7j6 KXUq2H24ndtdadz5t3yMi3SguONGZvk= From: Youling Tang To: Kent Overstreet Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, Youling Tang Subject: [PATCH] bcachefs: Change destroy_inode to free_inode Date: Fri, 26 Apr 2024 15:29:56 +0800 Message-Id: <20240426072956.7727-1-youling.tang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Youling Tang The vfs[1] documentation describes free_inode as follows: ``` free_inode this method is called from RCU callback. If you use call_rcu() in ->destroy_inode to free ‘struct inode’ memory, then it’s better to release memory in this method. ``` free_inode will be called by the RCU callback, so it might be better to move the inode free operation to destroy_inode. Similar to commit ae6b47b5653e ("fs/ntfs3: Change destroy_inode to free_inode"). Link: [1]: https://www.kernel.org/doc/html/latest/filesystems/vfs.html Signed-off-by: Youling Tang --- fs/bcachefs/fs.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index afb57ea99431..c82ee192a2e2 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1511,17 +1511,9 @@ static void bch2_vfs_inode_init(struct btree_trans *trans, subvol_inum inum, mapping_set_large_folios(inode->v.i_mapping); } -static void bch2_i_callback(struct rcu_head *head) +static void bch2_free_inode(struct inode *vinode) { - struct inode *vinode = container_of(head, struct inode, i_rcu); - struct bch_inode_info *inode = to_bch_ei(vinode); - - kmem_cache_free(bch2_inode_cache, inode); -} - -static void bch2_destroy_inode(struct inode *vinode) -{ - call_rcu(&vinode->i_rcu, bch2_i_callback); + kmem_cache_free(bch2_inode_cache, to_bch_ei(vinode)); } static int inode_update_times_fn(struct btree_trans *trans, @@ -1829,7 +1821,7 @@ static int bch2_unfreeze(struct super_block *sb) static const struct super_operations bch_super_operations = { .alloc_inode = bch2_alloc_inode, - .destroy_inode = bch2_destroy_inode, + .free_inode = bch2_free_inode, .write_inode = bch2_vfs_write_inode, .evict_inode = bch2_evict_inode, .sync_fs = bch2_sync_fs, -- 2.34.1