From patchwork Sat Dec 3 07:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 29239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1247539wrr; Fri, 2 Dec 2022 23:14:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Nvu+XBnkO2YUCbG4ZIqL4Il1Ge3n1xWgl8nrxgdljPPpwEp5MIRZXa01WIke6VSDFZIM+ X-Received: by 2002:a17:907:774e:b0:7ae:39b4:7208 with SMTP id kx14-20020a170907774e00b007ae39b47208mr46339361ejc.766.1670051691084; Fri, 02 Dec 2022 23:14:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670051691; cv=pass; d=google.com; s=arc-20160816; b=YCzZaVTB/ikIyiS4I9qdyv6K1gohIbKKvJTaJJydqf5I1wUCctbwVR4MhVVVecGE4T iHGdpRl8vVunYvhEj03wm2o2xfutNgxJdDp3A/RS4C5R6BbIa8XwJGNIXnWSp3cR00wT MBj+in1l/FpcT6m2W3f71XI0alqrE33C733HcZ3HRKWoHk40OrGSLR3+AMuE1ixqAF8R xmqmKlvRuIyCqfq/44oT9SXNgCcyeYmo1bpyBIqmqi/L8tNbgm5Hkh//kdOEq5fxMsor 7cXOEVntPUWcm6o9eBZYdcDrThyfLCGzy/O0cvMTfjh6P2p3Fo5SJhKguQqZ8gd4HDSq o/hA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:to:from :dkim-signature; bh=+U5fkHI4TQuAxE2JZf+ItwbgrXEkHo+MR32tMV+2Y20=; b=Hjg7zbOePz56UOQufX+UdI4pm0Z5cw1oOJ5zhHrgeaqsLNRqiNZDCxaY3SrWU1MPuV dceMMIobEdian0khQgSlItDoZeYVeka57S3OyxUilJSeYEJ+iAa1iEbWo0bNTmf2XJ8Y Ys4RVT3biEVQ05rXnDuXa7MJId7RnfUDEnao5D62DWgrdzAsiyPpCdpYcmFzUHeuAPA1 Y62afI+agH+fVpjDVkrUZBhsfJbNPV6Nw9APX/qd4lonuLdOctxobsbVZxIDd9G/v9Id xKB8UqAD+jQPXStqKwZpBzhJuiZiMamrDuzzeVrWpf/bsCiRgi6etKUMvnHOqo0o8Xvg jIhg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=SGd3vikK; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=live.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb35-20020a170907962300b0078d8db64fffsi7881775ejc.20.2022.12.02.23.14.27; Fri, 02 Dec 2022 23:14:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=SGd3vikK; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=live.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231337AbiLCHLT (ORCPT + 99 others); Sat, 3 Dec 2022 02:11:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbiLCHLS (ORCPT ); Sat, 3 Dec 2022 02:11:18 -0500 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2083.outbound.protection.outlook.com [40.92.102.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4F77F892; Fri, 2 Dec 2022 23:11:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j+GexYbov08ie+pOTm9ptIXGAHJwQnzOTmqcGUnn0m3mkW/1QV4o7r16H37cOiJ4LdQXwXk1vY+GPOH/ueYSoQEP6LCPmSWXmKR727VpxdWl+R8aaUS1gX5VGzXtU4lWLaxXRo2mG/4DQTa/VwXlQ9/d7WgWQ3PT8AKd3VZLldtMKDORQYqv9O0omDIytneRSEDwM3sdhvu1fFTlOxk1M81bsPX1V7/ZxGTX6qUQNVdK51TrFtLZQQ2oo4hhyq0PqTDAwoOX3LDBu+EwAOcRRxoGE8hS49Ap1u8zMU81uxQV3YHK3p11gx6edd/V9Qv+1U/TsK12N6pUVibZ6JSDww== 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=+U5fkHI4TQuAxE2JZf+ItwbgrXEkHo+MR32tMV+2Y20=; b=jF6oicP7rw8PKdTvyM2A1PJZpGq8bhmmtTAvS1m9RXEFXwN/ey3A8G59PwM00KVIeLdOUfk1Agatv+NWK2SkYBeits5ZAW9QOsa3KGBJ2/jPoKSanAKrvXO6DHp0SZmeCfL4OISkyE/PkAFaUimM5xu+StBZizQqDbQxTtNvJy7q4OjxPr7XxF/Gr64uvWs7IpLGgwolCXI9zmdpWLDBxd67OnMx5kgX/HcqRveRe9s1IP4RV7wnq64mpPcqjbibJqRuS0ypNkhDlayjJ5M3u6cr6H0wfC8EJmxI4yFICUBoJ1uDFfT5C7euuvyS0QHJYWYlkyQzVcI/V06qg9PrZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+U5fkHI4TQuAxE2JZf+ItwbgrXEkHo+MR32tMV+2Y20=; b=SGd3vikKPp7o6XJPD2WGa5ly99Q2aKddZyd7QYJDj2S9P1pvdG79bLVKb/Wd0B/gHvYc3WoQ4bjENpO7Z5ZKEqQ+CG2jqgDV9Fzxqj63osv5kqOlGlF9BnncQvBR2HvQKIN4GZMtXEqgYr6znvscXLxh7gDEky3tYK9ojBfIolWHCYttkbrl9qR5n47qOaq8fcrHhS3ln17NxqEXVepXJiWVqNf1kvGvsPSyuNwsh7dv7dCZwae9O2v1YhrAofEw5R46f/lSXd0ga1FaNtMLjh1MJeKwJJBUQxTnB/tIhgDYSEISE2OWsPvzJ7gLdnb237ylmiFpVkrZsbFSRlVvLA== Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:2::9) by MAZPR01MB5639.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:62::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.11; Sat, 3 Dec 2022 07:11:08 +0000 Received: from BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM ([fe80::68ba:5320:b72:4b1]) by BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM ([fe80::68ba:5320:b72:4b1%4]) with mapi id 15.20.5880.011; Sat, 3 Dec 2022 07:11:08 +0000 From: Aditya Garg To: "willy@infradead.org" , "ira.weiny@intel.com" , "axboe@kernel.dk" , "akpm@linux-foundation.org" , "bvanassche@acm.org" , "keescook@chromium.org" , "songmuchun@bytedance.com" , "slava@dubeyko.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2] hfsplus: Add module parameter to enable force writes Thread-Topic: [PATCH v2] hfsplus: Add module parameter to enable force writes Thread-Index: AQHZBuZqqiAp/Y+oEE6UMaTrbebMmQ== Date: Sat, 3 Dec 2022 07:11:07 +0000 Message-ID: <79C58B25-8ECF-432B-AE90-2194921DB797@live.com> References: <53821C76-DAFE-4505-9EC8-BE4ACBEA9DD9@live.com> In-Reply-To: <53821C76-DAFE-4505-9EC8-BE4ACBEA9DD9@live.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [PUYnsE624PIMRn3+XQbHAKLNEfZcWrwD] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BM1PR01MB0931:EE_|MAZPR01MB5639:EE_ x-ms-office365-filtering-correlation-id: 54a63288-d88b-4479-ad3c-08dad4fd8cbe x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sIoX3RkA8mHjJfKV/xLAFv8ZyywbI+HDqj0xj00788XTCQxSB9+/0sRSvtwNZj0dqbmjv/Zo3JglQHd4efGnRYS8pOT/VbpQEQVbHjFAKupglfrNAei1zwbif3mX2OQsWIsOhtfAS7CF1CjT3nZ/mfZYAqbX3whmRI2byX+hlD+pydVyLC2gAI+rfCDxmqJsB/cH/f8Wmvanhvq9B5oqXTklNxQOQoWmft9A4gKiweyZp/DVHI/foWwcfHxfHKLRvDGtsby85ppB4bySvd98xZKWBNxZpUQetErXH4/9vzL3a10yFE6SENOnx9cPhiqM7xd37UNgG3qO5/PoJA1ffjEwY8IQz6XNUInXbHsTFpJ1AkIMI5qAosqceYUvrBQDuIEFElcnXlf/z13JRspLpSNaIOjUJFLRdRtBM4ZLRtZPp0jb2aMLf8amnUJtU8/hLqQWBcRvSMl4FR/treW2vRV5F3gfeXeOlf/+FqQwM5G15/NLyqy0SDb+5h7qtzVxH0uck5ZUZMVx0iv9Fqv7KGDC2eBNPyS3F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q+xSzSjPOZzAsANvhpkLwBZfY3ixgh7cdZksYt47DM4YnTULOxBvFABovpff2wNRLTOeNZH8JpiqseGxU8PYqLl84pXWcqFAlD8mosHxiiHgWdIyq+GKAZ4vnQYx7TNHAl0FUhmmfgeHbpKWeZrXxCW3e7UigDqsXZv2GwapjELRI5D0oEOQt4809aB/SEU7cpUHbTmYp19FqYDOGzKPZqRMZNjDkjPEfCGKjnRSICoSrArIy6DJ4+5gfS9m8VKMtVhqB7Q5hqsAMrOrgRX8v0Mbq7JqCOQQmPyGd7MJYoWQumv03hCLn1EPmo5+S7z5Vkim6EqRlROGMzOBcKuWw== Content-ID: <20448BA4EDBDB84491D409D3550DCC7D@INDPRD01.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-42ed3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 54a63288-d88b-4479-ad3c-08dad4fd8cbe X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2022 07:11:07.8998 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MAZPR01MB5639 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751081171524863655?= X-GMAIL-MSGID: =?utf-8?q?1751176122133794043?= From: Aditya Garg This patch enables users to permanently enable writes of HFS+ locked and/or journaled volumes using a module parameter. Why module parameter? Reason being, its not convenient to manually mount the volume with force everytime. There are use cases which are fine with force enabling writes on journaled volumes. I've seen many on various online forums and I am one of them as well. Isn't it risky? Yes obviously it is, as the driver itself warns users for the same. But any user using the parameter obviously shall be well aware of the risks involved. To be honest, I've been writing on a 100Gb journaled volume for a few days, including both large and small files, and haven't faced any corruption yet. Signed-off-by: Aditya Garg --- v2 :- Add Documentation and split long lines across multiple lines. Documentation/filesystems/hfsplus.rst | 15 +++++++- fs/hfsplus/super.c | 49 +++++++++++++++++++++------ 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/Documentation/filesystems/hfsplus.rst b/Documentation/filesystems/hfsplus.rst index f02f4f5fc..85feca0b0 100644 --- a/Documentation/filesystems/hfsplus.rst +++ b/Documentation/filesystems/hfsplus.rst @@ -46,13 +46,26 @@ When mounting an HFSPlus filesystem, the following options are accepted: Do not decompose file name characters. force - Used to force write access to volumes that are marked as journalled + Used to force write access to volumes that are marked as journaled or locked. Use at your own risk. nls=cccc Encoding to use when presenting file names. +Module Parameters +================= + +The HFSPlus module supports the following module parameters: + + force_journaled_rw=n, force_locked_rw=n + Used to force enable writes on volumes marked as journaled/locked. + Its risky to use them as they may cause data corruption. + Accepted values: + 0 (default): Disables writes + 1: Enables writes + + References ========== diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 122ed89eb..91812c4c3 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c @@ -24,6 +24,16 @@ static void hfsplus_free_inode(struct inode *inode); #include "hfsplus_fs.h" #include "xattr.h" +static unsigned int force_journaled_rw; +module_param(force_journaled_rw, uint, 0644); +MODULE_PARM_DESC(force_journaled_rw, "Force enable writes on Journaled HFS+ volumes. " + "([0] = disabled, 1 = enabled)"); + +static unsigned int force_locked_rw; +module_param(force_locked_rw, uint, 0644); +MODULE_PARM_DESC(force_locked_rw, "Force enable writes on locked HFS+ volumes. " + "([0] = disabled, 1 = enabled)"); + static int hfsplus_system_read_inode(struct inode *inode) { struct hfsplus_vh *vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr; @@ -346,14 +356,22 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data) /* nothing */ } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { - pr_warn("filesystem is marked locked, leaving read-only.\n"); - sb->s_flags |= SB_RDONLY; - *flags |= SB_RDONLY; + if (force_locked_rw) { + pr_warn("filesystem is marked locked, but writes have been force enabled.\n"); + } else { + pr_warn("filesystem is marked locked, leaving read-only.\n"); + sb->s_flags |= SB_RDONLY; + *flags |= SB_RDONLY; + } } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { - pr_warn("filesystem is marked journaled, leaving read-only.\n"); - sb->s_flags |= SB_RDONLY; - *flags |= SB_RDONLY; + if (force_journaled_rw) { + pr_warn("filesystem is marked journaled, but writes have been force enabled.\n"); + } else { + pr_warn("filesystem is marked journaled, leaving read-only.\n"); + sb->s_flags |= SB_RDONLY; + *flags |= SB_RDONLY; + } } } return 0; @@ -459,12 +477,23 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) } else if (test_and_clear_bit(HFSPLUS_SB_FORCE, &sbi->flags)) { /* nothing */ } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { - pr_warn("Filesystem is marked locked, mounting read-only.\n"); - sb->s_flags |= SB_RDONLY; + if (force_locked_rw) { + pr_warn("Filesystem is marked locked, but writes have been force enabled.\n"); + } else { + pr_warn("Filesystem is marked locked, mounting read-only.\n"); + sb->s_flags |= SB_RDONLY; + } } else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) && !sb_rdonly(sb)) { - pr_warn("write access to a journaled filesystem is not supported, use the force option at your own risk, mounting read-only.\n"); - sb->s_flags |= SB_RDONLY; + if (force_journaled_rw) { + pr_warn("write access to a journaled filesystem is " + "not supported, but has been force enabled.\n"); + } else { + pr_warn("write access to a journaled filesystem is " + "not supported, use the force option at your " + "own risk, mounting read-only.\n"); + sb->s_flags |= SB_RDONLY; + } } err = -EINVAL;