{"id":2223449,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2223449/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260415105505.342358-5-yebin@huaweicloud.com/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.2/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260415105505.342358-5-yebin@huaweicloud.com>","list_archive_url":null,"date":"2026-04-15T10:55:05","name":"[v2,4/4] ext4: show orphan file inode detail info","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"052f49cc3623999de00d5f4a160264e8221cb734","submitter":{"id":85089,"url":"http://patchwork.ozlabs.org/api/1.2/people/85089/?format=json","name":"Ye Bin","email":"yebin@huaweicloud.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260415105505.342358-5-yebin@huaweicloud.com/mbox/","series":[{"id":499966,"url":"http://patchwork.ozlabs.org/api/1.2/series/499966/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=499966","date":"2026-04-15T10:55:03","name":"show orphan file inode detail info","version":2,"mbox":"http://patchwork.ozlabs.org/series/499966/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223449/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223449/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=zEQP=CO=vger.kernel.org=linux-ext4+bounces-15846-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=zeqp=co=vger.kernel.org=linux-ext4+bounces-15846-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c0a:e001:db::12fc:5321\"\n arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15846-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=45.249.212.51","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=huaweicloud.com"],"Received":["from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1 raw public key)\n server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwdSJ4DQvz1yHM\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 20:59:12 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fwdSJ40brz4w1W\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 20:59:12 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4fwdSJ3sv6z4wJX; Wed, 15 Apr 2026 20:59:12 +1000 (AEST)","from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4fwdSD6lzHz4w1W\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 15 Apr 2026 20:59:08 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 235AB30A926F\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 15 Apr 2026 10:57:49 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 96E4B34C134;\n\tWed, 15 Apr 2026 10:57:48 +0000 (UTC)","from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com\n [45.249.212.51])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id AA811347FD0\n\tfor <linux-ext4@vger.kernel.org>; Wed, 15 Apr 2026 10:57:45 +0000 (UTC)","from mail.maildlp.com (unknown [172.19.163.177])\n\tby dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fwdPb6FgBzYQtpY\n\tfor <linux-ext4@vger.kernel.org>; Wed, 15 Apr 2026 18:56:51 +0800 (CST)","from mail02.huawei.com (unknown [10.116.40.252])\n\tby mail.maildlp.com (Postfix) with ESMTP id C530D4058D\n\tfor <linux-ext4@vger.kernel.org>; Wed, 15 Apr 2026 18:57:37 +0800 (CST)","from huaweicloud.com (unknown [10.50.87.132])\n\tby APP3 (Coremail) with SMTP id _Ch0CgAHtL0fb99pbf70AQ--.45727S8;\n\tWed, 15 Apr 2026 18:57:37 +0800 (CST)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1776250752; cv=pass;\n\tb=BE8xJjeMPVH/HHTfOSZNHgKOHaFAom5FBouGYE6odRKE2OhsfgzVRVmMi5PuiiFMbQACMdSy2Nt6gpYcOvyo8OPDGvtKmKUr7XJ40SQfxN3shzBQoaeD/jPr/LQkCytHwRp3GPiXzg77umSp99t8CgxO2ubljE6+CIwiJnUgwq2gXUsDmJh45MZ7BRTauRceQCNLg09HJ6j6HZVJxzF5mmK6q98hkweTzRRAkGxM53OQ86jwhi0Pk1f1NTNUxgAhcTB854FiYvnJ+2jJCoWfpQhs5A6z0OGAGA9nqIfs+jVrKcpdUkNHHt855m1WltbZ04sRLGYqsiRkxPqif7tvEA==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776250668; cv=none;\n b=APBUr6BQwmn6e2m2tz7dxvqKNXQ2F6QuJRKZ+ZcoJ3DqOqIikrIeAwJ0DdyV7wmx5+d6PjEIY/9CjaLEDd0hHIcMESjHpyLzlzCrei64yIcf97Q1a0X+LzmQbYjR1odCYZSdTEbRDJ20TG7abc5QMw/3BaJ03+kvreFvKjX4gOQ="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1776250752; c=relaxed/relaxed;\n\tbh=QWlAgDIfFBc4xf1LMEUMvWW0bV+n2N9iKhM+r0N6yjM=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=DggBaAEiRCJaDrpYg4UXpYzjzGtlJvE0zk1EFBrG78C+CqJ1/y6uGyEObI48ZSgefhIoKcnMnUpA+eGMHpSb1TVdXkq2tFhf3HVCMaitOajpMmjYLa2/sCcWuaexBvLtgupehpQdei7ypRttKIrjElLWaes216FVEyPYOIgkikIdlH0HwIWZXb8AuBUigPHcVnoGV0DqieTx7AXRxsupjcEwNtvGdMUKx6LH1+/3bLbpfRSs4Cc9CEWvPkQggQKGQN9R125BALCvOPwXK2HihfjUiV8nbYQG4fN9jVwGNy4dpiPzyrk4BopMIgwNBkMosDbHH7liJa0fzEaU7oek3g==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776250668; c=relaxed/simple;\n\tbh=QMgA0vjYT1SaSCMl22Tl4PgBTOQAAWQE1b0ZB0vyKAw=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=cP1eYzs2zCN04kcsIc34fccRH/cn/GZczhEEukpvZN//8WhITS7YNpMj6iQlx6+bpPRTO4CZBL0ob3PDkCDwuK8U47ThZBL2dGPGiSTSc8lGegzoNkBe8P78ZgIyMP+CwF6qerhXpI44GAAOKLC21l6L8QPnSyew7Cng+9Z/YS4="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com;\n spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15846-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com;\n spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51"],"From":"Ye Bin <yebin@huaweicloud.com>","To":"tytso@mit.edu,\n\tadilger.kernel@dilger.ca,\n\tlinux-ext4@vger.kernel.org","Cc":"jack@suse.cz","Subject":"[PATCH v2 4/4] ext4: show orphan file inode detail info","Date":"Wed, 15 Apr 2026 18:55:05 +0800","Message-Id":"<20260415105505.342358-5-yebin@huaweicloud.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20260415105505.342358-1-yebin@huaweicloud.com>","References":"<20260415105505.342358-1-yebin@huaweicloud.com>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"_Ch0CgAHtL0fb99pbf70AQ--.45727S8","X-Coremail-Antispam":"1UD129KBjvJXoW3AryfCr1xWrW8KF1DAw45trb_yoWxtrWUpF\n\ts8Kr95Aa1UWas5Wan7XF4UXrn3t3WxK34UJrya93yFvFyYvr17tF18J3WUuF98ArW8Jrn0\n\tgw4jgFWUKF4UZFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDU0xBIdaVrnRJUUUvKb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2\n\t6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV\n\tCq3wA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0\n\trcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267\n\tAKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF\n\twI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2\n\tWlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE\n\tbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV\n\tWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF\n\t67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42\n\tIY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF\n\t0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh\n\tVjvjDU0xZFpf9x07jeVbkUUUUU=","X-CM-SenderInfo":"p1hex046kxt4xhlfz01xgou0bp/","X-Spam-Status":"No, score=-1.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,\n\tSPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"From: Ye Bin <yebin10@huawei.com>\n\nSupport show inode information in orphan file.\n\nSigned-off-by: Ye Bin <yebin10@huawei.com>\n---\n fs/ext4/orphan.c | 179 ++++++++++++++++++++++++++++++++++++++---------\n 1 file changed, 146 insertions(+), 33 deletions(-)","diff":"diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c\nindex 4d6f8c9edaeb..715d04e386d0 100644\n--- a/fs/ext4/orphan.c\n+++ b/fs/ext4/orphan.c\n@@ -680,6 +680,11 @@ int ext4_orphan_file_empty(struct super_block *sb)\n \n struct ext4_proc_orphan {\n \tstruct ext4_inode_info cursor;\n+\tstruct ext4_orphan_info *oi;\n+\tint inodes_per_ob;\n+\tint block_idx;\n+\tint offset;\n+\tbool orphan_file;\n };\n \n static struct inode *ext4_list_next(struct ext4_proc_orphan *s,\n@@ -724,24 +729,94 @@ static struct inode *ext4_list_next(struct ext4_proc_orphan *s,\n \treturn NULL;\n }\n \n+static struct inode *ext4_orphan_file_next(struct ext4_proc_orphan *s,\n+\t\t\t\t\t   struct super_block *sb)\n+{\n+\tstruct inode *inode = NULL;\n+\tstruct ext4_orphan_info *oi = s->oi;\n+\n+\tfor (; s->block_idx < oi->of_blocks; s->block_idx++) {\n+\t\tint idx = s->block_idx;\n+\t\tstruct ext4_orphan_block *binfo = &oi->of_binfo[idx];\n+\t\t__le32 *bdata = (__le32 *)(binfo->ob_bh->b_data);\n+\n+\t\tif (atomic_read(&binfo->ob_free_entries) ==\n+\t\t\t\ts->inodes_per_ob) {\n+\t\t\ts->offset = 0;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tfor (; s->offset < s->inodes_per_ob; s->offset++) {\n+\t\t\tu64 ino = le32_to_cpu(bdata[s->offset]);\n+\n+\t\t\tif (!ino)\n+\t\t\t\tcontinue;\n+\t\t\t/*\n+\t\t\t * Orphan nodes in the running state are those\n+\t\t\t * inodes that are still in use, so here we get\n+\t\t\t * them from the cache if available.\n+\t\t\t */\n+\t\t\tinode = ilookup(sb, ino);\n+\t\t\tif (!inode)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (!ext4_test_inode_state(inode,\n+\t\t\t\t\t\tEXT4_STATE_ORPHAN_FILE)) {\n+\t\t\t\tiput(inode);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\ts->offset++;\n+\t\t\tif (s->offset == s->inodes_per_ob) {\n+\t\t\t\ts->offset = 0;\n+\t\t\t\ts->block_idx++;\n+\t\t\t}\n+\t\t\treturn inode;\n+\t\t}\n+\n+\t\ts->offset = 0;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n static void *ext4_orphan_seq_start(struct seq_file *seq, loff_t *pos)\n {\n \tstruct ext4_proc_orphan *s = seq->private;\n \tstruct super_block *sb = pde_data(file_inode(seq->file));\n \tstruct ext4_sb_info *sbi = EXT4_SB(sb);\n \tstruct list_head *prev;\n+\tvoid *ret;\n \n-\tmutex_lock(&sbi->s_orphan_lock);\n+\tif (!s->orphan_file) {\n+\t\tmutex_lock(&sbi->s_orphan_lock);\n+\t\tif (!*pos)\n+\t\t\tprev = &sbi->s_orphan;\n+\t\telse\n+\t\t\tprev = &s->cursor.i_orphan;\n \n-\tif (!*pos) {\n-\t\tprev = &sbi->s_orphan;\n-\t} else {\n-\t\tprev = &s->cursor.i_orphan;\n-\t\tif (list_empty(prev))\n+\t\t/*\n+\t\t * Here, the code checks whether the linked list is empty\n+\t\t * because when the orphan_file feature is supported, the\n+\t\t * cursor is removed from the linked list after the orphan\n+\t\t * list is traversed. If the orphan_file feature is not\n+\t\t * enabled, calling ext4_orphan_seq_start() again would\n+\t\t * cause an infinite loop.\n+\t\t */\n+\t\tif (!list_empty(prev)) {\n+\t\t\tret = ext4_list_next(s, &sbi->s_orphan, prev);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n+\n+\t\tif (!s->oi)\n \t\t\treturn NULL;\n+\n+\t\tlist_del_init(&s->cursor.i_orphan);\n+\t\tmutex_unlock(&sbi->s_orphan_lock);\n+\t\ts->orphan_file = true;\n \t}\n \n-\treturn ext4_list_next(s, &sbi->s_orphan, prev);\n+\treturn ext4_orphan_file_next(s, sb);\n }\n \n static void *ext4_orphan_seq_next(struct seq_file *seq, void *v, loff_t *pos)\n@@ -750,19 +825,36 @@ static void *ext4_orphan_seq_next(struct seq_file *seq, void *v, loff_t *pos)\n \tstruct ext4_sb_info *sbi = EXT4_SB(sb);\n \tstruct ext4_proc_orphan *s = seq->private;\n \tstruct inode *inode = v;\n+\tvoid *ret;\n \n \t++*pos;\n \n-\t/*\n-\t * To prevent the deadlock caused by orphan node deletion when the\n-\t * last inode reference count is released, the inode reference\n-\t * count needs to be released in the unlocked state.\n-\t */\n-\tmutex_unlock(&sbi->s_orphan_lock);\n-\tiput(inode);\n-\tmutex_lock(&sbi->s_orphan_lock);\n+\tif (!s->orphan_file) {\n+\t\t/*\n+\t\t * To prevent the deadlock caused by orphan node deletion\n+\t\t * when the last inode reference count is released, the\n+\t\t * inode reference count needs to be released in the\n+\t\t * unlocked state.\n+\t\t */\n+\t\tmutex_unlock(&sbi->s_orphan_lock);\n+\t\tiput(inode);\n+\t\tmutex_lock(&sbi->s_orphan_lock);\n+\n+\t\tret = ext4_list_next(s, &sbi->s_orphan,\n+\t\t\t\t     &s->cursor.i_orphan);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\tif (!s->oi)\n+\t\t\treturn NULL;\n+\t\tlist_del_init(&s->cursor.i_orphan);\n+\t\tmutex_unlock(&sbi->s_orphan_lock);\n+\t\ts->orphan_file = true;\n+\t} else {\n+\t\tiput(inode);\n+\t}\n+\n \n-\treturn ext4_list_next(s, &sbi->s_orphan, &s->cursor.i_orphan);\n+\treturn ext4_orphan_file_next(s, sb);\n }\n \n static void ext4_show_filename(struct seq_file *seq, struct inode *inode)\n@@ -811,16 +903,28 @@ static void ext4_orphan_seq_stop(struct seq_file *seq, void *v)\n \tstruct ext4_proc_orphan *s = seq->private;\n \tstruct inode *inode = v;\n \n-\t/*\n-\t * stop() is called when the cache is full, so the traversal\n-\t * position needs to be moved back to the front of the current\n-\t * inode.\n-\t */\n-\tif (v)\n-\t\tlist_move_tail(&s->cursor.i_orphan,\n-\t\t\t       &EXT4_I(inode)->i_orphan);\n+\tif (!s->orphan_file) {\n+\t\t/*\n+\t\t * stop() is called when the cache is full, so the\n+\t\t * traversal position needs to be moved back to the\n+\t\t * front of the current inode. If stop() due to EOF\n+\t\t * then remove cursor from orphan list.\n+\t\t */\n+\t\tif (inode)\n+\t\t\tlist_move_tail(&s->cursor.i_orphan,\n+\t\t\t\t       &EXT4_I(inode)->i_orphan);\n+\t\telse\n+\t\t\tlist_del_init(&s->cursor.i_orphan);\n \n-\tmutex_unlock(&sbi->s_orphan_lock);\n+\t\tmutex_unlock(&sbi->s_orphan_lock);\n+\t} else if (inode) {\n+\t\tif (s->offset) {\n+\t\t\ts->offset--;\n+\t\t} else if (s->block_idx) {\n+\t\t\ts->block_idx--;\n+\t\t\ts->offset = s->inodes_per_ob - 1;\n+\t\t}\n+\t}\n \n \tiput(inode);\n }\n@@ -836,15 +940,21 @@ static int ext4_seq_orphan_open(struct inode *inode, struct file *file)\n {\n \tint rc;\n \tstruct seq_file *m;\n-\tstruct ext4_proc_orphan *private;\n+\tstruct ext4_proc_orphan *s;\n \n \trc = seq_open_private(file, &ext4_orphan_seq_ops,\n \t\t\t      sizeof(struct ext4_proc_orphan));\n \tif (!rc) {\n+\t\tstruct super_block *sb = pde_data(file_inode(file));\n \t\tm = file->private_data;\n-\t\tprivate = m->private;\n-\t\tINIT_LIST_HEAD(&private->cursor.i_orphan);\n-\t\tprivate->cursor.vfs_inode.i_ino = 0;\n+\t\ts = m->private;\n+\t\tINIT_LIST_HEAD(&s->cursor.i_orphan);\n+\t\ts->cursor.vfs_inode.i_ino = 0;\n+\t\ts->orphan_file = 0;\n+\t\tif (ext4_has_feature_orphan_file(sb)) {\n+\t\t\ts->oi = &EXT4_SB(sb)->s_orphan_info;\n+\t\t\ts->inodes_per_ob = ext4_inodes_per_orphan_block(sb);\n+\t\t}\n \t}\n \n \treturn rc;\n@@ -862,11 +972,14 @@ static int ext4_seq_orphan_release(struct inode *inode, struct file *file)\n \t * the entry from the 'pde->pde_openers' list. Therefore, when the\n \t * file is closed, proc_reg_release() will not call close_pdeo()\n \t * again because it cannot find the node on the 'pde->pde_openers'\n-\t * list. This prevents the UAF issue from occurring.\n+\t * list. This prevents the UAF issue from occurring. Maybe, cursor\n+\t * already removed in stop().\n \t */\n-\tmutex_lock(&sbi->s_orphan_lock);\n-\tlist_del(&s->cursor.i_orphan);\n-\tmutex_unlock(&sbi->s_orphan_lock);\n+\tif (!s->orphan_file) {\n+\t\tmutex_lock(&sbi->s_orphan_lock);\n+\t\tlist_del(&s->cursor.i_orphan);\n+\t\tmutex_unlock(&sbi->s_orphan_lock);\n+\t}\n \n \treturn seq_release_private(inode, file);\n }\n","prefixes":["v2","4/4"]}