From patchwork Tue Aug 29 04:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13368552 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D63D8C71153 for ; Tue, 29 Aug 2023 04:51:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234323AbjH2Eu7 (ORCPT ); Tue, 29 Aug 2023 00:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235658AbjH2Euz (ORCPT ); Tue, 29 Aug 2023 00:50:55 -0400 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3085C1A1 for ; Mon, 28 Aug 2023 21:50:47 -0700 (PDT) Received: from pps.filterd (m0209318.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37SN0fYC017063; Tue, 29 Aug 2023 04:50:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=pJ8lL+feJg/f4Rvxpz8FM8tisfvmxGCxc0Jb5PBfpCY=; b=Gj8OLYKex4zEykYy3xRp986f10DjJ8MxP7nvyTvT4uc+1rRxvOjv2m+qkPH4b1aRzB/d PRWVG4j1WO40sogvq7kgMwjWMHTKkBdfFjZNp3/ILExPF4YzC/0CSHRVkbNV81lTMv1F zfxz97RBlUGkJEdvgfUKID/qONMiMeNK396dQyKaxbmKb7yA9S5/6wXKzySppLSCThDZ n8dDQZorffOPiUueoYxjFESNN1F0BnkV6nUejUeaWRwR3qKkIxTM8z7WZ82ONhGmslGa nYm+w3UhFsF926hY0J3lNQa676uJAhxYbUho1wu3IJWSbb1fdDb3SHOpZ9njm4HmeAZK nw== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sgaapc01lp2112.outbound.protection.outlook.com [104.47.26.112]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3sq9hpj7jq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 04:50:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E0+8nbnRhH+bL+wMf+Sd1/oICDIPpNeL8r8MjCRomgtZMm3rLa6KxiFx6/IZfXwFfn7egt/lgBDuaDRgrl4FBP1rSzAvktK91iCMUDLh2rb/kEllZQr2pAyv/fpYpnINfiDvFsSR5PY3rWhzYzQ1vEtg0RQkCrHV1GQRgphWzxUr1aiXwop/qdge+IA3YbgX9qdzUn3hLk1i45rmbyXuGIRZ27Y7v9h0g/LYQLhx5Y+RJQFtBBMAbHFaRI6Q1A5es84ZQgXbl689GIzz53cfPqp8bdU8s6efR/eRIFhOkqAsXLBEjyD/70CeHq7MOFdu+2tgGFi01Gc9ufYm84md9w== 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=pJ8lL+feJg/f4Rvxpz8FM8tisfvmxGCxc0Jb5PBfpCY=; b=kvqu3MV1TztVcwNhMVTCOcL+tqP7SjHR0P7CZWkTZYZ2tVZn2DJfPi7mTx8tbUZ9eBlUXIjWI12yC2TjoX4TuiehcjpU4Mk5XqNHIJC0oG6bFC08Y1qNlAQA/23n++jPxnnwPNT1qROkbX0+srYDhS46ANppmmuF6lpOpqi4Yzw4S7kRRQ5ZpefhF6kc/U84YjjhY3NegZpYoAuACfYUYng23kbxAKqEqEXBelcKXsF4nyn0mEmpwMhu64OtnVwJOl4nUggo7Qjlq9gJiLjLwrQ2OMcDYYMsigwoW67bWTQ73ltcA6Fu6RYcV1zRVwpgDQ45rq4jcjomYjo0OL3qJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR0401MB4340.apcprd04.prod.outlook.com (2603:1096:820:24::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Tue, 29 Aug 2023 04:50:30 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::9391:4226:3529:ac7c]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::9391:4226:3529:ac7c%7]) with mapi id 15.20.6699.035; Tue, 29 Aug 2023 04:50:30 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1 2/2] exfat: support create zero-size directory Thread-Topic: [PATCH v1 2/2] exfat: support create zero-size directory Thread-Index: AdnaNBrmKC9P4VmURO2B4RgAsTksTw== Date: Tue, 29 Aug 2023 04:50:30 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR0401MB4340:EE_ x-ms-office365-filtering-correlation-id: b5a17500-e2aa-42e6-ddee-08dba84b789f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Z077RsQSdqG6NjGeUVA4LzN+HIyZa55yaFpE1Jcav9lD3PaKQrE5H2lRw+ZEwv3L6QNTf9KCgTcpr07BrShvQAs42ckQvP9BJdU50tN5gQrLqv0fvr3JOB4Zc/byPi66cGbAD+0xXGdLz8JRjFDl+exUxdOKpO6wNHTxhIIMS7hdkBRVakAzjX3oSWn3XqYhTDhf0vJF2ldtvEujJYn/7LTalmQX35ULV5w5roSrczPifKVGBa1JVw2w0uesIR+wDQQMfKzdAb7oquMyVLjOx5xY9Ie0eoH3gO80Zy40W+8MTuN+iVN9eWyAU+16/qpFNcg0o8O6kdjTbfot8hHR6J1reLrL8TDE+QJBr9AykP1Er7dt14svw787OOcqMuMiZLdr8V/+szJ/FS/wyLWefqhB3MpAb3ybZ7q7v/UuoV7sXwVKVR8wOyDQ3WVTs3YRutgsOAVeYnh63AJn5mzHtLjguIUy/wJJEdl4TJq+2NEG33jfclfofQ5hMKl82rn05IZojq540aLZn24sS/h0O4m0wr131xZimrLX9iAOWItxZHunRAQhQqPVi5qG86scVjdFBHVGc/3YCAPkzRYQRf7koQJSdg280YcCJQn9Qts8OqQH9//tmE4yjXthSEHt x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(366004)(396003)(346002)(186009)(451199024)(1800799009)(9686003)(7696005)(6506007)(71200400001)(478600001)(83380400001)(107886003)(76116006)(26005)(2906002)(54906003)(316002)(64756008)(66446008)(66476007)(66946007)(52536014)(66556008)(110136005)(41300700001)(8936002)(5660300002)(8676002)(4326008)(33656002)(55016003)(122000001)(82960400001)(38070700005)(38100700002)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0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CFPpP3uEKoMeGbdi7gy43eByv?= =?utf-8?q?yR8iwp3WpG/CBqZSMYozObwsy6JkRCbPV5yN5GU7H8igvMJDrUEhkVuqQmQAE1TFz?= =?utf-8?q?avubclgAc2I7Ynzy4jswElA4Po00UYjhs7hRjve8XOp6bbYRI8dOuuExYXsY9lMep?= =?utf-8?q?8OSBCKy5QthFmYttYFYNwhPseGTnt5wv7GqcCOAK+AhY4+xh1CNak0+/fngCZ+oR2?= =?utf-8?q?1Gtf7eXdIZYBqTdmGu74kIIWroBRwRFnEIJS6qLJaCuUYrjM3WFRD5SSHl6rxtGQx?= =?utf-8?q?25HwVWGJtuo9aCkWbVvTSh4A33LC2Ldd1YAYoLIUd3l8dlSR2P8TMzFjkyw0QaUOf?= =?utf-8?q?ED/z5bWkzkFAa/vk9o/M830azqCdu/LalOGq2BpmLlbo23U0UeoeRHyCDbQyRrwDt?= =?utf-8?q?KIRLDVBeqgJED3bu6DMpbe5U32MY6OWfxcprr1xAyDn/itZoixoI3LI58WaM3LR2M?= =?utf-8?q?lEed7+sWMRoZfHOYT7UhBdoP1eo1AlzkDMs8b+Hlt8dL3aB+qP8UBb0fIl9xsMaAf?= =?utf-8?q?UmgRFUBC7r77gP7SfbN5y9DQAmS+Fx7+P94W23LfQqfUnBTFp4+U5D8xb8WoPyZaw?= =?utf-8?q?mTbbGXqSEDwDErvCZmvwLzcxbLUJydLaFaDP9Wnx2wkAm3FkcaoqagQtdAIcgh/GD?= =?utf-8?q?stZh3cA01sYw?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +c/wfOT1WAk6ccGkEkue5pIoh7Dg12+5bZTYvfHBMtC805RFVh3lxnCjjMFpPLi/aawRQF77v+wW8dPI37lxhMiG3URK7CQLC1HiRtwQ7BXfXCF5OIoYvK4CitIRSZbl4paAeguLsElVj6lDaX4RyWUcHYYzqIthAxvIIRxNKJYRx1KT9H86LzkUZoitYqLlpsKCQ/OrgQzeUCCrXmbH7mYwJRabeZkbfoj65l89kxrBd1wAwYDUDSVDTLKzUwqg//EMYKr6u5p8WTgTnBx9DXjgplOtq6t6pZVKkWJ8Tsjpz4C1oLkS+Wi3VvXWcJglrry/URXkdZa4jF3Kn1UF7szvAOFpwUYaMAaGxmek3LOTXSV41wM6F0yD/sR+E9SQCFw4R5BriaRiC+SQME82SslpvUuyLn26g9DxXA0U1clnyQB9JjTDAduJ4ULtv+2quJYLo0AdODnzRcybsmCkphQwZOWGD4D1IEuspG0E5TBNfkXVlyn5apsiTG/+T/Cz9y/9QNhQ7uWVXGBAqwdCYebSY9DxxIP29wsEPueNPD5fSmPV/5/pC88NGOqPowyGFiqjY/gdQ6mePA9dRbYcuQzPe69UgY7HdJXE2CbL4OtzdUd1ZcMTc4068Grt8xVYAbH2nzmi6JxpFrXXF8Z+6FL/fhNKuGGupeAe8gaeLfW4Bc/c7jozNig3Fvns8Fmg7fEx3IS4FkX6CVT+iJvIPQSrNuwnTfN08kSgrZxXpXMcZPiN5SNhmT1twMyrx3kTUJBGlWB+/QX6l/OwChkaScPx5JcfVyx0KQTHusuxUKdpHjyo2R1T2Fy7zRdHqfBL63oGSbEOw3+tVbNMyILDQg== X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5a17500-e2aa-42e6-ddee-08dba84b789f X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2023 04:50:30.2709 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2AhPr2TeSZuqZr5uO1KK8TmpI81sp3lmph3N3YUkl2kqsV34VUQIxx+Umbz3GbhCveMdJlIHJMOLBDh0gghQUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0401MB4340 X-Proofpoint-ORIG-GUID: 1KVPk9FkpFlakBRLnoFSVMxDjQ3Ulh7h X-Proofpoint-GUID: 1KVPk9FkpFlakBRLnoFSVMxDjQ3Ulh7h X-Sony-Outbound-GUID: 1KVPk9FkpFlakBRLnoFSVMxDjQ3Ulh7h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_01,2023-08-28_04,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This commit adds mount option 'zero_size_dir'. If this option enabled, don't allocate a cluster to directory when creating it, and set the directory size to 0. On Windows, a cluster is allocated for a directory when it is created, so the mount option is disabled by default. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 12 ++++++------ fs/exfat/exfat_fs.h | 2 ++ fs/exfat/namei.c | 7 +++++-- fs/exfat/super.c | 7 +++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 598081d0d059..9ad5ff01456e 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -417,11 +417,13 @@ static void exfat_set_entry_type(struct exfat_dentry *ep, unsigned int type) } static void exfat_init_stream_entry(struct exfat_dentry *ep, - unsigned char flags, unsigned int start_clu, - unsigned long long size) + unsigned int start_clu, unsigned long long size) { exfat_set_entry_type(ep, TYPE_STREAM); - ep->dentry.stream.flags = flags; + if (size == 0) + ep->dentry.stream.flags = ALLOC_FAT_CHAIN; + else + ep->dentry.stream.flags = ALLOC_NO_FAT_CHAIN; ep->dentry.stream.start_clu = cpu_to_le32(start_clu); ep->dentry.stream.valid_size = cpu_to_le64(size); ep->dentry.stream.size = cpu_to_le64(size); @@ -487,9 +489,7 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, if (!ep) return -EIO; - exfat_init_stream_entry(ep, - (type == TYPE_FILE) ? ALLOC_FAT_CHAIN : ALLOC_NO_FAT_CHAIN, - start_clu, size); + exfat_init_stream_entry(ep, start_clu, size); exfat_update_bh(bh, IS_DIRSYNC(inode)); brelse(bh); diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 729ada9e26e8..cbf32949ff67 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -234,6 +234,8 @@ struct exfat_mount_options { discard:1, /* Issue discard requests on deletions */ keep_last_dots:1; /* Keep trailing periods in paths */ int time_offset; /* Offset of timestamps from UTC (in minutes) */ + /* Support creating zero-size directory, default: false */ + bool zero_size_dir; }; /* diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 43774693f65f..23220dd874e3 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -518,7 +518,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, goto out; } - if (type == TYPE_DIR) { + if (type == TYPE_DIR && !sbi->options.zero_size_dir) { ret = exfat_alloc_new_dir(inode, &clu); if (ret) goto out; @@ -551,7 +551,10 @@ static int exfat_add_entry(struct inode *inode, const char *path, info->num_subdirs = 0; } else { info->attr = ATTR_SUBDIR; - info->start_clu = start_clu; + if (sbi->options.zero_size_dir) + info->start_clu = EXFAT_EOF_CLUSTER; + else + info->start_clu = start_clu; info->size = clu_size; info->num_subdirs = EXFAT_MIN_SUBDIR; } diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 8c32460e031e..b1e03276e0a0 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -174,6 +174,8 @@ static int exfat_show_options(struct seq_file *m, struct dentry *root) seq_puts(m, ",sys_tz"); else if (opts->time_offset) seq_printf(m, ",time_offset=%d", opts->time_offset); + if (opts->zero_size_dir) + seq_puts(m, ",zero_size_dir"); return 0; } @@ -218,6 +220,7 @@ enum { Opt_keep_last_dots, Opt_sys_tz, Opt_time_offset, + Opt_zero_size_dir, /* Deprecated options */ Opt_utf8, @@ -246,6 +249,7 @@ static const struct fs_parameter_spec exfat_parameters[] = { fsparam_flag("keep_last_dots", Opt_keep_last_dots), fsparam_flag("sys_tz", Opt_sys_tz), fsparam_s32("time_offset", Opt_time_offset), + fsparam_flag("zero_size_dir", Opt_zero_size_dir), __fsparam(NULL, "utf8", Opt_utf8, fs_param_deprecated, NULL), __fsparam(NULL, "debug", Opt_debug, fs_param_deprecated, @@ -314,6 +318,9 @@ static int exfat_parse_param(struct fs_context *fc, struct fs_parameter *param) return -EINVAL; opts->time_offset = result.int_32; break; + case Opt_zero_size_dir: + opts->zero_size_dir = true; + break; case Opt_utf8: case Opt_debug: case Opt_namecase: