From patchwork Sat Apr 2 03:28:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 12798912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5219DC433F5 for ; Sat, 2 Apr 2022 03:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237944AbiDBDby (ORCPT ); Fri, 1 Apr 2022 23:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbiDBDbw (ORCPT ); Fri, 1 Apr 2022 23:31:52 -0400 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D297CBE6A; Fri, 1 Apr 2022 20:29:58 -0700 (PDT) Received: from pps.filterd (m0209327.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2323Hr7X026715; Sat, 2 Apr 2022 03:29:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=S1; bh=dabxZW577wjPEGEoff5pZu2w+a1quSirUwiMnGVHFWI=; b=SXZf0UnbeNtaW/FdtVk0hrDbdUFL1uOn1Db6u0zP+uQdy6On8UB6IU52yly9+2VbK1mc 9FtH50x4f4GESqM07RxSy/rSQCVAuklZ95Tb8nIM8xOsMXIFsgm7Q2b/MQaPXtqR0e7G pAh5l8mDfwy03sC1HPCDPTRDNVIzxVegqCtxjIRgq7XLpKZrVLkhpn6YeV4F0HI+vfr9 Ntm+BzG1Dn4XFNmoXi/3uKGRyzDAths7KydY9KBxPey4/+PC23NgQX74Geva7CrqgPHZ qpSwIfAmXh88Wgmcs4tIxNG1QgI/0yyIAUcHbAEkYzYerWVAyvLBmpIY5XeMp622Awpz LQ== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2046.outbound.protection.outlook.com [104.47.26.46]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3f6dbyr13h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 02 Apr 2022 03:29:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ex8ZBSvHLwV+Ik1f+Ce4vmuZ9OAz2vKe8kvKnnDoLRLd0OpO3t4eeIlTjquOvRmhipt11lgrd1lA4BnszqWV5fUHR4Cy8PK2SN+7pPjbOcnrZyJCcZJC/uxTj/t6v3tzETb1sx6TWAsuyEVQLGxJacB6fr2gDwa2EshQzsB3njQpeau1DLUNiN1cjl/kir8OetLCAy+/6aVbad2rFwPVYPJ4Ou/kNBjN+8U5BAn7JaL3NWrxH3omC3esJ/PMCmx7ZtiEQnst3N21llKySdi1yC2wRXi0SA70oNdBx2Vc1V4/viASp6kH8LEqt+hdthsxr7CL24NfzDIP9IoI9n8ugA== 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=dabxZW577wjPEGEoff5pZu2w+a1quSirUwiMnGVHFWI=; b=PbcNfhmKTtMYFvCQkbZ3dAg7/P8wpTtVPaHM+WroZ4ryf2hNNH7KX21rGH+2h/Xzsic8FOn6XN5Y26LRXg8MAcandUpDRD/uJ/SZ+9mv+ehVgOkZ04nccG5pIs/TxmgI+xfwTcRMe4ciclQcZoIXUG5MGLjhoYVmG5nk/w/D8H8Y1Cf4AR+91JFrQnGVpzkl+LnMElzgzd1Broz++Dc5T7siwD4MDRFuCJwgIR8la6caSKOAL8Q7WIIUv5/XYqbF3VQgo6I0Yd5eI8sPLd/+eDYyIQffOoHM3Fu8ABHUpQax/yfhFAUlqbX5ZxHWQK4EhKpcOY+i+xQXievnaLkXyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from HK2PR04MB3891.apcprd04.prod.outlook.com (2603:1096:202:35::13) by TYZPR04MB4173.apcprd04.prod.outlook.com (2603:1096:400:2e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.30; Sat, 2 Apr 2022 03:28:00 +0000 Received: from HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094]) by HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094%4]) with mapi id 15.20.5123.030; Sat, 2 Apr 2022 03:28:00 +0000 From: "Yuezhang.Mo@sony.com" To: Namjae Jeon , "sj1557.seo@samsung.com" CC: "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" , "axboe@kernel.dk" , Christoph Hellwig Subject: [PATCH v2 1/2] block: add sync_blockdev_range() Thread-Topic: [PATCH v2 1/2] block: add sync_blockdev_range() Thread-Index: AdhGQJxpg7LpERZLRKCnO5+IYADlBA== Date: Sat, 2 Apr 2022 03:28:00 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 89f95836-633d-4d11-51eb-08da1458ca17 x-ms-traffictypediagnostic: TYZPR04MB4173:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oCoOEj9P3IUFftIExB9zzpDBnyVyQ7xsxIY4Ozqv4WorXZbdFqcggrEpvZqhXzcZ/precdx2Sp49aqowcnU9DmLg5s48cejqP7q8aeFT0p84eh0InIC90zzOZgqpyeGz0dpXT6DC/4z/l/6nnXivoUBUnOKF60dsyBn8wzQwTfxDVfe7+IoRASZ6Cs6djHvSsdVJB+XfswyY7/B7xQkuzo5ZKjwAc6QZ3Cuxh8WNa66yxle+S/oiH1AzP8+ddtgDWoWij9mqGHjGDnjEKPgwtbR5npGtRRiPGSSaJpmgv7f8+pVdG1YdZA45BMaR2PlN46JUyNC+vM/9fDg1Ntf+2SDjjDZijaxvyaoWzN1o0zOveyULAARxrTMVYl1A+XdjvJ+3iz+JldNnWfr4Amq8bhqqFg8Yq0DsIk3rOjVujTHc6fxp8fu0VhgKRJt3PaDDk0YJvTK/NihortHEZcbWzO7FI5yh6Mwy9R8EYfCfYgkY6pAmxXDHvgV4+m8Amzqmmw0z0qa6s9+g75DZkkhm2q6YsV6wDDVz/ksZN0Ij9wXTZVXr+7tGJ03StXpXtYI3GE4EyTugKPGUD20G+fVdgXfmocSv9kNoBQfzxbE+GaeE2uBgYYzDshaiFB7EIW/CnsRJs6Wfd4VuecU0lZnkH6Iay9EE/LUSkqNVisWdikJEUY+EmuzMs7WkUP00h+qTGEsvfCwsbF7P92fa2u7IDw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HK2PR04MB3891.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(64756008)(8676002)(66446008)(66946007)(66556008)(76116006)(66476007)(4326008)(316002)(2906002)(508600001)(54906003)(110136005)(38100700002)(122000001)(99936003)(33656002)(86362001)(38070700005)(82960400001)(26005)(6506007)(7696005)(9686003)(186003)(71200400001)(8936002)(52536014)(55016003)(5660300002)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?ZQUI5WR0Sc95HMSD0oVuYr7mdA+6?= =?utf-8?q?sQnn50decrZCi6Y/C7gM6iZzxT87MpYZEkenRvpwIg3U8OSQg40ztqJvvnA0Ghe81?= =?utf-8?q?nOOMBbmqAmaGTb2nJowbOD4ragXANeJDcCRpoOG3GHZiuW+TcjhUwmjbLeMx+1Fg9?= =?utf-8?q?51JDnD/SHXvhbgO4JYMlwZOwFBRpsJFQ28jdgWPKQtcmURE9XFRj4OpvR0KkFHl5H?= =?utf-8?q?ftvNcdR6x8b8b4LNnubLTvyXoRLZz190PtzyK8X+oFWAZ4InenVM53rNtVp/upFiP?= =?utf-8?q?K4RTyC1onpLBxNZi3ZoL3Ub+IM7or8gL1RCKrsVNNagmThH6curGpFj9CQmy4fEJB?= =?utf-8?q?SkPRU3OW0DRFYqf7QasU5IYnMkcmTeBhjOxnno5boEq8TDXSBmsnUcsuXmyk+A9nn?= =?utf-8?q?FLRTQoF3asXsZz7ldFYtP4MHBAMWY2+c8ta4uLig7ldraVNU7oIafqj11XuW9aJ2W?= =?utf-8?q?DcghnsZ6jdnev/INt5OUUsqrxkHewwSva6dzU3je2G3+f0fUwoO+Y+Y7kSjcji9R3?= =?utf-8?q?jApPCsp703paB3dGJCigUr3483eWxAIsofU3M/+ch0jhRFhqqskl4n/IAJBIWDX2j?= =?utf-8?q?w4FgV18/ZUmANi8uIoT2eYlapepvMSiAX4MVN09oBJktlk8QQqDgMOV3IPlQKyahW?= =?utf-8?q?9GW46nFsbF59ptHm5kDQiBAJaQVjrCqoyhnbcvy9m9xDlpJnHEKYnIZZ1bPug80/A?= =?utf-8?q?8Enr1xdBpKjiLG5cYBdnmY1jnmaR4ypc5UrI1cQ8vSs3+luxQ4XtoqFLH/LK+Qybe?= =?utf-8?q?b4Vu71eFUYbBHdHbl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w=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: HK2PR04MB3891.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89f95836-633d-4d11-51eb-08da1458ca17 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Apr 2022 03:28:00.5143 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: AKA4VO7ztwdj5a2d43emB9ajkW/xp3RsF3sTAARFkwprzHhqO6lrjJkSQF2cY4/8mHWj5Ie1eJqL1NLZLHQWdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB4173 X-Proofpoint-GUID: iOj3eWM3NREe_IZx6ofuYMokxPob8TAy X-Proofpoint-ORIG-GUID: iOj3eWM3NREe_IZx6ofuYMokxPob8TAy X-Sony-Outbound-GUID: iOj3eWM3NREe_IZx6ofuYMokxPob8TAy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-02_01,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204020018 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org sync_blockdev_range() is to support syncing multiple sectors with as few block device requests as possible, it is helpful to make the block device to give full play to its performance. Signed-off-by: Yuezhang Mo Suggested-by: Christoph Hellwig Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru cc: Jens Axboe --- block/bdev.c | 10 ++++++++++ include/linux/blkdev.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index 102837a37051..57043e4f3322 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -200,6 +200,16 @@ int sync_blockdev(struct block_device *bdev) } EXPORT_SYMBOL(sync_blockdev); +int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend) +{ + if (!bdev) + return 0; + + return filemap_write_and_wait_range(bdev->bd_inode->i_mapping, + lstart, lend); +} +EXPORT_SYMBOL(sync_blockdev_range); + /* * Write out and wait upon all dirty data associated with this * device. Filesystem data as well as the underlying block diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 16b47035e4b0..1e85d0688d9c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1310,6 +1310,7 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart, #ifdef CONFIG_BLOCK void invalidate_bdev(struct block_device *bdev); int sync_blockdev(struct block_device *bdev); +int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend); int sync_blockdev_nowait(struct block_device *bdev); void sync_bdevs(bool wait); #else @@ -1320,6 +1321,11 @@ static inline int sync_blockdev(struct block_device *bdev) { return 0; } +static inline int sync_blockdev_range(struct block_device *bdev, loff_t lstart, + loff_t lend) +{ + return 0; +} static inline int sync_blockdev_nowait(struct block_device *bdev) { return 0;