From patchwork Sat May 6 11:39:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13233492 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (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 79FEEC77B73 for ; Sat, 6 May 2023 11:40:05 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pvGGf-0004Th-Vr; Sat, 06 May 2023 11:40:02 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pvGGd-0004TM-Ou for linux-f2fs-devel@lists.sourceforge.net; Sat, 06 May 2023 11:40:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZvK1aHZNaaaO9H16uLBWIMIWtfrCjWUZq0GRWdRdX/0=; b=WnFMHzicRQqYupFqW3wlCTxw/8 t9p7HVly2xbvmeiflKR9wk8R9/yRFtGms6gEWLA4Gz/j9t5Sh3ZUiF6m1+SrMNC63EoY1ajyQOcRM tbQOXFkYV+l1h6f+ot2ABoHMxBvVIMmwa3pkmdhvNsx4G0dYKYPZ1hD7zsSHnj+fEwSA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=ZvK1aHZNaaaO9H16uLBWIMIWtfrCjWUZq0GRWdRdX/0=; b=f NV7qyXXY5CaNuc2BuZcPpSgnjzHI8k7yJmfjZXLG/6Fopm7iiPoue2i5auB4vEUebVgUmAr5qt6ME kyTWxKzQBHB6YV2hr9qazI5OFoaJpUVeFXvCiX8Bar1ZpgwVVV+Fo3dHbzUtZQ/xNrt+rAv2sGUtp rOuzRbFLXSvdzg3g=; Received: from mail-psaapc01on2135.outbound.protection.outlook.com ([40.107.255.135] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pvGGY-00GF3v-22 for linux-f2fs-devel@lists.sourceforge.net; Sat, 06 May 2023 11:40:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eIcaWmt3sjR+1jqTSM0C7dFvgMiFyFrjPz4BeFlCXjjJQdKbDPyL0xF42asQcLenb2RwOGqLNeRwxUKwVjttW3y1hYPZlHWTdhJiEIYTcBqJN6xVg0+mMHx5bRHWMIdfzLuSc2Vl/Ih4sFe0me6OiYQunZxTBHsojIL13QGEnxEs7mPrSogZcZ1E+F60CXc0yGfWBGollNHsjGDhvM9tsY5cVhZjNPqVvolIefYDr51NigywOwPPKPFM34hDEnK0Mlzw/rc6BEts8jWhsMOzFgDln3TbZ46FJz0HqCWnHMZletpSfZ79wjbZhWIXEtKgAxt5RpEsjp45HfbcxjAZlQ== 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=ZvK1aHZNaaaO9H16uLBWIMIWtfrCjWUZq0GRWdRdX/0=; b=YY16dfG/gAatZ6lQHVdrcXhl7XbSyvN8uHAJN90aUL3xr0oPNA2PUchhPR1RnwylhNcnXbNmrr5LVZg3OzDVviqnwVuwZoWS6imnJWJy06G9ycMQugC368hiSYVaMjDhmx8RFHDrWM6FiQCjK32cgkkjHwwEIRE21323e9jjlZ/Awsd+D3TRNDE1r+ZpNXRH8jhEAzBD1zOkHe+rdxbbwOn3bKNfOSh/S7kJtI+P7baqeLawAPLu7jLdfLJ3i5yJ0d9109Mn7sV9swvHNlS8UFnEuNbvy/xON4HIjY/um8eiVdZKlUc1c9wjnqQuUeaMApmcT0FqlzXrZ1qcrF+few== 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=ZvK1aHZNaaaO9H16uLBWIMIWtfrCjWUZq0GRWdRdX/0=; b=JfCKDEToaabJUPimpHgJcs8WWMtfD7xKvFy2ruuzhJAj2TfcN9vrZgpkZoYV7lIIsR1xwduR90iKtsQZAFSpm4u9tLuAH96of8sDF/XkEcJ4e2XHdEzpW63AaYQuP4wCjgHYsV4bUo7i+rhFEUL+UOMw8Uv857zvcTlJDXHMhRXV3seEACqLSaRJkYBrBM7agRxfBqamjMMILH3YyA4GRdDQ+25uRNG/q3/2xqLfNLFpcQo4erPnnPujEpkIf/oX0dOxWPjM0XUhLOR1i5dOWItCzc3vYA2qmYqcRDFf28MlqMrYqzR8j+9gB/F0oUM64DhCRzclom+L50xjSvn1Cw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4267.apcprd06.prod.outlook.com (2603:1096:4:15e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.29; Sat, 6 May 2023 11:39:41 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%7]) with mapi id 15.20.6363.029; Sat, 6 May 2023 11:39:40 +0000 To: Jaegeuk Kim , Chao Yu Date: Sat, 6 May 2023 19:39:14 +0800 Message-Id: <20230506113914.23419-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: SI2PR01CA0006.apcprd01.prod.exchangelabs.com (2603:1096:4:191::14) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4267:EE_ X-MS-Office365-Filtering-Correlation-Id: ccbf2e5b-6f21-41dd-1d98-08db4e2693cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DlAUOEZKz3SqsrZkYylc05OArb3CyftySeQX1tfD6yd16RhTQzGOjCMDhPUsw6u7iW/2Bwzh6DgxRex2NDdZAahsKZYWa1ohX8tpz0rHLVHfbKoF5V3PIbdGX7W7UeNwfzRU2GbwNhkjO6d0ZYuIaJyU3rhnTEaCt9EaThBSWLN4fFaeGgrMksxAhcWj1oHWBrqAHAQtMeC1NChhq0Z5FYNx6nu0Dcol+8dRC7iUY1qaPoRCBh6Q1Q2HG4H85GxH9G3v3BIhYo8TUSqz7Fn3FNmGeNI1Eu1MxtxdeIwc2YlqY0PrLFF1kK9tmdDIohpbLMrAJcxeLy7PWcCDE9fDnXYWmbO1JMpjLFC6EPSNRnXLmv/X5osdHHp3/1TStjigtVFqcRPnsiojcbQ8/FXr5tCTLII1I86ZnMVd9PviKZ+ezpEM07wdq6L8arEsX7ZSNFxWZomiEEja3D8p1flfdBLxJ0BhMD1x8dCYF4ViNCpB8tYhhQVAfzxOGaiwmEYWB+RXnJgaZp92hGFAK9c4vESEMpl1YF96i0K3sF6smDfYQrMtfKhM+Pe4onbro4kqXzjgL32kq91XxKcSORyJr3NNV3wdryM2gwMXIzlw5r5KoE+U2/bw2dKED9uhKrFc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(366004)(451199021)(86362001)(8676002)(8936002)(6486002)(52116002)(66946007)(66476007)(66556008)(4326008)(5660300002)(36756003)(38100700002)(38350700002)(478600001)(83380400001)(110136005)(2616005)(26005)(41300700001)(2906002)(186003)(316002)(6512007)(6506007)(1076003)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YIFOUjaqWaDji8kICHwLtiCrIfKMPgwkAi9g+HN3vwqvVWpK6d31K2ChuaT2zD52UyvapBT7DKjZYzyAWVfcafbqPEDx1wyfQ3eVLuWd+V/daLpGu85AYzeDqhFr+uO/RXOR57trCezKrA5Tom776w/vXFJo6KAVWyZLNYiMs/7fWA89zYXtB2iTqFXH6l6jE7RT7viGPdyN7zkFs1GbD2AAf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VvE3RKrWJLuM4ibMZe26/b7QFdN9nMiF5fQZhk0sg7DryaFCaml04TvbKo2K2hLAGh0NJpZjmrFRvifGHbMoGcP9jJSVxfiYrP7Z4i3vTbfriQ1DkymNk+z0bwtAZcDe/CxsHMBvhTS2tIOomv5SdmttUaOOYz8Kqx87p8Nj855i6ubTwmZn4MB+lyhRxuMIZmFmYi005cTYyR4CzC41ywNujJl7G/G4u4pVtMIUTz/vcT0ie5DXhe1QU0KVnhY3eG6oGuUiHYxqyNCEiC5juiDRxxkc7mX6VqIrT0rJR3isp3Nf X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccbf2e5b-6f21-41dd-1d98-08db4e2693cd X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2023 11:39:40.3248 (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: 5UNTw9ksArxb6hFcqmlsYBk4PQKpv09WRYwz29RJkHoRAcmXf8/eJ2UJAGa0AtW5r9VNVj8hPLOrpIqSQwrI4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4267 X-Headers-End: 1pvGGY-00GF3v-22 Subject: [f2fs-dev] [PATCH 1/2] f2fs: move the conditional statement after holding the inode lock in f2fs_move_file_range() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net For judging the inode flag state, the inode lock must be held. BTW, add compressd file check and to avoid 'if' nesting. Fixes: 4dd6f977fc77 ("f2fs: support an ioctl to move a range of data blocks") Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 78aa8cff4b41..850e745ecf88 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2790,9 +2790,6 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode)) return -EINVAL; - if (IS_ENCRYPTED(src) || IS_ENCRYPTED(dst)) - return -EOPNOTSUPP; - if (pos_out < 0 || pos_in < 0) return -EINVAL; @@ -2804,12 +2801,17 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, } inode_lock(src); - if (src != dst) { + if (src != dst && !inode_trylock(dst)) { ret = -EBUSY; - if (!inode_trylock(dst)) - goto out; + goto out; } + if (IS_ENCRYPTED(src) || IS_ENCRYPTED(dst)) + return -EOPNOTSUPP; + + if (f2fs_compressed_file(src) || f2fs_compressed_file(dst)) + return -EOPNOTSUPP; + ret = -EINVAL; if (pos_in + len > src->i_size || pos_in + len < pos_in) goto out_unlock; From patchwork Sat May 6 11:40:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13233493 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (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 6F0AAC77B73 for ; Sat, 6 May 2023 11:40:58 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pvGHV-0001Cz-2e; Sat, 06 May 2023 11:40:53 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pvGHU-0001Cm-8S for linux-f2fs-devel@lists.sourceforge.net; Sat, 06 May 2023 11:40:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=a+mL6onjwYJFYgpqq2TyBD9eQM5EOD34JMpHoZzZFIk=; b=bsFlFZ5i64G4iygJxFzmacBDf5 Q6m40jNngc0RZzZU28reWWIGD2Czn7OWPdwB+uakAN8fnS30o47f/DDK2+75HhDT6gBb2L9yftQgu 7VPyv3u/K2rxdG2dzZVAfvwXAVQW2PuqCDeCTtB5qHtTbooJFqne4DerHddi5cgCxHiE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=a+mL6onjwYJFYgpqq2TyBD9eQM5EOD34JMpHoZzZFIk=; b=T AML9unkwxbVD0cUrHG80v64ouzbJ8L1PuF63IiiEG4rxdytvFjxnQZ8CKYCdhMn9HPTp28vE0X0aF fCeT2ifXy5HMGeuUJstnqB7d//xKdP5kywQef3nqA6ldOyXIBs88GwStKi8J3b/5xTHI7w4XNkvsE oanbQzR38Te36W0c=; Received: from mail-psaapc01on2139.outbound.protection.outlook.com ([40.107.255.139] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pvGHU-00GF5z-K8 for linux-f2fs-devel@lists.sourceforge.net; Sat, 06 May 2023 11:40:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8FLliVo5YUd7lgzFlAVWeE6Ua36Z2XCH1AX4yqhb1A3VX9kFyFyfeme8z/ZN1/CT61ivzCpVuoSpC8jaIsA6WXJc+pHEwgbPk2I4OIrfR5PhuxrIRn16fJsGNEWbgiQb8kzcleMshzBW36Pr1QsGHQHzicTaVoxncghsdO8yJoSHDwYnjRcGi4gXJn7WCXDSlUEyB8TYCVPk1ZvKSMAX2N80M2PFFEFgUXy55Ovjep7oU2e1cwDZmrFpU4X9fLCwbnAq4P/7Pd9Ujbo3jTLo+Sz7w4Un/NG77JVD7b/V3StgeSzIaZniSZORpknOaLcme1ot9IfGLA+dV3nYHnzUA== 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=a+mL6onjwYJFYgpqq2TyBD9eQM5EOD34JMpHoZzZFIk=; b=IdtQESIdNjqHGZU+TWr7A9Brr9mKhxI63ZrsprmftFcUNpTbCoQLc0j9tL15J0cFGPzPmXHv+jmeA9PN+6hkOeNzq6NMD2OG9nTj0KxDaK5YzlW4kziRUJ7RCyq3rNUwhVOdmXSWcaG38vZ4eLNS2oE6a8KqpIjYJyyrAdCbYOj6WDcDBhuPLJiLiBdDjQ/UDnr7YZDCz5Zqy88byzmC1SoUoMRQ/8ypOUhM+MlgWpeDBEfyjK6aAjxHOiQIbjUyLI/ZnEVqz5ZEiuSOikyLJRUOzHXHPG1qJn9C1vpUyPpOAtWy7fc2ufg+QIlrxDnBcdRYewYFUDZoyBmMd8RQLQ== 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=a+mL6onjwYJFYgpqq2TyBD9eQM5EOD34JMpHoZzZFIk=; b=ly4mqEAMqy0KdHA7N0nM82QoAFQvDlWHBLp1j7AWcwtZ+OMw4GcxzuIxIFC4bGnVHYPcf5Xrbt01FSmoXeImJ+NjeJoQiwaAvSk46q6ZIV+te7hAM4vo2tL83FXgXp0i92Ob2INapTT/Nq2re/nBBKfLB+BGdsmr/Hn2SlUCaX2w76P/6+5EsAH8Za9TB1i/njdzE1bUmzMlKRC5iyx/KvNevmDh1sDnrS9CGNXQ40SlMFh88YY1VWmVwmgNWSusn+RbYSOVPyA6bGEA1ZtdmS04Hp5fv+2S09sbLq8fvaQ7AjfckS3lDNnfXQj/h3luLQdblwaxrJxckXrhYezYJA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4267.apcprd06.prod.outlook.com (2603:1096:4:15e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.29; Sat, 6 May 2023 11:40:43 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%7]) with mapi id 15.20.6363.029; Sat, 6 May 2023 11:40:43 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Sat, 6 May 2023 19:40:33 +0800 Message-Id: <20230506114033.23908-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: SG2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::10) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4267:EE_ X-MS-Office365-Filtering-Correlation-Id: f6ae0b3b-672c-43bf-1748-08db4e26b97c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3s1OXUyG11T8Nbc0kqREN5C9DbwxT+t++zCc1w4H2z4GOihTiNv+9vo9MBFUxNbmYhic5QlleevxsTAFcbJPpIwektH8VweJ+3X8C2UaAi+qAmgrBDPfLSozwRuChKBWUEKJbFDZxLHRWEfPoHdW1FJa6q3M8E/IeuDRyy4OScrqkMSE+sKYSFmV2ZzsbPyIv0wURNeY1khgdvfKGzQjA5uyIb4HPDQkxyHrs8cSZWGS/qmD+y9Yi+y59iO15eL0HrBYgmTo26KJpWpwWgI0/XAVIxcW/3CNvA6mksfRTjf81cvKnrz9qSacYwKx23daIyXMVjKnnnOv0Qd1+wmEp+jsrnB7vEVvTa8dgd+eAFjbn/tpP9bG36yDQAtqntPYW0MCUDdIXsUk448dhPWX11YfgY3oAUD2zA9ST+0sj/F3HS6weWVAZsTspzcDV2XUaxt8qg69UTc2c39hjNWRmxcyK/BWr6uHSpZvSENSouLczJl4OLvG01Y/+6Qkgk2CAX/GhFgSUa22PJ6pcv96wu2XjKiB10eT2dmQvgcQWYz4iZJU43e501g6ZpxY+xywf4OK+x6iTbkFv6fsW5iErWBJOI7KVuK0sAVP8vhkgnzYNX4JzeIqqh/88wPCiUgS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(366004)(451199021)(86362001)(8676002)(8936002)(6486002)(52116002)(66946007)(66476007)(66556008)(4326008)(5660300002)(36756003)(38100700002)(38350700002)(478600001)(83380400001)(2616005)(26005)(107886003)(41300700001)(2906002)(186003)(316002)(6512007)(6506007)(1076003)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O3uCt/znlm2VovrEeZartlhp/FXn++rMCQP8wthnoojZG4buaC0TYGjr+l0rIJPY+iAC/M3DO+6tE2aRKttbKdsjp4GCpN3OZmgHMytQz7NqiRBS7ypMVbtXV3Sp3vHQbd7WcKYzuiW2qmm2YldUghYLtIAX141AJCkfBWuF1SEia6buJNXd7GonhV7VC6CitKKq0SpNpkbF2Xu7lyD82x16AOPf5fq2NdQMx3QolU1cBWDP1s8ypug7sWPR6kpKHPukvKZ/SlpNuEUWlfL61hYmEwiT62noQkLmD0lzIZ9hcelfYFj33TFdKwBkpSr6XCGUe6GFL8V6cdyAxAPLdeXY+EoB9USauqrwF5Nf4vf0Iw3qjx+/Zj/V8OgQS2CxbvUp9ay6tIM7VcLwcDiYDCARutlu6qKifI20hMO/zLjuePJBtS98k0cYmzyIZ/dFc44ScbiYjUoM20wJeUwIGDZyBbtfJM0H2Gw9jqphg1buCdJrXw5ru5LYsAYt6um/xIay772Hh+Wpiyz+25HA/S/Th0SKpRDgE4I1P6EutTMtUOaIgQEC/+b4OGC1ZxF/hczqRjiK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-1748-08db4e26b97c X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2023 11:40:43.2974 (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: F+1QFZ+OQJ76Xpsn9c66cPfQKEm/BjPfTzrlL1cQU1NEgWq6FMuIJuccb8lls2Sz6WF1DEUoJdDDwIgGDNSTpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4267 X-Headers-End: 1pvGHU-00GF5z-K8 Subject: [f2fs-dev] [PATCH 2/2] f2fs: move the conditional statement after holding the inode lock in f2fs_fallocate() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: Yangtao Li , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net For judging the inode flag state, the inode lock must be held. Fixes: fcc85a4d86b5 ("f2fs crypto: activate encryption support for fs APIs") Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 850e745ecf88..0837c500b990 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1801,6 +1801,13 @@ static long f2fs_fallocate(struct file *file, int mode, if (!S_ISREG(inode->i_mode)) return -EINVAL; + if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | + FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | + FALLOC_FL_INSERT_RANGE)) + return -EOPNOTSUPP; + + inode_lock(inode); + if (IS_ENCRYPTED(inode) && (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE))) return -EOPNOTSUPP; @@ -1814,13 +1821,6 @@ static long f2fs_fallocate(struct file *file, int mode, FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) return -EOPNOTSUPP; - if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | - FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | - FALLOC_FL_INSERT_RANGE)) - return -EOPNOTSUPP; - - inode_lock(inode); - ret = file_modified(file); if (ret) goto out;