From patchwork Tue Jun 20 09:55:39 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: 110410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3564132vqr; Tue, 20 Jun 2023 03:31:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LCv7DcphESwrMyjlyjKmnClFu5zLUiRlBNPRcM3URqq6v3NbOYOHpBnow8niNHKKlf1sB X-Received: by 2002:a17:903:1112:b0:1a6:74f6:fa92 with SMTP id n18-20020a170903111200b001a674f6fa92mr11760105plh.19.1687257110924; Tue, 20 Jun 2023 03:31:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687257110; cv=pass; d=google.com; s=arc-20160816; b=RgYPXG15uNIpanXl9scA5Mt24QVU/lzK9rFgZ+6JPxt0oo224DEXj7jsNsjUddz1+P tACtLmH4dKVgPTEq8u+QQbmyAhFPz9vXiL9rutX6wVvG4k/rxL4wj8LRNtrcFByjL1Zz HFaVuUnNcFcLSVGbq2bV5CpUljAIGowaCOSQVz1CeKe0sbSIcTPAO1uA+o678OLaeTBY K6L0csAq+NGXiCofG3hMdW43N05QBh3abicyLl0b/mQpvAxNxw2C9vDIm95Pv32JuNHh ljl+L5atuC0vom8W+MvfYO0a+1ZoibUvJcdcjN7JB/LlkOx1qSbxV6u8HCdu1niSNvFB 4R0Q== 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=hKg+8M7pawnqQaYZJKPH6cP1gXnNb0G9L1GTB/NIvWY=; b=uD6aQym5X/OuFPfrDPgVDYMF2XzgXUJaXEaBQgWPPpCZ8mSLpZQEciF3S1BX5XM7c/ VvDpTgCzS/hPqQJLTWqFefCUQ8sHsGTO81XqAfpvdT6641CZtQTi7gcSjAk4YaVAOOCx cKEVkyvcQ0s+qtewftCmZxQDPlmRnUA/aN4Hf7bWXaidfXUYRvb26r6tBnsOHjg0iT6a mUIq9I2e7lQOgejBAzt2KVj6Ovpe4vk8WV2f8BPOSYVwa/ERy197MXbqpO8jDqJUsmAj Q1Frr/Saa2gY5gGUqI18O99w47lFfZ10aSoCsY2RXkTUlBS4kr+NchjwU2Hl/BW2dpTf 7sOQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=gxZHQrVj; 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 j4-20020a170903028400b001ab21df5958si1579897plr.515.2023.06.20.03.31.35; Tue, 20 Jun 2023 03:31:50 -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=gxZHQrVj; 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 S232306AbjFTJ7q (ORCPT + 99 others); Tue, 20 Jun 2023 05:59:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231346AbjFTJ7E (ORCPT ); Tue, 20 Jun 2023 05:59:04 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2106.outbound.protection.outlook.com [40.107.255.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E672D72 for ; Tue, 20 Jun 2023 02:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IF07+5hZI1v6S0JtX3VtqA47jwkOtaQAvUH9dMwNcdWvHtHS6P+8RSIZtvDzkcHR172hqklJjqd265CjPRb1bV4XOiuAu7BIGsX41sGQGNLJ4z86ckrQ5q/P1POiGAi0dhjFO9Y5BxhyYRgJBrCFrQ6k7D+XB/YmPuRGOnXPKyarCRPzYwbQvZwKdNNiJMiCf0XX2CO359logNYvtmRc1E8YM+7KUQmz8xcNEdj2Ml+ZN6auwi7iBW8tQzg7tE2YSLgTeIBfP58WLLlmhGGS7vNRBtH7TH2649RYONtAu9iIOVIDxZWthOA7s6varrypDTeszmU0oXTe3sDE+75p3Q== 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=hKg+8M7pawnqQaYZJKPH6cP1gXnNb0G9L1GTB/NIvWY=; b=ahrpl9yFHzxvB/3t63uFZJVIe7MF3xJlxUVBuGYWvidnRkFd4xTbpH3swfSqy65EJA+zJFBTuqaiLFalicxcqQz02fcEdIsYCsCfLnL4zX5BfNmfeRlAN5vxV/K3HlPsYeYFLT/tJGEnrpbK4qUz3lE9BmIpevNpZzneC7fxwWU/9+SgFwX9T2B2udx+pg8boOF0DnT0YzmiC1GU2ZGCqrX/IZPRDmbZ2rUs6DdQlCwR/RrpFG6NRRjCU1T7yDGN5EwJxbCuRYPBmBm7w/VLBVSaLuCphRyeTgcDtF9n5SFQRMWHawrMosSnSav0nmGcPn48oYqOTMo19W/oOwD4RA== 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=hKg+8M7pawnqQaYZJKPH6cP1gXnNb0G9L1GTB/NIvWY=; b=gxZHQrVjmM+GTk5xjGykJSfxMRiUfjcdSqAOVgUIsEWhTqE7pFuDbQDbUv4X75SMcc01c2NgF1VtGdwmkc3gIT5xwl6GRdoLYHdM8MRJACvvbw5ye5Abe9xCaPa5tFBNsgvyxZJfaOz/B/zq/MeczvmSSA2bIUslj1pJNzQMffZF/kml7IlZZ3GL/ezrMmmMAJscZep/Ej0IUPX6UtOM6ZhijgjzHhOhoBsuG1xeaZrh2B5Px+crSjrQoWM9RJSDtcQ0IPUJJoju9Hol0HP9FaIf16YIseA0PcpfPJQV8e4UebdMJkovHOFL9CIZI5FdrIW1Rngq1hb1UVzdtkJQ0A== 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 SEYPR06MB6249.apcprd06.prod.outlook.com (2603:1096:101:de::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Tue, 20 Jun 2023 09:55:52 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%4]) with mapi id 15.20.6500.036; Tue, 20 Jun 2023 09:55:52 +0000 From: Yangtao Li To: Jaegeuk Kim , Chao Yu Cc: Yangtao Li , Qi Han , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2] f2fs: compress: don't force buffered io when in COMPR_MODE_USER mode Date: Tue, 20 Jun 2023 17:55:39 +0800 Message-Id: <20230620095540.64109-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: SGXP274CA0014.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::26) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEYPR06MB6249:EE_ X-MS-Office365-Filtering-Correlation-Id: dabb48b6-75a1-41a5-cf5a-08db71748831 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tbgb6JHUwkNruxoJwxC52Xzx+AcDsdRWAW9G1qm/aGKNR7vIIfApdJe0HxIh9If7dqYeRFcKkDFZjIxfanLtmYPQEXk8fu9VJUo7BXvWxCrHrCdcL/veACK84KclTy752/AfvnhxJshLwcNrh1lF+Uv5ze10cmVf0TqkgWv2oqNwI7NkMKl5jMA1JEyQsedwSazzA5eiyphtlwRPtlVDV+lKontYsebK5d6NVSBz5tFiFfciu9+QbjIdPwMujXmU77/rqE/2L9W/AcoewgVLxE91dgcjCjMTDMrFqqab3Ljr0xWeUQK3LIVCgGofw6VFL0P4elqwxh7QJmHt1Rkqgmr3SpcRLflYuz7zqp2gMIwqWn8ytA7s4z+9/vytvKOPQhMuw997r2+H0Q4jrJZrLVZVqHVijQ9+Gdl9EUCxVHo47/5YluVgBmS/nebovul270+n3UBrkx116EF6L/ewnly2F6nWr2J6OTiMhHNTNF4BV05hxFLwBnXfid5mHa877hqPn4mwWmhDImZOQJgkOOKxSEa77Gwl4VP7u9frAKpyEpVwfGV7MQ/arx2MuWYluufh7rpHPRgrf58hOrYxQVUyKwXjUh0NSAS+XpEUZQmpgng7vOBBzXYsZYI8+hmZ 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)(39860400002)(136003)(376002)(366004)(346002)(451199021)(83380400001)(6486002)(54906003)(6666004)(38100700002)(316002)(38350700002)(52116002)(66476007)(8676002)(8936002)(2616005)(36756003)(6506007)(1076003)(86362001)(26005)(4326008)(6512007)(186003)(40140700001)(41300700001)(5660300002)(66946007)(110136005)(66556008)(478600001)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 31gKd5CCxz2aEixEaP/h7PP/HC7cQNOR9wDg1BbTBytARdWjgEHjqFkJgvP5MZmHGhQkDwDYla0Az84GYbvCo7wJmd7IBqf/xG1shaNiuv51Rxmc+Qh+31y4GkXq6IskLX0vWolzY7Zgbvar7aZjNKS5eT7z503n0z+ujtRK4if+P9vrE0vshPUcRHK9lyJmkLsb1evnNHWFuHkDEypY/GAnZy1tQ1Zd5Tv9gAXjaM/OYuyQxjkvHAFqsu/ATqH+vwu2YuL0KvienlSRdeptz6ohiR9EEKNbMoPAqprPVuFxHmjZNKRtBRjtxbfwZZNensL7RV1yX8DEzBHnoLJe2Nwr/xfUap43PdnSCET5bw7LOVdrzMsUul1KptWcdFPvOqmmDgXef6SGL5F4jfPfpxhjKoHmLbdBbjnLiIqoqjjEnXW/4RU+09U8yf7/KBsIuHcHQl837v3Appg8VTvCCOy2W37bFkWZG0EO/h9FUCPqA8KrWUngxlHgQcCVEyuTCuAp/vBGEdMiPmKDw5PCpcu2zTIdoKxz7Gwz4yItmbkXoZjZ2LAkkgRoGysOt7i2bqLz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db71748831 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2023 09:55:51.9832 (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: BDuTPtBeH1UZLBCzfOCv3DAK0+rP/ZQwh1lRXj5jfxojLL2zx6Iu6C+PVUpdwmzewUGlIDannqpabx8meP5fgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6249 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?1769217311929863664?= X-GMAIL-MSGID: =?utf-8?q?1769217311929863664?= It is observed that when in user compression mode (compress_extension=*), even though the file is not compressed, the file is still forced to use buffer io, which makes the AndroBench sequential read and write drop significantly. In fact, when the file is not compressed, we don't need to force it to buffer io. | w/o patch | w/ patch | seq read (MB/s) | 1320.068 | 3696.154 | seq write (MB/s) | 617.996 | 2978.478 | Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Qi Han Signed-off-by: Yangtao Li --- fs/f2fs/f2fs.h | 14 ++++++++++++++ fs/f2fs/file.c | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3f5b161dd743..9e960f1a1117 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3170,6 +3170,20 @@ static inline int f2fs_compressed_file(struct inode *inode) is_inode_flag_set(inode, FI_COMPRESSED_FILE); } +static inline bool f2fs_is_compressed_file(struct inode *inode) +{ + int compress_mode = F2FS_OPTION(F2FS_I_SB(inode)).compress_mode; + + if (compress_mode == COMPR_MODE_FS) + return f2fs_compressed_file(inode); + else if (atomic_read(&F2FS_I(inode)->i_compr_blocks) || + is_inode_flag_set(inode, FI_COMPRESS_RELEASED) || + is_inode_flag_set(inode, FI_ENABLE_COMPRESS)) + return true; + + return false; +} + static inline bool f2fs_need_compress_data(struct inode *inode) { int compress_mode = F2FS_OPTION(F2FS_I_SB(inode)).compress_mode; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index f45d05c13ae5..75c9c3327bbd 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -822,7 +822,7 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw) return true; if (fsverity_active(inode)) return true; - if (f2fs_compressed_file(inode)) + if (f2fs_is_compressed_file(inode)) return true; /* disallow direct IO if any of devices has unaligned blksize */ @@ -4146,6 +4146,9 @@ static int f2fs_ioc_compress_file(struct file *filp) goto out; } + /* avoid race case between aio and ioc_compress_file */ + inode_dio_wait(inode); + ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX); if (ret) goto out;