From patchwork Wed Apr 13 08:29:53 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: 12812040 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 4F44FC433F5 for ; Wed, 13 Apr 2022 13:48:00 +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=qR5es484pEq5hCttYNRQTelaDEfGVHBYeFO7QYehfOI=; b=MgrzCLAvT5/hPmR7hWyg3DZHXXHLa4VuGJR69VMIc8JME/3G9fVxdCAPMQF903vSeLlX5Xs+DPlm sRrSyeB445H0XGNJiKzkgkeuM9szxze/8Gs/BUhMBRX0UpAGx57wQIYfMlUrjmyX4dCxPisK1Nhi 8aCkP+2rNjgCvWTGDlh2442v0muPy/tF1MgGF3TZ5+K1ebsescuSTzLF7R5chl2K50mNSPAtMSjg 2CGVABR8lhsZTAYIFkdMLFxliS4T8+IYj2K2ZgMbhGRVUso1fhyBqes1fPQ/dxZR97gcozLut/MO NaYNmpUlLRBEEyF+kLmux3amCHFYQU+mtH/Nrw== 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=qR5es484pEq5hCttYNRQTelaDEfGVHBYeFO7QYehfOI=; b=I/GUNqH0+LiCW1sFDHskK/b/VGxXh4+TYe+sRxklyoAg7MNbMIKf01MCuYo1hy0uamS0Kh30cQbs N3h4eOiXu3mciJT9WQflVIn0OEav/hFN4mLKcV0xRoBoLpHAwEXkY740df2JLngZDpW7/A+Hv76H wiS7RAR86GrTs3rYX7anJUcr6MwvBmwoYn0bTMs6a8OsgGYdW+1pImb4tfyEwp/3cEbOGpA3rQ6G hqkJQFCKxVZvhh6/IfTeR//iqP+4kpJbww3vPxSjV/auHjzElUeRqHASzb4qjN0lb5KaVJSwdpnP hXAWn7BGsPJToQVsBOLdIZKL2YkhDNiCluHlNw== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220319 64bit (built Mar 19 2022)) with ESMTPS id <0RAA007N86BZQ570@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Wed, 13 Apr 2022 13:47:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1649838621; 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=9gi3Ipv1rJ5wE/i3sQwq4H0Tz1fg7do6AgYCt9ICc0c=; b=Tu3GLDFGoCn2vs53JfL+bkQ62M6thlXfPC03P8w6ILBXWMS2Kzr429Svb+4+wld/f975Zm gSfwPIaNCxvQTiSH6SAfnMfWnV9z0P5AwWXPu5+pOh3FnYh0qpLOPvdvJvZGWZm88DGHHj qzuU8zfflSKFlw2DvGGUYEGtPuvyyAY= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mhh2PrVGRrt2eB4E8HFC75kPPJsEenROJP4ktne/xQdPVc7WfbeHa7W6VfwAvO5UjYaBEoj5cTCHeGJNuWRE7dDsJ++V3gHFsLaw6LWSvLXz3Alu532ELFohMMIWVkrcGkBtf6H3G574wejv3hVKWzSgeJmIRRyrsUNmWXvFB383j+rgRTqkOlhdYyINrW9+bxdl2PrecBVQQz3AA81NAuAqlwNZOq1PJPDZHJYTvI6Rr6FVdf+Jv284rU33I0oyG/qrwUX0FPBpBUB/UjD7T3oLsqH9zLjOshKnhnUxOi43FOwwdi/YiGY7zv1klUpmoVGfmaCMRmGC20D/KFg1aQ== 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=OzzcJ0/NDLaO0rhBHQpYvlU2BTUyO3ZNpaDK206ExyY=; b=HgQdCsgUEcY1Jbnj+db+WNSxLnXnT+cd5zzcghu8l+wxm2+6sZ09Kek1O1i6dy+NKERYiXPKQ8gOaItBafJf/fJjgfhXzHcd3XGFgnmnItBPz6iDCQfnCQwxMzGw/MJQXhe2f/rlwIy4osJWLjTI9E6hblwvV3iE55hZ/YVrXCbeQGl4uXidsb1qBjWvAOC23PvG+mTTtyeCfTIZbGjQHgu+eqgE8JY0ZlGYztPXpbRh6K/+b11xxFAXoroUh8gxkdHhac4mgwLMbSpFYiDbbKe03GbUcXF/FFrLtNvub3kb3JVRMDGZCOozkiLiJ0fUZ4o/lAFVTwegwOZ9pmTeUw== 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: Wed, 13 Apr 2022 16:29:53 +0800 Message-id: <20220413082957.28774-2-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220413082957.28774-1-heming.zhao@suse.com> References: <20220413082957.28774-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)(316002)(6486002)(38100700002)(8936002)(36756003)(508600001)(86362001)(2616005)(26005)(6512007)(1076003)(8676002)(66556008)(66476007)(4326008)(66946007)(83380400001)(107886003)(6666004)(2906002)(186003)(6506007)(5660300002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 08:30:18.4785 (UTC) X-Source-IP: 194.104.111.102 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10315 signatures=695566 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=202 malwarescore=0 clxscore=179 phishscore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204130047 Subject: [Ocfs2-devel] [PATCH v2 1/5] ocfs2: fix mounting crash if journal is not alloced 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: 34VJPQH8PdGKxIOY5l_VnA-1 X-ClientProxiedBy: TYAPR04CA0013.apcprd04.prod.outlook.com (2603:1096:404:15::25) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf5dfa78-1e59-48ba-21e3-08da1d27d76f X-MS-TrafficTypeDiagnostic: AM9PR04MB8100: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: CmJfBy1L5CslbKD5oYK5zCnYlGba/gVQMTkgs68rh8Xc7pFtVBrrecm/d01k1DrgNR2tBl9NvWV7yaIxcQbtGrH/we/8c7aGG9mNVpUi/d/+GT4SySW+FDAiRJROdVxKfoncvlRqrXw+mN4KEqdvRzoFXU4CJo+vQHad80SNa7/MrMtVVYttS9HDLosFzddtq2ovfZg9DX7e07/5PoHJcjhNHGu51D251yzpnPdFy8gJelYv5tjtrSmGwdv2Ld50K30fnu39ngf8a0EE42p+lW2Mc7CFQN/LD4huAteH3r45vuXWX4EI3tEJ9ly0C5yQwEGNr3OSc1HuN2ZAhmgN3IzrwlqrF2sLsl8dcz9ndH6yRvsXRVdd7RWeqk3VtQaVVcowGkunHj1+Xr7ppAkTD62G7yWg/Bhi9Iucj44NR4LYw4WAx2VsHR7RsADDwojoSwA54KSADF+y6rXhUWuNzhbORkjg+RrOkH0W7KWwTnrPwi0Bb913fu0KjBwEqf8m52aePVeLikf4eL7sOAg4FWoeYMdUZ/3181ToH3WuPLOe3QheDoONafbdeg6rcbMH/Z9rYnHYg3xVjFiezzHgWHT+JjYDPm/vUfxvyvrd2I+Km3X9gsra+tHHKC+6FCp+eOIvPGn4IxFc66L0WAhNqQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I/e60tS48zdPPynu+UK62ZXdjAMKgGbc1JAdMsK4F5koc6QNlpEDVWi6jQXRi2vovMJ5Xwo9cxsyH/7HjL6SZ3Usw0q2JvOZt7wE3XCfcshQ71tCmU84iNxFRwRm3T15q+o9S4FDBQoAlu2pR5wwjg6ztwLnFBkA93AJKcVZpzU5L2FLWQ0eUz5t8cRL5tS9FO1rONCcnavcSZLBOkluQj7OpHUFM/BzR/tYEMe8sTu6Ecds7wmbVlG9PJ9h8IX+h2MuzQTlLWyWJ0VDLMeOW07zq8llH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V2IX7jAEBK8yXGxVoIcOsIekhi1FM1J+Lbl+V9J84vNfTSwYvdvm2E8eeNsSe34sy4dX/dtSTU4n072DBuY4nokzhelKsfJp1wfZOPraA/QO1DWnPkm5YGUC3dUN4mE1RUPy/1Y8xPIDIX6BnAUR88lbCI7pxsRA28i+EuwNvOU9IbyDWXeypdthva6OyU23gqFglHmsS/DdQmMqcOcRybTF2RHrcJpUzB9MFX0LSWCJQJ7M1qYVZaNDc94an9Gjxv6a2fi+rAnaAp3pTeCbrtEnCSeZHzdcv2rd1E8kfWwiwt97cEFnwkzAwfIhPatUbedIu4j4WbPfLvPHWythRQ85LYAvXR2f7xTBoHkjCSUkwh188Or6H6p445ihcJ6UZjVmT+N1Q== X-MS-Exchange-CrossTenant-Network-Message-Id: bf5dfa78-1e59-48ba-21e3-08da1d27d76f 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: qaj6Stvi8YjLQETjH9i+AmoZTiR23jMrCMPefNvERTZ1yY/rigUcZfjgbr5yvV8C8/TI2Izd5WkLRAvMDLVgXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 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-ORIG-GUID: TK3AZ0IoOX2wG_mfFE36QbDfPpjZ82y9 X-Proofpoint-GUID: TK3AZ0IoOX2wG_mfFE36QbDfPpjZ82y9 Reporting-Meta: AAEMs8xmOUj4LdOzzyjRE3od5iiOHQtlSG05ZcRwV9uwJoIkrlkfpa+eJoE+J/tk tK3q4yRrUTNuxaz/iyQX8KhLL9DcsGgi4Tj9j+ChIZLDnjIh3caHPB5MboZLq1mL 6Lks8s8cdhfCSCXYawF0N9OdXZs6w2FwciGO9vePzhcXoilgThF7DVCP2yCBqrrD 4O/kXVOkaFea+Xt8v12v6fa4ltPjPlFmB90cNOHqCfmeG9qaoEzPG0w0lbYAmHHB 26kSYcSX4As0pefc2T7/a/HrL7Rg9ef0V83S3fjet0hyL2w2waHhN5hRDCMxPZsy v0AkUKDyHrlgsQ+CxPQhyR/NgrYG5FOU7f4nJmNv59wRWHFeyjiIsnHB0G3Fx/nb GmV93m3jmnjDTTdcK3y/XiKLeE6DA9N4+o9B222FEy9aACXKM2/nNyWCVqpyB4ir HwV+Sf+3dFOnJtOqskjyBqH+jz7MMzXZ48h3iJj5CsJ7EioLTQ8iUJsjB9CfogD4 uhIksJpeRXiuspj5M8QgSP0x2qEfFnn94ZYqhQnBT+9a After commit da5e7c87827e8 ("ocfs2: cleanup journal init and shutdown"), journal init later than before, it makes NULL pointer access in free routine. Crash flow: ocfs2_fill_super + ocfs2_mount_volume | + ocfs2_dlm_init //fail & return, osb->journal is NULL. | + ... | + ocfs2_check_volume //no chance to init osb->journal | + ... + ocfs2_dismount_volume ocfs2_release_system_inodes ... evict ... ocfs2_clear_inode ocfs2_checkpoint_inode ocfs2_ci_fully_checkpointed time_after(journal->j_trans_id, ci->ci_last_trans) + journal is empty, crash! For fixing, there are three solutions: 1> Partly revert commit da5e7c87827e8 For avoiding kernel crash, this make sense for us. We only concerned whether there has any non-system inode access before dlm init. The answer is NO. And all journal replay/recovery handling happen after dlm & journal init done. So this method is not graceful but workable. 2> Add osb->journal check in free inode routine (eg ocfs2_clear_inode) The fix code is special for mounting phase, but it will continue working after mounting stage. In another word, this method adds useless code in normal inode free flow. 3> Do directly free inode in mounting phase This method is brutal/complex and may introduce unsafe code, currently maintainer didn't like. At last, we chose method <1> and did partly reverted job. We reverted journal init codes, and kept cleanup codes flow. Fixes: da5e7c87827e8 ("ocfs2: cleanup journal init and shutdown") Signed-off-by: Heming Zhao --- fs/ocfs2/inode.c | 4 ++-- fs/ocfs2/journal.c | 32 ++++++++++++++++++++++---------- fs/ocfs2/super.c | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 5739dc301569..bb116c39b581 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -125,6 +125,7 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags, struct inode *inode = NULL; struct super_block *sb = osb->sb; struct ocfs2_find_inode_args args; + journal_t *journal = osb->journal->j_journal; trace_ocfs2_iget_begin((unsigned long long)blkno, flags, sysfile_type); @@ -171,11 +172,10 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags, * part of the transaction - the inode could have been reclaimed and * now it is reread from disk. */ - if (osb->journal) { + if (journal) { transaction_t *transaction; tid_t tid; struct ocfs2_inode_info *oi = OCFS2_I(inode); - journal_t *journal = osb->journal->j_journal; read_lock(&journal->j_state_lock); if (journal->j_running_transaction) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 1887a2708709..49255fddce45 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -810,22 +810,20 @@ void ocfs2_set_journal_params(struct ocfs2_super *osb) write_unlock(&journal->j_state_lock); } -int ocfs2_journal_init(struct ocfs2_super *osb, int *dirty) +/* + * alloc & initialize skeleton for journal structure. + * ocfs2_journal_init() will make fs have journal ability. + */ +int ocfs2_journal_alloc(struct ocfs2_super *osb) { - int status = -1; - struct inode *inode = NULL; /* the journal inode */ - journal_t *j_journal = NULL; - struct ocfs2_journal *journal = NULL; - struct ocfs2_dinode *di = NULL; - struct buffer_head *bh = NULL; - int inode_lock = 0; + int status = 0; + struct ocfs2_journal *journal; - /* initialize our journal structure */ journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL); if (!journal) { mlog(ML_ERROR, "unable to alloc journal\n"); status = -ENOMEM; - goto done; + goto bail; } osb->journal = journal; journal->j_osb = osb; @@ -839,6 +837,20 @@ int ocfs2_journal_init(struct ocfs2_super *osb, int *dirty) INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery); journal->j_state = OCFS2_JOURNAL_FREE; +bail: + return status; +} + +int ocfs2_journal_init(struct ocfs2_super *osb, int *dirty) +{ + int status = -1; + struct inode *inode = NULL; /* the journal inode */ + journal_t *j_journal = NULL; + struct ocfs2_journal *journal = osb->journal; + struct ocfs2_dinode *di = NULL; + struct buffer_head *bh = NULL; + int inode_lock = 0; + /* already have the inode for our journal */ inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, osb->slot_num); diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 477cdf94122e..babec2c9d638 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -2015,6 +2015,7 @@ static int ocfs2_initialize_super(struct super_block *sb, int i, cbits, bbits; struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data; struct inode *inode = NULL; + struct ocfs2_journal *journal; struct ocfs2_super *osb; u64 total_blocks; @@ -2195,6 +2196,15 @@ static int ocfs2_initialize_super(struct super_block *sb, get_random_bytes(&osb->s_next_generation, sizeof(u32)); + /* + * FIXME + * This should be done in ocfs2_journal_init(), but any inode + * writes back operation will cause the filesystem to crash. + */ + status = ocfs2_journal_alloc(osb); + if (status) + goto bail; + INIT_WORK(&osb->dquot_drop_work, ocfs2_drop_dquot_refs); init_llist_head(&osb->dquot_drop_list); @@ -2483,6 +2493,12 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb) kfree(osb->osb_orphan_wipes); kfree(osb->slot_recovery_generations); + /* FIXME + * This belongs in journal shutdown, but because we have to + * allocate osb->journal at the middle of ocfs2_initialize_super(), + * we free it here. + */ + kfree(osb->journal); kfree(osb->local_alloc_copy); kfree(osb->uuid_str); kfree(osb->vol_label); From patchwork Wed Apr 13 08:29:54 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: 12811839 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (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 D9EFCC433EF for ; Wed, 13 Apr 2022 10:05:12 +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=EonWfD5oayTWmLVCw6Ee4yHLqdab3EnLtrHINobJPp8=; b=kLfTxyAszDNaYSRalm3NX4nTDghLeBaQkgdB1UKnJNwn/L6XQrE8fLg/5JDSr4iWxPIRiOKZ4D0o 8eSi7yhvYxHBH5hkMbmZs8oyjgejFwf5rRD6IFDC2pO+ZzG07EGtXeSEcq7QeS7v6ZlDX63tDDJX uhzTvCtTE+Ji3kMBum/AvK1ICEM70OkT89+dA/L3ljJuJechsgLDrbRBKlEYoxT2hwoKIYtbE7+3 TOoutI0j3KfSI9UuZo/nh6Ucu7yia2CQs4o+ZrQFnsBRvKN/EwHqGbrP+A3NS5Wqc/HG3fe3BvpZ 16Png6nqSlkQPrh0/fZjjE8qAYngEefEnHZF3g== 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=EonWfD5oayTWmLVCw6Ee4yHLqdab3EnLtrHINobJPp8=; b=Q23c7CT/6cldBBfquBdOLS1VzOt727yfX8MLyGVvOu1KAW3lPrTHbZp4cm3PLQTWwUcA0IlIDUn6 6u5Z+504XNjOMvYSzQwXfGiYpH+AxyVcdRDVG/rFMfUE7vwRX1sHVw/LD/QEkVuGb1GlGFlATUuw mGHYTEqq1NvP9/qd4zWrr5D1suMB1GWGy5nqqeRo44Pstqpj3gD1kuIC/RBpyL6cDREk94449+hw D6ZTia13vY+7b4oLKvNk5uwZox65CDMo/MOCSlXCZ3MsSSJPLjirE7gFnMZy2SHyysu1/SXJTwtO RzucdJ+WRjAbi/WpWiWu1lcu8Ej8TZ3Q6zaYyQ== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220319 64bit (built Mar 19 2022)) with ESMTPS id <0RA9001ZOW0O6W70@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Wed, 13 Apr 2022 10:05:12 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1649838628; 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=w1fN5PKVHQ3C4Na1DwohHEyVc/EpHkk6iJz2kYgELLA=; b=ZrT8Q4ix5DJk8UQx38G/tZH9sVjXaFXDcSJMfhxzYd6Q/18dRuHHZb32a9W1JeuCIzdSqn dsA29VU4p3W9y2eP4CVGAyK4alYXqf9BD8jtP9BSxms9vkkbxEH/Od+DPXlOj+XMS/jmOM tDgdJm5GT7UBUlXlvfc53/UcN3ZwEwE= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hlXvnwUL3FCkBOPJQJwyW2vlTGoqC7ZeUEhqXiCnLSkIGFS+pWbYaKyebhaEpF4VNvDNnVJlsV6dJUGXFDtq8GaQzoydZZOM1Zl2+uO8BCIw03rVK3PykmWnPW9sI4r8z2wGCCGZ5jZlfpFrAFlqe+siN7IYh6FLNRlpp18RCEdjUYw7DfMXL+qVY9KEeY07Xuo0wJVBATuSZLdho9Cr+VjOZdV6rrzbU7trUtVY8din8rVzDmjnWUmSRDneoTFF/COj5IxTHIjXRZJwlphjAwaY8WgQWX6f8lI+UOk5+H3CvFMacgqhFUlSS44GATyBr6JvTthrEbW7Aaph8FuFeA== 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=9BzVf/NOcs7f5uTMYB4NRc+D90MHqXSlaIPSWccqPes=; b=gBAHttxgAZNnerRdUGMmRcb4lBdEyPcsFTe/E5S5vNplosNnlJrqqD3liO9bKVXxUiE+BvAWjTUBZu9hS9kvCFk+cKFjHl2TJ73ZeM4paccguDPnu9GpZ1rm3ttSe3sEbFPgRvGrrFptcVHR6Kun59RP2KIB906DFLMYCZaGmdDRZO0phzgFyZaBIxpYmngk5m/iKHcGoFeUkFUgbMfexBMQHUDnn3NnELPq2BvsrkGeG36F8oPIL/iDw86qwsd5Lrz+YcmIAOAP9FU4fXibczFYJsBtUmuu07jJl1UWVHNihfok1Nm+1dxnAVxTL2zLivaw8qLZ5xtgvGe/z+Ob5A== 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: Wed, 13 Apr 2022 16:29:54 +0800 Message-id: <20220413082957.28774-3-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220413082957.28774-1-heming.zhao@suse.com> References: <20220413082957.28774-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)(316002)(6486002)(38100700002)(8936002)(36756003)(508600001)(86362001)(2616005)(26005)(6512007)(1076003)(8676002)(66556008)(66476007)(4326008)(66946007)(83380400001)(107886003)(6666004)(2906002)(186003)(6506007)(5660300002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 08:30:27.1029 (UTC) X-Source-IP: 194.104.111.102 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10315 signatures=695566 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=225 malwarescore=0 clxscore=165 phishscore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204130047 Subject: [Ocfs2-devel] [PATCH v2 2/5] ocfs2: change return type of ocfs2_resmap_init 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: 58FL_ohmOe-Cboi8jpMkkQ-1 X-ClientProxiedBy: TYAPR04CA0016.apcprd04.prod.outlook.com (2603:1096:404:15::28) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c70d5b54-8dc9-4a31-7ab1-08da1d27dcb4 X-MS-TrafficTypeDiagnostic: AM9PR04MB8100: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: G2aFjRSq+7IOabd2RrxM3SGeXlz1/rn/jW3jELVCYVD/VD5ghBoDcoZNTDwoy2WjrEt2AlgO6qiRIxfol89V/q1FpT0F/MXey/MgPa7/fpPvxizQ1qY8d7s/t5zlk6Fjnemq4ebcruL3NPMLd1mhbSBRW0vnjzWxNEsFV0QkjkaErhQ2mT0rXOKZ23UZbsVTiFYhkhJ4mYddtDeVIDo1Kx/fu1CveGBLOTL+ik53d2GywYZc28JaAucO6lpOoORgapj1fGNzfSD3Qb0toPszymt4so44RuP3OjNEP7+VOtUcF/q3XqmecbHYpD0slHFVYx2gw4Z2eaQnQwtcMXCa/2gCfIBFNAQ1s66HWUXLD/X3JLMnr2dDm4PchNn38EHBeENTeHO3BI8HcxrZjozGYfPIzZH7JJynZNdqS3nk4Pnn8kk2YPaJxm7V5iAKBAJ/h1vkAfrWOkboqfB7MSEEUs7LLN/uEAS3RMGAAdQo6aQaAYoD85F6srkPXjqUMXwgvlNeQinAmMkRvFle8UzfjF1Dh1gQw+TwAbKVf3KXOxX7nb/ChcJ6xCqRFZwym3ZFW/uzJ/0RVZBuE00Om4u7Z+7k/jqVOQpHfDbi0VFKktbRjdBMFD/2bOiXBIWqzSt7cP+66u3sPH5hw05KgttqkA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G4rZ1kOtgy/gbQxs5Y3Ww13i0wFUP1tRJXvXTNDhUuyGs4aR/B4tUG1usgeKp7Gjva0bmjMdU9qQTCzHGLuh7u2nGl6+8zqRkViNOhR+kNRNvo3jczpfMYifu7vRamXwyld8HKxxU7zupIuFBVGCnhVqeDLhVWzJOpZPO6iMqafqKh8DN8o+WNZpUhvmWPmDj7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ZNRKhAZicAnhJa42weRCF62DAbEQ4o4UPnsJIH0SW/x9udV0ws5yi5TmHXiHW1FomE81qsfwUpS/krA7LNt8cr8HIgYQaVZHgVIMm2bof4tOnhKix5er+FjRo86m6zVOIZO4zlnmml+y2hy72TB26HKtmlvmfN07RQ0pLetKX24xeHmKRiGQ6OR5wfkH1N3KqqzuipluySDHQM25uwxJzYrqeG5i42udrcc+y7vEKv+Q1/XLCYgHz2Ljb9hm+1VFrtOwU0vybT5S9OCB6xMArl8ark1Md0kll2bFOZdE/AoPxvMNhIHc6EwOzVxxVuTbcUFuouina6PIlCOsakIWSpa27XsHuO5TxeTnyvO8y1m08lN7KM24xOxl6QwHisWMEK/Lr+kEp2/CAJQJ8/eh9fJs5v/3mJHRmXlr3wtvCgJ2NbDhjLUGox9sHWZFZN6EW99Yh/H99kuIHOOC0nkQGTw/wmEIfQHxKxQ== X-MS-Exchange-CrossTenant-Network-Message-Id: c70d5b54-8dc9-4a31-7ab1-08da1d27dcb4 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: 5e27c9Ph4Mu0KerAz+qBXn5gLNv+kMBG1Fe2r/pVNLwN4Ulmen9JjX3teSRTwLRUD0RQxum9Fu2P8dIwlkYYKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 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-ORIG-GUID: kJZPrOgzdc5TX3tPvj-GTIFG0Qzx2DqS X-Proofpoint-GUID: kJZPrOgzdc5TX3tPvj-GTIFG0Qzx2DqS Reporting-Meta: AAFRRFPzCOYA7scLqU+Bh6De4YR3aJptXLz2lwKMY4AFW2UjnI4G6YPVlBWKTEy+ 85membudIqfGt2LRoYCQudOcBFEQ/MOor0CiXsUZ69xzgGA8cFQSWNbJ4OFCFN0x mAUMfb9/6pBxbwtNTh4RWGChZyP5JlbWV+edhq5a/3G2gNN3xwPxyZirA4WrfDWG wF9Zktn22sq4jq2CcMIeK3atOLDNJrBg6POXb97TkRqesMTRi2bBSwn8DTidYGwT uJf12+xTPt8TmQ67coadknWbZVTDBa6tV8uL+FPeo3Vfhm2IZlkagSSaQaOB5Azh 1CuqAZNdjTftQUL3SsdqPpJOI0l9T9j1c2EqzcIRKPmyV/Lrc3Nk4LLzQzUplYpU uCnXNWsQq9TCffE6h3we4YoBoyTQoML9mnK3dpQvzOMbtLWIBXktRekXBgbLGmhT 3cp5aWVucsaTDqpZniBXcV3i6AirprIV+JGmPci8lWWTC+4g1UN6y9OiP0cTfYNc b15x9lUw9DtYS5fn4dUgQ4tEUGOjiG7rZ99/bUUKXU4= Since ocfs2_resmap_init() always return 0, change it to void. Signed-off-by: Heming Zhao Reviewed-by: Joseph Qi --- fs/ocfs2/reservations.c | 4 +--- fs/ocfs2/reservations.h | 9 ++------- fs/ocfs2/super.c | 6 +----- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/fs/ocfs2/reservations.c b/fs/ocfs2/reservations.c index 769e466887b0..a9d1296d736d 100644 --- a/fs/ocfs2/reservations.c +++ b/fs/ocfs2/reservations.c @@ -198,7 +198,7 @@ void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv, resv->r_flags |= flags; } -int ocfs2_resmap_init(struct ocfs2_super *osb, +void ocfs2_resmap_init(struct ocfs2_super *osb, struct ocfs2_reservation_map *resmap) { memset(resmap, 0, sizeof(*resmap)); @@ -207,8 +207,6 @@ int ocfs2_resmap_init(struct ocfs2_super *osb, resmap->m_reservations = RB_ROOT; /* m_bitmap_len is initialized to zero by the above memset. */ INIT_LIST_HEAD(&resmap->m_lru); - - return 0; } static void ocfs2_resv_mark_lru(struct ocfs2_reservation_map *resmap, diff --git a/fs/ocfs2/reservations.h b/fs/ocfs2/reservations.h index 677c50663595..ec8101ef5717 100644 --- a/fs/ocfs2/reservations.h +++ b/fs/ocfs2/reservations.h @@ -73,15 +73,10 @@ void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, /** * ocfs2_resmap_init() - Initialize fields of a reservations bitmap + * @osb: struct ocfs2_super to be saved in resmap * @resmap: struct ocfs2_reservation_map to initialize - * @obj: unused for now - * @ops: unused for now - * @max_bitmap_bytes: Maximum size of the bitmap (typically blocksize) - * - * Only possible return value other than '0' is -ENOMEM for failure to - * allocation mirror bitmap. */ -int ocfs2_resmap_init(struct ocfs2_super *osb, +void ocfs2_resmap_init(struct ocfs2_super *osb, struct ocfs2_reservation_map *resmap); /** diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index babec2c9d638..7076125f5b46 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -2111,11 +2111,7 @@ static int ocfs2_initialize_super(struct super_block *sb, init_waitqueue_head(&osb->osb_mount_event); - status = ocfs2_resmap_init(osb, &osb->osb_la_resmap); - if (status) { - mlog_errno(status); - goto bail; - } + ocfs2_resmap_init(osb, &osb->osb_la_resmap); osb->vol_label = kmalloc(OCFS2_MAX_VOL_LABEL_LEN, GFP_KERNEL); if (!osb->vol_label) { From patchwork Wed Apr 13 08:29:55 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: 12812055 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 D0E9FC433FE for ; Wed, 13 Apr 2022 13:50:54 +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=yKtwdSoG6Mn29Ao82UIQQSbJApfuOAQaxQ6HIaBcutA=; b=KmISFVqwplennGlQEo2+1q0M4/esbiw+wUx8BAAMX18uI4A75B7cV3307HG7XTgo0e4eiGj9wyYI gw4PIsdYs00TwiB5eCzfyMomD/bh/F2+/SRcrnIkuLQu69e+KhWuEiIkiFa0HlvI7LiCu+x/NS8H I9BItrbTGTjINEGAM97PJpk7fEHupndZITQUKe/PL1rHT3tRB/qi0qPwY1ngLhaP6vVeyJpCLerg T3rRj2RgxHjFFn7DlnqxQk/F0W4xzC4mj8hJT+q0t1nN6NIrB5k4ntMu0vATtmDMi1aHv72UK6p+ 4obkKXqkJVz2iwvLbZR4LR+UVZ1vJkuNz7/7mw== 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=yKtwdSoG6Mn29Ao82UIQQSbJApfuOAQaxQ6HIaBcutA=; b=W7SEsNLBkk7LtJfG3oCsTh15ixScbz7M5vGnRivdNX55HagFYYVSGOuCkoRZQgRQZabSv8jsw+wP UJNqcVOpJJtoIXszLbW6gqV9I6VDptF2qTy5kWZtr3guBEyaEchfqlZvHq/SIJ9AklHRSf/3AN7Q /AjP4hmRzOvX0zhGlvfwdixLXn7wkt6z3ZbR7CU2cvL7F3Y83ctvespCsGJAP5TE/Sx+KRGhN7M2 NaC05H818DF+Qf5SWTF4ER21CYWYsz1imUB4sS2AEHOFeKh5yL5VeqklvVdnWyyi+tA/hsDnHLlE KEWrWCKKLXNRp1RKJCUOl6N+MV21gXDrsx1yLg== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220319 64bit (built Mar 19 2022)) with ESMTPS id <0RAA004OE6GUUY70@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Wed, 13 Apr 2022 13:50:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1649838638; 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=Ta6kF3L0w3X9dxZXi5dX0moODGNzVF58ft5uqaNKXhI=; b=NqNC5kyWWiv5+fVv2xiwrT0u+tJjQWgjMkH/ysEa1e18Yxi32badydXhZDMLrEdcQS2bgK 2+vsicu86ElBPTFuvGPawNMsS9UFQ8Ozk84JUAsLh7oBBnhzKzNfb9eahtz2qpbeTrAXLF m/BnqbTclS7306OOs+PR6PoYqN4GuLg= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OKp73bppgeqVABsnfgu31sN27XVAIc/6oDrQAqEVfZHezwdorj1uXYSgYX1u6nkqG3+owQTMNnwRN4qga1i4Yx52PXZAzH2TY4/1lMjkNmSaKQXue40pdHtLX9SYEwhoZL/pbcVbM2MUnSgawKdnL08udiI2DCAt9phrJHqnDj3DiuDOJCxLYwSNkymXwnOeF9secsOI3WQi+SM1hm3Dca5M/pKzvZmrC04OWa4BNCK+8JLWH4h71uVkp2s9LNgeUUh8UDe0cnhPRiV2T7QQq/HFDjB40aElQauH9ht8RAFYyXgWZMfoUbKITI2u8k7dj5WGkh4eVxtLHDnoY0MPHQ== 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=u1DEE5+yVgyC0/njfhLkiM9eSCpHnirRql5N9hoyZVo=; b=f8MZg6xn8CgtahUaXj/lMEdIQ7rpd4kDZScUyyWnRq/u6kUNzWRqCf6J97vqsZsxXl2M67WoXi+E4SK8kZMtDAw13xiS7NTaj1rPS/52d+gnY/ZDoP9KJqkUj4hnNZKLLpvyEBboWVbyveaVcdooQrTZGjDNQQ4FXR8fuOp/3rnzL8Ri25rqtb6FVAvyQHfruEBeEcp/AFprb7tqDgmAQ9/bEwIBe61+f+ebuVA4i2xmSgWJIYNy10LoNzB7SW///dT/WqeE6x6H32WpCeGqvT2/p7FSO+weRZC3SA7tb8Gx93tTnQdj/7Vle3GEZineYSqRVQ/TqudTGFHtaqSmSg== 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: Wed, 13 Apr 2022 16:29:55 +0800 Message-id: <20220413082957.28774-4-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220413082957.28774-1-heming.zhao@suse.com> References: <20220413082957.28774-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)(316002)(6486002)(38100700002)(8936002)(36756003)(508600001)(86362001)(2616005)(26005)(6512007)(1076003)(8676002)(66556008)(66476007)(4326008)(66946007)(83380400001)(107886003)(6666004)(2906002)(186003)(6506007)(5660300002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 08:30:36.5553 (UTC) X-Source-IP: 194.104.109.102 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10315 signatures=695566 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 spamscore=0 mlxscore=0 clxscore=176 mlxlogscore=999 priorityscore=178 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204130048 Subject: [Ocfs2-devel] [PATCH v2 3/5] ocfs2: ocfs2_initialize_super does cleanup job before return error 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: k4mqwODJOkOj1EfHDHDa7g-1 X-ClientProxiedBy: TY2PR06CA0035.apcprd06.prod.outlook.com (2603:1096:404:2e::23) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84546787-7fd9-41ba-a860-08da1d27e230 X-MS-TrafficTypeDiagnostic: AM9PR04MB8100: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: Swc/RMCFkRu2WNN3B0TuEW/hZcDpKwN9LgP++V1A7CtuzrwjxHmMiuJcL2IVUUTjA85MgfwzUaas/QffgvjM6cwr2wyLO3+kZm/Ul0rIXuOdCWgAhgCtvA5EXWpJSEHANL5VAKRhrq70AMOOY7rK66hc12Slzk2i8ftRhRq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fom0eYrOyH3mAB6igCEPLzAHNkLYET+YtkYzINX6kDvHEYMqm6cgWCvJUgQB2DQ9PgmT1LNAuYfvQ977bABU5CuXQ9ekO+EFM6bGedGlcDwddQ6crmIWQj2XM4yVJKiAkKbmkcqO2xTYXsh8Gn9EhBkZ4eAhD9JA== X-MS-Exchange-CrossTenant-Network-Message-Id: 84546787-7fd9-41ba-a860-08da1d27e230 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: jyHKtGbiYhC8ywNyRW1u9IoJMk3nb3vQb4dgSZvaI7IWQTodS9HYCjC5it/GBhSUFboczK0zyDE+m8pqo/bDlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 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-ORIG-GUID: GyzsKVLYkVg7n7nk7h3FybbYcUqDk82T X-Proofpoint-GUID: GyzsKVLYkVg7n7nk7h3FybbYcUqDk82T Reporting-Meta: AAGnNbjM3X4BlyMGdKKHqt2dZiIQfnZtimhveY7oaF4ZnaHCRrDWUlALLkh7i1cF oY/Lkzp4gKFijjd2F0FTSU/KnZTBVq9X0z1BP7xdw33wk9A12iuHszTXIkWFmNit VKVAg0ulcPWsbS62xlyCoDCmJSOTNp7v+sKSZqZp9gg1n7MXIX6hqihn+aR+l3fS 91XqhgmCTCXrGvGNM1Szznk1/KFB19M8j9qMoi9Ja7U8XmRsy50c2KINpyFmKw32 8OQ23E9+jbKaRN88gc5SNoUNH7g70W5mKadG/oH3pkET0l9pG3w8wSP8Z5CRSUJ9 4wbfLjWcbRVuvBlnZ3ycyJXtM8iK+1wzS8/YJbo6uIS5yF54D1Fc4ZIxQrUNLHy+ /i8ijSm/h04zGYPXwSa+m8Twvd23V+x4ViPv65PX34x34I/qmz38mWc+W7SGZ/bj P1gBHagwavmg6aUxC4xKx0LlgZ6cllcJiD01Qle3OfZWPOC0p7u6rP7HLAfWCX6H A79fHrQMFGBmSzkOjrOflEzN3oLFBOVH8u+s3vmHl/n+ After this patch, when error, ocfs2_fill_super doesn't take care to release resources which are allocated in ocfs2_initialize_super. Signed-off-by: Heming Zhao --- fs/ocfs2/super.c | 59 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 7076125f5b46..4302c3e9598c 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -2023,7 +2023,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (!osb) { status = -ENOMEM; mlog_errno(status); - goto bail; + goto out; } sb->s_fs_info = osb; @@ -2084,7 +2084,7 @@ static int ocfs2_initialize_super(struct super_block *sb, mlog(ML_ERROR, "Invalid number of node slots (%u)\n", osb->max_slots); status = -EINVAL; - goto bail; + goto out; } ocfs2_orphan_scan_init(osb); @@ -2093,7 +2093,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (status) { mlog(ML_ERROR, "Unable to initialize recovery state\n"); mlog_errno(status); - goto bail; + goto out; } init_waitqueue_head(&osb->checkpoint_event); @@ -2117,7 +2117,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (!osb->vol_label) { mlog(ML_ERROR, "unable to alloc vol label\n"); status = -ENOMEM; - goto bail; + goto out_recovery_map; } osb->slot_recovery_generations = @@ -2126,7 +2126,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (!osb->slot_recovery_generations) { status = -ENOMEM; mlog_errno(status); - goto bail; + goto out_vol_label; } init_waitqueue_head(&osb->osb_wipe_event); @@ -2136,7 +2136,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (!osb->osb_orphan_wipes) { status = -ENOMEM; mlog_errno(status); - goto bail; + goto out_slot_recovery_gen; } osb->osb_rf_lock_tree = RB_ROOT; @@ -2152,13 +2152,13 @@ static int ocfs2_initialize_super(struct super_block *sb, mlog(ML_ERROR, "couldn't mount because of unsupported " "optional features (%x).\n", i); status = -EINVAL; - goto bail; + goto out_orphan_wipes; } if (!sb_rdonly(osb->sb) && (i = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP))) { mlog(ML_ERROR, "couldn't mount RDWR because of " "unsupported optional features (%x).\n", i); status = -EINVAL; - goto bail; + goto out_orphan_wipes; } if (ocfs2_clusterinfo_valid(osb)) { @@ -2179,7 +2179,7 @@ static int ocfs2_initialize_super(struct super_block *sb, "cluster stack label (%s) \n", osb->osb_cluster_stack); status = -EINVAL; - goto bail; + goto out_orphan_wipes; } memcpy(osb->osb_cluster_name, OCFS2_RAW_SB(di)->s_cluster_info.ci_cluster, @@ -2199,7 +2199,7 @@ static int ocfs2_initialize_super(struct super_block *sb, */ status = ocfs2_journal_alloc(osb); if (status) - goto bail; + goto out_orphan_wipes; INIT_WORK(&osb->dquot_drop_work, ocfs2_drop_dquot_refs); init_llist_head(&osb->dquot_drop_list); @@ -2214,7 +2214,7 @@ static int ocfs2_initialize_super(struct super_block *sb, mlog(ML_ERROR, "Volume has invalid cluster size (%d)\n", osb->s_clustersize); status = -EINVAL; - goto bail; + goto out_journal; } total_blocks = ocfs2_clusters_to_blocks(osb->sb, @@ -2226,14 +2226,14 @@ static int ocfs2_initialize_super(struct super_block *sb, mlog(ML_ERROR, "Volume too large " "to mount safely on this system"); status = -EFBIG; - goto bail; + goto out_journal; } if (ocfs2_setup_osb_uuid(osb, di->id2.i_super.s_uuid, sizeof(di->id2.i_super.s_uuid))) { mlog(ML_ERROR, "Out of memory trying to setup our uuid.\n"); status = -ENOMEM; - goto bail; + goto out_journal; } strlcpy(osb->vol_label, di->id2.i_super.s_label, @@ -2253,7 +2253,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (!osb->osb_dlm_debug) { status = -ENOMEM; mlog_errno(status); - goto bail; + goto out_uuid_str; } atomic_set(&osb->vol_state, VOLUME_INIT); @@ -2262,7 +2262,7 @@ static int ocfs2_initialize_super(struct super_block *sb, status = ocfs2_init_global_system_inodes(osb); if (status < 0) { mlog_errno(status); - goto bail; + goto out_dlm_out; } /* @@ -2273,7 +2273,7 @@ static int ocfs2_initialize_super(struct super_block *sb, if (!inode) { status = -EINVAL; mlog_errno(status); - goto bail; + goto out_system_inodes; } osb->bitmap_blkno = OCFS2_I(inode)->ip_blkno; @@ -2286,16 +2286,39 @@ static int ocfs2_initialize_super(struct super_block *sb, status = ocfs2_init_slot_info(osb); if (status < 0) { mlog_errno(status); - goto bail; + goto out_system_inodes; } osb->ocfs2_wq = alloc_ordered_workqueue("ocfs2_wq", WQ_MEM_RECLAIM); if (!osb->ocfs2_wq) { status = -ENOMEM; mlog_errno(status); + goto out_slot_info; } -bail: + return status; + +out_slot_info: + ocfs2_free_slot_info(osb); +out_system_inodes: + ocfs2_release_system_inodes(osb); +out_dlm_out: + ocfs2_put_dlm_debug(osb->osb_dlm_debug); +out_uuid_str: + kfree(osb->uuid_str); +out_journal: + kfree(osb->journal); +out_orphan_wipes: + kfree(osb->osb_orphan_wipes); +out_slot_recovery_gen: + kfree(osb->slot_recovery_generations); +out_vol_label: + kfree(osb->vol_label); +out_recovery_map: + kfree(osb->recovery_map); +out: + kfree(osb); + sb->s_fs_info = NULL; return status; } From patchwork Wed Apr 13 08:29:56 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: 12811840 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (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 A8913C433F5 for ; Wed, 13 Apr 2022 10:05: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=BjyfFbrFxf8tdsSaH/28PoC+2BeWx7zchIeEvkmyKbM=; b=Pvi+kAOYZd5oL1akEcA01lJam7izBJVwDhqsFGM7/v5obKJlcU/3hsa1JDbG8hC0U/6Js70GQcSb AdPITcRqMD7N322xlhgsMx0MXa6APOWoJ7Ujk7T5LrJKJj6l9+zYL0iZWxX1Qf7WUEiow7DVE9Eb Y302CbhHuhle/zMYY0XlM1c2Xyi13FoPR9QGWaU/FWrs6T+W010+UEJxkLJSQ2xV7EMUegsXoJoD 3GFvkBEOUW/xZTYQp1FeDzPhtnWjSJ/UgISrR7DDRIJ8LfXciEGMHQtW8p2nHlbt0+bZV5VBrfqw iWWQQR1Pb0VFt28xj7iYUCzId6Bqtgx/s332Mw== 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=BjyfFbrFxf8tdsSaH/28PoC+2BeWx7zchIeEvkmyKbM=; b=t2JwL7qE++aK5xXKDh9cEI5t1g1zmRxgWXXjNXD6gwDYZCYuWiFoM52hCNMlb+E1it8wQo9b2UrE YkcNgkYtPHoTjcu8NK7YYIg23kUndZSn1wkAprojH2XVZxHrMLI1PtnYPr1TCY1AhZNpqUj58PsJ cyw2+tBpQkshwFJd1dEC4dLzpg7OMMxSTgWH9zW6+WNVBETNkxZ0WyWNzYJ9p998ae0WL+Nz7wYu T7tGQEfryAv5cBT2/t0eDWp7GzF5228DenMp5ImGpc67HOvr+WfhUseQW3nLf6PTnO0EmNBqvljw 7IWJfEeEf3ImQ0VGrFYgWkrLRGYsoE+2Snw34Q== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220319 64bit (built Mar 19 2022)) with ESMTPS id <0RA90010FW1R6W80@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Wed, 13 Apr 2022 10:05:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1649838649; 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=2uiCqWXBBPKrJm2qBFdAVw3E+YWomuIoLbdOzCIvGtY=; b=hMK5c6hk6/t3A6uU413HVTefsdp2ADgAh5ZfWFiejQ9b+XqIZpnZs7/IHJ7UT0Lsppwpzs FTI1U2lO8e5J24PXRRhiS3XAA5MMr7lLv4ozKtdbvOjxZQAVfCYzc9HA2Sd7WDr64MSrBK SB7VdEksEBhljq/PEOZPJk3yCuPdFyo= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ValNMGk10hZ0aSYbo+NTDg8uoLTQBKtW9ku5ZWlVA0FEm9U81+l6DWqMt9Vbo3md7n4+CREguYZvQPaTVAFhfBnaXodwDt0ETSPEc+50LBhAUgzhg/n1/jw7/I+Ibghfr642ebjPtFaLYxAFQtYxKCtFf6LbY0sMk4cwzdHEYRWFK9DClsSAJ7BcAMOubLUS+3hHc6ovpcixfU/p5fYfAOiD2ERkHXRdIMHDDXFtiMEHcfmXgxm07DWpr7OF6FpL60kIjiC/M5GD6u8dTZ14MXLktyFgujEu8D84schsKq/RUiukeS3lgufPoNy42OQxhEPf/zpUqJna/QkuzkRURQ== 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=GHP/41mZkK3isCHKViJs17Vf5Nfb2a0JAuTZ6kbQVKE=; b=T4NbDlOwkCb+WSWatU4Zj6TjFSTRZGP0GxBDPBW7Zb3dif0YXt7Gj18hpconn9rn349wiDbG2l7jo8tm1+0UAMl/JVtLXb6xJLJtd//3vXSCAJeFujWfk1NKRoz7BWVC7j7p80d+vz9BInyFnuD/1Kl3hevN/kobteR+erLayo4/l1hX/kdl/0KKKRkn3SvUYvW1woC5kKrDmQzudyd5d3SydFixfXL3LkgzPWx0pByk7rDBjJ7X+7CBGTzmxnW18VSBgZ3ACgqaBUl0gCXy0eDfGuGMFWCosaUgyRbMk6zmkxtjnbjd9+EZ/n/gGIcyf0WlvCKDuEcml7hTDNuTAA== 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: Wed, 13 Apr 2022 16:29:56 +0800 Message-id: <20220413082957.28774-5-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220413082957.28774-1-heming.zhao@suse.com> References: <20220413082957.28774-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)(316002)(6486002)(38100700002)(8936002)(36756003)(508600001)(86362001)(2616005)(26005)(6512007)(1076003)(8676002)(66556008)(66476007)(4326008)(66946007)(83380400001)(107886003)(6666004)(2906002)(186003)(6506007)(5660300002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 08:30:46.8826 (UTC) X-Source-IP: 194.104.109.102 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10315 signatures=695566 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=225 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxlogscore=999 clxscore=166 phishscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204130048 Subject: [Ocfs2-devel] [PATCH v2 4/5] ocfs2: ocfs2_mount_volume does cleanup job before return error 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: sh6d_YKoOHmToiGLanquew-1 X-ClientProxiedBy: TYAPR01CA0096.jpnprd01.prod.outlook.com (2603:1096:404:2c::36) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d5a1990-ad44-458a-a0fe-08da1d27e87e X-MS-TrafficTypeDiagnostic: AM9PR04MB8100: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: rmo/4mEoB/52OHOBpngHJqzLNXS2fMf/8QBy0hd7tRwCBM+E/4Gty+Gsk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d0Oo+OcAnlfabO0GpOcYBpzPdBaFOYcy80yL9molIm6yCnWt1iHlrISBgbBIHJ2EfO17KURmRPaMjrM2ICuDZwMBFMXuW7+HNWOb41uGLNIfKTZ8N1w1l8zCR6zeQbjNYR/ZMiI2QBNiFjBIZeolTsY2kTEBMvDhfnw7w+Aun9yLm6Ldt0zntWDTSnaN5vYmssVCW5jYyiYSxK0vAT0NvMzM2YXO6j5zM2y1yLCABY+ztxbNt33xjwgiUEf4jiENpXKqE6jf3yZK90IPtd52aXqtg= X-MS-Exchange-CrossTenant-Network-Message-Id: 8d5a1990-ad44-458a-a0fe-08da1d27e87e 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: kOayRlodFeAyf7ZXtOqVF7zyssANHZyeP2owmMs3KC1CMTwoWuMpp/CfiOtmqKtwG/hPX/M6qZ5CS3rZKdZ7PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 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-ORIG-GUID: rGkwLeSkIbWxCIVGoFVVdJL6__RJiCrY X-Proofpoint-GUID: rGkwLeSkIbWxCIVGoFVVdJL6__RJiCrY Reporting-Meta: AAEQ+Mx9NJMmmrb89ZnCLUZ7Pw9cHViJpkhtZmzit76jhAJylKQxqtXK/ZRXbiWF gyk6FK/P3ZTFzbAk+ljp8pfrdMPVD6YNarYp+BfatUT0pXgCoQFvAh9sYx6G+I9n QZucGU75AF4VgNcGvg9/Qoq9fHywoZFjkuRwT0y9KnMnKu1fgZNayQKuWE1mHvKd 76DADYTI2+/nth98fS4iC762oHG9S1NAdvccc4IwwmztwvwLCNEC1kfz/doMJh3s Qy/TNw3FQYtnMU1m0K/13lElfbJZCafNg4tRgJ5Zao2BT/vQQpkR3Osb8ULvpDC/ GQ3O4g5fbcO+ucfXcfKC3R6sRnx9mF0sESaHey7XmRHMYowHXAs7ERHQ2HT/OLV2 3PycCqkvEYvtDo6pMGv0O62iPbiIYvthvG0R3Ax9cNoIMi6ebrvKchKDQeH3/VIu YC15k4u+yvKavGWga1XRHDtMo4ikQ4cVXBWafNaEXeS1HW57yorwR+BCmc6nL3rr bzvjjIZ+o5CjucsKiZKX8n4is+LcJdSH/vsGMRgYBuK9 After this patch, when error, ocfs2_fill_super doesn't take care to release resources which are allocated in ocfs2_mount_volume. Signed-off-by: Heming Zhao --- fs/ocfs2/super.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 4302c3e9598c..5e860d7162d7 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1803,11 +1803,10 @@ static int ocfs2_get_sector(struct super_block *sb, static int ocfs2_mount_volume(struct super_block *sb) { int status = 0; - int unlock_super = 0; struct ocfs2_super *osb = OCFS2_SB(sb); if (ocfs2_is_hard_readonly(osb)) - goto leave; + goto out; mutex_init(&osb->obs_trim_fs_mutex); @@ -1817,44 +1816,54 @@ static int ocfs2_mount_volume(struct super_block *sb) if (status == -EBADR && ocfs2_userspace_stack(osb)) mlog(ML_ERROR, "couldn't mount because cluster name on" " disk does not match the running cluster name.\n"); - goto leave; + goto out; } status = ocfs2_super_lock(osb, 1); if (status < 0) { mlog_errno(status); - goto leave; + goto out_dlm; } - unlock_super = 1; /* This will load up the node map and add ourselves to it. */ status = ocfs2_find_slot(osb); if (status < 0) { mlog_errno(status); - goto leave; + goto out_super_lock; } /* load all node-local system inodes */ status = ocfs2_init_local_system_inodes(osb); if (status < 0) { mlog_errno(status); - goto leave; + goto out_super_lock; } status = ocfs2_check_volume(osb); if (status < 0) { mlog_errno(status); - goto leave; + goto out_system_inodes; } status = ocfs2_truncate_log_init(osb); - if (status < 0) + if (status < 0) { mlog_errno(status); + goto out_system_inodes; + } -leave: - if (unlock_super) - ocfs2_super_unlock(osb, 1); + ocfs2_super_unlock(osb, 1); + return 0; +out_system_inodes: + if (osb->local_alloc_state == OCFS2_LA_ENABLED) + ocfs2_shutdown_local_alloc(osb); + ocfs2_release_system_inodes(osb); + ocfs2_journal_shutdown(osb); +out_super_lock: + ocfs2_super_unlock(osb, 1); +out_dlm: + ocfs2_dlm_shutdown(osb, 0); +out: return status; } @@ -2393,14 +2402,17 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di, return status; } +/* + * If this function returns failure, caller responds to release + * here alloced resources. + */ static int ocfs2_check_volume(struct ocfs2_super *osb) { int status; int dirty; int local; - struct ocfs2_dinode *local_alloc = NULL; /* only used if we - * recover - * ourselves. */ + /* only used if we recover ourselves. */ + struct ocfs2_dinode *local_alloc = NULL; /* Init our journal object. */ status = ocfs2_journal_init(osb, &dirty); From patchwork Wed Apr 13 08:29:57 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: 12812039 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 aib29ajc253.phx1.oracleemaildelivery.com (aib29ajc253.phx1.oracleemaildelivery.com [192.29.103.253]) (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 29A8CC433F5 for ; Wed, 13 Apr 2022 13:47:44 +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=N174OW/jlhPu2G8qcM1X6TRBxCM4iQS5XSuq0YKlFGM=; b=fR1aTNcOpEaYjQugSgwiK4EaoeqscbvWxDHpR5XGxb3Rp6B3gdzu9tG8pp0tVHdQT339FtG/Gh4u fEkk7l8UiHwoq84nQU0n75Kct7KVIPVx3ZoCyTykGvA3MHss1hHY9lOBEA5W8FPE7/iFWPscHdW4 a/3D55K70Nq2h2oOEBYKOMuYvny1JVigPFW/cEvL/+gHzUcXjfxod4q4Rnh8ERRThjUsBqEPBk4O ja5t90xMHFPnpw419OAXl+mZquQexpCt8Sm9bu9E3FsDVTRiFfh8/4kU5keMcaosevNjV5kjB1HY pM/X0Vlb/PCpC+uXHAFQciF0kPcKHiYl1yV+gg== 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=N174OW/jlhPu2G8qcM1X6TRBxCM4iQS5XSuq0YKlFGM=; b=QbnoQCgkzC6dl9cNZGpbshVYVNd1b8D5WB5R+Q9/EogUERQaO75L76dqhtdZVWMFMt2xc5yiOQsk xUSzzoa9eW6cZgsOShAWUJHxHo3X9/hN3G0yVWxXqae2jHWIURlT/tdVsmnfc+FseogP22ObZXtC 5zAgH5sVMWYDhZ47iu7edX9KsME27/VQD2iFh0HrS+5oYmgI7zA9+HHB+TXoKlg5/XstwT5laAJB wqljdJYUQu1COtuUVN4vRiD6XpQt54vajDAZJt27ltRFRB76VYUkUrVZ+R43goOO8U92FgYt3xvE TwQkaxfUxT0IY7oWS8uf8SXKDHgZ6GpTGpJLsw== Received: by omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220319 64bit (built Mar 19 2022)) with ESMTPS id <0RAA002BI6BJ6BF0@omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Wed, 13 Apr 2022 13:47:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1649838657; 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=dtyBVsqLUmvB+HY6RYqvkzXscwkDPIt8X2zwOsKTrMA=; b=JctDXfsV1u/G326+tOY2ytoDhksBdoVJ2ByUtZboLUHaZ5LltRCnCjOtSskN5L2QtPP7jl BTsqDCZX8YwuP9EKD+XhJU6ZOmHIcxHjxjILuTQ+/6ufa/rjFELv9TkI5R9W6+2GSAtcI3 CL9UvIRlH1lXkDdgf4g+r7mM7Vkqc5w= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fZ7ZYVQz0YCOrzO6CgdarLnSsLnDtnnZypKMYY9E454+puJUBCAGbcTDH5SRKA65xBf+Inb8MQLv3/ZyHxJLngpmdR/JfWvYDjz1eqhLwth09Ir+1KbdEE4pjB3uTHNibAW0vAIyacFs4vNWIsVdNluL0C/zGJ/HWegccwBO6NKcV3L3wL/uuYKobgCjqkP8Abb2xR0ok+aJ+hU/7c+shUixFzKO2U39ecZCtp2jycrMN0YuW1nlBzarNEVmgvR37LKa/ZG5GyO9avpiovxjdYeBvj/qz9NbBINRtzMOFFUoJnxzWlRANShy+6B+wwHcTgPPLRxwlutoPsFtq9O0dA== 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=xbD7nx4BsNP95qYWULEUA9UIUpHN3fc37qs8bb2KqXY=; b=fzVkaDxiiMSsKS4TakfR7fympFZBl6wSWC2e6R3wNMpKu9dLrb1kYmMGKW2mvuWJVvVfRTyKvm6x6SiHNQeaRsIw/vWfwI8RY8BijHSgN2RXtonKmm2pm8vy6ClWT/xBOCtTf4lYbT7pAoZ/sxld3zueGzIDqAiJTJdGz5KwfGrm1wk8FAw6e6sgS4r02IbCLmD215aLbe9ZF3Q3ZbXSkFVHqPP5t5N+Rr1bLSrq/P9ZvFRdPJbfMu+Bh3QghffpQByuqOGZwUYfdBN5hWHxVOljNsFMeD8xeb3p5XJ53tiiUxMWG5q+VQE5a6nbxLWCmYpzlw1s3Da0DRRMh85Hzg== 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: Wed, 13 Apr 2022 16:29:57 +0800 Message-id: <20220413082957.28774-6-heming.zhao@suse.com> X-Mailer: git-send-email 2.34.1 In-reply-to: <20220413082957.28774-1-heming.zhao@suse.com> References: <20220413082957.28774-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)(316002)(6486002)(38100700002)(8936002)(36756003)(508600001)(86362001)(2616005)(26005)(6512007)(1076003)(8676002)(66556008)(66476007)(4326008)(66946007)(83380400001)(107886003)(2906002)(186003)(6506007)(5660300002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2022 08:30:55.6163 (UTC) X-Source-IP: 194.104.111.102 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10315 signatures=695566 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 clxscore=179 lowpriorityscore=0 priorityscore=202 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204130048 Subject: [Ocfs2-devel] [PATCH v2 5/5] ocfs2: rewrite error handling of ocfs2_fill_super 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: 8UE4GuUOMterniroPn-BgQ-1 X-ClientProxiedBy: TYAPR01CA0093.jpnprd01.prod.outlook.com (2603:1096:404:2c::33) To DB7PR04MB4666.eurprd04.prod.outlook.com (2603:10a6:5:2b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d895cce-276b-4d95-4997-08da1d27edb3 X-MS-TrafficTypeDiagnostic: AM9PR04MB8100: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: IEzCT9btjjgbQTiSJ15NZ1lNzAvUEmOL/2hYdpWzEZmfhDIGsmAkMR7ULOQd86UlP+Figc47YxQIrIPAMNE1NawVPXaUGYnKDhUwsGjHjcW8FOaZ7w63FjasPd7/9XBHZOYLxQgyi/lli4np375Dh7QUHG+2yi/cRLsfy9bhwMdQ/gb5RWH6rbbuOlrA7kZNtnoT3dej+dFjdsg0TwvLdYcAsiPlfBw7FxuWXVw7WnA/06AvJ911m1/emoRxko0GrzszxQXh8XRRU0gNfEJoe3pjt0UOWZk+p+5zna4SnUX94Wsab75ienN6rljFfmpfXpMc2R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EGnX9kupnEM+ieJKyQ8= X-MS-Exchange-CrossTenant-Network-Message-Id: 8d895cce-276b-4d95-4997-08da1d27edb3 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: AYLFVpPtR+TXKLhqY21WwpLeWGFvQRZOvw+y/hNAq9C+9PewoyvUv1xYnVKU726e8sVgEJcm1GxltN/hRBt0YQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8100 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: Q52YEOvzbay2fS6OJ26uxdXjRzSmQBj3 X-Proofpoint-ORIG-GUID: Q52YEOvzbay2fS6OJ26uxdXjRzSmQBj3 Reporting-Meta: AAEQ+Mx9NJMmmrb89ZnCLUZ7Pw9cHViJpkhtZmzit76jhAJylKQxqtXK/ZRXbiWF gyk6FK/P3ZTFzbAk+lhOBZjrdMPVD6YNarYgNAriMZDvOisI6a6sTznlacDuwgaA Wr1ljuMna8TbmXTB7xth9VhVWkqmH1stUB6XKHNspVeaiTztUNfevQp1v9J3LKe0 syyJnej3b5Olb8zEe3Lj+MupZaWxHhNV1FWyOHivNA7qZZAckTrGLPT/SKswtSjz dXsOXkBD4AqUtsVuaqbu9+U8+A9h/kTc46k+EpTt6wXVieWf5SJMs5RyIu7T4PAC egQB6aNnn0AgDi4g5J8jnU4Fop6ARqRkAma/X5Sj/yNk8ohYBKVSCGFMgCss4/SW OydJ9oztexfgHDBE4NfmsASJxPePRElxgnEoIX8UyB86gflz5Rd3D1nnSKeSF9T8 c04q4XQUnxmw3hI4VN2Vz3l8cqEJejG0brqOtBkVJZVWP4tgXlebUo6TgPXOmcoj k+RXDeu/Xd1ldFvJLUI38JOEurtUKANhI/OAc4RVp1aM Current ocfs2_fill_super() uses one goto label "read_super_error" to handle all error cases. And with previous serial patches, the error handling should fork more branches to handle different error cases. This patch rewrite the error handling of ocfs2_fill_super. Signed-off-by: Heming Zhao --- fs/ocfs2/super.c | 67 +++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 5e860d7162d7..72673d40d29c 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -989,28 +989,27 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) { status = -EINVAL; - goto read_super_error; + goto out; } /* probe for superblock */ status = ocfs2_sb_probe(sb, &bh, §or_size, &stats); if (status < 0) { mlog(ML_ERROR, "superblock probe failed!\n"); - goto read_super_error; + goto out; } status = ocfs2_initialize_super(sb, bh, sector_size, &stats); - osb = OCFS2_SB(sb); - if (status < 0) { - mlog_errno(status); - goto read_super_error; - } brelse(bh); bh = NULL; + if (status < 0) + goto out; + + osb = OCFS2_SB(sb); if (!ocfs2_check_set_options(sb, &parsed_options)) { status = -EINVAL; - goto read_super_error; + goto out_super; } osb->s_mount_opt = parsed_options.mount_opt; osb->s_atime_quantum = parsed_options.atime_quantum; @@ -1027,7 +1026,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) status = ocfs2_verify_userspace_stack(osb, &parsed_options); if (status) - goto read_super_error; + goto out_super; sb->s_magic = OCFS2_SUPER_MAGIC; @@ -1041,7 +1040,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) status = -EACCES; mlog(ML_ERROR, "Readonly device detected but readonly " "mount was not specified.\n"); - goto read_super_error; + goto out_super; } /* You should not be able to start a local heartbeat @@ -1050,7 +1049,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) status = -EROFS; mlog(ML_ERROR, "Local heartbeat specified on readonly " "device.\n"); - goto read_super_error; + goto out_super; } status = ocfs2_check_journals_nolocks(osb); @@ -1059,9 +1058,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) mlog(ML_ERROR, "Recovery required on readonly " "file system, but write access is " "unavailable.\n"); - else - mlog_errno(status); - goto read_super_error; + goto out_super; } ocfs2_set_ro_flag(osb, 1); @@ -1077,10 +1074,8 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) } status = ocfs2_verify_heartbeat(osb); - if (status < 0) { - mlog_errno(status); - goto read_super_error; - } + if (status < 0) + goto out_super; osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, ocfs2_debugfs_root); @@ -1094,15 +1089,14 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) status = ocfs2_mount_volume(sb); if (status < 0) - goto read_super_error; + goto out_debugfs; if (osb->root_inode) inode = igrab(osb->root_inode); if (!inode) { status = -EIO; - mlog_errno(status); - goto read_super_error; + goto out_dismount; } osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL, @@ -1110,7 +1104,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) if (!osb->osb_dev_kset) { status = -ENOMEM; mlog(ML_ERROR, "Unable to create device kset %s.\n", sb->s_id); - goto read_super_error; + goto out_dismount; } /* Create filecheck sysfs related directories/files at @@ -1119,14 +1113,13 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) status = -ENOMEM; mlog(ML_ERROR, "Unable to create filecheck sysfs directory at " "/sys/fs/ocfs2/%s/filecheck.\n", sb->s_id); - goto read_super_error; + goto out_dismount; } root = d_make_root(inode); if (!root) { status = -ENOMEM; - mlog_errno(status); - goto read_super_error; + goto out_dismount; } sb->s_root = root; @@ -1178,17 +1171,21 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) return status; -read_super_error: - brelse(bh); - - if (status) - mlog_errno(status); +out_dismount: + atomic_set(&osb->vol_state, VOLUME_DISABLED); + wake_up(&osb->osb_mount_event); + ocfs2_dismount_volume(sb, 1); + goto out; - if (osb) { - atomic_set(&osb->vol_state, VOLUME_DISABLED); - wake_up(&osb->osb_mount_event); - ocfs2_dismount_volume(sb, 1); - } +out_debugfs: + debugfs_remove_recursive(osb->osb_debug_root); +out_super: + ocfs2_release_system_inodes(osb); + kfree(osb->recovery_map); + ocfs2_delete_osb(osb); + kfree(osb); +out: + mlog_errno(status); return status; }