From patchwork Sat May 21 10:14:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "heming.zhao@suse.com" X-Patchwork-Id: 12857758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc252.phx1.oracleemaildelivery.com (aib29ajc252.phx1.oracleemaildelivery.com [192.29.103.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D46CC433EF for ; Sat, 21 May 2022 10:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=HVq4Atxx4rvn+d+qMoMWcWjIlse/jyN7NxIV1MgqIL4=; b=uFsWbtpFA3BHFVDgrC66SrvTxbUsk3+H9mweMZUItsqc1Z4qTZ0fgCHN7ibxcMzhGU6z22WOzk/J hbt20JdMXOGyyKy/XonFaDzToIlOPVvE+kXVmQOhTGOJYXdt8cChVcBxWSX8Z7rgw3YpxCYtWdvu HTnPntIcrrOVmJ70vTA3/dkIkVhlFrd7DHuCWi/ij3G9enaMt3Xppvs/fvNsYHCiBgq//cxzKh+Z UvhIchRlTMZAoyFbyf/ior0pN+33G1RfEOcdhF2gP8f2n2MLhCfBBZh3OY8xR7H2UjMgaKtCQhkB Wjc7WiRM5DXOojC7X0Wkc5ilI60DFhCsa0YTAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=HVq4Atxx4rvn+d+qMoMWcWjIlse/jyN7NxIV1MgqIL4=; b=cVQ3/RyFRrrWxVrezxMBBdEwYjFnCiAcATvWTpdlH0XFsDiTXZaDufyQ16i87OP5Y7lNKqvc0xOx j8LX6WNn8NUCcjsln+KBSMU7xzTUxYo1+WiRKEtpTgz40AgTa0WVqMxQqIavDOzqIDdVtF+khoNW EIcoZqEjflrFP9jSVRG/uMiOY1FNOQonAYJAmWccetNp2Einh8i+Q4/OsiMI8pCJSFuokqIErZ56 uef8QZdLu8ClWdQ8UryoFPzPOqTuNTpprvmuITtUwZSJLiexfFfXN3WHl2HPYmqtuHSLqCp+wr9o psBJ+Ii1txGWdpMPk3FFKtc8C44EZ+3bUKLW3w== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220413 64bit (built Apr 13 2022)) with ESMTPS id <0RC8005TQ9SQU7B0@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 21 May 2022 10:14:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1653128071; 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=oM3c3SD+f06uAuuWzZm+Y7lk5IAciOy7GKNYczD8edE=; b=nBlYiu6i8IalbUiqZPvlPh6NePiYutx3RPipaq/7QKVONzbxmipkhmAsSyBtHiy+0uFd0o HMT3xNPKgElXhD0/Y3TZ5wI5B0b7q5c7Sj4nnypsFQPDh0zJFRaJ107CWowLbnqGrChBHM xm6SS8aZ0FGqm5Ctlk0PfebMLQeOeuk= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVpqXlfnRT6UrHcEDyyvKLu+g43WfKqLMO5gBnngb0osH733HyuE5Hm033+vg/mgXowyJ5PQ1OVAHp4Sxz7P4tqdF3FYVwP7+/2NMK3gvV/XxdLVwp7kyB+nUfYLU+2n0/7+t1a43H6BlRacXhV7bT54rJUIL/iic1pg3xI+iGmIkyQA59NepwQtfQEfHXPqhYqQ+LVezbj1MnAj4pRBl9fMhfMatYGZt1H1tStd4kHoKQllhs6YTyJYGzVaTRaXdN63uCslDwG9DcnhvXqEDKLBzbNLys8r0wNTQvyn4MQ+U4X+j8OeAgXWEAWRadB/XD6P7vZTDgNPcBsiuo95yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PVoGT7V5+TVxzQa9ZeiOlvjxQriLH60Wh/r2d8qmfV8=; b=AHxBzpbdM/BH2vId1VIGCRBKhXvIYgn2shyi7/VVjOtfhB5iNed8J/O1OquESnwrp8ZpfZRF4I9s7mHCBIB8zwG0vYK9IVUAT65rBBRWgS3XwdT59pGXu0p0dzx1fqa+NXSV1vz4PunjTvrA/yHddS4mliHvSEL8oNp+gKwi/gJ316life8UAdzKzJF90WnnH5+3Fl33RYkcklsmkcmfDR6dP7vO6OA/rk+WyQvNKCSy362UYhEdi0tnykNuK9r/IZXo8zjDHT8XKR33TBnT+L3PcZLLYhaxtytzBxOx/hVWYQ9EQkjkMXCzl9q/mm+o12EIXArNsfmJ3rYFWRz5qQ== ARC-Authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none To: ocfs2-devel@oss.oracle.com, joseph.qi@linux.alibaba.com Date: Sat, 21 May 2022 18:14:15 +0800 Message-id: <20220521101416.29793-1-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 MIME-version: 1.0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB4666.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(66476007)(86362001)(6666004)(38100700002)(508600001)(8676002)(316002)(6486002)(66946007)(66556008)(4326008)(186003)(1076003)(83380400001)(6506007)(2616005)(5660300002)(26005)(6512007)(44832011)(107886003)(36756003)(8936002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 10:14:28.1176 (UTC) X-Source-IP: 194.104.111.102 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10353 signatures=594197 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=616 suspectscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 priorityscore=164 spamscore=0 adultscore=0 mlxscore=0 clxscore=182 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205210062 Subject: [Ocfs2-devel] [PATCH 1/2] ocfs2: fix jbd2 assertion in defragment path X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Heming Zhao via Ocfs2-devel Reply-to: Heming Zhao Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-MC-Unique: GZ833OmZOSu3yOeQnZum_Q-1 X-ClientProxiedBy: TYAPR01CA0203.jpnprd01.prod.outlook.com (2603:1096:404:29::23) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0efa0cde-371b-4b71-403b-08da3b12b037 X-MS-TrafficTypeDiagnostic: AM0PR04MB5556:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bCu7Z4BQy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Q1tr2DUYpw1Loth4fK+Vth2dKg8W4Jxx0Sp7pTdUr4PQd7q6lf8nP8gCtuBWLYCqiozyme0qY6ernGI+0rHtu9VSiKhKJesBu2U7VHowpQAea0qaf//OWKL9r4UtiOSgUJvO9WRbzDhBIN7pToxNiX4YnjFHMDGAetdIMODoSs4lzWYQdjJyuJsb8ud3gcBndM7kHihmFA6zRX1JCREPMdoZzx30G54V2NfpMG/RZrOEwtMQrpXmMcMSocfu/iycSz2j0bK8Z6sR1Sffl54EgA== X-MS-Exchange-CrossTenant-Network-Message-Id: 0efa0cde-371b-4b71-403b-08da3b12b037 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4666.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eAm7PfeOLsgRSeKYs7K2sguNe4/jqNp/de+W3avEAedR68oUQYUiE/MBoQLsmPhWLNCooY4v42F0esPS1XAQkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5556 X-ServerName: de-smtp-delivery-102.mimecast.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.suse.com include:de._netblocks.mimecast.com include:amazonses.com include:spf.protection.outlook.com include:_spf.qemailserver.com include:_spf.salesforce.com -all X-Spam: Clean X-Proofpoint-GUID: YqEXcbzkSsGBN-yRAopauqOr1I3VcFw9 X-Proofpoint-ORIG-GUID: YqEXcbzkSsGBN-yRAopauqOr1I3VcFw9 Reporting-Meta: AAHthZZ52wL+yu2fQ0N/tucFbWh65VhVcC5mxnxcuG8CdqwKCaiW0GHbmCkFtv6v xR9VjofiWWJNg5Hup8jazTnNvLxxmnL6tPhybbRv/nXeGIOYO3Ofglm8IH9YW87J x8/YrsU0XhTe345ndhj8hOjbvfhVDLZ7HfgNDN8JAyDSbG1hfO5Svl/RHQ+eduvC pkxj/uOmNj0zaBwGnX04gNPWH4NdhZJNCeWfONjggNY/bSKRZtcMM1uCBhcBRxj3 Z9SzWAKxzg9Hfr36EbSLZBLj5zs/Sbn7pJzj/zUkfjQXmOjL9/CrLi0o8KhlwhlL 4i6udLezGjoNG+bYZZGbfc2Cf6qSxeRKO/9QuTQE8k69m0onvuDTdUXUhZzzSGG4 qacSosMuLWzZ4NbxVVPNrfT9q0cKHC1zS9Om8D4RAvMlHFzBcg1qrT2B3xM026Ii nyui5GhyoCye7qtT3CW56H5UpMn5RAKvmxtukKMgs7kdwiHXrU1FlwMn0HXy0Wjn kn1eu6vOWIukiwKZbYkvhjXRgnWtuUSMeWhHtdN7W8/PoA== defragfs triggered jbd2 report ASSERT when working. code path: ocfs2_ioctl_move_extents ocfs2_move_extents __ocfs2_move_extents_range ocfs2_defrag_extent __ocfs2_move_extent + ocfs2_journal_access_di + ocfs2_split_extent //[1] + ocfs2_journal_dirty //crash [1]: ocfs2_split_extent called ocfs2_extend_trans, which committed dirty buffers then restarted the transaction. The changed transaction triggered jbd2 ASSERT. crash stacks: PID: 11297 TASK: ffff974a676dcd00 CPU: 67 COMMAND: "defragfs.ocfs2" #0 [ffffb25d8dad3900] machine_kexec at ffffffff8386fe01 #1 [ffffb25d8dad3958] __crash_kexec at ffffffff8395959d #2 [ffffb25d8dad3a20] crash_kexec at ffffffff8395a45d #3 [ffffb25d8dad3a38] oops_end at ffffffff83836d3f #4 [ffffb25d8dad3a58] do_trap at ffffffff83833205 #5 [ffffb25d8dad3aa0] do_invalid_op at ffffffff83833aa6 #6 [ffffb25d8dad3ac0] invalid_op at ffffffff84200d18 [exception RIP: jbd2_journal_dirty_metadata+0x2ba] RIP: ffffffffc09ca54a RSP: ffffb25d8dad3b70 RFLAGS: 00010207 RAX: 0000000000000000 RBX: ffff9706eedc5248 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff97337029ea28 RDI: ffff9706eedc5250 RBP: ffff9703c3520200 R8: 000000000f46b0b2 R9: 0000000000000000 R10: 0000000000000001 R11: 00000001000000fe R12: ffff97337029ea28 R13: 0000000000000000 R14: ffff9703de59bf60 R15: ffff9706eedc5250 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #7 [ffffb25d8dad3ba8] ocfs2_journal_dirty at ffffffffc137fb95 [ocfs2] #8 [ffffb25d8dad3be8] __ocfs2_move_extent at ffffffffc139a950 [ocfs2] #9 [ffffb25d8dad3c80] ocfs2_defrag_extent at ffffffffc139b2d2 [ocfs2] The fix method is simple, ocfs2_split_extent includes three paths. all the paths already have journal access/dirty pair. We only need to remove journal access/dirty from __ocfs2_move_extent. Signed-off-by: Heming Zhao --- fs/ocfs2/move_extents.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index 192cad0662d8..6251748c695b 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -105,14 +105,6 @@ static int __ocfs2_move_extent(handle_t *handle, */ replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED; - ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), - context->et.et_root_bh, - OCFS2_JOURNAL_ACCESS_WRITE); - if (ret) { - mlog_errno(ret); - goto out; - } - ret = ocfs2_split_extent(handle, &context->et, path, index, &replace_rec, context->meta_ac, &context->dealloc); @@ -121,8 +113,6 @@ static int __ocfs2_move_extent(handle_t *handle, goto out; } - ocfs2_journal_dirty(handle, context->et.et_root_bh); - context->new_phys_cpos = new_p_cpos; /* From patchwork Sat May 21 10:14:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "heming.zhao@suse.com" X-Patchwork-Id: 12857759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc249.phx1.oracleemaildelivery.com (aib29ajc249.phx1.oracleemaildelivery.com [192.29.103.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 705D1C433F5 for ; Sat, 21 May 2022 10:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=lRxdgetcag4COer2eANwTXhd4G9pPbTLXlF7vtlLLP4=; b=YU9XUQiS/2hUqxlpq9zl2MFgcoPHHr+pv9ppwBL7PGINeRZMkpKKdIdgWATRazgKKZxXeNF5sTud tN5YqdVhOCK98MXFUKmjSwA8esQuYLmPQw31q0Bu2ngRN82oGFPBdnx0FkOvQzfy5XlAIl/uJkig DK+zuFyjvXUzwXXKRwHIVtVu5dBFkJFp4UHHtdtrtxhFuj9FPnTeW6mtE90IUQh38+kPbIs7Slvb CLkkiskj1ejtjNq75I6jAiueoSlA4BUrrLL/b0N6zhVrlcjWFYAcn8ZhwPfi9mwYeTFG5GamgT1b BVrk1+Ao6e72iKJ3Q0slDD0WTKVhuAfsTbPZfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=lRxdgetcag4COer2eANwTXhd4G9pPbTLXlF7vtlLLP4=; b=Nzl8/yr/FY9tCAWGUVs2SZ5YRlNZeb3EdJOpNPjfd8LC/yn/9JHn3PXLeLTCSBMbY68fcgi4anPx lPGgdy5OW+xS0F27rd4m/XdYTG9cLIbLMuIa/hld6WhalJb13C8NaBvtXGl46rDwDna9g0rBS4mx ykdcafXxDE3xkhF4kUFRxmYTVZs+Tj9jR3+LLEiqKsHBn7tPBb85DJVM6+cL0QSDL9iSQxnZuMYw Eq348UWUjiXpqPcb2wVQo6YPm/ARAAQIAXl/5In8++DQNvu5eO2AspMLv0dUf4wNjsAGDFyR7i1R r4YlDOxAFTGma5Vv/HLYIdZwknww4T/tJw+JWA== Received: by omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220413 64bit (built Apr 13 2022)) with ESMTPS id <0RC800KGC9SQMS20@omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 21 May 2022 10:14:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1653128077; 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: in-reply-to:in-reply-to:references:references; bh=AwWuPlc+Ovm81Wj4q0BFfvQsfDt+azsvN4ToAucNzTM=; b=VHMDoUrCzygpBu0CR8ZU5y0bgMyPB0/X7GZZ6ZTtCeOq/PwvnD5aVJzoZUab1f5xloxb64 nrnvCpkQo0KB1+jqIoXMmgnuHBPErqyC2ayhAH5RRJ7KuN4byZcKptogv+E3jghunrJb3I 0qg5C1JDVnn5I+DUNtpe9+cztugLghs= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YIpzdf/l6o/NjHceTk6m5y3V6CEidArxE0K/tTlWT8X7Y3AFrtquDCZgjkGNkfdXqknzp+Wocia5uzKyBy9lABUkpsI051xz4jQArre6f+kL3hB3AkdTviXAqANvPBVSw9YbBuRAnxN3CD5GuG9iMKDvjczyBQdE4JzF3dr67gkdEPhh3Rc/Os+fYRNFPMHtakGKtdaK3CoIXE4eVO8KLZiHYfTr+3ZQ/r3O1OsD/UocgcK25rEyhZOI86nROHx91NntmkP0+eiImQSXPFOreycZvBGiK8hBfgmC5FzfvW8DaugCRcy5uAA/GKaxEcwbAs+4tfD652UCH084vgmfEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Mm2FGWGMjIbeKYaV1hx6Z8t+ZZPIyg2NqGcBbWlxrLs=; b=ZuET6hnXXrkb3iA07zoGldzQHzZc3NBdtqbOUck0rIe/jLKNPHBlUMV2FwG0isJt6wMlnPQjNvjWE6+DJH7o1pIkhkrtQuCz82IgOCZX/K8naMbB8zKOvyiyivQEfuSwS437M3sHrZK8ZgwLR+dQDyzY1r4rpEktvSq6RX0TGzcLJ5n6FF9s/B4LXjhq4PdzHuWywI97rvZVlyU7BholurQMYwW7d0ZasekYYfsbd96M1PVzrmGLN7TsmzcTK0rsxlxpRZGqBEpWpIpT33B9OcuB6gYzAEQM3F+0q1nOSIQdYeKqP8Bqi8fF8MYKkoRpq3nbHGu6OBcAZurKnNYgRQ== ARC-Authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none To: ocfs2-devel@oss.oracle.com, joseph.qi@linux.alibaba.com Date: Sat, 21 May 2022 18:14:16 +0800 Message-id: <20220521101416.29793-2-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220521101416.29793-1-heming.zhao@suse.com> References: <20220521101416.29793-1-heming.zhao@suse.com> MIME-version: 1.0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB4666.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(66476007)(86362001)(6666004)(38100700002)(508600001)(8676002)(316002)(6486002)(66946007)(66556008)(4326008)(186003)(1076003)(83380400001)(6506007)(2616005)(5660300002)(26005)(6512007)(44832011)(107886003)(36756003)(8936002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 10:14:34.8514 (UTC) X-Source-IP: 194.104.111.102 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10353 signatures=594197 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=999 priorityscore=128 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 impostorscore=0 mlxscore=0 adultscore=0 bulkscore=0 clxscore=228 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205210062 Subject: [Ocfs2-devel] [PATCH 2/2] ocfs2: fix for local alloc window restore unconditionally X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Heming Zhao via Ocfs2-devel Reply-to: Heming Zhao Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-MC-Unique: oOxrmcXyP_uUYLdwuDEbNQ-1 X-ClientProxiedBy: TYAPR01CA0203.jpnprd01.prod.outlook.com (2603:1096:404:29::23) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1043194-d76d-4723-fd38-08da3b12b435 X-MS-TrafficTypeDiagnostic: AM0PR04MB5556:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r6GtAfW/s4hmW40YVSiJmzMZor8Dg6Ht8CXXJpHRr/jRISpOj7Z5P7EWdCOCk5bxPpczLDkEjGSKnrn6DwdCGCIUy0hxPtecCXXHHmr3gyPkgyvWkr+7TxAPUYk49JjUlSkxLjqOpDBALsDg5C3J+/CmldJeAfl0fOQxEeF384FUq7hmmmYhfJsSruTX+npnzocZRnYXyvIbFuP4ntsfYpDVU4RY/ZH+quuS1lt0UoDKEOeIjZg947Io1grU6bbscbZYqf2TbP8F8pDCVPLx/3CTdqhcWjQgGh0Kbz04BybM0wWhczluDB5wNPzE3yaU+PoqzVKtZfE4YGeuSsxcQHNxnRem5mzNOwX6l08zXaOnDTFZPDHuyfj0JKnmSe5ddRas2xP6nWzjQYEpOZF67H2QYPhOLXSDwAcTwb3JijsKAKDgLu4p48XHkyYheB24140mWCSA+AJmtP5u1ZfuMGu5UeW2VNZ3fdNpj8BMF6wc9Y65rNiKcVjuTlhU1oNcXkwSp+nQP4mWw4bDhzW8XfEZaA0Cro23ytOQL4ZsFuavk/ymsoRom17fDo4hUQLKxuWzWWOCsK2aRr5rMoJhC+KAxzBWVrIwFfU4ODgA/KaTxFzPJvQXUf6qnWuuudRLdprKMF+0KAkirE83mnM5cw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e5ORUmKuCv5s6iG449neA0VPEIbY1XNXOFu6QNz3PylShxYmErcSTyo6wrRV9yPW+ZfIVP+ZfKZHHADfWY/CcELIlO6qp3c3ebriQQXzxINARTGhr/cG6JypWq93lb/eMsewaxJO7gAwNDIjAGtJrlO7o5yQxHLOKjqgzVcYHElXOa01iaTp6Pns0mySTe9URL6s89rhSmnBQfghO+MOeAWJ8UVqXvczOsTLK95zHcPi5ftssQfRHBlemysWilpJo2aO7qfMWDAafwRP9DISvyESRq5K6e/8FK1fE5zhJOrCOuhkQR64juJxWg80KkJQsBpUk14tLZkV9Yb5i2uwXxbH9O6vZV4056OCKzYBE4wGg8WVZ+OpBUy0I0gM/aBacgvRJaw351UuTfaSgWp72rZWE/RkHwliqL7NO9ssqHWJz8yPMv3M6hSqmBXrGLh+mhOoCWrVTilq/6UUS5Cem7CO8WIK23cLPGdrTC386OB++P5TFm15w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LEnhqx8gwzrTE9Q9rBqrEH5qj7nfXGeLSY/AdRU6n/jj+WO1tyaUKNZENzZKfzPoz7KZvUTD0Mdmf5u+kAhfomAaIYji8wNyjT8JHoo8FEzjJZihaeafwVW5oZCXTvEQQ7VYq7ZBoYw63jSL/ThRbvnnmng== X-MS-Exchange-CrossTenant-Network-Message-Id: e1043194-d76d-4723-fd38-08da3b12b435 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4666.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jVAmx1FEBMn/yIlvNM5xHfBf9WjLhL8It9KnckNj0UraPMe8PYyO3+NlicWxoQUz6teMiQ6kKsUkLOJky0d9hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5556 X-ServerName: de-smtp-delivery-102.mimecast.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.suse.com include:de._netblocks.mimecast.com include:amazonses.com include:spf.protection.outlook.com include:_spf.qemailserver.com include:_spf.salesforce.com -all X-Spam: Clean X-Proofpoint-GUID: ZjhDNrzDtcZSiSa70PwotrvH4UaF1eBV X-Proofpoint-ORIG-GUID: ZjhDNrzDtcZSiSa70PwotrvH4UaF1eBV Reporting-Meta: AAFDFthjS9xoi2LsSMHTuYz1IZ5Mwx8Z4+c8jtfMitFYJeo2ktN921Gj16wjypI/ sjNZ8H8sktuESHBcAwOmo6L9Nyk5qG8PYz8BrumW/HMzVNwMYfrepQvd2dNJQmcL kehSimp5qGxPZ9jJzmsoMMqXfwstR7KkElogO0KVGv7zlI7Ld9XCJy3N94B8+QN1 y4GeUTvFR7h63+qgig+JAxNX9oOPrgGFvStxOmclkq2GL1dP11dbeD6SlUqFaS1L OzlJmRcivtA6iSS0n1sAT5u33JLYNRPTgDfNzd7AELkBciORv5zfAxO94ghOEn64 8yRzRUTtBdFphBQKBm9TGznaCymOzAff2uV+6M5DeNkyT06tdgRVtMaf7MoBWJif vR8RTyo9CrJEKwR5vRUac5DDnK+OjpXiumGat+PgEE1sFLgbrR5xryrpgVVhSjIn 16cX636XA5MhMwwAvxpmFKqxGPSh/xQ5qZjNbEW5R6Mw32v6VT3AJzB8nIRtKCYp bG3OC27te+LvgjJPoJey+3ot4dN4wpbaVnVfk9CY3pDsUA== When la state is ENABLE, ocfs2_recalc_la_window restores la window unconditionally. The logic is wrong. Let's image below path. 1. la state (->local_alloc_state) is set THROTTLED or DISABLED. 2. About 30s (OCFS2_LA_ENABLE_INTERVAL), delayed work is triggered, ocfs2_la_enable_worker set la state to ENABLED directly. 3. a write IOs thread run: ``` ocfs2_write_begin ... ocfs2_lock_allocators ocfs2_reserve_clusters ocfs2_reserve_clusters_with_limit ocfs2_reserve_local_alloc_bits ocfs2_local_alloc_slide_window // [1] + ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE) // [2] + ... + ocfs2_local_alloc_new_window ocfs2_claim_clusters // [3] ``` [1]: will be called when la window bits used up. [2]: under la state is ENABLED (eg OCFS2_LA_ENABLE_INTERVAL delayed work happened), it unconditionally restores la window to default value. [3]: will use default la window size to search clusters. IMO the timing is O(n^4). The timing O(n^4) will cost huge time to scan global bitmap. It makes write IOs (eg user space 'dd') become dramatically slow. i.e. an ocfs2 partition size: 1.45TB, cluster size: 4KB, la window default size: 106MB. The partition is fragmentation by creating & deleting huge mount of small file. the timing should be (the number got from real world): - la window size change order (size: MB): 106, 53, 26.5, 13, 6.5, 3.25, 1.6, 0.8 only 0.8MB succeed, 0.8MB also triggers la window to disable. ocfs2_local_alloc_new_window retries 8 times, first 7 times totally runs in worst case. - group chain number: 242 ocfs2_claim_suballoc_bits calls for-loop 242 times - each chain has 49 block group ocfs2_search_chain calls while-loop 49 times - each bg has 32256 blocks ocfs2_block_group_find_clear_bits calls while-loop for 32256 bits. for ocfs2_find_next_zero_bit uses ffz() to find zero bit, let's use (32256/64) for timing calucation. So the loop times: 7*242*49*(32256/64) = 41835024 (~42 million times) In the worst case, user space writes 100MB data will trigger 42M scanning times, and if the write can't finish within 30s (OCFS2_LA_ENABLE_INTERVAL), the write IO will suffer another 42M scanning times. It makes the ocfs2 partition keep pool performance all the time. The fix method: 1. la restores double la size once. current code logic decrease la window with half size once, but directly restores default_bits one time. It bounces the la window between '<1M' and default_bits. This patch makes restoring process more smoothly. eg. la default window is 106MB, current la window is 13MB. when there is a free action to release one block group space, la should roll back la size to 26MB (by 13*2). if there are many free actions to release many block group space, la will smoothly roll back to default window (106MB). 2. introduced a new state: OCFS2_LA_RESTORE. Current code uses OCFS2_LA_ENABLED to mark a new big space available. the state overwrite OCFS2_LA_THROTTLED, it makes la window forget it's already in throttled status. '->local_alloc_state' should keep OCFS2_LA_THROTTLED until la window restore to default_bits. Signed-off-by: Heming Zhao --- fs/ocfs2/localalloc.c | 30 +++++++++++++++++++++--------- fs/ocfs2/ocfs2.h | 18 +++++++++++------- fs/ocfs2/suballoc.c | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index c4426d12a2ad..28acea717d7f 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -205,20 +205,21 @@ void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb) static inline int ocfs2_la_state_enabled(struct ocfs2_super *osb) { - return (osb->local_alloc_state == OCFS2_LA_THROTTLED || - osb->local_alloc_state == OCFS2_LA_ENABLED); + return osb->local_alloc_state & OCFS2_LA_ACTIVE; } void ocfs2_local_alloc_seen_free_bits(struct ocfs2_super *osb, unsigned int num_clusters) { spin_lock(&osb->osb_lock); - if (osb->local_alloc_state == OCFS2_LA_DISABLED || - osb->local_alloc_state == OCFS2_LA_THROTTLED) + if (osb->local_alloc_state & (OCFS2_LA_DISABLED | + OCFS2_LA_THROTTLED | OCFS2_LA_RESTORE)) { if (num_clusters >= osb->local_alloc_default_bits) { cancel_delayed_work(&osb->la_enable_wq); - osb->local_alloc_state = OCFS2_LA_ENABLED; + osb->local_alloc_state &= ~OCFS2_LA_DISABLED; + osb->local_alloc_state |= OCFS2_LA_RESTORE; } + } spin_unlock(&osb->osb_lock); } @@ -228,7 +229,10 @@ void ocfs2_la_enable_worker(struct work_struct *work) container_of(work, struct ocfs2_super, la_enable_wq.work); spin_lock(&osb->osb_lock); - osb->local_alloc_state = OCFS2_LA_ENABLED; + if (osb->local_alloc_state & OCFS2_LA_DISABLED) { + osb->local_alloc_state &= ~OCFS2_LA_DISABLED; + osb->local_alloc_state |= OCFS2_LA_ENABLED; + } spin_unlock(&osb->osb_lock); } @@ -1067,7 +1071,7 @@ static int ocfs2_recalc_la_window(struct ocfs2_super *osb, * reason to assume the bitmap situation might * have changed. */ - osb->local_alloc_state = OCFS2_LA_THROTTLED; + osb->local_alloc_state |= OCFS2_LA_THROTTLED; osb->local_alloc_bits = bits; } else { osb->local_alloc_state = OCFS2_LA_DISABLED; @@ -1083,8 +1087,16 @@ static int ocfs2_recalc_la_window(struct ocfs2_super *osb, * risk bouncing around the global bitmap during periods of * low space. */ - if (osb->local_alloc_state != OCFS2_LA_THROTTLED) - osb->local_alloc_bits = osb->local_alloc_default_bits; + if (osb->local_alloc_state & OCFS2_LA_RESTORE) { + bits = osb->local_alloc_bits * 2; + if (bits > osb->local_alloc_default_bits) { + osb->local_alloc_bits = osb->local_alloc_default_bits; + osb->local_alloc_state = OCFS2_LA_ENABLED; + } else { + /* keep RESTORE state & set new bits */ + osb->local_alloc_bits = bits; + } + } out_unlock: state = osb->local_alloc_state; diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 337527571461..1764077e3229 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -245,14 +245,18 @@ struct ocfs2_alloc_stats enum ocfs2_local_alloc_state { - OCFS2_LA_UNUSED = 0, /* Local alloc will never be used for - * this mountpoint. */ - OCFS2_LA_ENABLED, /* Local alloc is in use. */ - OCFS2_LA_THROTTLED, /* Local alloc is in use, but number - * of bits has been reduced. */ - OCFS2_LA_DISABLED /* Local alloc has temporarily been - * disabled. */ + /* Local alloc will never be used for this mountpoint. */ + OCFS2_LA_UNUSED = 1 << 0, + /* Local alloc is in use. */ + OCFS2_LA_ENABLED = 1 << 1, + /* Local alloc is in use, but number of bits has been reduced. */ + OCFS2_LA_THROTTLED = 1 << 2, + /* In throttle state, Local alloc meets contig big space. */ + OCFS2_LA_RESTORE = 1 << 3, + /* Local alloc has temporarily been disabled. */ + OCFS2_LA_DISABLED = 1 << 4, }; +#define OCFS2_LA_ACTIVE (OCFS2_LA_ENABLED | OCFS2_LA_THROTTLED | OCFS2_LA_RESTORE) enum ocfs2_mount_options { diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 166c8918c825..b0df1ab2d6dd 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1530,7 +1530,7 @@ static int ocfs2_cluster_group_search(struct inode *inode, * of bits. */ if (min_bits <= res->sr_bits) search = 0; /* success */ - else if (res->sr_bits) { + if (res->sr_bits) { /* * Don't show bits which we'll be returning * for allocation to the local alloc bitmap.