From patchwork Tue May 9 09:57:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 91490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2757165vqo; Tue, 9 May 2023 03:06:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5O+PIXh+B082GqQX0WuDqyzkoG+uNq9b2xej3F/dOXaPsR+N/72tyVPzl/VTqWNtL7wpHJ X-Received: by 2002:a05:6a20:428e:b0:101:4d10:e406 with SMTP id o14-20020a056a20428e00b001014d10e406mr1989927pzj.16.1683626774164; Tue, 09 May 2023 03:06:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683626774; cv=pass; d=google.com; s=arc-20160816; b=Q5F1BZdwPTTxfAP3MzryHLHNbjDB9hFdU0X/kvKqmguE6ymetjOoAz0U0hbfWIokrf 2VW60rZIjyIaCo772i6ij+K6LHRVTnkFKGwqcx5UbyVyVdYHYWCxNrtrq1YaQqqJlLTo h7xyTfELpRBhMKm9a738CBCJjw10DNt9d1wuunGmzq8msWnnVOFnIQN3bxymTBxJqZ94 4p0NmPtIwZBu8fvYdmzYvkZ/6uoQSmgP2cfZjRZDaD2/mO+wnyLx8FSaElajTQSabxki 8X7KrrJWmw3DINQdxkar5NRtZyeHc7c3DpeY43H+mQncsr0vZBa/gMnfrP5koVrL/7Ec Z/AQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Ciyak4ApemOiGcAYqhdzZj7ZzKBroG9JAocEbmxXWn0=; b=GJLHrGxG78NZthi3gAD4NCSgceC06y1H7Faie3RmkbbqrUrDF0YJl8uCuBRHKhnyOU EucCzBBv/pnZKM+4akHutezCzuaOi6gJPvc4k41wfE0dTGwhq1gzE7czSESca5IyluXh e85uOZHdLatbPKVh+tZDnntyv19vf5/6K9JIw6XWypmxpfy9JoqSpLdIuosPBhmvMpAh tV/s7wCyfMKMpjFtCs4GgoE8FDs8yvTxuDLfqFzdsVBxMbPjPqgD1X4aNy12+ZSpsk4n hcc+1SvaXid3QOs8TuiagONRnrHfHXqUiTUgxZMP9/2ETTKL7N49zL+7KSYnojlut64i IWpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=LhboLZJi; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l191-20020a6391c8000000b00524ecf898a2si1128393pge.359.2023.05.09.03.05.59; Tue, 09 May 2023 03:06:14 -0700 (PDT) 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=@vivo.com header.s=selector2 header.b=LhboLZJi; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234431AbjEIJ5b (ORCPT + 99 others); Tue, 9 May 2023 05:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233625AbjEIJ5Y (ORCPT ); Tue, 9 May 2023 05:57:24 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4231146BD for ; Tue, 9 May 2023 02:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sq+qFWuNWEQBQvFy3CcUgfbVuQSIv4jJzW2f576cy3D9N/+TkW4h/q8MP8GkbdYgPjfVZdoT4B45r32Otf3os57b5kRHML0/isyoPhN9KnmjcmQWmbBzR3bnPqnN3xjKbV2a3aVvPCOESh6FZg50i9FErkuTlAvLJckU+QZUjF23vmZrcSDJMOiTx/CN1/kvOI07reWvVnmCHVbfLhtBRQ2fKrRvXv5X7B9Y5iGpUdaOIEJ/QFOflBcUqKLel3sL+OloafVX+of+d18rMinC4x1jjRRkNEb8g0fzzXHQn3bso50CggdHWNKPdJ1MGrqyuH0GP3n/9FpHWVBbKVAdcA== 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=Ciyak4ApemOiGcAYqhdzZj7ZzKBroG9JAocEbmxXWn0=; b=I5TsMZdjLymrHjM9RFJ0RddAcFE0LFHJFrmsFWWS1wOgav6gSf32wu3+Porpro+w+qCWH+13csGxTL4SukXYB82Q9N0lgTLGItUvT+CvxdcU9MwG9kL5+lMnzT03/rX5qs9sbwZ6nj0DzEcwW8rYJ32ZaCfH7iIV4GThHPZHD9hEwd10wY4A6Jwz/3EjwGMBsXDt12H64bIWfLgriHpK7/5+vCJWF/K5uzv3GWgKKHvTbCP1Pk2kUKjbKOBKpUYkCCF0tXA6uDGzO92v/SogAhvWOm6Thdhn14gbrQQJwKLbpfvhYp697bs4xbAecr7oXdH/Wv6MnNR1i8nBAH8xAQ== 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=Ciyak4ApemOiGcAYqhdzZj7ZzKBroG9JAocEbmxXWn0=; b=LhboLZJiiKE654Cqllo5dHACjMqaEhtmZz4sDgGquc4hkPrxJv4Xf/rkTC37izovVAxYMeoJ3mGUydoaGIKP9w6MNEINS50NOyGFaXhjo4GTwGBPgsy8+K2qtUtYo0oXcxLQ0Zn7ltXSfhwAgetO9NcBB+htdeQmvFQdGiPhG1GGWBHJQGRV2IpjU6QZdYWdC9tI1M8W1l2W79r5NwfiOMKKZvWNUaO7CcNRI0X0rCjP6Zyk0Ju7y2D+N5cjeWu9L341ytw0sh/Fzz5ACIsbjuNZeRN3c1YG0xFXyI/x+PTh5UQ/JCB5sC4f70dfn5HInPDlFunYYGw018S6F6/WsA== 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 SEYPR06MB6130.apcprd06.prod.outlook.com (2603:1096:101:db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 09:57:18 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%3]) with mapi id 15.20.6363.033; Tue, 9 May 2023 09:57:18 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH 1/4] f2fs: convert to use sbi directly Date: Tue, 9 May 2023 17:57:03 +0800 Message-Id: <20230509095706.17844-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: SI2PR04CA0017.apcprd04.prod.outlook.com (2603:1096:4:197::15) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6130:EE_ X-MS-Office365-Filtering-Correlation-Id: 1487afe6-a0c3-49d3-3b56-08db5073c5fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1yZAKTXTaPLt9jt5/Rjgay0t4Exuvr7XR+YWbZ+LKHt/2JXL5TJBLOByru+QamP/5YRR1YFxpRr4dqcD3rZ1Nim+vJ2mcVHSDZj87WfAg1IMEHEVTMViccfCCJEdyXtPURfkStVjV/8nE7LdGYTxbn5FMTCDQhNi42ZRZLPGEl5RSxJUh22J6zXGWdGfzbaAOu9akqgrwApuw2Fb7NLtyqBRJVH+ogSXFClICxFbgcuW4sa8/j06txZZ53SgfDpVCapIAIZaAkzmry25ZWIW65foYW1+csR4AWR8FbvAw7QvfLs14jwYn5yq5x0OmrH+87sZv9d1LPkzArf0gHrNJbPgeZLaer5bpDBIe7tvIX5nDICX28g490AK2qzHdpQxPPcnoiQKe2DfHr+eg0d494NTPJVa8I3vjFlZLZLEifrq6JslvPOru4o/Ta0Qe9cbbtTYg82Gsst+LerZX4XltIXaGU5ugeSr36fTOFTAwfAfwtMg8xf35FDDbRT4QtEP7BoCZ53zhAm7+fbE/ur0GXjPGt+aBZ2yFRSYWYnlO07Ode/NPCqnYV1RuAlO6kEaZzt8HjCkotq/P84NNWmv2YMRGjDitijnExzrwEZqU/A= 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)(396003)(346002)(39860400002)(136003)(376002)(366004)(451199021)(6486002)(83380400001)(316002)(66946007)(66476007)(66556008)(4326008)(478600001)(6666004)(52116002)(2616005)(6506007)(6512007)(1076003)(26005)(107886003)(186003)(2906002)(86362001)(36756003)(41300700001)(5660300002)(8676002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KG251XEDqWAwpwIrilUHKd36dPcuFVswOyVSAsLbMHHePsUzqYJlcUgPg5XLWv00JQlq3xZ24gH9DR1f1yOiZr+s2LMxuDz4HlYZvDapaYtp9FMVJ8/VB3/Pr7z5PA7z6h2tyaEXWTdQSwSKLHaBmFifqlHKbxXPGSce7Jw17w+ggNq6CKJqJA/du/2G4uvJPPTx5GQ0eFeVOoXBXMb3RlKlFBYbYekAm9gN9ID7hBHM4+FXlFwQ4wpQlBO+dAKkql+/72CiALHEuYR6DqGRI1jm9MqeR0IA4q4DBIUFNFXBYtEolFHgOXWkKqfGF6cbuDZFFN0jSXBB8WWhoCNgoX6MYpLpv9sTe+9FFT6m+cRhhT40JmqiclVRuxrzXYHM/u62g8wwo97oURUgRKzEcuEPRTph3R99IbIex4SofTx3LQ781VTchHqZyTZ3OMHtOClHumBJP7+oxA/YX82RIl6/94P3lnR8eS7Z+kXIme78nycVhgP2pUOJthU7VLqCRf8ocHVSYoqsu3Rk3Mg2G4GEgftsMuG27EBhhB9+k3ggMrnjaB5MrWgRTxrY6udJroMVnyuUVfare6y2xeFxqJYOjvVhdrgLfAfDP7Oh7dCDsRZY4jYTSOPxaguePZys5BdR2FJFDR6LJ9tZ3Ew5kuosKpZMcXxUXL177VxtMhRja/rN2PIvRI3KSZGWkPxrIEha/ai8nDfw2dyRZnPsQm5n7AfpforV5OYy1tVU0JNVwWsdJJx2sslUQbopHUDPadid+sOeAWHY0on5dO21kqXhLmwX28ayPSv31SddDciSdxFIvuq496qc/pX2z4NAWUoH2VrWqiQesZegFSICiDJ9dLbPbxSynsH4Z1c7ZtiS9TRIq1IQKRkx+J/bENV/x7seBKMgDjD40eweas8LH7j0gqYksns795byeutwT9OIlg2mBtbGPyXvn0ovtXu/9JuBpPvl3omQ87Bx4g/aVHw6Kqne8bZ3IvngeLGzpakSOtqCu+4/DU9dw9k6WAr5psOvaa+FpVAnX/9YJyoPpG2qEiSoc5F14Uy9om2p/kYBzM+4cNBC/EaS23YkUd1mx70jStb1OkAGZKgz42JL0RczFXHtEQDdVUvqbmP2y8RE7bDw9sqqIK5nPQV0fvi9oitDshxa9ioFmHTMW1hypOyt+j1EYxBqTR2L8rV5OekRSSNEQPQ3cSyf+S38j5V/bSVGlwpWsMYHLkpj7wikGfLUVOwJsYOK7e+/yxKlez1CnBGVqNWOe4Zn6hLLPczpBRKNRgnayNhEQvOfIMISED7zxZseNIfcDOpFoBjEW/riK1DM4d70PnLhINi6qw1rzFqYPuXntuYi+2NMO6YNCu1pU+gAHruCIdxZm55n/W9Vdd69abn7SEQj0vfo4Bkcq6lqxpCaF41MGwtcRjGKejhWtRTgr5TgIs/Nc2/Fr6wydF92np3OsaQhYK7/dEhojsMJiI+OZ6YNCUu4SyfsGde0BC/RGI56DZtEkksiQX+g7fShYbzIGnKEQlqV21M8V6FRjTH1Z3yWUjQARWc+xC/QTU/iKyZ6JspmigygrswDQ590Tw9WtQa6Cph6vqMk X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1487afe6-a0c3-49d3-3b56-08db5073c5fd X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 09:57:18.1483 (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: 0rjJCbHO8V6pibiP8z4k7qbBgLWCO4H7/nYJOdP4yVxNTfkVbocYHICghTMdtTPoxABohW1NfDhKG4V/tYelCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6130 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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?1765410628273725496?= X-GMAIL-MSGID: =?utf-8?q?1765410628273725496?= F2FS_I_SB(inode) is redundant. Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 0dbbcb406d3f..6f8936ec689c 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3466,7 +3466,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) int ret; int writecount; - if (!f2fs_sb_has_compression(F2FS_I_SB(inode))) + if (!f2fs_sb_has_compression(sbi)) return -EOPNOTSUPP; if (!f2fs_compressed_file(inode)) @@ -3479,7 +3479,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) if (ret) return ret; - f2fs_balance_fs(F2FS_I_SB(inode), true); + f2fs_balance_fs(sbi, true); inode_lock(inode); @@ -3636,7 +3636,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) unsigned int reserved_blocks = 0; int ret; - if (!f2fs_sb_has_compression(F2FS_I_SB(inode))) + if (!f2fs_sb_has_compression(sbi)) return -EOPNOTSUPP; if (!f2fs_compressed_file(inode)) @@ -3652,7 +3652,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) if (atomic_read(&F2FS_I(inode)->i_compr_blocks)) goto out; - f2fs_balance_fs(F2FS_I_SB(inode), true); + f2fs_balance_fs(sbi, true); inode_lock(inode); @@ -4046,7 +4046,7 @@ static int f2fs_ioc_decompress_file(struct file *filp) if (!f2fs_compressed_file(inode)) return -EINVAL; - f2fs_balance_fs(F2FS_I_SB(inode), true); + f2fs_balance_fs(sbi, true); file_start_write(filp); inode_lock(inode); @@ -4121,7 +4121,7 @@ static int f2fs_ioc_compress_file(struct file *filp) if (!f2fs_compressed_file(inode)) return -EINVAL; - f2fs_balance_fs(F2FS_I_SB(inode), true); + f2fs_balance_fs(sbi, true); file_start_write(filp); inode_lock(inode); From patchwork Tue May 9 09:57:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 91494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2758442vqo; Tue, 9 May 2023 03:08:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+7FNfEQhbhdXOoO2P2sUGzRppPqP6ni1vLxTPMpsoEn6a/ZjxXHy7rkx23M3dtewTfI1Y X-Received: by 2002:a17:902:f391:b0:1ab:275:5abf with SMTP id f17-20020a170902f39100b001ab02755abfmr11214174ple.55.1683626900525; Tue, 09 May 2023 03:08:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683626900; cv=pass; d=google.com; s=arc-20160816; b=kbowiA26abvifdbLnw6el6sPfxRDJoLA6Vf3CYQReHVJF+mrQohaqsQEnX4GJd4ETw BFjoiVtbBp3FcXNRqIwTRUZzaXln9SJjBzNP2ZG9oj9mlcptItuuYjFyDoI1PUWmSZHy vZCibAwZF/5Y8F8wbGxkPC8flKPyaCu4X9SAEq7mqMOWCrzfuVqz29rdQ4Ctshj2ZrQy 41/iYow3MjWWMZs6yBv1cVrLCgFwdNbGTJwSojsQ/0gOTpZgy2dCKw6Nut597cJvCQqW ViWcWWXvQsJPIev8SsRzzD9bL0ItSIFiDB6sQvh+E7a5dXAcCXh2hTTkh0zEdygQMOm0 E/vA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6luf1sDdpq7vm+r+VRwsJaFqPhL7j1YIsUOYdY43Kko=; b=sSenXvIohBnpBzx4UtrzBbIlx1nfdQOa7ifE6Nyn68LhHlAhOxrgeEkbMoAcS7bIYc f93RGORM0hhQO/0ryEro8pSTNt4L0M/YluUDKwZS0Yxd7WFg1+2f0AS97BFmfMuyrI1v YB+gCbkzk1rUlRcjcDydbyG2isRvHXnzRIU4B5cLgL05q5jr3eIc9b0XbCESgP0Mibmg V3UnPhDWLThf2aGfIl9jWkDGxTjgvvWDwwO+vfph7xg3ZWxZ988tOQaLNhIQTrHIMMqT 8HIg7V/E1HejjN2guB7XqGAxtgltpEbQGNCgtEijdbE4eEpbXE1WTJ0nw65rggANGCS9 6nWw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=dzvELX6w; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jn20-20020a170903051400b001a6fce122basi1143274plb.322.2023.05.09.03.08.05; Tue, 09 May 2023 03:08:20 -0700 (PDT) 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=@vivo.com header.s=selector2 header.b=dzvELX6w; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234621AbjEIJ5e (ORCPT + 99 others); Tue, 9 May 2023 05:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233789AbjEIJ50 (ORCPT ); Tue, 9 May 2023 05:57:26 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8A4A4C16 for ; Tue, 9 May 2023 02:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ID9mqbrjWdGhvYaHk9rcAxiM5TP5aKs8rHXyvCYIw/ofNdJ/OtFYpFW2WOwaQUscwRsPtIsVr8EGoc6KmpoHq7e8vAxJsQgyOxiDUruDd3MBjmR6zytoB8adWr1J6Mp1CI0p4+c9Ges+oANbgoyNL+Nl3KArsBVXaBV9LQP4kJFOg2y3gvXYfAvqvbEcYtUrNYTOPq8yyvoCDHKVmbrAtxEal8ZBn7c9q+VtIgJPaBp9hCy3fr2DnPjSvm3hcez3Ozwb+gP4JVZ978SH98VGdLzp8W8pS9kOybI4JjHB872wEI+a2sfZL0LjwOU9v+coER6DhwTmIo8BH6BS07SPpg== 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=6luf1sDdpq7vm+r+VRwsJaFqPhL7j1YIsUOYdY43Kko=; b=ZJdJo6ZOVE0Nw5icSlifCXkl7iEF7m5BzeRK3i5Ve2HVXWMVtiu8S7uGoxSpO9yBSpYo+6PcZt1KfEOEYl6YdKwYMs4JLmVS5JJen4SaXssmBbiizhYD5yPRR7dVtKgvCUwXakEZ9chu4PK/2PJIJ7Pmhu4Hfp9rjq7+1Gov28J7kPP2XMGf37q1XR4pk2Yjf6e24JHpdENWR2L1hexZlZ2czm1JU8jUtvwLHmYiiFX13YY1WcEIY47E+6c/8ALcPRugLKOiIxezPCt9mhjk2v6ja1Te6z3tGgo4Hzgn7vMvEwQHRc1Ri3Qw/jAuZXQCE1XCJJfUJ38aSWGYgH6TPw== 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=6luf1sDdpq7vm+r+VRwsJaFqPhL7j1YIsUOYdY43Kko=; b=dzvELX6wEDZKlg4rpMjLsJStToyfe+Cp7KAFnzyNm8oRsIHWGfMKXfvAWnOFJAJVOQhVYrQlk9tVDRGfykwK3hvqqIDEi4FmDoDtF2ssMq3Ur0DX0z5Q7DSWU1oT+dv2zQjkPasJyKEHXu+67ZEqGcwaABMNCN3kogpbnfouVCHhqpV88TfoLgcB0tAZXvo/9elrMolC6DzgNi/1J3rLtIRhS/F2UfbZSYztZdXu3lkotdHzyNj/JXRgxsOEX8gm+sMuG5WmAFDx0hw1Rkh0mtJAqv5guzw87++T4JGHd6B/Xf3d7INrQsXYgQCP3U6e1q7oZ80muVfZSIjDG0oN8g== 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 SEYPR06MB6130.apcprd06.prod.outlook.com (2603:1096:101:db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 09:57:20 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%3]) with mapi id 15.20.6363.033; Tue, 9 May 2023 09:57:20 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH 2/4] f2fs: move the conditional statement to hold the inode lock in f2fs_ioc_decompress_file() and f2fs_ioc_compress_file() Date: Tue, 9 May 2023 17:57:04 +0800 Message-Id: <20230509095706.17844-2-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230509095706.17844-1-frank.li@vivo.com> References: <20230509095706.17844-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR04CA0017.apcprd04.prod.outlook.com (2603:1096:4:197::15) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6130:EE_ X-MS-Office365-Filtering-Correlation-Id: 97c37b63-ab5f-4a0d-c806-08db5073c781 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6l99tE5w3DDX9R3o0uriggDGr7khTXWrjryU48YwNGEi6pHmk6MjLns+A0K57Q7aWLjV1FBN91ESJgxPwGUOyzAi5itCf4SF4U+bXgcjAK5VETxMCtw+8eFs8LTHz4VSvQlxLBfqfsafr55VI+k+2PurARZe7h66LWfqqphWuAu7IXNKksWAjNhR86xwygB4cs01PIeoKc2zdLjVi6K4iRKjT93O+exsddiPwKVqxrGm9IhSq9XQcTdA7zmxmUSuASYHdb0WyQ0rsuNtu+tyvZRAYU8Ry0wYqhtMHpZnFovUQ6fPdpK9nh1hywyUhQ5thcO1trBeu3xt6CKLwqjfmZK/AqYic4OszEmmpueCEF7hDIUMDU1tDB2kOMok5u+IviXR7XpZfwrDJiC7QB5VBnddBKOTeOveLdB0SpI5lpTJ4aTeyTHADvdpp8sMo1VK3jrz/Q2aAx5Z4rMCbkQWSJB0pjsamuENRN4ES25Wbnfk1SP1FHYswc9iHQOouok0vPjLQ3pZZhHaMdQWbmkQACd4qOTMMDONr2FiIN/1T9F495F9SBpjHnbcWmxRuOA4mujDlNmwahV4ZwoNF4iJBY34IGOI8mgXRZ6QJxm+n6OYSB2wfACq9CoYwXMVLWJD 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)(396003)(346002)(39860400002)(136003)(376002)(366004)(451199021)(6486002)(83380400001)(316002)(66946007)(66476007)(66556008)(4326008)(478600001)(6666004)(52116002)(2616005)(6506007)(6512007)(1076003)(26005)(107886003)(186003)(2906002)(86362001)(36756003)(41300700001)(5660300002)(8676002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n/15Gt9E5lmgjRW/p1l5QBAqVrRUMZBfY7E2Elo1lNkO0xYCqb+Ov6SAwRpeU0a4VHcF80f9AiCBbN88HWHDat0f8h7DKsU7OobRnfbzSgN/QsJTxJzsvXpGUOgZK0M8bSbM7xPk1c2UeNlIgwhYzIizIywjdJ9mzugLiLIPV5P6LFDj4OSkWSROOw+O/FXq+TuOt48EuSIBnvCPZ2iaejXJK9uMl8E5jsRg4+t7UdKol0+7hN2+yP7IfGuUIIdMuPbOswUr6q+oWo1N3LccF8trKZHNHyLSom2dKl5rIXaWZYnVYCUk4wJB0/nhgL9H1b5SOWr8XIxYdKGrbdS6VdihX/PCGrPzXq/yMh6yYuJJs99F6XZBnXZmj8Z9pNS2OVjaG92HCvVYgvCiPBRVQ5fpTNrYZ1pdYAEFDmgEb7P6FbLP2NkOK0s0aI6pK/QV2+L33RuRep7HaR+UNUBnHkEFYMrfGosvPbN/pB7DwLEnH2TdzfH4SwzE/gM/QHjZljFdHBMZMIfWYBwr+B+27OlNEqk4hzBEYLT7L9/GR4qAp7671wAEDTaxvWf07G8Lfn9cl5RJn8EcFB1wm8wxtdymfHKrtuf1ryw/GHUIHNe2yoxs6zuKW4GF3NmShFaN7G0uN8nOadFFx6Sten5sD9pBIaDaBjQ8hMhXfNBnofs/dbl/fLAEGlfkmQ4i3Zx0ewjXCwQDid5XjbcoK+RhD/LHSRqJqCFuyr0x0Gqwwso6AnEff3c91fWkaXYjftwOCaLLG/y2DGkbTl/D/tCMji3VIy/lLeMfBsOo8LEv67+9zGDM4hli+tK5Egsgvfx3xdDzDb3Ho9sxttSjsl2sLLjKCxbBHdA1/fwVSrUBaMeT4TKNEw9sgirnzEgWGwbkCa1kC3APZ4SQCfRGGF2bGZA8ooTFzm0doHgoHCBk3H2n0j/1TzifUanvGdbyqgxle4tTMWMibBij3a52XoPcVIxCobNeky/IL+DgOHNqvAxk3BTuvmf4JrvowXrvJYJ2ZVkA+6TwoygKJ473UstzipEmlKDWB9w1UJLRA/JfFHtnl5eDLD5Wgtue6oeLikcsHXR99B15Qn7rmItqYxYof327ygauI/WIkXoWswyvDHcUFDx5a9YTnrNC5y6lO8wU9fQP9lg27Nvt341fvOHNMLVqsxh1buWDbAKTXofEsb0aD6MaiWwVKyXGJYU8sQ2upH5gXBCcxagnMnvRlVAGCNOVVqwddmrwa9LHUUqAhoyclFrSbocb7jLUYbk+RMHTDDFr/XSpRbCZ5AbPH3G7RvpgK5EeGPnujzYqDZd5+MkZSIFoswCTrJ5N5egAqesMxhZ4VkyfR/X4Hn4EqrJPPZFbM1eQfpzkf12OW+CvrHlRVT+SLBhgUKM4IphXb/0RG/9Fo8UWdnOYlH6wQ5LwzbjpsYgegbqAUYt6uK2oj15mQLfXNbD5W+YXuzFTfIhUTCV+MpcdiiC6BK3AxHrn+W6oxDB+nUTbtikYhesP3EXFxM7hHizH60FS+2gKic9gsnDFA0spUU5WxvaeAYR911yYvh9g0Ct7Ohosz34xr4hHAvr622DVYLJKbjS7d4kc X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97c37b63-ab5f-4a0d-c806-08db5073c781 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 09:57:20.3153 (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: OuQiTvc/rfSNjWP4ofBTNSMcOsguGSk4W0+8GL2gzPs81gHEieU3+1gu5h+sGpeqGqjEhaHO0pRauaekR5ThwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6130 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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?1765410761302854649?= X-GMAIL-MSGID: =?utf-8?q?1765410761302854649?= For judging the inode flag state, the inode lock must be held. Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE") Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 6f8936ec689c..a6180d4d94cb 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4043,14 +4043,16 @@ static int f2fs_ioc_decompress_file(struct file *filp) if (!(filp->f_mode & FMODE_WRITE)) return -EBADF; - if (!f2fs_compressed_file(inode)) - return -EINVAL; - f2fs_balance_fs(sbi, true); file_start_write(filp); inode_lock(inode); + if (!f2fs_compressed_file(inode)) { + ret = -EINVAL; + goto out; + } + if (!f2fs_is_compress_backend_ready(inode)) { ret = -EOPNOTSUPP; goto out; @@ -4118,14 +4120,16 @@ static int f2fs_ioc_compress_file(struct file *filp) if (!(filp->f_mode & FMODE_WRITE)) return -EBADF; - if (!f2fs_compressed_file(inode)) - return -EINVAL; - f2fs_balance_fs(sbi, true); file_start_write(filp); inode_lock(inode); + if (!f2fs_compressed_file(inode)) { + ret = -EINVAL; + goto out; + } + if (!f2fs_is_compress_backend_ready(inode)) { ret = -EOPNOTSUPP; goto out; From patchwork Tue May 9 09:57:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 91487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2752197vqo; Tue, 9 May 2023 02:58:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VJKXg/PST7u1L1gTQE4lPXQ4Sycae1N7gUgo+3hEOCIUCEKksquT59BkXn210a19vNBcJ X-Received: by 2002:a17:90b:4b90:b0:250:78d0:f78c with SMTP id lr16-20020a17090b4b9000b0025078d0f78cmr8389519pjb.9.1683626308543; Tue, 09 May 2023 02:58:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683626308; cv=pass; d=google.com; s=arc-20160816; b=xiKqg5md+QWjh+c3L1zFcllWY7S5t7aQkjPhSaqf6z0+7T4IR1mOGp/k8ZZ/fh8HI9 jhl/HT/79tJay7vTMDzNwqNQniBHMWBR+7zVYYOSYQTWltvxFANU4lEn6OG0TfFr0f4N prpG+rNOfKA7UT+xgJsHBm+mYJ/fKHKjctU/DZ5jgabjed2NN33lup/BdoYB3WdvEZxU 13nP6Yr86Om9/1lYvpOZWeyy/WgelqEp2oHAEM57cyqOJrP9tmWI8SLx9ZbkAHGNrOKr asjkS7q5pLGi957XP6HbFXdm24SqBGnY7oNE0mYJUojtQzOLnaT20B0LEZ3dUIHvB/nT GyIg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sii75NAAI9OpzP6lLy9C36XQIKc2FSlkNLV2KdQ2sOA=; b=P17yR55EnNy5cvS/Y7b4drVg30F+RcGSXj7wnEbWybI0UtnmDh4NOboIvRvdKQ+MHi uOc7Qi0LMgu8GoBCkwS53po4uBMztjVO86xGAOQKgYnhBRa4RRwpkUrqmxXDHjlnaKgQ 8apulD1PJbvrdbeiEPY5sS3SwjnPLGTBkpcnG7xp0MArTeFwpsjC7xEXLz7i2t8Uthy0 fJOvyxsS9jJFr2Q13Y86YL3Ihbok0xf4XtPuHrSCUIkHP8/HGs85yIB9odTqzn+o/qmO wxzg3HyGUT0+HR69ROeRGjst7NPouaDogXYn4xlaczPakVwZ4/vNP4HIRP4+XSyEULSq lwOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=EFypjI2E; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k69-20020a638448000000b00528b78ddc06si1120047pgd.455.2023.05.09.02.58.13; Tue, 09 May 2023 02:58:28 -0700 (PDT) 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=@vivo.com header.s=selector2 header.b=EFypjI2E; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234764AbjEIJ5j (ORCPT + 99 others); Tue, 9 May 2023 05:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232299AbjEIJ51 (ORCPT ); Tue, 9 May 2023 05:57:27 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1402D44 for ; Tue, 9 May 2023 02:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PwQJXStuk+jtuo7JPCkMUO07P0BpLUNU0J83KtTj6M0SBoJRiIgbaKY5YXrCKB3noOITpSnHo9Byyt6alhHaUgBV20nhocokxd5tO3mpge3NdRtvAg6lh8TSthit3+zphwekwuLossJz8z0lRdTC7xM9ewgtK0tEnsoa4NT4SnJrU0R5B9qd0kXSjXX0EgLmElxIevvbJ4JPvPogM0tV8JGfY86wYCeqt9ixaj/AuSsaVy2BnIIrRHErMAnVwdyFGT3fldSOhBznj4AAJV7kJZEawgXidcIrftNKsJruLhAPjlDkChxXS25R0NRluzxTaTPS5RIL7hisBNFmE7YUDw== 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=sii75NAAI9OpzP6lLy9C36XQIKc2FSlkNLV2KdQ2sOA=; b=Gp60yItnHS2wu8717wqtmGa5CW24cFBJglGjahSzkWclBYSTbg61q1asaVK4VR9Q3YcW9irm9cbqqIZTaK4z2vPjzBQTRNTlS0Xw8jstzumKV1V7F7NTF2vjJQVF/XaiDon1xFHtw78GCRAS4BfbzkCDuC1Cm6u0PPAQBa80nAAnysiMvG/IIu2m/0b6HcvUoMbcrhXiFpDxl4bq+sab3DtQhx+wDRsblklbhuqrhLUHSddGH6SWfrwqb3EGSBU2wl7z7GqABrXgd/FPCflz5W88uKGRK3zj+XRMG6wWI5j5S5GAkOJcE6jscaMLGmk5QUKcffgsNy7cFMr6Ak3K5w== 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=sii75NAAI9OpzP6lLy9C36XQIKc2FSlkNLV2KdQ2sOA=; b=EFypjI2EYmlMGbchgY0Tu24UfwDswmGXOMYEVXMzXrsx0zD7Cb40JUXtyEmiPSqK+Z4rUHxNmQ+tKJTxwLQzimoaE7JwwhAslL106cr3tG/Ngaccaw6gi6BSVhToG5SQ7l59k6yieSkg9haRF/l2PfX0GFK0CiqaIp/S7e8d9l7XmvJJbi3Q3gL1qyv4beLcamXsKQShodSRetbAlvIvCMC1UQZlxg+4QX1uz8+Xovl0D/enDB+7A9nrr/noaP+41/EQydNmOHw4cD+A0VuYIbSd5o9b6Gru9ynBnalCSpdmZnGB+FdcvEhcMxMEriYhDtiXzzOe54qLTzarhVTnaw== 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 SEYPR06MB6130.apcprd06.prod.outlook.com (2603:1096:101:db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 09:57:22 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%3]) with mapi id 15.20.6363.033; Tue, 9 May 2023 09:57:22 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH 3/4] f2fs: move the conditional statement to hold the inode lock in f2fs_release_compress_blocks() Date: Tue, 9 May 2023 17:57:05 +0800 Message-Id: <20230509095706.17844-3-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230509095706.17844-1-frank.li@vivo.com> References: <20230509095706.17844-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR04CA0017.apcprd04.prod.outlook.com (2603:1096:4:197::15) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6130:EE_ X-MS-Office365-Filtering-Correlation-Id: 14fc43ed-cf77-44ac-fac8-08db5073c8a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TnQG86mKug7SC7Cu6NbQg9c2p/zrO56T3B7uDBSfAxAjtTWdyp70LycKLsY3Ju34/jP1DY3r3nmfyYS67h6pUGwL9cPP3egI3jDPBjZSHaJjPR314zNnElhwEImoNRRXSDs1hOxSjeK7nrG+eZflPi1QJ8rYqB6HcSWUHgKIUy0FPgHJ2Aju/8EnAJXVXVpNYdvG2AS6pgvVqF6QQVKvYkte5EB+DwJ9iX5lAISHLuee1YWASweFi1FIOk48/zBkWL3XjgUYzlnuIe2pBR4UdkmrCnGU7U8mAVD2/JTckhuLDwZeQeQdXKFF51ZfIkPgxMIeP57nqixGB4VPcvYGW2DF9YJsyrOx+xvnn/ScW34nnbffxaWJzVLL0dvm+WlkdpHVzg0z4c+Ud5rzCutE5sKMRla5WwbVguZjsJF0FXuVjagunsw0Rwh/v/hoXCAztW8T8si4ioI2vmeA63y7If6bmSDa6HqTL0gDUM959/kuebjBCXOH7+OtaNoPCiFp6FtQD8rExsDMGwf7ZcVHHbyVlpV8PPz8hCoPWUe1BzUR69v8SyXpanM5lPLKCKwL5ioAjxW/Nzi2eMClsCTeUCZOlRJTmsDyc3/YiNfNR5Uzj7g9C2G7qe9mrepyO1d/ 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)(396003)(346002)(39860400002)(136003)(376002)(366004)(451199021)(6486002)(83380400001)(316002)(66946007)(66476007)(66556008)(4326008)(478600001)(6666004)(52116002)(2616005)(6506007)(6512007)(1076003)(26005)(107886003)(186003)(2906002)(86362001)(4744005)(36756003)(41300700001)(5660300002)(8676002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f1rGVgq6gkOdQ0zi8zvvUZf7uXzt6gYkMi0SDej75U0tIugx0upy0jHfakeQdXG8Begza5miyxCepDb++OiVr0g4/7J+q2gR5Obpymzcpv+qwUu41hmKZ9jIhF8CVn5D8jVaVgpJe0DQNMWRTgQZQGHxW+sJA7MHQM5JIlbhTOzmGsx1w/G5JzF0pBOJq7x1utjKxbVKeQdG9uAMHZkZVjLLCKFZax54SKDKTVtxhmf/akFgH82wexPzFB+yzrgQ2u/o9lO5wwrnAtn8WmbayDGOPBw5QjVJbty8PYCFrTa0csmlVUFGbOw3MSG6jIjQRE4NaZxGShxNPXUepERVF4I/bpHiG6WZLEF9rwRwSJwizhctv3cHjK9iAC52W5CtOpJumGu7CNkYT4dGwI1Rf94gHvKelg9lHzFd/+w4Ipx51eO02hIqFEiaKSSlecVhSW7BIam8jzJhaWmhc2SK68TikqlFM4toE/+zioQHW6x7gFzNiPm0YxQq4lyQSdM9/HspXrk1Utb22Hz6H3rhq8cR6BTLIj2aNRY7ReLIXzlq9X6C9Tw3DJ6bR1zZtATo/N1Gsr30zaGKqjq3ANDU2MqSCnBjcitEWzyhjd0+Np8DfVE5fLvJlwshTQX48+IKK6TD2aWxwA+UjuPOczdWmu5Zx2pCrbNsFZQyi3eZyagVtTgYf/VCuvhFAoSZZr4fZDvm7SUgQgNRutJxaUTJ3I0NtN6cGmN4ZwohNpNiD8CoJsOsRHNOWStVG5yK3gW+qRMrjPU63Au4pHQJim6SPejpP5DyNI81rzq6H7om4v1F6a/LB57wGtXaoBsqZ0/RK729JQGheHyyeMYZbwsbOl8Du6nMp1pgjvmeF11RO/998uXiKUtJBpfez8YJRCjRz0iMUAMN/op4rPQkbDWRGU3873nBq+2QZWO8zROUr1Zroh9nbCAMiD4n/P5mB4+NbkW3IbynJl40UDC3z2aPxuZImhwdqdD+ou8ASu6vAH9I237YQmEJk1QWvrauRdjf5cOxqkwIMZccU0IVjStAJBHBsypGDjSrsdfmkf7wnoXJmr3qirqHv2Zmd1FAFIoKh11iCICBCnWOoXodU5x+gL2gByfFopyHsN9NAn4pfPGjff47i8mpseJaudGWGNTH9DdlVOd4q5EvNdYOLyiXUxLhsJzpgZ71cdzEqP6/SbXpBoYebqLvJy5QIb+ZvvELkCgjglCWzufHpGZjusWAJls7AFj5EHlVt5zFX1qaakaI4qKnS1mGhb+aTEwL5/mi+2aTNlYOZ5+PM2TOZMMerPTsHysoKlAOmSODlHD9i84CcvlZIOKUT8oxCSJAdFQBGbl3LQ5BXZ+hR6wwEKtt9Y2CNJPMRgfL4XfMHbE19GNHoFwkFoti91/B/IvAN+9mhp0aq75pureb/WZuDCyJlVr2UwO0qkuhKi13ptCPAea2PESEfa5y+V/m/TnNhQgqd9ZMISMX2fF9w324NPjOmjHrx2HGJQloQsiW7XfyV+Fndc9cSdtQ7SgbLQxLPvejdPpi4jlSRl1Oln9gmoFVOMhl7RjA/J+1rFe9uKMnAiD9pUDPakMUlTCub4zIGPCJ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14fc43ed-cf77-44ac-fac8-08db5073c8a6 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 09:57:22.2818 (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: oun4Z8NKXNFUomNrHGbkA4vzV4piuMHbKTNq/mMvDiFN/jqPMCNONR3ZjOJQFo5kw36FsnL1EVftAgXT6lpOeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6130 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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?1765410139898139667?= X-GMAIL-MSGID: =?utf-8?q?1765410139898139667?= For judging the inode flag state, the inode lock must be held. Fixes: ef8d563f184e ("f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS") Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a6180d4d94cb..32dc9a250a36 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3469,9 +3469,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) if (!f2fs_sb_has_compression(sbi)) return -EOPNOTSUPP; - if (!f2fs_compressed_file(inode)) - return -EINVAL; - if (f2fs_readonly(sbi->sb)) return -EROFS; @@ -3483,6 +3480,11 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) inode_lock(inode); + if (!f2fs_compressed_file(inode)) { + ret = -EINVAL; + goto out; + } + writecount = atomic_read(&inode->i_writecount); if ((filp->f_mode & FMODE_WRITE && writecount != 1) || (!(filp->f_mode & FMODE_WRITE) && writecount)) { From patchwork Tue May 9 09:57:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 91492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2757946vqo; Tue, 9 May 2023 03:07:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5is2PEuVmbBBUZWYzczHywafgmnid8DKfZl4UzsOveGnI3khAFIlIMg8i11fadASi3Xe2G X-Received: by 2002:a17:902:ec87:b0:19f:87b5:1873 with SMTP id x7-20020a170902ec8700b0019f87b51873mr17938192plg.62.1683626850983; Tue, 09 May 2023 03:07:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683626850; cv=pass; d=google.com; s=arc-20160816; b=EtmRlWVEtRjrbzVquLCme5T5/AadybZKFBqfNKFOP3IeCElxVVqjb34ZPk+4v1TrDB 309yASP7f+JEu58D5BZoaHLpCWGmMZ+/LWSX/3LkwT7I6vydYWkezHyJ05Sb80JPAtQL rVyQY/JZ1ng1GAwbJF/AbcmdF+rhQfMy5MtPV2QiL9U0AUXBYQ6K1H56uH1hadf6NfLt 8Ww6LRrmvmRlcaPN6EY7abc9BK0WjRY6wyhJRvnCdFLyh5sNcwC8i9RqwIDVLZTgN6rA xiPcj4yEX6hXPRPzDfzZ6+fgVkHxctsRFNhg7ovywpLNlvjGWZlXc3pHQsaymvDn9wI8 wWLA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F/t+i2j+kVdvYLFav+22gZBD0CWgejaaUXH4Ec/omx8=; b=q/YqSMgSyWg2xoX0HvUKN2gex0foBtoqqzNVBiYPBjy/+v7AlABAs/e7Gp3gmRbHY4 zvt2jWqBWQcLhABusjvvexCfy5K8PsDcbs234L2NCSbnkbjz0p+2oJnl7iZFCuNB7XU0 iB3PUwZ1DuJ54Lot+toHsJ+C87W+4RPkjjUVnNcvRDsyicihqFr3Ifxau9JbWWODnaQ1 YoQmwZTw8lZA7HF3++G0YKwlVwTjogtgafk874j3172GnnWjFOFu/uELYmbd66vqcilk nTT8StIY7nEU09GIOGfPrpQ9GIzflHpZw1TG82Q4wbieGOxiZNykVuPTQJ/F/w7zK74g bqiQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=XVH9L1ac; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170903120900b001aadb1147e4si1207858plh.456.2023.05.09.03.07.15; Tue, 09 May 2023 03:07:30 -0700 (PDT) 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=@vivo.com header.s=selector2 header.b=XVH9L1ac; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234721AbjEIJ5m (ORCPT + 99 others); Tue, 9 May 2023 05:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233976AbjEIJ53 (ORCPT ); Tue, 9 May 2023 05:57:29 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3236C46B0 for ; Tue, 9 May 2023 02:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyD2VunX31+4+V4jGo0g0dAJoi+ldvGV9GX4xoKEbbm2oDwO+6cjbBHV16RuG4EWUk142aba+ZBvI/tQ0svKL2ctDPdhI1XIwEBxHx2mAoEd8L+CNoIhnLDE//dDAPp+VSwVCWbktKnmvspsiWLwI63vYBbocU5O3FEp8Fv3honhfKqKTuLq9bgFTvFVhVlhkNDrcW6cw40u/gjoOgRXcLBx4ICjZQYD5Wg2Q7b7NCYWo65IEdnIGE3mehpWyELh1xGnYGeleitSx9dN0RBeUOuUN2+YdleAmrTeQS6IynmrEGZ/uu1PwT1a9DhkU6cfcnvUHwHiHd84450hZUWSBg== 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=F/t+i2j+kVdvYLFav+22gZBD0CWgejaaUXH4Ec/omx8=; b=e9BVXvIh+VoMtzBFghz7Fq16M7GoYJPLV/5HADM7NPx7Jd153FYiuALA4RZ8JjW59r2UeUWV4mHF4jY5ujxfCNp+QF3Cf0cjhdNIogo3G0irGzDf2hP9SRsEmdzjNfcbGt6Ejzegz1o4s9DpZr98tvw6215AsK0pTnWbbrKcBePJqhH+p9Fp6BVQV0C38rQGOlnDZ4NhhC+JuKAuz7VhyCcpNb+61M1DaQDIlP3Y3FbALTPT4mezk+gkXErf8c6QAMd72ZHdUsQk7md4uKIjQZmg41jZLl3K0jdqQkuYcxp7/jLEpj2T9UXqqS3g8rUnvpOgxukCHXNGkb8QidjRRg== 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=F/t+i2j+kVdvYLFav+22gZBD0CWgejaaUXH4Ec/omx8=; b=XVH9L1acvykGXBnIHReVTrpoySYCFh+2zIWX0wIDyajBxcto/5ZQ75yI8ioEXMNz/uHn5nfTHSZ+pWnOgayyC0HpS5IF4VI2t7j49reQzT8d6ZlZZuhqc3nt1iLbRakZAK3r6+MusJMSf3WuDZDXaK8qWIA+BQBMTDa0+Q7xIRmUyQBRWYgmCT28I7q/pwvA/qynSLoDfKGqhzTISZMu8mW7iNvEi+hm+Td36RTNMU607sAXwuD9FJHef3VOHo4Cu4Xud2tPwSGDuP33HrSNgAJHx3XMV4ex8amjMpQ142ym8FZ6Vv5Zq6FtBwJ22FhQkVBtrw1p2eP83XivIo9Gnw== 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 SEYPR06MB6130.apcprd06.prod.outlook.com (2603:1096:101:db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 09:57:24 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%3]) with mapi id 15.20.6363.033; Tue, 9 May 2023 09:57:24 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH 4/4] f2fs: move the conditional statement to hold the inode lock in f2fs_reserve_compress_blocks() Date: Tue, 9 May 2023 17:57:06 +0800 Message-Id: <20230509095706.17844-4-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230509095706.17844-1-frank.li@vivo.com> References: <20230509095706.17844-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR04CA0017.apcprd04.prod.outlook.com (2603:1096:4:197::15) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6130:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e3d83b6-4057-4691-1bdb-08db5073c9b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2vfbsW5fugn5rMFE7QDF14WOQ41z44eWp0cb/k9dAln/kFMaWabadEsBVXvCw70L7KOdyE+mo6zxyMMh3L9QiL7csdlgI3mBISeQcKUcBIvZa4xUEQ16Y4HKv5k7r/ND0Hp+QB9bPrz7L+G5uqGnhj0iXg4EyiO6HN99pTVKlsC/fXiaX7XTHVMmjD8r3IpSgmAgEXlxbJP8D3+IsHdZvREEnO08CmPwNHxvkdssQfafcrYDPv6DDU6rdczPwB+rGuIa331scPw8ogbCEEYlnp339+MIT66N876nSK8eCUJlF0P4sJ0WWJihR5b6dRjFCefkSzlJ7t5d7CZJe7k2AquNKScR3R5ffnkIG+BYFO11RoYk2T9Ngpexlc7/1mF9U4yhhgcGZTfJ6bdd3cp1LvJQ7nWU4SIa1U7N6A51LWt0uE/uPJXu4leO253s0FvLC32r6wSdoGmlt3W6TX0FVrsIkYPSRyuW0P2J2KsAypuq0q3oKfwYmc3uJjIap8LIZv1OfZ92nHZK6NoX7O73C1pHnR/FS+RI2m6v5qFuLJoWsk5kQj+SqzqLT5SpKh8WCOTwcfHvuQ3pePm3WVWo9ULCg+Tk9kgFeGGc4hfFyhE= 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)(396003)(346002)(39860400002)(136003)(376002)(366004)(451199021)(6486002)(83380400001)(316002)(66946007)(66476007)(66556008)(4326008)(478600001)(6666004)(52116002)(2616005)(6506007)(6512007)(1076003)(26005)(107886003)(186003)(2906002)(86362001)(4744005)(36756003)(41300700001)(5660300002)(8676002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: schJyaQIXg92eYU+aMpoJFw1MvFb6UwOcE+6CJhthvlRnN9TsS2DK91V9iXVEzyI7ZNIyS1cFG+2+CJUSfPbeoKkH74HttScjpoeVbHWwWBKsMAioNQ8yLwhP7Gde+3ukBSr7RdatbMG9+SL/bPDhEdesNAyqD0r/xYrM6pvRUA1hokHJ4t4GqyCqFykcZY37GGWOKbMrd9mBW2QMaDJaZSG+hXwgQNvwmESdPHqikR3eZHO12/TBTAPaFLAHi4QTJO1A/irKOGtdPJcp48Q1XKPeVN9UdyjH+COPprs+G8K01z4qcdreoMjfOzoW15fp4FFrgwacSt6Hb2UOmWcRBvXSfiF7j91v6mUXa9r/3rnoNXVSevDMAEmgvys5XtGnx5zpsbMjcgvA2x78LXf/s3uIf3lnJvRozxdnxH2ohWeOy8hxSn2j1PPVxac0UY311B1OETTZu5euXdGwC2bP7JsmCqmi6/1xrsQkXPvywWz5dcy3HpKQCYx9uAPVopfvlY/gxWCqXxv+B2zQY6AiAheJYOP1idlIwOu0GklDDXr4qFdo0++liYj15Oe7eAxlFMARpzDYNK+atlTabhfhtuI2BP+iMU8hCl2YT2mGTE0BYnKlYKEtm9gwSxFaDN6vLSJTvCkm0wm//El9UJE1aD7qDFIYQwGEDW5MS747kc+HrCG1eEBj4vl49HotWDDehWECpNr3qqgImbfW9EVgOZ1R13cAURG/AOcGzYxvDfM0MPon6+RknewNV5qOqvEEaInWO2iyyg6yoBw/D/eGqfOc55Xab89tF6ErJbRFE0/UUAsK7nmIJOahI34Xrp9D8K77h57WCXPP9TBeZQLO55zZFQrt8Co0173sU441/BUBpUGLdUSQaPTMI88nIuxfu4ucJTxmaAVhFErgI93J4PBmQIEqR+gNDqWH5s0u0MAqLLDpHQRJ4TPWWtfXbi35ebL3ygLzAqKgpg58mQ4jZzPCdOFQ7vGAaZy+vAfDx0gGJ2wFCCd7d7P5nuJ/LPCmu7Sa1c8uuKHffd4b6KroxQgHjeJSciDibkSSDhe8RVVPeRwjQbHk4/nSlbl20TSSUVlbCIddlClaEF5ako/AMG/OZqo/xoUc00yOvqrHewCXZ4Z0KzK1kBr+BNbsyENX6kYlD7XKUf3VmcJu5Oa4aINUO73NE8v14uXTuspmUvn48KLGar5lxZ8YZruHr6hyLvS6TvrTJzPc+JStE05cwNsKyXWoCPGtFQBuwq5UmhBy+pY/HqcjFwihm8M6MTEBqrTdsvLc2JHjaGOZLmco14ildkrG4hpmEXkEjXLrf4ph6BNEOSlmYFBvZQWdROTUdVB2KJ5pVFHMDClOkUZ5DxtzHxt2OfNhxOCHLCkS4FUIGqhEDQfY37Fi+gPSNdKULYgPWYj9jTRyHteVgFXQNwnApxpyCRR0XUhZL4qHltkVAvSDQja9xe5SBFWXqjfqbwGthDVTkbblZ79Z/pAdKqvl5t69EOmIisuV1qkY/zQ1nFa1CZyHOBJt43oVPeigcAJOMswSrNH+0PICPLJrPHTX3JlR+q2LfETv5y5Uz/tqnsD8pdpnsmvNn5M1tuJ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e3d83b6-4057-4691-1bdb-08db5073c9b9 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 09:57:24.0822 (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: +o/nLCsPX7LU6eUOVYbJGZpf5InMkKqmFFJ8Y8EN1ga4MBUVd7yWt2CBoCb1AFhmB/c5DUQ2N9emSJooMFW9qQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6130 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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?1765410708889137266?= X-GMAIL-MSGID: =?utf-8?q?1765410708889137266?= For judging the inode flag state, the inode lock must be held. Fixes: c75488fb4d82 ("f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS") Signed-off-by: Yangtao Li --- fs/f2fs/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 32dc9a250a36..0959cc3e6394 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3641,9 +3641,6 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) if (!f2fs_sb_has_compression(sbi)) return -EOPNOTSUPP; - if (!f2fs_compressed_file(inode)) - return -EINVAL; - if (f2fs_readonly(sbi->sb)) return -EROFS; @@ -3658,6 +3655,11 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) inode_lock(inode); + if (!f2fs_compressed_file(inode)) { + ret = -EINVAL; + goto unlock_inode; + } + if (!is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) { ret = -EINVAL; goto unlock_inode;