From patchwork Sat Jul 30 01:14:08 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: 12932856 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 EABD5C00144 for ; Sat, 30 Jul 2022 01:15:13 +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=DFKwk/zZo7EoZDlgVhbo24GfvYX+BUgRQ6NWuC5jae4=; b=r2vd4IPkjXwH34eDi/ZeYrePEuXY+dPJYBC+kHPCns+X3JcSiE1mcj/NftVUhJGtEr3kTsS8CW02 3dpPu5UBp2LyIllmwwANBj537HDaLmyoM3lFVqTPPhN9c0ILgy8nXkJhhAHLX/Mwtm72FndYGhms 0q8nGNHRgc5LbTzr1ET5M1DjhU+mE3AwYWYL5q4gSns9Pt6XCktZcGbjpGiPdDaEvBpLVXZsXhcY AzA6qzIfxRDfoF8VnsNYbeddrymL8JCCwGY37OOR4WlL+rkg6wr2xgvD3qept+0J7ZV4iVzdgJAY yKech/341Ux3fQ3ZgFYrNAQVLZD+xFRE1wgxLg== 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=DFKwk/zZo7EoZDlgVhbo24GfvYX+BUgRQ6NWuC5jae4=; b=Dnpd75BoyfO1X+c0LaIGmRKYCnjRuA7LOmTatLhDyJ2PubgSDgoXeAO75s7Vc0GLakE5pjhLwvdv UIYdu4XKtwLiK9kVpH0dWNJmtMdZJoSSDDMgIe+vF4qPn7X3lXvDaiCFYa0bU7xqzdVgvVKBn7bz yAdUv2s2ksYwjZqwkYa0SuiuDi6pEfqQs6un6B8IPUMxnXw+4DInRjDheY7NkDVd7uIQzaaYbg2t KPuuZPMlX3TflDBqfeSZr5LbaPiCYB40KyDor0prplSCtnWjL7FyS2qPcz1YUYdTYqo03oGnkr/R fDHwY2tThlSb8R/DO7hwcqqIdrimWYwYFs1a9w== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220621 64bit (built Jun 21 2022)) with ESMTPS id <0RFT00CDS7HDQE10@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 30 Jul 2022 01:15:13 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SkU/rtGkJDSMy1C5dAEjpDBzQO3elzrcTJm5MY/EN4HF/AKmo5M00oLQhFkF1rtSFAFLGMYdh5tJ4TEsQxZvYptPsdxjcta81B0bmPJhKKyVtULcpn6ZvuuRSYYriioXgmfV9vEKW/tI72vN8O6n6Mh4geIoMQukYAuoD+5FzGGX7LkDVX4B4tIait04em+xu9koHOEPhf7ZEZdAg71VgN9YMWb6Ie6MjAAFKyv32KlI1f0eIyVSjX0g4kfYbLWMM99ctRtVr21+qAxW/gX070jumIgf3dK7NpXftq6iT/HK3G76MD1zU5BZkd5577ofiuKWAW85Q1tNQLmltGxzfw== 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=9kQN82qkD64NVy4vaY1Km1PQQDgXtKTIcRmnSUVpf04=; b=epkuMZxis80wAkx3fjdPYbJlL/SDdQknWtuARca01JrjTThVQSc6x5i/I33STW9Wnof2xkoOf0mXTOexnqX/ZNb+bAcjkYdsBcMM9qNcyoHZCdRoZptqG7DtdG+Al4aIzyl0wi1q1fAkujEedY+EuB3aSyhMz9BAoX+Ax/2OBCC8dj94u6lAJASTQhdgig/GKIBsvO3WOo/2aJqTPrURbt9AB1nMQDPaiRg3nUYMjeXVwsszB2L8N9RHt5NW0DFrT0yH5Hl9PIRtjPBubZ2D9796Er5iU+W4GCY/gj1oVuMD9qSjJuPGJWoH8BRY9g+JXsSgYFawt29LEy8xvP8PTA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9kQN82qkD64NVy4vaY1Km1PQQDgXtKTIcRmnSUVpf04=; b=sjDOJXztbU94L482JlM45levzQhIAqM/2JDy55BxYbEhGzv6I7UQvVvE2SQMxuC+Gq+wZ+4ow7Q3dP3zw4MCVZpHTPx7NIAIY2buhR8IeKOy+aTtmOJkO2tlkB+bMbeUsvuUQ9PBRo1n2eWOJGp1iEuGwESkrmq0j4z/ZBPSfla4NPY6haSemI7BL03L5aR3PhmGqRLT1ED+t3yLgWbpuJpE7T3taptQ9k0PH9hc3wGDCkuGQm9o92+2JyYERfOd62/nfYsmR63M+XLzPNyRoZlpCwWI3lqgm3v46T1Lm8yhaiFrHmIy+TTMXv217+XC44JhWt602OsChWW4U076FA== To: ocfs2-devel@oss.oracle.com, joseph.qi@linux.alibaba.com Date: Sat, 30 Jul 2022 09:14:08 +0800 Message-id: <20220730011411.11214-2-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220730011411.11214-1-heming.zhao@suse.com> References: <20220730011411.11214-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:AM6PR04MB4662.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(39860400002)(376002)(136003)(346002)(38100700002)(41300700001)(5660300002)(8936002)(66946007)(478600001)(83380400001)(66556008)(8676002)(316002)(4326008)(66476007)(6486002)(2616005)(1076003)(186003)(6666004)(6506007)(26005)(6512007)(2906002)(44832011)(86362001)(4744005)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 01:14:52.9491 (UTC) X-Source-IP: 40.107.1.63 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10423 signatures=596356 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=768 spamscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 adultscore=0 clxscore=243 priorityscore=136 suspectscore=0 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207300005 Subject: [Ocfs2-devel] [PATCH 1/4] ocfs2: Fix freeing uninitialized resource on ocfs2_dlm_shutdown 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-ClientProxiedBy: SI2PR02CA0001.apcprd02.prod.outlook.com (2603:1096:4:194::10) To AM6PR04MB4662.eurprd04.prod.outlook.com (2603:10a6:20b:1b::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4da20fdf-41a6-472d-7796-08da71c8e828 X-MS-TrafficTypeDiagnostic: AM6PR04MB4840:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c76Zv51icaieKee4IYwURt0fosKCJR9M5hju4Xm4j4pf14Ht+IOWurHIqf9jas/tIDctFzOobz6eJg/qoj9/A7W8oGHwYX3S4VVjHlLQ21a5SKz5LARW3lw7TDLljjy1Mn33Fz8nnErOFlU07kiNZOnNtOG8SCaAOQiD/mT1uXhtI+ZI7/gYESgdJLGBAZvkyQCcJMie0bbt+jz0f2leWhlV3tyH/rVWB3w9eWdz3kZUhwJp4yq3wxo0hZjakFzT7yBcbsQzjkLqmzaaQI1wuOmcPaRHu0azpmW0HKP2zEibljU9T42xqdm89BynKbfP/QuHqqKmRLsC246XTK9b1uUd55dH6uoSwMgs3cj+OkiEJeaxRycS9dA8jbu7EWjKhqSgnrdGzTmLKLfCIlWQDHeIVJjDB7ckV7bt6P2dPZbm6EVCbBqozfpzcOgc+J8rIG0awjfo/JzOvgyUXeVSVaSHotdEygvIvYY3oEXH2BScU9cpZGCKav4SGV9B9LWqaYS178tca48+W7rLt28HeuM65cc0yar6afdWzhX0gA6GVy0lg1nr0lTLEFv1svShfgONc4jf2Eg/jp/p9d7pTE1FY/M47qrp/PBUY4iwr2Hehjtq3iT8L6hgkQZyCCPyg99Zo33H+VFUWpt10L5KNjb6MyUlIiPLX1rYYrgcSAXIt0XqJqwbSIcGAuSuxkgP11qwcIFSLhev0tyIBGi8s9lPVGlkmZj3rpLKGrUFf/OpJC4kRJrU05d9OAIfqm9a X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qh4rqHCCPuw6HZLTyejPOfB/izGpphcDNVUlI8+Bcq/kHwoakThIayROfWdD0v1+m0iWxutGWh3A+kYGEC4KIb3zXDC1G1rIXiaWZS3UWv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IQ+GrLgWwaM8xfccuPZ4Hje6MKFe7kYK5bqY1tSsbIegCwgD9KB3OqLSnz0pFk3tSPtGhhKQuYRri/jAOiZ3B+J9owVHsb7st9OC7nIIMHPB5D3ydCK6lJPyAytwLla3eOug21lQ6nQwBxVUr0m+yborSYER4eNq1YVWxVjdlTTqopUkEan3QhzzhrjskGyQszAzRCX8NtSpZrXWQwV+sQsxW4st9WI/djs5NRY2W2SdAg5/k3NygCDE2YHn8SnUPWy6otHwjSY6kdZK2oRLkhO8sDxlsiebX03NV+zNGDxS0xegnj1sziGiIQVKE5hkSW7+b4FPAKz6kpw2Iqr0y/WmJ1m95/0WzlUMEBaysE4/cIsIvrWqxq7IK32uj2wdLNXh/M2Uga9pwBp0ZP2hCsKUIFmqixfyMTlw9 X-MS-Exchange-CrossTenant-Network-Message-Id: 4da20fdf-41a6-472d-7796-08da71c8e828 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4662.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: 27iKvAS6m9qV+MGTHp0NxuBAUbyVrdulSPmymUQXLlIAzjqR/N2XgOojqFeCZ0I1maQB5mgLX4XwAiBUl3KGOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4840 X-ServerName: mail-eopbgr10063.outbound.protection.outlook.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.suse.com include:amazonses.com include:spf.protection.outlook.com include:_spf.qemailserver.com include:_spf.salesforce.com -all X-Spam: Clean X-Proofpoint-GUID: -qcCBBxQ0jY8zIG9JsOTjdwE9RRy_LHY X-Proofpoint-ORIG-GUID: -qcCBBxQ0jY8zIG9JsOTjdwE9RRy_LHY Reporting-Meta: AAE6QCW4jA13R4dKotUifuiEypCDC9h+J1uAefMF4sueB3OfoH+28MM5zXtB2GvU 1heXzZ6kUKZXHTKTzsXBAny/TgGJLIeWyRJudf+xWGFrk7WcqtEcYoVjUKzpaRwh E7oqCwsOKe/abC0j5/7uHtvgnCEuO1G9YHdeJpQS30zRf3NJiets1E7Hm8Fck9NF jay4rs8MRsjw1wKe7r2zMp+rBkJGtvNpT64jZU3I1uXzgplKvFHdThhSYV83WCiK HxpP/RSg2j10XSnJhfzkV1Vdo7U03Vlfe4qq9lcKFDSz8llCEG6R2If2iFUKU2em fNuSsig4tDJxgYe2AREy0S2XXwwBbxci2+0PlIxJ+gcSEcfoUieYsDs46s0SSqlJ IGC6B05T1gABXdwcUUwEJJcHorBYEjc+aclLStKS9r0UuuVz+cTdpzLW2GLiUbfb y0RL1NOEtpW6OODaUf/DtU3kwmlOkovw8MFIV0XdB9y/KJLXqicSSL3vDeYl9OT7 Q50B/g+9sN2hK8ZD12lF7xlDfOK66o2XhP9jgerQnbU= On local mount mode, there is no dlm resource initalized. If ocfs2_mount_volume() fails in ocfs2_find_slot(), error handling flow will call ocfs2_dlm_shutdown(), then does dlm resource cleanup job, which will trigger kernel crash. Fixes: 0737e01de9c4 ("ocfs2: ocfs2_mount_volume does cleanup job before return error") Signed-off-by: Heming Zhao --- fs/ocfs2/dlmglue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 801e60bab955..1438ac14940b 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -3385,6 +3385,9 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) void ocfs2_dlm_shutdown(struct ocfs2_super *osb, int hangup_pending) { + if (ocfs2_mount_local(osb)) + return; + ocfs2_drop_osb_locks(osb); /* From patchwork Sat Jul 30 01:14:09 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: 12932857 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 aib29ajc255.phx1.oracleemaildelivery.com (aib29ajc255.phx1.oracleemaildelivery.com [192.29.103.255]) (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 1D62EC00144 for ; Sat, 30 Jul 2022 01:15:34 +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=A7B23MmhUdbvrioWgomQce/q/No5tWnC88HYKHebeLw=; b=m9/gcwhSW4jW49rtypEhCMJvr6qeaRlU+5paTWukGRW6Ihp/wGcDIuE16XcrNHkJjRbjxMbhpoXz vvP43dGOayhus+0uL3BauYmiS0FGOsEAXdUZT8tBDfImIu/mtP9WgpM8mog7ZeBeSDFd7lQ8iebX CdWz4RO7uOUIiisV/X/qgwG1pj8goRC2/ZfaMBxSE3YScMPR1yTlEfDoJIr9DLu5YZfecyKXc32C Go65x6M+iUljM+hIbxadJ60r655M9viWgeh9J+QOv4EA++3W7Qmm8EqwYCUhbcMvvnzEP+q0xNAY WVuq8iOggKW9o8QNZtpPJJ7h+TFS7Cdj/qFJ5A== 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=A7B23MmhUdbvrioWgomQce/q/No5tWnC88HYKHebeLw=; b=IAL++VU5PLHk/2z1sJkX5wsaLAM0JX0yYPccsxpuxbMtvADIMqD4zfc/kaCEbMNIWErGMkgqadKT +C+8YpOReERLnleM033wzN/yLNcRFsFPsE1XgTLRP4uYG1rVOaOJCU7qBZ6fR5DqNFCMm80lOyMl 9jxd6Ne+X08Eiaa3DLkw+Y6dU/Hli3y0riMu6dZy+wYGlBUqBdUiIJ9haflecPwAut1MHcaXhuc8 IxdoCwaCIl62GMqCcAGcaT+DT9iO485Re4GYAUA6s71voqLp3zV8NEj/BAxkRDbdQG2ggb/ISzHp wPwkHc9UotB/odOsnDdAxfD5CrbiU47kaq6Dlg== Received: by omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220621 64bit (built Jun 21 2022)) with ESMTPS id <0RFT00E6D7HXCJ60@omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 30 Jul 2022 01:15:33 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdYFNUaFxR+dPNUTawRrOPPPusYrOqe74T5vUYtIlxOfbhevNwob/Gek0nTi/E67ZFOC0km+3TN1hnh7lSwSQmCTcQDPbm0LXZsIqeSz9G8tenPTIPct4EdWAtA9EsYHw73z21H0645ssO3Ip6m7Z4xqtKMgwgYqh0Ns4g4Z3YkmTy+IgUIwvt8lgWzGVzbCT9/AX9iR8UvHwfB/ZenGxvj3oPhInZn8+xB4TRslv3CohUz28rq2v/at3qyaBOpbHDjBmNOh0Snmolk7ceOyTf3250RJewx2lPTwhJ2VG1mY4tM5g3FovhVfYkm6SLOxOHdgCoy+DoSgKe/AsaxpGQ== 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=3vuuBchB+O51IoiA5C4i5O89wdRv0b4+1Tc18qq+cZk=; b=doHzyOBqfnl4dge5vfdlEoPN1pP7D7lgTvsi6zZaW2D0n8sya52ois+p5lypsUe+3RcW6dAXjHdBQYwmVcYunTC2upK+wz8RmXRfeAB3/eeXvXYA/kHMW22KiJ6eX6qCMOBUOW7Kk36+ljN+mXrOqDvku9mnm3xsk5BRpyjCchfeVW7aHIMsf1HmGuzJFVWRBmBt28YO/C8lTlHNEpLTXEwdBfGalfJ5B7l6Ne3dT8ptEnnE0GK+JWE1gwbx4sgoQOMLGjLUjhBnJCKHynajJ1VnZbw3/URKlHhOihLZIapuMl+GpbAXQSYX51Hey93U9fmYVkXY423F9pr8bN8PQA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3vuuBchB+O51IoiA5C4i5O89wdRv0b4+1Tc18qq+cZk=; b=wieZFGNtvbyCWmJ3FRBDIXdKIgk/vQxvoAUUbHvI3ksAXgl7Hkv7n+l400WEdhg4UFdRkum+eoddMRcHzd4rvuJOEj2Nioh0F6FfvwE2qHu+RfzOW/nr7+Xh0dpWi3MhoCcaLdXNbb5zez4t5opDfWomhNB3u06PX3d1hy4l9JekfaefugjZyndj8QfBfIHsBwBbgK4RjUaggwC9fdwy/1mnc5YuGRKSyXaRC16SHt66j+YeElcYYvogvJQXWeDPj7iqFn436QGiudkCaxlhHaltEadYGiCXhwQUCnU+appKmObgG7YdkdnIzU0cSGq0vSgP6UFYu705gCd/9DYcZw== To: ocfs2-devel@oss.oracle.com, joseph.qi@linux.alibaba.com Date: Sat, 30 Jul 2022 09:14:09 +0800 Message-id: <20220730011411.11214-3-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220730011411.11214-1-heming.zhao@suse.com> References: <20220730011411.11214-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:AM6PR04MB4662.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(39860400002)(376002)(136003)(346002)(38100700002)(41300700001)(5660300002)(8936002)(66946007)(478600001)(83380400001)(66556008)(8676002)(316002)(4326008)(66476007)(6486002)(2616005)(1076003)(186003)(6666004)(6506007)(26005)(6512007)(2906002)(44832011)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 01:15:09.5261 (UTC) X-Source-IP: 40.107.1.64 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10423 signatures=596356 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 adultscore=0 clxscore=190 priorityscore=140 suspectscore=0 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207300005 Subject: [Ocfs2-devel] [PATCH 2/4] ocfs2: add mlog ML_WARNING support 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-ClientProxiedBy: SI2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:4:194::14) To AM6PR04MB4662.eurprd04.prod.outlook.com (2603:10a6:20b:1b::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e105d33-9f1b-4b61-ec76-08da71c8f1ea X-MS-TrafficTypeDiagnostic: AM6PR04MB4840:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s/qlTbAPndrpxWTdDjoV3bkSITBouXmIBC6qIOAi8+vwqZC+OfZOkm4aPFrhdYCRub/LfCI/6z/zBHw0KiamojJ5GK7YznehYQhfxWSHOUU9zqknkm0yMmCfzQXM5X7D0Ale/7dfCsjSoyVQ+7ZA3+EhuGxFwGlcIWnQ2iTADqaObqsy5raLSHrz+rqMSGXkrMmEFCJI8K9NFEvHogewQnO1pNG0RXCHvjXo97577cDOnO9SUnKEvyoeL6obTPBwwZG4e0sx6aHCXexKrIlsMNiBMVKX512MNa0l/215t4HBez0JHM/TwKZmpxICFhs4l52RFG3rVGWezKseEz/poruOxuPyI9ojsyZz2oeNq5xcbMW+2NfXnR3CBu9U84ovrbsYw1RZGo9pOdCCCGXKI35r3pN7sE6j1F2/rNZxTePfYUevGxPQZXnnqInJAHw7aRO+AzLytOP6MnUJY8RKqT9P5elLRnSpRjdMzQkXOroM5Bftf76ltTTvlMwb2wkWjbRoAlzBiwXqNpFx+m9tf2ofByeH++L8MrrCoAFqGpetPUtbUe3f6p2kjv0v6BkD9SUt4DBr+XeImRFdSTAzQDxavBWgd3J3EPLX9bvsuAabx9obDeih+FrMkXKx6pYHUU3j3epgCERs+mPQFma3CESvfHBkpRwgqd0Ld65dmT+8A7K58koVdnbdE2JambH8nP0hE0GOvQQPv8zyrIZE1PmG2WaqoPdO+9VWJZm9j2GKd78Y+BkAL7UF62oX3AJ0 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g4nLdlzONDczW/NavSQUSYmIFlmVIy1f9uVDKg6xgycUrwze8T4XuavX6n9uTspBWnqqSCgIEaSpcASX97RRdcOsGobadn/K6usC1VMIxKYCdWAPPnYz5kg+nCHCVlklV4cyx2P14mc2rEKzpS4LCWK9W/XD6KUgHqgOnWmxx8blIpY6Tp9f/g7vO7QglcsVtBfTHD7NtG0n5b+G4eBUheuxSutIkMD/S11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6lM0P4CLDauUE0wwi3Js6oLRu7WF0SV51b7wCFOH/IFefqVx4g2tI8Ju3fdSbo5UHUXWsM4FXbc0SKdhEMKDjZOgKpKla2rDB9wpdjEYzDy+SC2oG1HSfGuvXJroF03woMdtv9hm5r8SSD6+CGSw9mN+nHsOIKswL1cDl1wI2W9A0oHdOjRVZG8aU6uKxclxS3SJHe335ZJa0VkwtcxnJq9r930PGwIH2dm1/D0cw0WhVegwWyPuq/bUkwv0zLwLOhb2kSUc4R+DnYZGEoehvjATgz5Yneomdi04iKqEXIPplZnPhWy X-MS-Exchange-CrossTenant-Network-Message-Id: 5e105d33-9f1b-4b61-ec76-08da71c8f1ea X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4662.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: r+rBcnyQcXJAwR7QW29YyM/UG/CTlV2QeDDoDEl1veaVjSHmtc/akCmNlaxeLEerR6d7h1aWCvIt5w7cy7t6+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4840 X-ServerName: mail-eopbgr10064.outbound.protection.outlook.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.suse.com include:amazonses.com include:spf.protection.outlook.com include:_spf.qemailserver.com include:_spf.salesforce.com -all X-Spam: Clean X-Proofpoint-ORIG-GUID: jQdGWXhY-bnDM6QNHw4SsGSfFKMONSHP X-Proofpoint-GUID: jQdGWXhY-bnDM6QNHw4SsGSfFKMONSHP Reporting-Meta: AAF3Sof+ipe41aLJfEoXSte+rQliFlE2IFVPBR9SeTrkm7xvtuQv2MbozowSBQgV U/mJyATS9PiRxexGmzuE9n5Xh/xM1z/c5kg8RJjIVkX3IJPBxI7D0DkMXJmp69fC 4uC6LKcJWYTpUVlXaZU3Hlhi6FKwBnVPsIiaMN4Bl/mjAeVrRIiQk5mRL6/M2/qk oNCaAkmFKAkdJSUeq2kBqc3ADqNLJv1MOadXY0EfhwLWLuoWC6l9X4CQ4Jm5MITF 5mF1+WcHKQXTb4OeavesoH5iTjWO0BvXvCgVzKE7OBmZcSagqBnfukLTLQdrae9s UkzVPSEEgPw8WCQ0ClH2WRfeA0wdnIvGCBx9tO8rOK/TQTF6UmAZinkJShPG0MXd ta/7HSmPJnGFES0Z68+ZThb3c558cOr5KdRYyItCfGgZX5F2HfystKGaYCpVgffS mLpplwo1dLUGFqcO6ohz3hUBPawXLeR6vWY5sRWx/hwR/n70Z9ytrsG0M5bVltBY Sqsb1CPvnnxQxXP8RvVM1moF9D8yb6OuSr/usP3+nGs= This commit gives new message type for ocfs2. Signed-off-by: Heming Zhao --- fs/ocfs2/cluster/masklog.c | 3 +++ fs/ocfs2/cluster/masklog.h | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index 563881ddbf00..bac3488e8002 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c @@ -63,6 +63,9 @@ void __mlog_printk(const u64 *mask, const char *func, int line, if (*mask & ML_ERROR) { level = KERN_ERR; prefix = "ERROR: "; + } else if (*mask & ML_WARNING) { + level = KERN_WARNING; + prefix = "WARNING: "; } else if (*mask & ML_NOTICE) { level = KERN_NOTICE; } else { diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index b73fc42e46ff..d0bc4fe8cf3d 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h @@ -86,10 +86,11 @@ /* bits that are infrequently given and frequently matched in the high word */ #define ML_ERROR 0x1000000000000000ULL /* sent to KERN_ERR */ -#define ML_NOTICE 0x2000000000000000ULL /* setn to KERN_NOTICE */ -#define ML_KTHREAD 0x4000000000000000ULL /* kernel thread activity */ +#define ML_NOTICE 0x2000000000000000ULL /* sent to KERN_NOTICE */ +#define ML_WARNING 0x4000000000000000ULL /* sent to KERN_WARNING */ +#define ML_KTHREAD 0x8000000000000000ULL /* kernel thread activity */ -#define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE) +#define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_WARNING|ML_NOTICE) #ifndef MLOG_MASK_PREFIX #define MLOG_MASK_PREFIX 0 #endif @@ -102,7 +103,7 @@ #if defined(CONFIG_OCFS2_DEBUG_MASKLOG) #define ML_ALLOWED_BITS ~0 #else -#define ML_ALLOWED_BITS (ML_ERROR|ML_NOTICE) +#define ML_ALLOWED_BITS (ML_ERROR|ML_WARNING|ML_NOTICE) #endif #define MLOG_MAX_BITS 64 From patchwork Sat Jul 30 01:14:10 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: 12932858 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 aib29ajc244.phx1.oracleemaildelivery.com (aib29ajc244.phx1.oracleemaildelivery.com [192.29.103.244]) (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 2CE76C00144 for ; Sat, 30 Jul 2022 01:15:48 +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=fifuMse5vzT+KtFkmoHbCMFanP16oUlqtUKqEL8FQjU=; b=WXyTz2EqZ4BzyloZvZfFVa9xV9GJ6DZWLUhSOoCiAbw3g4In/ZeBqU5lsMLoRrXm/KZIhmHYur/G +xZ3JbrDmumKw6i4ncGxyJOV3hT8veHhqyz4aDvG/XayMBgXqAZbyJkLAZwsXVKUH5p1toPX3NHy J6iICyHXAu3H6wctVhXJvb9CrwKj0Y1Ma4eu+WyknJT+AxKj1SdbUWamsN6H4VgSm9hY5LuHMKcj 3jKuoqTvw49HckGfttVc9ajBaOIJW3mSYu10qi1WMbIX779wRL2IRNgEl8SRncbWdvdazppNZgA+ GSPxG5Q690LLq8DBO9XcHSN436Z+Xqr6yZOObQ== 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=fifuMse5vzT+KtFkmoHbCMFanP16oUlqtUKqEL8FQjU=; b=szBwP3Ph/VmQPxof8HdByVYa5AIarCGLQLat9HNLsjrPB3nzPKgxCj8/XVY3CeZ4i6wCAmlF3Yuk MOBqnCZ2Vqk9IOklp6gXBUUCCOZEFN7245AaXqKHJkhXvh5AQhQX3OajoWznIV4VkQehZUgn0/Lb bKjtsfMYVYt4RKMdgMB3i7g9gTLELhqQse5o2NkXk0E5cm938PeEBjdee3SPaWtEvW3yByvf1wHn obkZoaau7maz2R4D0LlEMClv6IM7PifRsPu0RHQtAthFV4YhaTz+IFIGPbnyBQ5+DMs/8gN1xprF bLLIvG1GkMZRa0QcKbpFaFC2GYmaTyoiMVQTvQ== Received: by omta-ad1-fd1-101-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220621 64bit (built Jun 21 2022)) with ESMTPS id <0RFT00LXT7IBFW50@omta-ad1-fd1-101-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 30 Jul 2022 01:15:47 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MGYm4mF19ZP82xcz9kcH66gqWwGMVIDvJh8ErK0vdSIQPJSCW79ypdtLUoCa5EbLr1i4Cn6foY7eX5YxDgiXnDLsqtjOFXfmQ2C8Ke7X8+M/NzKJxeVu54LY0oTKz8UHNcmn8v33HYsxhhr9iwD2XMGRqOCacg0o1Jmhy6MDGNRvNnheIxh25tFnJ2h6viQ9MZF0H0jYUoVQ3N7Z65No+rLS/sNpBJ0J8WaiylN5JOSizu0ReIaWUYvNG5JtpFeS8XP+3hgaFj0apn6QWpQUUaFA7BVEcpERJfpl4yCV+f4jIQ4l3FCBica2ODYuluVzE3kk+Tja+bnOYNBtofULHQ== 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=425b47NZ//VZqj5kKNsbt72n7ssm1cUueu+VLI/DP2w=; b=Rojjt+Nt7cmadVEhsa1Qo2RK8bBansAecPw5NmAdEwJIEGcrZkBgjkbV2WtsletiYJ7fYgaPp2aayZ8DLMD/3RDRfFLegeTIn6n7JrrWjbLVy/knG44okgRt45zlb9riqEGKjuxDCx0BwaJS6J7vM+j+H9Yr8mTB3lFqE5hfZoPPz7SlEHs9rfqLA9e2cAKJmX85W/64GExlGMlnF9SFMCUwy39ecOZMIrLIsVC7kWc4GLkdFdpf2T74uI2UizQcyGZywaK+V3REQC5BBNkUjYDk/twhzKNNL7fQ2ytlkk5WfIjPI09W4+pmIqC3bxk03eCx54f6bQOPaD/FwbUWWA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=425b47NZ//VZqj5kKNsbt72n7ssm1cUueu+VLI/DP2w=; b=YTIlbupT/WpSBmBhzz7ZHk39MY2PlpegMzzk6P7ArisWqHRvHsg671PidTYfPHERlFd6UUgnO6eYaNkCZF9nK9LzNYE2dXO+dcABRqSzTpMo5faAE5Hx+hqBoR8iXsAZilkgX5Hr6AMBimRmniKhDaWern72cX8S0hDNY1fZnfVoOQcyLcApzeDY9dg88oQtGpkmxJ/Q6WwQDwSF8jGcqotw3mfVQxJntcqUsactwOSGdsMwXkAmvs9DBoFtWzusiCIk4duLhFOEEDzT/F4khmqYzdnl6Py0+/SFNGOAdkTWR6pqi7js+cjfJof9Bwp/ouQXjw9NEuMGbt+8ZQ4HRA== To: ocfs2-devel@oss.oracle.com, joseph.qi@linux.alibaba.com Date: Sat, 30 Jul 2022 09:14:10 +0800 Message-id: <20220730011411.11214-4-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220730011411.11214-1-heming.zhao@suse.com> References: <20220730011411.11214-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:AM6PR04MB4662.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(39860400002)(376002)(136003)(346002)(38100700002)(41300700001)(5660300002)(8936002)(66946007)(478600001)(83380400001)(66556008)(8676002)(316002)(4326008)(66476007)(6486002)(2616005)(1076003)(186003)(6666004)(6506007)(26005)(6512007)(2906002)(44832011)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 01:15:27.8218 (UTC) X-Source-IP: 40.107.1.68 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10423 signatures=596356 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 phishscore=0 priorityscore=136 spamscore=0 lowpriorityscore=0 clxscore=243 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207300005 Subject: [Ocfs2-devel] [PATCH 3/4] re-enable "ocfs2: mount shared volume without ha stack" 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-ClientProxiedBy: SG2PR01CA0109.apcprd01.prod.exchangelabs.com (2603:1096:4:40::13) To AM6PR04MB4662.eurprd04.prod.outlook.com (2603:10a6:20b:1b::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70add5a9-805c-417e-9d83-08da71c8fcd2 X-MS-TrafficTypeDiagnostic: AM6PR04MB4840:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rFVgW6jebLVxP4NV88SSI5QN/9mnAawUo8wcdCTgWaqge0z1rfhmLchLTM8uwzWMG425jdaYZOTL6mBMlXSEJ2CN/FkGi7pMBOq2Ervrp2MxwC+rR1SWvuZTpM+pzNy1fNvtFbF6///T0LJOgOdiiUpGFQPHxYqXMnwkolsb+EDvHF0ZjJ1EXKdShK5llaAgRNxMiDsHtzQy/WEkEkeT5kJVnc3rNkrY1EXFjzHmQ2NXlBVeBQCmkCSsZcuZTTzKKvKr7udbnm1mJPkqKU8iFBrYk1VbJAtjkr5y7BY+3s4WjEynqQI6nr6k5FG/8Rcpyhp3L8NZLp4KHWO4u5UvGT9W1k9CPxACkprr4dDeaQ5cRjrqWrnToR/SeThVrqlQZAE5RtDD2RZI949P/OrsLlFSK+CGa7Rs9lWOFGONsuU7jxCFfKX9bm7q5fWVDdF5fXNtSeQzzLr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2C3KTq7MSa3RZYngH9GxWGuICwe41GJAalBgiBmBOBbaKbgGqhZPqlsVIMAQmjXFUEIGL70+SlUL5mCkKtWsmrp8VYZVRX4HdKJfduNJ2WeDqqYLq/elwcmRUU58jFZR/GxSM833/+ucKdNOXx5lfLuqrXaiX7chJhgEifLg7vL4cMBH74Ij17n3GKonnXHagzhJ38ZoY3muspAlRhIfxmmSvk22kjnbvYK41eAtqe1SvT7NK9jqKXR+ArNWLl6bukEpeqY8Zz9ruQSnnWaFHp3d8tiZm27jRroNPXZ/uPEhTtKLa1aui1yFG1SGZXvnqFeLaCIBC3zJ9BLaexDHsoH3GwOxfhQTbwf8UYq6VV3aoiop47WnCj5qGdoC1ZyXo50C1522lC4PKNiclvn206iG1euQ78gtpQbGrEPjGBcn6tfgSx3D4wyIDMmi37VJf+jlQxBKeyoMkTru7Z/Xs5JTqlMNBpmUDdrqC7tXxLsenKKsisS9DReoWbwlTwzHYzFooF75d7xC/INXUw7VEzrD+2+6hzE0um3r13XQ3uLcR2ZHqOh4Xz76QbqwEOXlkcsRs6wY/PI3wsifg2gVzFks4++koR4OH6xDIXTKYy614dtygyzgpebEllQT2Sc82hQAE8m8xAIPk9smeZTLnyjnDYecsU4nBC909+mtqO4Vn1xo8LU2dMy9k8LF1h+QzpHudPYmz96WLGfMLJyPvUIG4Pwc+k27HVWkj29KzGuf8PNVSUN6TU3dTHr9cKqk7qjRVqRX0EQJEre7n96NCi0PInxNT6i38GkntC+XJGw+z3ILYhMeke75h+AJWYLfWICRsBfqXpGAN7YH6zJ3UaUL1TyiKElSTw7axS7ScDYVp028L28 X-MS-Exchange-CrossTenant-Network-Message-Id: 70add5a9-805c-417e-9d83-08da71c8fcd2 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4662.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: gT9zEGFMKbfdpA+F0Vh+x4nH1cPuzUFviZLd7/RSdB2nJde8D+7JbxuWTfNJXv+kNtAFWoRtBO4tTFyuEqeEOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4840 X-ServerName: mail-eopbgr10068.outbound.protection.outlook.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.suse.com include:amazonses.com include:spf.protection.outlook.com include:_spf.qemailserver.com include:_spf.salesforce.com -all X-Spam: Clean X-Proofpoint-ORIG-GUID: gB8bqNNApMxhAyLiXvwsCzVxoNE-bjax X-Proofpoint-GUID: gB8bqNNApMxhAyLiXvwsCzVxoNE-bjax Reporting-Meta: AAE1DFZ4j7U4WpLz07R9UegAw7/CF68Ncp7MSoO+wT6mcBdNWgLkYhRZsS04yyDI fIvUpY+ONG2cGXdbkAveBJHMFpLDsY85a6xp5NCNGBMoud2Ub6n5/Urkj72GQxXE rx5OuoTa6DLI2hUaW7KtyHLrvinTARigs4Ybh0dO1ZPKD2N3Ldz8ejGknSib7yqY meLioi/e5QmoYwJvBmJrUzy7QnLqm9PQFtH2/5p5tQEe6uNDKnaXBzqedzgGMBvX gNIsm3ehPKuN2VzL+GInlISWkIDdfdfqYLE1GjGnQgMxKUkXDnUtilwafoEEJp9m z3vZ/KMWI4anZ+/fpf+rEGARCApsbA8tVSMuaalJ4n5Hvs09RocxlfUdaekByb5Z gPDBSzTp3HIRdWi/3Qy/o8By/yw/DB0/R7sptDo1Kf2eOsOKvxIc9yIUuWK3aMCK LSeyq8h7AQk5pbAyB/CpTfMDPZsrSJC9fjHuMJxrpjXrGveyhhu0oYeNYx2kxIBx YPsHo6ewLlqs6DAYp27PVPtVGOb+pQPbhlMlkFU12cY= the key different between local mount and non-clustered mount: local mount feature (tunefs.ocfs2 --fs-features=[no]local) can't do convert job without ha stack. non-clustered mount feature can run totally without ha stack. commit 912f655d78c5 ("ocfs2: mount shared volume without ha stack") had bug, then commit c80af0c250c8f8a3c978aa5aafbe9c39b336b813 reverted it. Let's give some explain for the issue mentioned by commit c80af0c250c8. Under Junxiao's call trace, in __ocfs2_find_empty_slot(), the 'if' accessment is wrong. sl_node_num could be 0 at o2cb env. with current information, the trigger flow (base on 912f655d78c5): 1> nodeA with 'node_num = 0' for mounting. it will succeed. at this time, slotmap extent block will contains es_valid:1 & es_node_num:0 for nodeA then ocfs2_update_disk_slot() will write back slotmap info to disk. 2> then, nodeB with 'node_num = 1' for mounting this time, osb->node_num is 1 (set by config file), osb->preferred is OCFS2_INVALID_SLOT (set by ocfs2_parse_options). ocfs2_find_slot + ocfs2_update_slot_info //read slotmap info from disk | + set si->si_slots[0].es_valid = 1 & si->si_slots[0].sl_node_num = 0 | + __ocfs2_node_num_to_slot //will return -ENOENT. + __ocfs2_find_empty_slot + if ((preferred >= 0) && (preferred < si->si_num_slots)) | fails enter this 'if' for preferred value is OCFS2_INVALID_SLOT | + 'for(i = 0; i < si->si_num_slots; i++)' search slot 0 successfully. | 'si->si_slots[0].sl_node_num' is false. trigger 'break' condition. | + return slot 0. it will cause nodeB grab nodeA journal dlm lock, then trigger hung. How to do for this bug? This commit re-enabled 912f655d78c5, next commit (add MMP support) will fix the issue. Signed-off-by: Heming Zhao --- fs/ocfs2/ocfs2.h | 4 +++- fs/ocfs2/slot_map.c | 46 ++++++++++++++++++++++++++------------------- fs/ocfs2/super.c | 21 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 740b64238312..337527571461 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -277,6 +277,7 @@ enum ocfs2_mount_options OCFS2_MOUNT_JOURNAL_ASYNC_COMMIT = 1 << 15, /* Journal Async Commit */ OCFS2_MOUNT_ERRORS_CONT = 1 << 16, /* Return EIO to the calling process on error */ OCFS2_MOUNT_ERRORS_ROFS = 1 << 17, /* Change filesystem to read-only on error */ + OCFS2_MOUNT_NOCLUSTER = 1 << 18, /* No cluster aware filesystem mount */ }; #define OCFS2_OSB_SOFT_RO 0x0001 @@ -672,7 +673,8 @@ static inline int ocfs2_cluster_o2cb_global_heartbeat(struct ocfs2_super *osb) static inline int ocfs2_mount_local(struct ocfs2_super *osb) { - return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT); + return ((osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT) + || (osb->s_mount_opt & OCFS2_MOUNT_NOCLUSTER)); } static inline int ocfs2_uses_extended_slot_map(struct ocfs2_super *osb) diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index da7718cef735..0b0ae3ebb0cf 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -252,14 +252,16 @@ static int __ocfs2_find_empty_slot(struct ocfs2_slot_info *si, int i, ret = -ENOSPC; if ((preferred >= 0) && (preferred < si->si_num_slots)) { - if (!si->si_slots[preferred].sl_valid) { + if (!si->si_slots[preferred].sl_valid || + !si->si_slots[preferred].sl_node_num) { ret = preferred; goto out; } } for(i = 0; i < si->si_num_slots; i++) { - if (!si->si_slots[i].sl_valid) { + if (!si->si_slots[i].sl_valid || + !si->si_slots[i].sl_node_num) { ret = i; break; } @@ -454,24 +456,30 @@ int ocfs2_find_slot(struct ocfs2_super *osb) spin_lock(&osb->osb_lock); ocfs2_update_slot_info(si); - /* search for ourselves first and take the slot if it already - * exists. Perhaps we need to mark this in a variable for our - * own journal recovery? Possibly not, though we certainly - * need to warn to the user */ - slot = __ocfs2_node_num_to_slot(si, osb->node_num); - if (slot < 0) { - /* if no slot yet, then just take 1st available - * one. */ - slot = __ocfs2_find_empty_slot(si, osb->preferred_slot); + if (ocfs2_mount_local(osb)) + /* use slot 0 directly in local mode */ + slot = 0; + else { + /* search for ourselves first and take the slot if it already + * exists. Perhaps we need to mark this in a variable for our + * own journal recovery? Possibly not, though we certainly + * need to warn to the user */ + slot = __ocfs2_node_num_to_slot(si, osb->node_num); if (slot < 0) { - spin_unlock(&osb->osb_lock); - mlog(ML_ERROR, "no free slots available!\n"); - status = -EINVAL; - goto bail; - } - } else - printk(KERN_INFO "ocfs2: Slot %d on device (%s) was already " - "allocated to this node!\n", slot, osb->dev_str); + /* if no slot yet, then just take 1st available + * one. */ + slot = __ocfs2_find_empty_slot(si, osb->preferred_slot); + if (slot < 0) { + spin_unlock(&osb->osb_lock); + mlog(ML_ERROR, "no free slots available!\n"); + status = -EINVAL; + goto bail; + } + } else + printk(KERN_INFO "ocfs2: Slot %d on device (%s) was " + "already allocated to this node!\n", + slot, osb->dev_str); + } ocfs2_set_slot(si, slot, osb->node_num); osb->slot_num = slot; diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 438be028935d..f7298816d8d9 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -172,6 +172,7 @@ enum { Opt_dir_resv_level, Opt_journal_async_commit, Opt_err_cont, + Opt_nocluster, Opt_err, }; @@ -205,6 +206,7 @@ static const match_table_t tokens = { {Opt_dir_resv_level, "dir_resv_level=%u"}, {Opt_journal_async_commit, "journal_async_commit"}, {Opt_err_cont, "errors=continue"}, + {Opt_nocluster, "nocluster"}, {Opt_err, NULL} }; @@ -616,6 +618,13 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) goto out; } + tmp = OCFS2_MOUNT_NOCLUSTER; + if ((osb->s_mount_opt & tmp) != (parsed_options.mount_opt & tmp)) { + ret = -EINVAL; + mlog(ML_ERROR, "Cannot change nocluster option on remount\n"); + goto out; + } + tmp = OCFS2_MOUNT_HB_LOCAL | OCFS2_MOUNT_HB_GLOBAL | OCFS2_MOUNT_HB_NONE; if ((osb->s_mount_opt & tmp) != (parsed_options.mount_opt & tmp)) { @@ -856,6 +865,7 @@ static int ocfs2_verify_userspace_stack(struct ocfs2_super *osb, } if (ocfs2_userspace_stack(osb) && + !(osb->s_mount_opt & OCFS2_MOUNT_NOCLUSTER) && strncmp(osb->osb_cluster_stack, mopt->cluster_stack, OCFS2_STACK_LABEL_LEN)) { mlog(ML_ERROR, @@ -1127,6 +1137,11 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : "ordered"); + if ((osb->s_mount_opt & OCFS2_MOUNT_NOCLUSTER) && + !(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT)) + printk(KERN_NOTICE "ocfs2: The shared device (%s) is mounted " + "without cluster aware mode.\n", osb->dev_str); + atomic_set(&osb->vol_state, VOLUME_MOUNTED); wake_up(&osb->osb_mount_event); @@ -1437,6 +1452,9 @@ static int ocfs2_parse_options(struct super_block *sb, case Opt_journal_async_commit: mopt->mount_opt |= OCFS2_MOUNT_JOURNAL_ASYNC_COMMIT; break; + case Opt_nocluster: + mopt->mount_opt |= OCFS2_MOUNT_NOCLUSTER; + break; default: mlog(ML_ERROR, "Unrecognized mount option \"%s\" " @@ -1548,6 +1566,9 @@ static int ocfs2_show_options(struct seq_file *s, struct dentry *root) if (opts & OCFS2_MOUNT_JOURNAL_ASYNC_COMMIT) seq_printf(s, ",journal_async_commit"); + if (opts & OCFS2_MOUNT_NOCLUSTER) + seq_printf(s, ",nocluster"); + return 0; } From patchwork Sat Jul 30 01:14:11 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: 12932859 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 aib29ajc248.phx1.oracleemaildelivery.com (aib29ajc248.phx1.oracleemaildelivery.com [192.29.103.248]) (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 229FDC00144 for ; Sat, 30 Jul 2022 01:16:09 +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=2lqSQYB93ZFlc5NuhjPVwsnECKlJ4ZS3IOWViUQ1Q8A=; b=EhTRubwc8ks2N3Wjez+vO8n7SaHdVFxeHShsw8ror4YUkxZAodwR+6rgRGwtJEHukSjvm7R29mBT yhe3yTZmnYF13AJ97bVd5P2W/KS1h8/zl1arC7lQI1kvnQxXpAVGmtHamAZnJonpK5lEajPFukTs Pgkk+ZLIeD9iyt38LyWfEdUh2GdOTaUQKMbCbP+8OR4Ru/2uTWAHDYxURT3FTATtbnL8RuBYvr2J 2inoAmnIflQcRl1yrZtGy3bT2dEQjVE7aHZEL3o/PD1jwxWSFVNTbrKqdndOP5IcvlPSkEiwglk8 ckKCjwqWNiwv9DJi/IJbwplwqf4BeBipCmZwMA== 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=2lqSQYB93ZFlc5NuhjPVwsnECKlJ4ZS3IOWViUQ1Q8A=; b=qXO/Y8nOA7s/E1YLO1JCSQcYVc2C1LByYwvnrCjLbkbzojpbWqtUflvxU0IbAvbFGoj5pCYt/uuT 3t5Tar1fjR1VOETTUYu6Sh1KSv7b3RcCVl8rPm9UDLOO1saQ5SFLNrBDV8F+qSzH0I0Jc0MyNKKy PlgHgjm0HksZTxxi5+kiwtWaR6TQ8SWCn8O4A1JnIpmTzM8mwAW05jn2E2PLxHj3aY5zDdW8ibPK Izez0Nc4jZP8rVLOFnYUb92AjxPgKcxZtQBJUWM/5ngyJflHLxaLHRJXKjIbh8U+Jhe3fnuhs9di e45KqVt1pInDolbvoblJkYhLSAyzkANfnQVrTg== Received: by omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220621 64bit (built Jun 21 2022)) with ESMTPS id <0RFT00CQQ7IWKGA0@omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 30 Jul 2022 01:16:08 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RIMVQTGmcgJYFOqLdoPpP9xrIaLdn9XHT4nt0H+bHONNSIgexwRtksHOJ8ZMNNlmzqhOCqRU+IQw7xuDco7ql6SF+g0nH1XneCvfR3KtTN6RA5/clz4OaDM32YOnw0Tlg4j0X22zarX/XnxxOMFWidM7+2DvmMzqAW1kWqXde3meGualEb2nOlcTHBsImHHYJOT3KCgFyqxL9AVu7/9w64QP25NffJiD47ZQfSC4VVRHrU4ok4+5wUnxDwYKpmh+PHu2hkdX9Lav4X8ZSn086VUL8+GKOVywfYUupwLraKPmyB4Qg0iJtgC+WOEBYhGpS/Hd9pCNi/cmwsRBhA6C+Q== 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=sYOhpJ4fwnUDdb5+ttdraBsf5p2FWLO5hio+0UNQEHk=; b=GbxnD1v2NPJZwlAiMcXNTsj/rKBwMZqNDlPzoDPQCOIKdYatseNBA+UQ+oz60svp7BQigkoy+MEqpAkebhiDhzodfRXWfos1oL5Vu7CZkcyCasaVi+yeHs4NeEKOZo2h+6qN49o3yCmTKC44aYROVTfOnCVD1lcH+yr7DkZ8dkoXl8A054WBplIiO3x5l5PpvtbZBhFj8o/EH9tueVwu/D3+D8FBvGRuCRgN+7+14WcPcpptsTEdL/AEyOToIJzTlJUsWR/9KNnsZTawpfdCXOVsjKwWYlpSp/6ejz92bkfNFs51x34IV4vS13Bh0M4c/rM7SFFectllBSKKXmGFxw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sYOhpJ4fwnUDdb5+ttdraBsf5p2FWLO5hio+0UNQEHk=; b=C4NHG5VLMvBgwZEAgzQQvDm1Bi0xWP3VDUTXjmm0FV2HMWA3ZrkXX6DKZrMNiQFTLt6VIxDZ4z/asfBuaW17l0IfHcKtyAy4gVeJZZhvaV0y1VTAhQ6tJ7uEuSfMBTpfKimNLgAIJjFgPL/v3M0oV0yN1zGfuFHlbC9sg/Ojnw8g35pIejPa/hQWOKPxDpgiKh8WR7ATCqG5j6e4eZpYs6iUTY0PL3Kv4CKhKxNWjNgCsihp57WN/h77qfwI49qiFyftPMlpfNOyyewdbSJFBu7ezxr2Bbd6V4bdXndD95+xbn+awe8Twoxy/rvpOqGOjizxpnsAJI9idaxv6IVI0Q== To: ocfs2-devel@oss.oracle.com, joseph.qi@linux.alibaba.com Date: Sat, 30 Jul 2022 09:14:11 +0800 Message-id: <20220730011411.11214-5-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220730011411.11214-1-heming.zhao@suse.com> References: <20220730011411.11214-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:AM6PR04MB4662.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(39860400002)(376002)(136003)(346002)(38100700002)(41300700001)(5660300002)(8936002)(66946007)(478600001)(83380400001)(66556008)(8676002)(316002)(4326008)(66476007)(6486002)(2616005)(1076003)(186003)(6666004)(6506007)(26005)(6512007)(30864003)(2906002)(44832011)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2022 01:15:41.9302 (UTC) X-Source-IP: 40.107.1.84 X-Proofpoint-Virus-Version: vendor=nai engine=6400 definitions=10423 signatures=596356 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=999 clxscore=238 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 malwarescore=0 priorityscore=140 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207300005 Subject: [Ocfs2-devel] [PATCH 4/4] ocfs2: introduce ext4 MMP feature 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-ClientProxiedBy: SG2PR06CA0220.apcprd06.prod.outlook.com (2603:1096:4:68::28) To AM6PR04MB4662.eurprd04.prod.outlook.com (2603:10a6:20b:1b::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1627ad1-ad68-4685-c5bf-08da71c9053d X-MS-TrafficTypeDiagnostic: AM6PR04MB4840:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8fzTUOoxWyZTcvABXeNZqVYdO1TRSou0/SLsfmgbJTAssqDF/j7cBuN8oxvn8JGYq1/QxMtxKU/iZcN/51eB1Nin3S+ZItbUkRG04oH4P6JvBfiNpWFwNWMsN4TOZ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iWdHmSsXvG5J+i8uGoOu/2jWnGp1qO/vwAYelu6OF3ZbcZmv+VlzOu86LTB2gkCtTT3YmnDFfyiSA0WkA/9mgP8kcRX9AdM38jmYOMHp5H62Lj83OvtItWgUe+M72qjZJCes7EJWjOH X-MS-Exchange-CrossTenant-Network-Message-Id: d1627ad1-ad68-4685-c5bf-08da71c9053d X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4662.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: z19F2zbd3uIaS71KxLUTg8azcoZdlSIOCvMP00EVfVZiAZxI/hjxptbfCUFYhkjgejdI/CD5iMkmprBL2bv1cQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4840 X-ServerName: mail-eopbgr10084.outbound.protection.outlook.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.suse.com include:amazonses.com include:spf.protection.outlook.com include:_spf.qemailserver.com include:_spf.salesforce.com -all X-Spam: Clean X-Proofpoint-GUID: RWrOkXj0rL5PnsPwCVjDBV-_HgrK53vH X-Proofpoint-ORIG-GUID: RWrOkXj0rL5PnsPwCVjDBV-_HgrK53vH Reporting-Meta: AAEVTnDnICN6a7kNav0bf01jdKJOmBSFL55ehdtxOBtg8foFvOdlFk4Yg0WA9GPb UdQX9muSG5qiLwFaXDB3qcdeT7OTJrv7K95Lc4a4VCaD1MKSMnloQBzSU0m1wo2p vqUyT9inmJ8nlHAvYr0xv6BGrSzFAudmV+YVvrFZcQqZATwMQNwOW4aa4AFLyII5 InFrsNss+W3PyTe0UfynQUYGFgSxQ+DC65QNI1g4MAs2NOQ0AkZ50+uuygSX1qpk WwmyiSbmfCTTiahMmOMjTRSXQfqMYs9zf+C07I1nrIyhnrIs+13OY8DS6VaEX6iH Qm4qxcM8Nr7rbgN5PKQofZEuwM5ZOqcdevKs9KCkx8s+1HvHg1uK8OT5Tu8zwnJ0 I3qodfglSTIVWUaPjwvtdJq2P1alF7b5yrdYEHOX8/PrZ+VhCa6OL2T5w8KV8fpj Lti+UIKGKX6jIVGHliQZV+LdgXP+t8xcEms14iv0cqtPj88mmoJpOWEZQZ+1PRF+ lNRtYER1xnhHOd03yhI5FJIBk4S32ER6V+qgl5OkBjEL MMP (multiple mount protection) gives filesystem ability to prevent from being mounted multiple times. For avoiding data corruption when non-clustered and/or clustered mount are happening at same time, this commit introduced MMP feature. MMP idea is from ext4 MMP (fs/ext4/mmp.c) code. For ocfs2 is a clustered fs and also for compatible with existing slotmap feature, I did some optimization and modification when porting from ext4 to ocfs2. For optimization: mmp has a kthread kmmpd-, which is only created in non-clustered mode. We set a rule: If last mount didn't do unmount, (eg: crash), the next mount MUST be same mount type. At last, this commit also fix commit c80af0c250c8 ("Revert "ocfs2: mount shared volume without ha stack") mentioned issue. Signed-off-by: Heming Zhao --- fs/ocfs2/ocfs2.h | 2 + fs/ocfs2/ocfs2_fs.h | 13 +- fs/ocfs2/slot_map.c | 459 ++++++++++++++++++++++++++++++++++++++++++-- fs/ocfs2/slot_map.h | 3 + fs/ocfs2/super.c | 23 ++- 5 files changed, 479 insertions(+), 21 deletions(-) diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 337527571461..37a7c5855d07 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -337,6 +337,8 @@ struct ocfs2_super unsigned int node_num; int slot_num; int preferred_slot; + u16 mmp_update_interval; + struct task_struct *mmp_task; int s_sectsize_bits; int s_clustersize; int s_clustersize_bits; diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 638d875eccc7..015672f75563 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h @@ -87,7 +87,8 @@ | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \ | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG \ | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO \ - | OCFS2_FEATURE_INCOMPAT_APPEND_DIO) + | OCFS2_FEATURE_INCOMPAT_APPEND_DIO \ + | OCFS2_FEATURE_INCOMPAT_MMP) #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) @@ -167,6 +168,11 @@ */ #define OCFS2_FEATURE_INCOMPAT_APPEND_DIO 0x8000 +/* + * Multiple mount protection + */ +#define OCFS2_FEATURE_INCOMPAT_MMP 0x10000 + /* * backup superblock flag is used to indicate that this volume * has backup superblocks. @@ -535,8 +541,7 @@ struct ocfs2_slot_map { }; struct ocfs2_extended_slot { -/*00*/ __u8 es_valid; - __u8 es_reserved1[3]; +/*00*/ __le32 es_valid; __le32 es_node_num; /*08*/ }; @@ -611,7 +616,7 @@ struct ocfs2_super_block { INCOMPAT flag set. */ /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size for this fs*/ - __le16 s_reserved0; + __le16 s_mmp_update_interval; /* # seconds to wait in MMP checking */ __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash. * s_uuid_hash serves as seed[3]. */ /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */ diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index 0b0ae3ebb0cf..86a21140ead6 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include @@ -24,9 +26,48 @@ #include "buffer_head_io.h" +/* + * This structure will be used for multiple mount protection. It will be + * written into the '//slot_map' field in the system dir. + * Programs that check MMP should assume that if SEQ_FSCK (or any unknown + * code above SEQ_MAX) is present then it is NOT safe to use the filesystem. + */ +#define OCFS2_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */ +#define OCFS2_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */ +#define OCFS2_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */ +#define OCFS2_MMP_SEQ_INIT 0x0 /* mmp_seq init value */ +#define OCFS2_VALID_CLUSTER 0xE24D4D55U /* value for clustered mount + under MMP disabled */ +#define OCFS2_VALID_NOCLUSTER 0xE24D4D5AU /* value for noclustered mount + under MMP disabled */ + +#define OCFS2_SLOT_INFO_OLD_VALID 1 /* use for old slot info */ + +/* + * Check interval multiplier + * The MMP block is written every update interval and initially checked every + * update interval x the multiplier (the value is then adapted based on the + * write latency). The reason is that writes can be delayed under load and we + * don't want readers to incorrectly assume that the filesystem is no longer + * in use. + */ +#define OCFS2_MMP_CHECK_MULT 2UL + +/* + * Minimum interval for MMP checking in seconds. + */ +#define OCFS2_MMP_MIN_CHECK_INTERVAL 5UL + +/* + * Maximum interval for MMP checking in seconds. + */ +#define OCFS2_MMP_MAX_CHECK_INTERVAL 300UL struct ocfs2_slot { - int sl_valid; + union { + unsigned int sl_valid; + unsigned int mmp_seq; + }; unsigned int sl_node_num; }; @@ -52,11 +93,11 @@ static void ocfs2_invalidate_slot(struct ocfs2_slot_info *si, } static void ocfs2_set_slot(struct ocfs2_slot_info *si, - int slot_num, unsigned int node_num) + int slot_num, unsigned int node_num, unsigned int valid) { BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots)); - si->si_slots[slot_num].sl_valid = 1; + si->si_slots[slot_num].sl_valid = valid; si->si_slots[slot_num].sl_node_num = node_num; } @@ -75,7 +116,8 @@ static void ocfs2_update_slot_info_extended(struct ocfs2_slot_info *si) i++, slotno++) { if (se->se_slots[i].es_valid) ocfs2_set_slot(si, slotno, - le32_to_cpu(se->se_slots[i].es_node_num)); + le32_to_cpu(se->se_slots[i].es_node_num), + le32_to_cpu(se->se_slots[i].es_valid)); else ocfs2_invalidate_slot(si, slotno); } @@ -97,7 +139,8 @@ static void ocfs2_update_slot_info_old(struct ocfs2_slot_info *si) if (le16_to_cpu(sm->sm_slots[i]) == (u16)OCFS2_INVALID_SLOT) ocfs2_invalidate_slot(si, i); else - ocfs2_set_slot(si, i, le16_to_cpu(sm->sm_slots[i])); + ocfs2_set_slot(si, i, le16_to_cpu(sm->sm_slots[i]), + OCFS2_SLOT_INFO_OLD_VALID); } } @@ -252,16 +295,14 @@ static int __ocfs2_find_empty_slot(struct ocfs2_slot_info *si, int i, ret = -ENOSPC; if ((preferred >= 0) && (preferred < si->si_num_slots)) { - if (!si->si_slots[preferred].sl_valid || - !si->si_slots[preferred].sl_node_num) { + if (!si->si_slots[preferred].sl_valid) { ret = preferred; goto out; } } for(i = 0; i < si->si_num_slots; i++) { - if (!si->si_slots[i].sl_valid || - !si->si_slots[i].sl_node_num) { + if (!si->si_slots[i].sl_valid) { ret = i; break; } @@ -270,6 +311,43 @@ static int __ocfs2_find_empty_slot(struct ocfs2_slot_info *si, return ret; } +/* Return first used slot. + * -ENOENT means all slots are clean, ->sl_valid should be + * OCFS2_MMP_SEQ_CLEAN or ZERO */ +static int __ocfs2_find_used_slot(struct ocfs2_slot_info *si) +{ + int i, ret = -ENOENT, valid; + + for (i = 0; i < si->si_num_slots; i++) { + valid = si->si_slots[i].sl_valid; + if (valid == 0 || valid == OCFS2_MMP_SEQ_CLEAN) + continue; + if (valid <= OCFS2_MMP_SEQ_MAX || + valid == OCFS2_MMP_SEQ_FSCK || + valid == OCFS2_VALID_CLUSTER || + valid == OCFS2_VALID_NOCLUSTER) { + ret = i; + break; + } + } + + return ret; +} + +static int __ocfs2_find_expected_slot(struct ocfs2_slot_info *si, + unsigned int expected) +{ + int i; + + for (i = 0; i < si->si_num_slots; i++) { + if (si->si_slots[i].sl_valid == expected) { + return 1; + } + } + + return 0; +} + int ocfs2_node_num_to_slot(struct ocfs2_super *osb, unsigned int node_num) { int slot; @@ -445,21 +523,357 @@ void ocfs2_free_slot_info(struct ocfs2_super *osb) __ocfs2_free_slot_info(si); } +/* + * Get a random new sequence number but make sure it is not greater than + * EXT4_MMP_SEQ_MAX. + */ +static unsigned int mmp_new_seq(void) +{ + u32 new_seq; + + do { + new_seq = prandom_u32(); + } while (new_seq > OCFS2_MMP_SEQ_MAX); + + if (new_seq == 0) + return 1; + else + return new_seq; +} + +/* + * kmmpd will update the MMP sequence every mmp_update_interval seconds + */ +static int kmmpd(void *data) +{ + struct ocfs2_super *osb = data; + struct super_block *sb = osb->sb; + struct ocfs2_slot_info *si = osb->slot_info; + int slot = osb->slot_num; + u32 seq, mmp_seq; + unsigned long failed_writes = 0; + u16 mmp_update_interval = osb->mmp_update_interval; + unsigned int mmp_check_interval; + unsigned long last_update_time; + unsigned long diff; + int retval = 0; + + if (!ocfs2_mount_local(osb)) { + mlog(ML_ERROR, "kmmpd thread only works for local mount mode.\n"); + goto wait_to_exit; + } + + retval = ocfs2_refresh_slot_info(osb); + seq = si->si_slots[slot].mmp_seq; + + /* + * Start with the higher mmp_check_interval and reduce it if + * the MMP block is being updated on time. + */ + mmp_check_interval = max(OCFS2_MMP_CHECK_MULT * mmp_update_interval, + OCFS2_MMP_MIN_CHECK_INTERVAL); + + while (!kthread_should_stop() && !sb_rdonly(sb)) { + if (!OCFS2_HAS_INCOMPAT_FEATURE(sb, OCFS2_FEATURE_INCOMPAT_MMP)) { + mlog(ML_WARNING, "kmmpd being stopped since MMP feature" + " has been disabled."); + goto wait_to_exit; + } + if (++seq > OCFS2_MMP_SEQ_MAX) + seq = 1; + + spin_lock(&osb->osb_lock); + si->si_slots[slot].mmp_seq = mmp_seq = seq; + spin_unlock(&osb->osb_lock); + + last_update_time = jiffies; + retval = ocfs2_update_disk_slot(osb, si, slot); + + /* + * Don't spew too many error messages. Print one every + * (s_mmp_update_interval * 60) seconds. + */ + if (retval) { + if ((failed_writes % 60) == 0) { + ocfs2_error(sb, "Error writing to MMP block"); + } + failed_writes++; + } + + diff = jiffies - last_update_time; + if (diff < mmp_update_interval * HZ) + schedule_timeout_interruptible(mmp_update_interval * + HZ - diff); + + /* + * We need to make sure that more than mmp_check_interval + * seconds have not passed since writing. If that has happened + * we need to check if the MMP block is as we left it. + */ + diff = jiffies - last_update_time; + if (diff > mmp_check_interval * HZ) { + retval = ocfs2_refresh_slot_info(osb); + if (retval) { + ocfs2_error(sb, "error reading MMP data: %d", retval); + goto wait_to_exit; + } + + if (si->si_slots[slot].mmp_seq != mmp_seq) { + ocfs2_error(sb, "Error while updating MMP info. " + "The filesystem seems to have been" + " multiply mounted."); + retval = -EBUSY; + goto wait_to_exit; + } + } + + /* + * Adjust the mmp_check_interval depending on how much time + * it took for the MMP block to be written. + */ + mmp_check_interval = max(min(OCFS2_MMP_CHECK_MULT * diff / HZ, + OCFS2_MMP_MAX_CHECK_INTERVAL), + OCFS2_MMP_MIN_CHECK_INTERVAL); + } + + /* + * Unmount seems to be clean. + */ + spin_lock(&osb->osb_lock); + si->si_slots[slot].mmp_seq = OCFS2_MMP_SEQ_CLEAN; + spin_unlock(&osb->osb_lock); + + retval = ocfs2_update_disk_slot(osb, si, 0); + +wait_to_exit: + while (!kthread_should_stop()) { + set_current_state(TASK_INTERRUPTIBLE); + if (!kthread_should_stop()) + schedule(); + } + set_current_state(TASK_RUNNING); + return retval; +} + +void ocfs2_stop_mmpd(struct ocfs2_super *osb) +{ + if (osb->mmp_task) { + kthread_stop(osb->mmp_task); + osb->mmp_task = NULL; + } +} + +/* + * Protect the filesystem from being mounted more than once. + * + * This function was inspired by ext4 MMP feature. Because HA stack + * helps ocfs2 to manage nodes join/leave, so we only focus on MMP + * under nocluster mode. + * Another info is ocfs2 only uses slot 0 on nocuster mode. + * + * es_valid: + * 0: not available + * 1: valid, cluster mode + * 2: valid, nocluster mode + * + * parameters: + * osb: the struct ocfs2_super + * noclustered: under noclustered mount + * slot: prefer slot number + */ +int ocfs2_multi_mount_protect(struct ocfs2_super *osb, int noclustered) +{ + struct buffer_head *bh = NULL; + u32 seq; + struct ocfs2_slot_info *si = osb->slot_info; + unsigned int mmp_check_interval = osb->mmp_update_interval; + unsigned int wait_time = 0; + int retval = 0; + int slot = osb->slot_num; + + if (!ocfs2_uses_extended_slot_map(osb)) { + mlog(ML_WARNING, "MMP only works on extended slot map.\n"); + retval = -EINVAL; + goto bail; + } + + retval = ocfs2_refresh_slot_info(osb); + if (retval) + goto bail; + + if (mmp_check_interval < OCFS2_MMP_MIN_CHECK_INTERVAL) + mmp_check_interval = OCFS2_MMP_MIN_CHECK_INTERVAL; + + spin_lock(&osb->osb_lock); + seq = si->si_slots[slot].mmp_seq; + + if (__ocfs2_find_used_slot(si) == -ENOENT) + goto skip; + + /* TODO ocfs2-tools need to support this flag */ + if (__ocfs2_find_expected_slot(si, OCFS2_MMP_SEQ_FSCK)) { + mlog(ML_NOTICE, "fsck is running on the filesystem"); + spin_unlock(&osb->osb_lock); + retval = -EBUSY; + goto bail; + } + spin_unlock(&osb->osb_lock); + + wait_time = min(mmp_check_interval * 2 + 1, mmp_check_interval + 60); + + /* Print MMP interval if more than 20 secs. */ + if (wait_time > OCFS2_MMP_MIN_CHECK_INTERVAL * 4) + mlog(ML_WARNING, "MMP interval %u higher than expected, please" + " wait.\n", wait_time * 2); + + if (schedule_timeout_interruptible(HZ * wait_time) != 0) { + mlog(ML_WARNING, "MMP startup interrupted, failing mount.\n"); + retval = -EPERM; + goto bail; + } + + retval = ocfs2_refresh_slot_info(osb); + if (retval) + goto bail; + if (seq != si->si_slots[slot].mmp_seq) { + mlog(ML_ERROR, "Device is already active on another node.\n"); + retval = -EPERM; + goto bail; + } + + spin_lock(&osb->osb_lock); +skip: + /* + * write a new random sequence number. + */ + seq = mmp_new_seq(); + mlog(ML_ERROR, "seq: 0x%x mmp_seq: 0x%x\n", seq, si->si_slots[slot].mmp_seq); + ocfs2_set_slot(si, slot, osb->node_num, seq); + spin_unlock(&osb->osb_lock); + + ocfs2_update_disk_slot_extended(si, slot, &bh); + mlog(ML_ERROR, "seq: 0x%x mmp_seq: 0x%x\n", seq, si->si_slots[slot].mmp_seq); + retval = ocfs2_write_block(osb, bh, INODE_CACHE(si->si_inode)); + if (retval < 0) { + mlog_errno(retval); + goto bail; + } + mlog(ML_ERROR, "seq: 0x%x mmp_seq: 0x%x wait_time: %u\n", seq, si->si_slots[slot].mmp_seq, wait_time); + + /* + * wait for MMP interval and check mmp_seq. + */ + if (schedule_timeout_interruptible(HZ * wait_time) != 0) { + mlog(ML_WARNING, "MMP startup interrupted, failing mount.\n"); + retval = -EPERM; + goto bail; + } + + retval = ocfs2_refresh_slot_info(osb); + if (retval) + goto bail; + + mlog(ML_ERROR, "seq: 0x%x mmp_seq: 0x%x\n", seq, si->si_slots[slot].mmp_seq); + if (seq != si->si_slots[slot].mmp_seq) { + mlog(ML_ERROR, "Update seq failed, device is already active on another node.\n"); + retval = -EPERM; + goto bail; + } + + /* + * There are two reasons we don't create kmmpd on clustered mount: + * - ocfs2 needs to grab osb->osb_lock to modify/access osb->si. + * - For huge number nodes cluster, nodes update same sector + * of '//slot_map' will cause IO performance issue. + * + * Then there has another question: + * On clustered mount, MMP seq won't update, and MMP how to + * handle a noclustered mount when there already exist + * clustered mount. + * The answer is the rule mentioned in ocfs2_find_slot(). + */ + if (!noclustered) { + spin_lock(&osb->osb_lock); + ocfs2_set_slot(si, slot, osb->node_num, OCFS2_VALID_CLUSTER); + spin_unlock(&osb->osb_lock); + + ocfs2_update_disk_slot_extended(si, slot, &bh); + retval = ocfs2_write_block(osb, bh, INODE_CACHE(si->si_inode)); + goto bail; + } + + /* + * Start a kernel thread to update the MMP block periodically. + */ + osb->mmp_task = kthread_run(kmmpd, osb, "kmmpd-%s", osb->sb->s_id); + if (IS_ERR(osb->mmp_task)) { + osb->mmp_task = NULL; + mlog(ML_WARNING, "Unable to create kmmpd thread for %s.", + osb->sb->s_id); + retval = -EPERM; + goto bail; + } + +bail: + return retval; +} + +static void show_conflict_mnt_msg(int clustered) +{ + const char *exist = clustered ? "non-clustered" : "clustered"; + + mlog(ML_ERROR, "Found %s mount info!", exist); + mlog(ML_ERROR, "Please clean %s slotmap info for mounting.\n", exist); + mlog(ML_ERROR, "eg. remount then unmount with %s mode\n", exist); +} + +/* + * Even under readonly mode, we write slot info on disk. + * The logic is correct: if not change slot info on readonly + * mode, in cluster env, later mount from another node + * may reuse the same slot, deadlock happen! + */ int ocfs2_find_slot(struct ocfs2_super *osb) { - int status; + int status = -EPERM; int slot; + int noclustered = 0; struct ocfs2_slot_info *si; si = osb->slot_info; spin_lock(&osb->osb_lock); ocfs2_update_slot_info(si); + slot = __ocfs2_find_used_slot(si); + if (slot == 0 && + ((si->si_slots[0].sl_valid == OCFS2_VALID_NOCLUSTER) || + (si->si_slots[0].sl_valid < OCFS2_MMP_SEQ_MAX))) + noclustered = 1; - if (ocfs2_mount_local(osb)) - /* use slot 0 directly in local mode */ - slot = 0; - else { + /* + * We set a rule: + * If last mount didn't do unmount, (eg: crash), the next mount + * MUST be same mount type. + */ + if (ocfs2_mount_local(osb)) { + /* empty slotmap, or device didn't unmount from last time */ + if ((slot == -ENOENT) || noclustered) { + /* use slot 0 directly in local mode */ + slot = 0; + noclustered = 1; + } else { + spin_unlock(&osb->osb_lock); + show_conflict_mnt_msg(0); + status = -EINVAL; + goto bail; + } + } else { + if (noclustered) { + spin_unlock(&osb->osb_lock); + show_conflict_mnt_msg(1); + status = -EINVAL; + goto bail; + } /* search for ourselves first and take the slot if it already * exists. Perhaps we need to mark this in a variable for our * own journal recovery? Possibly not, though we certainly @@ -481,7 +895,21 @@ int ocfs2_find_slot(struct ocfs2_super *osb) slot, osb->dev_str); } - ocfs2_set_slot(si, slot, osb->node_num); + if (OCFS2_HAS_INCOMPAT_FEATURE(osb->sb, OCFS2_FEATURE_INCOMPAT_MMP)) { + osb->slot_num = slot; + spin_unlock(&osb->osb_lock); + status = ocfs2_multi_mount_protect(osb, noclustered); + if (status < 0) { + mlog(ML_ERROR, "MMP failed to start.\n"); + goto mmp_fail; + } + + trace_ocfs2_find_slot(osb->slot_num); + return status; + } + + ocfs2_set_slot(si, slot, osb->node_num, noclustered ? + OCFS2_VALID_NOCLUSTER : OCFS2_VALID_CLUSTER); osb->slot_num = slot; spin_unlock(&osb->osb_lock); @@ -490,6 +918,7 @@ int ocfs2_find_slot(struct ocfs2_super *osb) status = ocfs2_update_disk_slot(osb, si, osb->slot_num); if (status < 0) { mlog_errno(status); +mmp_fail: /* * if write block failed, invalidate slot to avoid overwrite * slot during dismount in case another node rightly has mounted diff --git a/fs/ocfs2/slot_map.h b/fs/ocfs2/slot_map.h index a43644570b53..d4d147b0c190 100644 --- a/fs/ocfs2/slot_map.h +++ b/fs/ocfs2/slot_map.h @@ -25,4 +25,7 @@ int ocfs2_slot_to_node_num_locked(struct ocfs2_super *osb, int slot_num, int ocfs2_clear_slot(struct ocfs2_super *osb, int slot_num); +int ocfs2_multi_mount_protect(struct ocfs2_super *osb, int noclustered); +void ocfs2_stop_mmpd(struct ocfs2_super *osb); + #endif diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index f7298816d8d9..b0e76b06efc3 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -609,6 +609,7 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) struct mount_options parsed_options; struct ocfs2_super *osb = OCFS2_SB(sb); u32 tmp; + int noclustered; sync_filesystem(sb); @@ -619,7 +620,8 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) } tmp = OCFS2_MOUNT_NOCLUSTER; - if ((osb->s_mount_opt & tmp) != (parsed_options.mount_opt & tmp)) { + noclustered = osb->s_mount_opt & tmp; + if (noclustered != (parsed_options.mount_opt & tmp)) { ret = -EINVAL; mlog(ML_ERROR, "Cannot change nocluster option on remount\n"); goto out; @@ -686,10 +688,20 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) } sb->s_flags &= ~SB_RDONLY; osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; + if (OCFS2_HAS_INCOMPAT_FEATURE(sb, OCFS2_FEATURE_INCOMPAT_MMP)) { + spin_unlock(&osb->osb_lock); + if (ocfs2_multi_mount_protect(osb, noclustered)) { + mlog(ML_ERROR, "started MMP failed.\n"); + ocfs2_stop_mmpd(osb); + ret = -EROFS; + goto unlocked_osb; + } + } } trace_ocfs2_remount(sb->s_flags, osb->osb_flags, *flags); unlock_osb: spin_unlock(&osb->osb_lock); +unlocked_osb: /* Enable quota accounting after remounting RW */ if (!ret && !(*flags & SB_RDONLY)) { if (sb_any_quota_suspended(sb)) @@ -722,6 +734,8 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ? SB_POSIXACL : 0); + if (sb_rdonly(osb->sb)) + ocfs2_stop_mmpd(osb); } out: return ret; @@ -1833,7 +1847,7 @@ static int ocfs2_mount_volume(struct super_block *sb) status = ocfs2_init_local_system_inodes(osb); if (status < 0) { mlog_errno(status); - goto out_super_lock; + goto out_find_slot; } status = ocfs2_check_volume(osb); @@ -1858,6 +1872,8 @@ static int ocfs2_mount_volume(struct super_block *sb) /* before journal shutdown, we should release slot_info */ ocfs2_free_slot_info(osb); ocfs2_journal_shutdown(osb); +out_find_slot: + ocfs2_stop_mmpd(osb); out_super_lock: ocfs2_super_unlock(osb, 1); out_dlm: @@ -1878,6 +1894,8 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) osb = OCFS2_SB(sb); BUG_ON(!osb); + ocfs2_stop_mmpd(osb); + /* Remove file check sysfs related directores/files, * and wait for the pending file check operations */ ocfs2_filecheck_remove_sysfs(osb); @@ -2086,6 +2104,7 @@ static int ocfs2_initialize_super(struct super_block *sb, snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); + osb->mmp_update_interval = le16_to_cpu(di->id2.i_super.s_mmp_update_interval); osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots); if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) { mlog(ML_ERROR, "Invalid number of node slots (%u)\n",