From patchwork Mon Nov 18 11:44:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878431 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 55B4B176AA9; Mon, 18 Nov 2024 11:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930316; cv=none; b=jzJE9l+zfJPIDZFPZlB5SbEEic7IKhEyqNwCoyBchyX2TvcrM8n6rUESYcYXrO9mcUxdVCAW2UOPQL2pJMhrtpusnSzcYOkaQUgR+ZzLJnf3a9Yk4a2YHGZ6eYFh1fNLHGyjdNZXOMdDBoaFcnPz2xPyng0kBCNNF1XXzC9XbIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930316; c=relaxed/simple; bh=Fmpzr+4VilJEIsxQkky2Ak7IZhFT54pKHZH1FgLJg8k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hnhd8IpH59KE0rzSoZdJfE2qsQuP5F967FNcmn3+6oNOHATw+D++l2tF4crNSHnAASMsVprAGRsaoR7s/Ao61qFF8rpL8mmtpBhr+O0Kqco9CFq9I0LixtOjYhAVMdq9Y/85V1XpRWj6Y3MNPu67D4WGSS1Z1MDAWOIzzCbLjww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XsQlm2Q5wz4f3nV2; Mon, 18 Nov 2024 19:44:52 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A542B1A0568; Mon, 18 Nov 2024 19:45:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S5; Mon, 18 Nov 2024 19:45:11 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 01/11] fs: introduce I_CURSOR flag for inode Date: Mon, 18 Nov 2024 19:44:58 +0800 Message-Id: <20241118114508.1405494-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S5 X-Coremail-Antispam: 1UD129KBjvJXoW7uryfWr1fuw48JFyrAw1xAFb_yoW8tF15pF W2kry5tw4DXFW7Cayftanxua1fKF1xCrW5t34xWws5Xr17tw10q3Wvqr1Yyr93JFWkGrWY qrs0k34qgFWxJFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPFb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI 0_GFv_Wryl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU3cTm DUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin This patch introduce I_CURSOR flag for inode and introduce sb_for_each_inodes_safe/sb_for_each_inodes/sb_for_each_inodes_continue_safe API for foreach super_block->s_inodes. Signed-off-by: Ye Bin --- include/linux/fs.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 0a152c31d1bf..cf2734e0b2cd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2473,6 +2473,7 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src, #define I_DONTCACHE (1 << 15) #define I_SYNC_QUEUED (1 << 16) #define I_PINNING_NETFS_WB (1 << 17) +#define I_CURSOR (1 << 18) #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) @@ -3809,4 +3810,48 @@ static inline bool vfs_empty_path(int dfd, const char __user *path) int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter); +static inline bool inode_is_cursor(struct inode *inode) +{ + return inode->i_state & I_CURSOR; +} + +static inline struct inode *next_sb_inode(struct inode *pos, + struct list_head *head) +{ + struct inode *inode; + struct list_head *start; + + if (!pos) + return NULL; + + start = &pos->i_sb_list; + + list_for_each_continue(start, head) { + inode = list_entry(start, typeof(*inode), i_sb_list); + if (likely(!inode_is_cursor(inode))) + return inode; + } + + return NULL; +} + +#define sb_for_each_inodes_safe(pos, n, head) \ + for (pos = list_entry(head, typeof(*pos), i_sb_list), \ + pos = next_sb_inode(pos, head), \ + n = next_sb_inode(pos, head); \ + pos != NULL; \ + pos = n, n = next_sb_inode(n, head)) + +#define sb_for_each_inodes(pos, head) \ + for (pos = list_entry(head, typeof(*pos), i_sb_list), \ + pos = next_sb_inode(pos, head); \ + pos != NULL; \ + pos = next_sb_inode(pos, head)) + +#define sb_for_each_inodes_continue_safe(pos, n, head) \ + for (pos = next_sb_inode(pos, head), \ + n = next_sb_inode(pos, head); \ + pos != NULL; \ + pos = n, n = next_sb_inode(n, head)) + #endif /* _LINUX_FS_H */ From patchwork Mon Nov 18 11:44:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878434 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 ADA301991C6; Mon, 18 Nov 2024 11:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930318; cv=none; b=S2CHhV8AuF9MrFcf8AKwSJ1Tvh9UIS28xvrKc4pmy+JzKZ691SWsmN8O7POfCzJwPeofeTtOINvwwdm4wwM15UMTLKw0yKTd/fB/ujr7OKinB9U8pQgtke7+HkQS1TD1JiwPlwnvg/gcnj9oNOd59zo2locLjcaZ0qHFF2ZNrJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930318; c=relaxed/simple; bh=R1MKjdiumblZFGZdDvMtW02CeKC/L/abULNWROFP7Fw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jb2jpKcvtjY9G656uq95vuDSLK6cYLL+zDIiK9TXpFW9U4vbn7/9NOtr4+pqy5UOErIfV+uFNjqkidtbbkCXsiIPfmENW8IyyB4MnHqMynWwHzlxLhM8B91fdpL8QgxrFaV2n5gaUFpCMTLs16AMCCTkQy6oboGQCdL2xwXib7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4XsQln6HjNz4f3jXJ; Mon, 18 Nov 2024 19:44:53 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 4ADA21A0197; Mon, 18 Nov 2024 19:45:12 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S6; Mon, 18 Nov 2024 19:45:11 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 02/11] block: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:44:59 +0800 Message-Id: <20241118114508.1405494-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S6 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13ZryUKF1UKr1fCrg_yoWkWFg_Ja s3ZF4jgr1xZwnYkrsFkrnxAFZYkw1xGF13trnxtryxZr15X3Z8Aw4xtry5Xr1DCF4UG3s8 ur1xZFyfGr4fKjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbq8YFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r15M2 8IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxV W8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUIID7 DUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- block/bdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 738e3c8457e7..b29e2c5c7c6e 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -478,7 +478,7 @@ long nr_blockdev_pages(void) long ret = 0; spin_lock(&blockdev_superblock->s_inode_list_lock); - list_for_each_entry(inode, &blockdev_superblock->s_inodes, i_sb_list) + sb_for_each_inodes(inode, &blockdev_superblock->s_inodes) ret += inode->i_mapping->nrpages; spin_unlock(&blockdev_superblock->s_inode_list_lock); @@ -1219,7 +1219,7 @@ void sync_bdevs(bool wait) struct inode *inode, *old_inode = NULL; spin_lock(&blockdev_superblock->s_inode_list_lock); - list_for_each_entry(inode, &blockdev_superblock->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &blockdev_superblock->s_inodes) { struct address_space *mapping = inode->i_mapping; struct block_device *bdev; From patchwork Mon Nov 18 11:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878432 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 B02881991C8; Mon, 18 Nov 2024 11:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930317; cv=none; b=T3DK3TvMP+XQrKWrKOT/LWsyT1XvfWNWVtCDZsu4YFlAyM4U+z4t5dy9PlCqbj7+7bbThY091iKm3S4vpAGyhzdpmK+9BWx00yKTLmcmzu+wc4kvhF4hKPrSawLUf37NH7aUFKgG6Fon/MlOG282flBW82GHTYfByXThy/xEt0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930317; c=relaxed/simple; bh=Xoxgocw0U/RFftDc5alO/55z3W+6FINIIJEUZYNh2rw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=io25W2/4XtpouPPMqtmzG1mesV5/Y0dI6X3IDRr5S2HugR9yG+T1xqAcL7TPaDUTgCPqJtBfN8Ew9O16RpgijVEUnyOURRCKCEMJ9a4bWgdv012FC2aAjHtLu1LjD78ZbCmcKvIwIAvhr89cyKe6f7fmg7fB+qhkHY3i+ujL0J8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4XsQlp3wzRz4f3jY3; Mon, 18 Nov 2024 19:44:54 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id EFB101A058E; Mon, 18 Nov 2024 19:45:12 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S7; Mon, 18 Nov 2024 19:45:12 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 03/11] fs: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:45:00 +0800 Message-Id: <20241118114508.1405494-4-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S7 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13ZF1DAr18JFWUJwb_yoW3XFX_XF yrArW8Gr4fXr9a9rs8trsxtFZY9w18GF15ur1UtrZxtr12qFs8Jws7tr98ZF48uF43K398 Zw1kXFy5GryjgjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbq8YFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r1rM2 8IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxV W8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUIF4i UUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- fs/drop_caches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index d45ef541d848..43a31fa2b7c2 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -21,7 +21,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) struct inode *inode, *toput_inode = NULL; spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { spin_lock(&inode->i_lock); /* * We must skip inodes in unusual state. We may also skip From patchwork Mon Nov 18 11:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878433 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 6E8C1199EA1; Mon, 18 Nov 2024 11:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930317; cv=none; b=XtrKode+sBRe1TBO+NXIXdNG8LhXWpLSygyvJ24r6YlDASGxw9qSac5UFwlW8WDYjd7JtKDBif4luxwrF7qgwbCKaFjQL7z3+ffY05pNI/Qd/2UHMgazh2bPMlYw6pq9zWNS24Lapts1nEQ4Ij3BcOdq7AuYrg+sthhFMF/pjX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930317; c=relaxed/simple; bh=rArUOL1ah9o3MPtwONY96Xbhi8FLlRq/rJnitC3VHmk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GtYi/G94MXab8NaXPQYBobb9ZVIS8mQJHbA/18ygLW+GrvjsVu5rkbTMDTjmk2x7cKIIX0oW6+P95j0PUnjKMpYGclZhcb9UCC34ECABwmdNUDSKCWGzGnXI3NsRM0ZebHFewPh4majQ3y/NqsmSqDht1K6DhlXU0/QUk3F5P0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XsQlp2G38z4f3nV5; Mon, 18 Nov 2024 19:44:54 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A11841A058E; Mon, 18 Nov 2024 19:45:13 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S8; Mon, 18 Nov 2024 19:45:13 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 04/11] gfs2: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:45:01 +0800 Message-Id: <20241118114508.1405494-5-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S8 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13ZrWkJr48ZFyUtrb_yoW3ZrcEq3 W7Ars7Cr4rXr1S9r4ktrZIyFnY9r18GF1UKrW3tFyqyr1jqa4kXw4kKr909r1Du3W3t3sY vw1IqFy5JFW3KjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxV WUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU I-eODUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- fs/gfs2/ops_fstype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e83d293c3614..e9dd94f01b90 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -1742,7 +1742,7 @@ static void gfs2_evict_inodes(struct super_block *sb) set_bit(SDF_EVICTING, &sdp->sd_flags); spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { spin_lock(&inode->i_lock); if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) && !need_resched()) { From patchwork Mon Nov 18 11:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878435 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 468F8199FBF; Mon, 18 Nov 2024 11:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930318; cv=none; b=jVFFHVkfBTIGBjGW1Mi4P34zxpe7hYQl+OhY50wlt4MDQVTKILg7LJLGW4GGkm8aUKWnGCkecS1U/qCaDq3Tt210Av+hUIADqgeNU3RnqyVtnLxqYbzSfnY4hNKWXcnPDUqCWEvl9ZEUryvygwUsyA9Vtj+Ak6+6cvFWIsZ4N68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930318; c=relaxed/simple; bh=lWSLPRuV+mb9jmNhM4FND2hrmaTWA3erZEgnMnmts00=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dtIogiW6qKBhwx0Lk8waihV8YRYcKvCAYdoIPqglAQ0RQ83l+Grb+Gno5f4i0NiqJiPO0D6ttFhlGFP+pLYv8ASu/etrjXgHSMiYfXD0KqDjMiCw0oclnhB/zOhVc6+VwW+kr4fcLqTA4Z8YUP5zlOUHLQHusFjqqkgJ8xBZW+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XsQlw6kknz4f3lX4; Mon, 18 Nov 2024 19:45:00 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 4CC601A018D; Mon, 18 Nov 2024 19:45:14 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S9; Mon, 18 Nov 2024 19:45:13 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 05/11] fs: use sb_for_each_inodes_safe API Date: Mon, 18 Nov 2024 19:45:02 +0800 Message-Id: <20241118114508.1405494-6-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S9 X-Coremail-Antispam: 1UD129KBjvdXoW7GFWkXr1xtFWUXw1fJryfXrb_yoWDCwb_Aa 43ZF95Kw4aq3sYkr4DtwsxXF909w1kGr13ury7tFW5trnFqas8XwsFyFyYvr48CF1Sg398 Ar1fXFyfGr4IgjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbgxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x 07jIPfQUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes_safe API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- fs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index e5a60084a7a9..dc966990bda6 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -861,7 +861,7 @@ void evict_inodes(struct super_block *sb) again: spin_lock(&sb->s_inode_list_lock); - list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes_safe(inode, next, &sb->s_inodes) { if (atomic_read(&inode->i_count)) continue; @@ -911,7 +911,7 @@ void invalidate_inodes(struct super_block *sb) again: spin_lock(&sb->s_inode_list_lock); - list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes_safe(inode, next, &sb->s_inodes) { spin_lock(&inode->i_lock); if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); From patchwork Mon Nov 18 11:45:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878436 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 BE01319ABC3; Mon, 18 Nov 2024 11:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930319; cv=none; b=fcgp1IQoX7LQHS1SZ8rOJAH4hR3+LP9n0AurKhk32l+37eRPY9xrFURvNDNvxCx/dh7oc7PK7c9V1htfQkzwjM1mWkl4i//zFdYFp+g6Au+l5N2tvobwyo/iWOMF/NYgFSSp7pj5Wpj6WSGNrRHHTdnQuMwSOoZrmei1/Jo5Os0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930319; c=relaxed/simple; bh=fDmN+0rl4p6XTOwNk557Bs4jaQqJuN4meCMuf2wwwoI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R6Y6qhJ04Fa4wyNM64s+WzITExcSADWde4/2E06SksmxuHp6PAOW3wlGHnf9PoySFzNctFCqdQtYRBkSOKQjyAdXRDyi/Kyz6jNU79sJUu5QL86UpBFjXTwPylWR9ENOyv+Zgd4VhZWm0Z6vfPqgQmV9lMhmu8HCUvY1CdEuz5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XsQlq4PwPz4f3nV8; Mon, 18 Nov 2024 19:44:55 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id EA9751A0196; Mon, 18 Nov 2024 19:45:14 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S10; Mon, 18 Nov 2024 19:45:14 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 06/11] fsnotify: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:45:03 +0800 Message-Id: <20241118114508.1405494-7-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S10 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13ZryfKFyrKFyUWrg_yoW3CwcEgF 1UZrWrKr4aqr1fKrs8G39IyFZY9r1rGr1UGrnrXFyqyF1aqF1DXaykJr98ZF4Uua15KrZ3 JF1ktFy3KrWIkjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbgxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x 07jIPfQUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- fs/notify/fsnotify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 82ae8254c068..11a4eb61b5b2 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -40,7 +40,7 @@ static void fsnotify_unmount_inodes(struct super_block *sb) struct inode *inode, *iput_inode = NULL; spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { /* * We cannot __iget() an inode in state I_FREEING, * I_WILL_FREE, or I_NEW which is fine because by that point From patchwork Mon Nov 18 11:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878439 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 5292719AD8C; Mon, 18 Nov 2024 11:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930321; cv=none; b=KL/RMUyDNsq1inpPEEaFtl664C5F2K9VYe//vgk7FwYT5lZIxSs3Ow5cAiBjCw5vyX90UpnNFfrAlYHYFshCQtJGSAatcjjOlYQhhlGLZDWVrVbg0SPD+0K6hPUshNWlYA7rrOsQeRZI0O/nS0lkJOasiWDkaX8W0iY9s63xI/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930321; c=relaxed/simple; bh=0gvTj1u+Nh96S3z8U1HSnGFASw5nn0sz0706NVg2GlI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ec3egEtKqj2QKn6HxsT+CMxrPeoBnjeZ2K0tdVtsde7Si9j6XjKtodgU2pAlyVaCnFqenUcUC0dCDzLdqKO23zwUMUUGqoi1t++HdClcTpADJR8PzqYC5qiVTf+w4pewPowPWqjl8t51ITw7i6Y0rEImwX7QE3e8SoM+cyNRWLU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4XsQls1JDYz4f3jM1; Mon, 18 Nov 2024 19:44:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 95FCC1A0197; Mon, 18 Nov 2024 19:45:15 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S11; Mon, 18 Nov 2024 19:45:15 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 07/11] quota: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:45:04 +0800 Message-Id: <20241118114508.1405494-8-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S11 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13ZrW5tFy8CF4xXrb_yoWkAFX_CF yfAr1UCr4fXrsagr4qyrsxXF9Y9ws5Ga1UWrW7tFnxAr1jqas5XF4Dtr98Zrn7Ca13K398 Crs7JFy3GFWfKjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbgxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x 07jIPfQUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- fs/quota/dquot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index b40410cd39af..414f92bb762c 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1027,7 +1027,7 @@ static int add_dquot_ref(struct super_block *sb, int type) int err = 0; spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { spin_lock(&inode->i_lock); if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || !atomic_read(&inode->i_writecount) || @@ -1083,7 +1083,7 @@ static void remove_dquot_ref(struct super_block *sb, int type) #endif spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { /* * We have to scan also I_NEW inodes because they can already * have quota pointer initialized. Luckily, we need to touch From patchwork Mon Nov 18 11:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878437 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 F090C1A00F8; Mon, 18 Nov 2024 11:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930320; cv=none; b=G8XcnEd4dPb7+GQW+ON9oZb9/FvIipHTYCqTyU2qTVfn60/4/nnr4sus16up+tcIWHtQHzaAViWImKQwz2PZRs/WKATkMWLh0/Uw0cesigvLA0a4soNce6UAVN3Bea/x8G3bBXAC2IFivdmGc+5CFf9XdNYI+PdUJFOYpi1yMtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930320; c=relaxed/simple; bh=Ie7+Y2P96jQDsIJ9iZsKmlswzDmS/OznA23gsg+kWe0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ql1TIFmWzxXlRB04iU86qMUsXquG9b0NYrsPaYI2TRGvkFp1ITQJXNfdJ/YcX6E8SMTxg7JIuIcxhpTztFyyH//jBdVO/mJOxfdaTQAlC6wtGAPJzIdKQ7XcvAHdbevRetvY8hsTS79j+kB/nglQwDMJIsCfJ6AalQ5sMitLvbw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XsQly6Pswz4f3l91; Mon, 18 Nov 2024 19:45:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 44E311A0359; Mon, 18 Nov 2024 19:45:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S12; Mon, 18 Nov 2024 19:45:15 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 08/11] fs/super.c: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:45:05 +0800 Message-Id: <20241118114508.1405494-9-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S12 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13Zr4kGrykJw15twb_yoWxtrc_ZF 4xAFWjgw43XryS9r4DKws3ZFsakwnakF17Gr43JF15Aw4jqFn8J3yktryF9rn8CF45tr98 Ar1xtFW5ArWUGjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbgxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x 07jIPfQUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index c9c7223bc2a2..71bd0b41468e 100644 --- a/fs/super.c +++ b/fs/super.c @@ -658,7 +658,7 @@ void generic_shutdown_super(struct super_block *sb) struct inode *inode; spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { inode->i_op = VFS_PTR_POISON; inode->i_sb = VFS_PTR_POISON; inode->i_mapping = VFS_PTR_POISON; From patchwork Mon Nov 18 11:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878438 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 CC6F11A0B0C; Mon, 18 Nov 2024 11:45:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930321; cv=none; b=CyE3v5iSFufWtekSMUScAnwDFzqy7fTQjpVOJ/gSTl22WyMvblKVOioD0AkzDNkaLaTxsqWr/fOlR15Yc4QOvHgxWbrWadeSD427jPQQdcr+etto5RXP9jjh53+Kms08tW3XfiJt+DuUoYARt4yrNaQFJxyCjqSfZiRI+xeEoGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930321; c=relaxed/simple; bh=bVSQkyJzzpOn0f9mMGo+Q10YPGNGo/OVRmZEMp3yFxE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kDptvAd2XTggNLhG8gIHMGMyzKjxrjb3ACMpG8TvlNr0p2+tQZfOyYS53JwdnGV5OFn3QRcpX8/iLNx8108Iolx/b4DKBhLd5OcUMixVfIETFM6JlRkIBiYrnpzpkCw7clhMbAjfuEzqLwN8Sze6oK9y2dMaDbKU8ORLaU6WaCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4XsQls4ByNz4f3nZr; Mon, 18 Nov 2024 19:44:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E6A721A0196; Mon, 18 Nov 2024 19:45:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S13; Mon, 18 Nov 2024 19:45:16 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 09/11] landlock: use sb_for_each_inodes API Date: Mon, 18 Nov 2024 19:45:06 +0800 Message-Id: <20241118114508.1405494-10-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S13 X-Coremail-Antispam: 1UD129KBjvdXoWrtr1UWw13Zr47Gr47KrWruFg_yoW3GrbEkF 18AF4Uur13ZrnagwsYyanavF9a9w1rGr4Uur97KF1DAwnIvF98tw4xtF95Zry3ua17tas8 WFnagFy3K397KjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbgxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x 07jIPfQUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin Use sb_for_each_inodes API foreach super_block->s_inodes. Signed-off-by: Ye Bin --- security/landlock/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/landlock/fs.c b/security/landlock/fs.c index dd9a7297ea4e..ccb7951f1404 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1217,7 +1217,7 @@ static void hook_sb_delete(struct super_block *const sb) return; spin_lock(&sb->s_inode_list_lock); - list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { + sb_for_each_inodes(inode, &sb->s_inodes) { struct landlock_object *object; /* Only handles referenced inodes. */ From patchwork Mon Nov 18 11:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878440 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 6C6451993B7; Mon, 18 Nov 2024 11:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930322; cv=none; b=EVsOTQ1ac1L3qVnz9/XyrgKgCmWWrRlBBO7VGVODkj3ET0mbnvg982etaamGMCBRvNPN6JrVBlfqWqPOThDyvixWjM48G+2s8MrfahWQEwaYH2rLpRN87sS1jMTKuXdyckNLNXhw9eCP/rIWVVZ01GpzYgjBv5DJ1VyoT3umSP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930322; c=relaxed/simple; bh=tcEC9Qws+CAfgbzK3YhseY1iB07hGxl6Vnv/o2oi4YA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cSfETIfG7OK1s0ZrwrWO7oevZF1OIZAG4qXXFDl+1nGegFR+X1qBmNmJU89wtbWHMmxd+xwlF4orT9krCK+330OTCXHwFVA6avg7FhL45TzfuEE3hALl3zaHuSxY8b8q+nxf6gOk/I/VMiiawmPWm4VzRTx92lHvCpCslnmMI5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4XsQlv1G9fz4f3jY1; Mon, 18 Nov 2024 19:44:59 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 95A821A0194; Mon, 18 Nov 2024 19:45:17 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S14; Mon, 18 Nov 2024 19:45:17 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 10/11] fs: fix hungtask due to repeated traversal of inodes list Date: Mon, 18 Nov 2024 19:45:07 +0800 Message-Id: <20241118114508.1405494-11-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S14 X-Coremail-Antispam: 1UD129KBjvJXoWxWF15Kr18WFWxJw1DtF1fWFg_yoWrKr1kpF y3tFW5Xw48Ca4qgr4rtr1rXryftayv9ws7JryfGr13u3WUG34aqF97JF13JF97GF47Za1a qF4DurW7Ar4kCw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPvb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2 AFwI0_GFv_Wryl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6r W5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14 v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuY vjxUI-eODUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin There's a issue when remove scsi disk, the invalidate_inodes() function cannot exit for a long time, then trigger hungtask: INFO: task kworker/56:0:1391396 blocked for more than 122 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. Workqueue: events_freezable virtscsi_handle_event [virtio_scsi] Call Trace: __schedule+0x33c/0x7f0 schedule+0x46/0xb0 schedule_preempt_disabled+0xa/0x10 __mutex_lock.constprop.0+0x22b/0x490 mutex_lock+0x52/0x70 scsi_scan_target+0x6d/0xf0 virtscsi_handle_event+0x152/0x1a0 [virtio_scsi] process_one_work+0x1b2/0x350 worker_thread+0x49/0x310 kthread+0xfb/0x140 ret_from_fork+0x1f/0x30 PID: 540499 TASK: ffff9b15e504c080 CPU: 44 COMMAND: "kworker/44:0" Call trace: invalidate_inodes at ffffffff8f3b4784 __invalidate_device at ffffffff8f3dfea3 invalidate_partition at ffffffff8f526b49 del_gendisk at ffffffff8f5280fb sd_remove at ffffffffc0186455 [sd_mod] __device_release_driver at ffffffff8f738ab2 device_release_driver at ffffffff8f738bc4 bus_remove_device at ffffffff8f737f66 device_del at ffffffff8f73341b __scsi_remove_device at ffffffff8f780340 scsi_remove_device at ffffffff8f7803a2 virtscsi_handle_event at ffffffffc017204f [virtio_scsi] process_one_work at ffffffff8f1041f2 worker_thread at ffffffff8f104789 kthread at ffffffff8f109abb ret_from_fork at ffffffff8f001d6f As commit 04646aebd30b ("fs: avoid softlockups in s_inodes iterators") introduces the retry logic. In the problem environment, the 'i_count' of millions of files is not zero. As a result, the time slice for each traversal to the matching inode process is almost used up, and then the traversal is started from scratch. The worst-case scenario is that only one inode can be processed after each wakeup. Because this process holds a lock, other processes will be stuck for a long time, causing a series of problems. To solve the problem of repeated traversal from the beginning, each time the CPU needs to be freed, a cursor is inserted into the linked list, and the traversal continues from the cursor next time. Fixes: 04646aebd30b ("fs: avoid softlockups in s_inodes iterators") Signed-off-by: Ye Bin --- fs/inode.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index dc966990bda6..b78895af8779 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -857,11 +857,16 @@ static void dispose_list(struct list_head *head) void evict_inodes(struct super_block *sb) { struct inode *inode, *next; + struct inode cursor; LIST_HEAD(dispose); + cursor.i_state = I_CURSOR; + INIT_LIST_HEAD(&cursor.i_sb_list); + inode = list_entry(&sb->s_inodes, typeof(*inode), i_sb_list); + again: spin_lock(&sb->s_inode_list_lock); - sb_for_each_inodes_safe(inode, next, &sb->s_inodes) { + sb_for_each_inodes_continue_safe(inode, next, &sb->s_inodes) { if (atomic_read(&inode->i_count)) continue; @@ -886,12 +891,16 @@ void evict_inodes(struct super_block *sb) * bit so we don't livelock. */ if (need_resched()) { + list_del(&cursor.i_sb_list); + list_add(&cursor.i_sb_list, &inode->i_sb_list); + inode = &cursor; spin_unlock(&sb->s_inode_list_lock); cond_resched(); dispose_list(&dispose); goto again; } } + list_del(&cursor.i_sb_list); spin_unlock(&sb->s_inode_list_lock); dispose_list(&dispose); @@ -907,11 +916,16 @@ EXPORT_SYMBOL_GPL(evict_inodes); void invalidate_inodes(struct super_block *sb) { struct inode *inode, *next; + struct inode cursor; LIST_HEAD(dispose); + cursor.i_state = I_CURSOR; + INIT_LIST_HEAD(&cursor.i_sb_list); + inode = list_entry(&sb->s_inodes, typeof(*inode), i_sb_list); + again: spin_lock(&sb->s_inode_list_lock); - sb_for_each_inodes_safe(inode, next, &sb->s_inodes) { + sb_for_each_inodes_continue_safe(inode, next, &sb->s_inodes) { spin_lock(&inode->i_lock); if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); @@ -927,12 +941,16 @@ void invalidate_inodes(struct super_block *sb) spin_unlock(&inode->i_lock); list_add(&inode->i_lru, &dispose); if (need_resched()) { + list_del(&cursor.i_sb_list); + list_add(&cursor.i_sb_list, &inode->i_sb_list); + inode = &cursor; spin_unlock(&sb->s_inode_list_lock); cond_resched(); dispose_list(&dispose); goto again; } } + list_del(&cursor.i_sb_list); spin_unlock(&sb->s_inode_list_lock); dispose_list(&dispose); From patchwork Mon Nov 18 11:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 13878441 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 304EA1A00F8; Mon, 18 Nov 2024 11:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930322; cv=none; b=IGctFQph3MA5777HgMJt6qco4vW4xlpC1jFjDi2RRA5FxRVmOzTWEB0AtZjR4CyYBjBnTXxRBQFM3cgmi8rULZLnr9Y+JzeimcOJVOrOHgwL/0ZpVVXJ9Y1f8sq3SuyuZg0lJ9jGPwqelCdP0Eyw+0fHSBxVW6rKjQ24xgVbnuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731930322; c=relaxed/simple; bh=5kGt5YdPzQR7JjnloKlub9ZvkTDiI38fa29tAWFwlR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pttNn4bi4B6+4suQzKyyIjgu60BFLbSDYhCu0qahQwzRrjNv0yuMdCccV2l7pLDvWhb+Jxdo0InS47VRVvHRss3/KHTdQc5cGAFGfG8060eonnVq0vdzU20ysk9nIpSE7TFoYJFE/9THwSu08PjyrSZaj8pRbga4NkDmWFbElcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4XsQlv5nt7z4f3jXs; Mon, 18 Nov 2024 19:44:59 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 3F61C1A0568; Mon, 18 Nov 2024 19:45:18 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP4 (Coremail) with SMTP id gCh0CgCnzoLEKDtn3fCKCA--.48005S15; Mon, 18 Nov 2024 19:45:17 +0800 (CST) From: Ye Bin To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, linux-block@vger.kernel.org, agruenba@redhat.com, gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net, gnoack@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com Subject: [PATCH 11/11] fs: fix potential soft lockup when 'sb->s_inodes' has large number of inodes Date: Mon, 18 Nov 2024 19:45:08 +0800 Message-Id: <20241118114508.1405494-12-yebin@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com> References: <20241118114508.1405494-1-yebin@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCnzoLEKDtn3fCKCA--.48005S15 X-Coremail-Antispam: 1UD129KBjvJXoWxAw18GFWkWFyDXrWUuw47XFb_yoW5Cry7pF nIgFW3Xw48KayFgw4ftF1kWrn3ta4v9r4xtryfCr9xAayjy343tF1UAr17XFWrKF47Zr90 qF48Cry3Ars3AwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPvb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2 AFwI0_GFv_Wryl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6r W5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF 7I0E14v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14 v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuY vjxUI-eODUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ From: Ye Bin If the memory is sufficient, a large number of inodes that do not meet the conditions may exist in the 'sb->s_inodes' list when evict_inodes()/invalidate_inodes() traverse the 'sb->s_inodes' list. Then it maybe trigger soft lockup. To solve potential soft lockup, move need_resched() check from tail to head when traverse the 'sb->s_inodes' list. Signed-off-by: Ye Bin --- fs/inode.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index b78895af8779..e865fc1f5a95 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -867,6 +867,21 @@ void evict_inodes(struct super_block *sb) again: spin_lock(&sb->s_inode_list_lock); sb_for_each_inodes_continue_safe(inode, next, &sb->s_inodes) { + /* + * We can have a ton of inodes to evict at unmount time given + * enough memory, check to see if we need to go to sleep for a + * bit so we don't livelock. + */ + if (need_resched()) { + list_del(&cursor.i_sb_list); + list_add_tail(&cursor.i_sb_list, &inode->i_sb_list); + inode = &cursor; + spin_unlock(&sb->s_inode_list_lock); + cond_resched(); + dispose_list(&dispose); + goto again; + } + if (atomic_read(&inode->i_count)) continue; @@ -884,21 +899,6 @@ void evict_inodes(struct super_block *sb) inode_lru_list_del(inode); spin_unlock(&inode->i_lock); list_add(&inode->i_lru, &dispose); - - /* - * We can have a ton of inodes to evict at unmount time given - * enough memory, check to see if we need to go to sleep for a - * bit so we don't livelock. - */ - if (need_resched()) { - list_del(&cursor.i_sb_list); - list_add(&cursor.i_sb_list, &inode->i_sb_list); - inode = &cursor; - spin_unlock(&sb->s_inode_list_lock); - cond_resched(); - dispose_list(&dispose); - goto again; - } } list_del(&cursor.i_sb_list); spin_unlock(&sb->s_inode_list_lock); @@ -926,6 +926,16 @@ void invalidate_inodes(struct super_block *sb) again: spin_lock(&sb->s_inode_list_lock); sb_for_each_inodes_continue_safe(inode, next, &sb->s_inodes) { + if (need_resched()) { + list_del(&cursor.i_sb_list); + list_add_tail(&cursor.i_sb_list, &inode->i_sb_list); + inode = &cursor; + spin_unlock(&sb->s_inode_list_lock); + cond_resched(); + dispose_list(&dispose); + goto again; + } + spin_lock(&inode->i_lock); if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { spin_unlock(&inode->i_lock); @@ -940,15 +950,6 @@ void invalidate_inodes(struct super_block *sb) inode_lru_list_del(inode); spin_unlock(&inode->i_lock); list_add(&inode->i_lru, &dispose); - if (need_resched()) { - list_del(&cursor.i_sb_list); - list_add(&cursor.i_sb_list, &inode->i_sb_list); - inode = &cursor; - spin_unlock(&sb->s_inode_list_lock); - cond_resched(); - dispose_list(&dispose); - goto again; - } } list_del(&cursor.i_sb_list); spin_unlock(&sb->s_inode_list_lock);