From nobody Sat Nov 30 07:35:17 2024 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2086.outbound.protection.outlook.com [40.107.255.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3472013A3F9 for ; Wed, 11 Sep 2024 03:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726026239; cv=fail; b=bEr5TQGlvWXy7cyccTqskfXylA+r3PPR0Nt/oFZ7rmeBSaT5FwTB8DurzOVbQq3AiFt1lX41l/LKoE6nVxevd05aL8wl20ORGb/aNQ1xew9sdzeP9tsB+2vnItB0qE4/qwi5aI7s70r6TLUZDLluFIazFq29o2liGBNQhGSfjpM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726026239; c=relaxed/simple; bh=aoXKwyCkI2oMCOwFGXiDOy+bY+HgnmOcFMLwyz/nOrQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tiL/PD5bt9nxy3dbEOKrcV8ecRvghHWZOwSH7uo6QSyrbDruCxeAJei/bgcLW+6JDBmgEkZgeS4Ef98yWMHvdQyq+eEBhVcG1KPYrqL/IoUdncx2tzMWg9XnPvY9mdpQHPJFqDvY9+K0tcQn35bGt75U6G4AFx8C5RNtJCNkM48= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=m/KsiDEQ; arc=fail smtp.client-ip=40.107.255.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="m/KsiDEQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CWYX5xi9CvIOQskeUDg2XR0LcMaGhBf/mVNvFnk4P9zjeEpLkF1RnbBVRsc9CfUKu9nRNl2QdX4eYy4yVBBepNtVKZtFMIjO+mQO9c0tL+Y8o6p1eRvlH29ipQZOWstHJwmZ7asCUeE2Q6gq0Puq0GbdGLTZwNKTdMjhlgFyROCLNWhkrgL59H9DrMWlW8n+XKcHa7oXjusb/ruSSeRK3csw6kGXQwqGasKipBcN26Dwga+U1PhBL2nrtB/JOoX8ecA+kxHAJA7JZ+NmOsMpM4faZd9wgJu1S6pN7trRCVtL2rFqhF9p9ZxH8vcaWQ6zYqudDCh3q6T6VCrvGooR4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hJpfXRt+D/Xi10u7fADuMjbX+4YLotlKl+Ws+v+nkzo=; b=LcCzD+eB35gxxOevA8wIV7xvfrXcpGT9qwSmSTVeFGSAeqjyjruhHecDs9WOubO8zXU6p9OrS7Y51MKHNKPb/uSlHBM6mDhgDsXD5gb939XrMeQoRq4K3/WiTutuLB7AOWidjwVyTXe4HyqIytVcgqPbvDHfsr5R0kb2KG9mV7rvtMMqAT1vSxDpbyPSU4c7N3RllwA+0OJmRrmNJGrDkYjnPTbCGDZ539kHA3lpkh1gTTaauMQhb5Lddp/5T4wduOMsVSBbfOEMEgn/4DVsUlELsHziLL3XT3e1TOAZuH89hcuRY3e6PUwrfY/aSEtd8gfyVoMaKVHm/bsZF8jLVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hJpfXRt+D/Xi10u7fADuMjbX+4YLotlKl+Ws+v+nkzo=; b=m/KsiDEQFaBr+X1O8eN0pMWwrQG+e0jZTe6t1vulmBbKf3zQKagZwa7ReP6dwRl78O5sV4ThIYaHYVRpWLqI6af2Avl9Wip22oFLRZygFnXDdfSdtbTUC29ZRQQ6meRIVctSjrki5HP4d38glvSGRYR2yhU0IQhUo96Y6G7JrOux982jN+Q29ScZ5RES6T77V6yQchroe4OV4gz50+QjAj2l42pO2LA0a5ZQxuaQmQ74l3lPaA5ceOTs2kK3vZfPytB+cVU26jl0jwAqFSU+w9OGsI1Aje9VRu2NWl+ktWXyy6YYPdgk+U9OvqxRSg58wWUB47siw4srihi8WypRww== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PSAPR06MB4486.apcprd06.prod.outlook.com (2603:1096:301:89::11) by JH0PR06MB6917.apcprd06.prod.outlook.com (2603:1096:990:67::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Wed, 11 Sep 2024 03:43:47 +0000 Received: from PSAPR06MB4486.apcprd06.prod.outlook.com ([fe80::43cb:1332:afef:81e5]) by PSAPR06MB4486.apcprd06.prod.outlook.com ([fe80::43cb:1332:afef:81e5%4]) with mapi id 15.20.7962.016; Wed, 11 Sep 2024 03:43:47 +0000 From: Wu Bo To: linux-kernel@vger.kernel.org Cc: Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, Wu Bo , Wu Bo Subject: [PATCH v2 12/13] f2fs: convert inline tails to avoid potential issues Date: Tue, 10 Sep 2024 21:57:25 -0600 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR02CA0049.apcprd02.prod.outlook.com (2603:1096:4:196::7) To PSAPR06MB4486.apcprd06.prod.outlook.com (2603:1096:301:89::11) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PSAPR06MB4486:EE_|JH0PR06MB6917:EE_ X-MS-Office365-Filtering-Correlation-Id: b70cfb3f-8389-442f-b9d7-08dcd213f12b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3IOuxKljOkAkHnxeIQ0pnX80Zvs5Ra4LQc92DrRhqVISIGFBPU4AYeouJ/01?= =?us-ascii?Q?3v2ZYIOgtP+SSDzokOB+oJQJCdUmAF2yD3jSCz8+wrADD3tt+1gOSNFzHCVN?= =?us-ascii?Q?P8aZi+qOdQ8iXBxQvhlTG8NlSf7jK6qefiemq8yHVJB15jN6rmiDtbw5fQpd?= =?us-ascii?Q?OWAlzduDK1n2bOrs7/64dp0ox9h4EjMnlGRh3uwYPW3swUKCOXF4TJSmdY/p?= =?us-ascii?Q?v0ZoW36NLTCkDarqe02nkpcwx2R8hPXtwIOIyhFrOo6Yly/FjofY5LTYX5TI?= =?us-ascii?Q?aYpVqX8kO8XXY6OZnywVestmVasMhHjS565vNcprozw/k1WSaygObnY1gxj1?= =?us-ascii?Q?uK4mGQ8P0/MpTpXgvJmVpeY12HO9wtbRjlkJlidyOJ1ypdAvYyBHX+lB2lSi?= =?us-ascii?Q?M2NZ/lzQuHo7xNUzoHOoPk+OeBcN1ZIggDdcgCXNSakLqSjk7S4UPYqIxMmb?= =?us-ascii?Q?e/XH0Qo01bp0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iSl?= =?us-ascii?Q?PhCmmJ3dcowbNxCTF0GVNisAtAdOovjjkw+hIUeVDVPJ3U4e2g=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PSAPR06MB4486.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1XDYL6cG533Aflir+q+xbd4PIwAHpkMM7dcLzSB/ML9gKyVNjMSaiPfeSGMD?= =?us-ascii?Q?nVWhj4iaWfmPL7PmnB+PkuX/+VUqlmgqtU8FE3mLzY6M50G5lRiPWA+N9ijL?= =?us-ascii?Q?jN/zhMqtIAmpcUbJe7lu+rYjmMuiIK6joEb4YuVNDEXg9xxwbnR42qe1z8W5?= =?us-ascii?Q?RvEOM/yXV7lSfOUfTMYtqAL2UtPy0bKR/pwf843JClY/BwPuM8um9T+h2v/l?= =?us-ascii?Q?jZWGepD8CTKrMjjp1V3NJRW9JItF0aHmc4DoEFfm7Zr5soNZZJw+qmllixNJ?= =?us-ascii?Q?BtXiUW+uWAiX+ndoJXZNw1YOwE2Tq6l+tuCBt5vgwGxaG4aAMOkI4hPEc5c3?= =?us-ascii?Q?5T5txGBAUtfPayli2Gj2owKpCJ1cinTY8PbXNH15h5sIoEK6ybx6NLXm3W8e?= =?us-ascii?Q?BPCOmbUJjlVVPYnD1KFBoQGL3x7+ST/56VdHwHUnamm+LzhEgcEqKuT+5i1k?= =?us-ascii?Q?+zSNet2ajwRhgmzZqGky1RrTOvlU8IuC26EBYRo4Dms7DIeKeHuR9H0AMASk?= =?us-ascii?Q?4sIFFkY/L+vBPr/SFp1O67mQWTbyVuWtMn7QJBsBpKO69/pPfhJYdfjIFhX7?= =?us-ascii?Q?/fl4vhMKNQ5kk+NYgrFR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gRmgYiNXUImlDgLfqUN3OWulMUr2CY+qFoicLO+rKk3I6peg7nazFckGLlXa?= =?us-ascii?Q?6pIHyv23IX02GsRrVR1wanOIeHuo3RTGaTq43KVM?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b70cfb3f-8389-442f-b9d7-08dcd213f12b X-MS-Exchange-CrossTenant-AuthSource: PSAPR06MB4486.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 03:43:47.4260 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: paU7Bzf2AWWyd15bVgVrrIXwJGtDqpXh3KLIdNEXcEDctMUMZE8CabBNhA6LJaZK5Sc1J7bfcp6ouzZJN4qFww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: JH0PR06MB6917 Content-Type: text/plain; charset="utf-8" Like the commit: commit b3d208f96d6b ("f2fs: revisit inline_data to avoid data races and pot= ential bugs") Due to the limitations of inline data, there are many scenarios where inline isn't supported well, such as move file range. Therefore, in these scenarios, convert the inline tail file to a regular file. Signed-off-by: Wu Bo --- fs/f2fs/data.c | 4 ++++ fs/f2fs/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ fs/f2fs/verity.c | 4 ++++ 3 files changed, 55 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index f52834c1cacd..a59758e1c878 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -4141,6 +4141,10 @@ static int f2fs_swap_activate(struct swap_info_struc= t *sis, struct file *file, if (ret) return ret; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + return ret; + if (!f2fs_disable_compressed_file(inode)) return -EINVAL; =20 diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 64ea0bfc2e1e..3dcc5e363c13 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -84,6 +84,10 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *= vmf) if (err) goto out; =20 + err =3D f2fs_convert_inline_tail(inode); + if (err) + goto out; + #ifdef CONFIG_F2FS_FS_COMPRESSION if (f2fs_compressed_file(inode)) { int ret =3D f2fs_is_compressed_cluster(inode, page->index); @@ -1070,6 +1074,12 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct den= try *dentry, return err; } =20 + if (attr->ia_size > MAX_INLINE_TAIL(inode)) { + err =3D f2fs_convert_inline_tail(inode); + if (err) + return err; + } + f2fs_down_write(&fi->i_gc_rwsem[WRITE]); filemap_invalidate_lock(inode->i_mapping); =20 @@ -1191,6 +1201,10 @@ static int f2fs_punch_hole(struct inode *inode, loff= _t offset, loff_t len) if (ret) return ret; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + return ret; + pg_start =3D ((unsigned long long) offset) >> PAGE_SHIFT; pg_end =3D ((unsigned long long) offset + len) >> PAGE_SHIFT; =20 @@ -1501,6 +1515,10 @@ static int f2fs_collapse_range(struct inode *inode, = loff_t offset, loff_t len) if (ret) return ret; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + return ret; + /* write out all dirty pages from offset */ ret =3D filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX); if (ret) @@ -1591,6 +1609,10 @@ static int f2fs_zero_range(struct inode *inode, loff= _t offset, loff_t len, if (ret) return ret; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + return ret; + ret =3D filemap_write_and_wait_range(mapping, offset, offset + len - 1); if (ret) return ret; @@ -1705,6 +1727,10 @@ static int f2fs_insert_range(struct inode *inode, lo= ff_t offset, loff_t len) if (ret) return ret; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + return ret; + f2fs_balance_fs(sbi, true); =20 filemap_invalidate_lock(mapping); @@ -2010,6 +2036,9 @@ static int f2fs_setflags_common(struct inode *inode, = u32 iflags, u32 mask) } else { /* try to convert inline_data to support compression */ int err =3D f2fs_convert_inline_inode(inode); + if (err) + return err; + err =3D f2fs_convert_inline_tail(inode); if (err) return err; =20 @@ -2172,6 +2201,10 @@ static int f2fs_ioc_start_atomic_write(struct file *= filp, bool truncate) if (ret) goto out; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + goto out; + f2fs_down_write(&fi->i_gc_rwsem[WRITE]); =20 /* @@ -2964,10 +2997,16 @@ static int f2fs_move_file_range(struct file *file_i= n, loff_t pos_in, goto out_unlock; =20 ret =3D f2fs_convert_inline_inode(src); + if (ret) + goto out_unlock; + ret =3D f2fs_convert_inline_tail(src); if (ret) goto out_unlock; =20 ret =3D f2fs_convert_inline_inode(dst); + if (ret) + goto out_unlock; + ret =3D f2fs_convert_inline_tail(dst); if (ret) goto out_unlock; =20 @@ -3353,6 +3392,10 @@ static int f2fs_ioc_set_pin_file(struct file *filp, = unsigned long arg) if (ret) goto out; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + goto out; + if (!f2fs_disable_compressed_file(inode)) { ret =3D -EOPNOTSUPP; goto out; @@ -3998,6 +4041,10 @@ static int f2fs_sec_trim_file(struct file *filp, uns= igned long arg) if (ret) goto err; =20 + ret =3D f2fs_convert_inline_tail(inode); + if (ret) + goto err; + f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); filemap_invalidate_lock(mapping); =20 diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index f7bb0c54502c..aaf3e754140a 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -139,6 +139,10 @@ static int f2fs_begin_enable_verity(struct file *filp) if (err) return err; =20 + err =3D f2fs_convert_inline_tail(inode); + if (err) + return err; + set_inode_flag(inode, FI_VERITY_IN_PROGRESS); return 0; } --=20 2.35.3