Received: by 10.213.65.68 with SMTP id h4csp2189660imn; Sun, 8 Apr 2018 22:04:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+iJEInxtBHyMv6m7zPbTljX3XorSE0xJKlsyGa7q8SQZrBTFlu5PjGZuNKiPHkjJKlXe/Y X-Received: by 10.98.102.131 with SMTP id s3mr27705654pfj.89.1523250287024; Sun, 08 Apr 2018 22:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523250286; cv=none; d=google.com; s=arc-20160816; b=Y1mdRczeAbHPfuLxEtH2bH1CSor8Zbq1bKBoPOXUPCN7EPg9jRmezM+20B3Xk69btE TRHVw3MDwOZfiOImrQpGrqRFVA1vzthXuNDMSqaAZpvWEGuAtJXPUfCWDVCV6mNiD71A 39zBirmT1++u5rqJUkQYlsvv9gd23jgQKEBcKe/vBwT8u1gcHz+I2F6W+rV7sKNmy5f1 PialyhSeerdgGvJcn82W2SCygUEBZu1vUknDxPdPhxGYlM4o7w4e1H2XJzVkGsUcjHc9 5+qr7RoUbZxkh4Si1arpB7m6fBokpy8+R8DM2QBTO7WV4uVvGFVKU37fjYI3lWNKNmIn Zpxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=pTS+Dgog2xH/j+k6vxdzD43SwoMsgD5coCllED9B994=; b=XhzeUJK+MpFdo2c6r5soXK6C4id8rLrE8SZ3Y8Kbv/0JPnTWGvql7HUOVScenqcuf5 rjVSGZqyTscJvZrk9JaZx8B7Kc0j592ry/43gx95tOzNcN7yhCRFsKhrLGmCWJatPT8L AtyygMroYIkhmMPdMD/RJBK/kmLMsvevZFPHREnk+tGlxwnOA4Qz3Mw9E8xidpdRrgjf 4fjHFRj3DMuEp0PbrtDDF56nS4BzkF+cUWWKOc9h2RayCfUOzmgEM6IXvlfmqEzHl9k2 RtOn05eKPxi7PErH4aYbVJu9agW8V5Wa52fykmXhwANsDYXRJ03HtmNDge+ZbaOW9HBy ABnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GkipOyKY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c23-v6si13179568plo.80.2018.04.08.22.04.10; Sun, 08 Apr 2018 22:04:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GkipOyKY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753636AbeDIASf (ORCPT + 99 others); Sun, 8 Apr 2018 20:18:35 -0400 Received: from mail-co1nam03on0109.outbound.protection.outlook.com ([104.47.40.109]:37278 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753596AbeDIASa (ORCPT ); Sun, 8 Apr 2018 20:18:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pTS+Dgog2xH/j+k6vxdzD43SwoMsgD5coCllED9B994=; b=GkipOyKYofg3oc5NGwKtb788yJeMTcV8FWkcBs7FqzYkZA+XZz31lJMrLc46KvU0C58ORiP537cGShdVSj/Gyf5ymHIt9L0gsFL5NIIB3SE+5EftJ19c3+U2TaIOMxQaPGLW6ao3AMCOWWujp70ZIem5rDwHQa9q1ZtJuTaRUvs= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1046.namprd21.prod.outlook.com (52.132.128.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:18:27 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:18:27 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Liu Bo , David Sterba , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 061/189] Btrfs: set plug for fsync Thread-Topic: [PATCH AUTOSEL for 4.15 061/189] Btrfs: set plug for fsync Thread-Index: AQHTz5gnMKh/GHPDBECrqyLEm1tWEw== Date: Mon, 9 Apr 2018 00:17:33 +0000 Message-ID: <20180409001637.162453-61-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1046;7:JdGUYevYeiSBueNtQHa/cZALvfmxkkwxc7pOj3ot0LWtb3+Y3q9MGV/rASAXUVOGpI5+cYD8+TvGK74D/RHEwBHtWswXw4TWkcgStGBG/t9QTFzSQbOx/bBMpQF0+zELm16FrBMFUdPoDoT4Ya6aaCax7u/NiB5d4en5NUp0+mhQc9bxGkPhWbKc7Yp8oYXOCC+4O88gtdnTHwDxruwyndgE9ZLotoGgkReA9Ykj4pSq36beOi7lLmfqVVAYDriz;20:qngk+11WnU5/NETjWbzTDUYAMeprG3u2FstaacbVcxIPaTP18NJ+B3l8Gpcd6Fixk8NIUVq97d1IafaRKy8IDPzAnpy8Byoq8JmEUZtxdSTJkzLJcDewfR86Xz3oZWeu6GnUajpIFi2olKaiDk6Sl1BeJG/hM2c+eUVNMgUTaec= X-MS-Office365-Filtering-Correlation-Id: d610d605-0d99-4b89-d960-08d59daf6aaf x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1046; x-ms-traffictypediagnostic: DM5PR2101MB1046: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1046;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1046; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(376002)(396003)(366004)(39860400002)(199004)(189003)(36756003)(186003)(11346002)(446003)(476003)(2616005)(7736002)(5660300001)(26005)(10290500003)(478600001)(106356001)(6666003)(68736007)(10090500001)(54906003)(3846002)(59450400001)(22452003)(6116002)(86612001)(110136005)(99286004)(86362001)(72206003)(305945005)(76176011)(102836004)(6506007)(486006)(316002)(3280700002)(3660700001)(81166006)(81156014)(8676002)(2906002)(14454004)(2900100001)(97736004)(6486002)(8936002)(1076002)(6512007)(6436002)(105586002)(25786009)(4326008)(2501003)(5250100002)(53936002)(66066001)(107886003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1046;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: eTyYfB7w934pXXJn+ne0eN8pQcEpZK8REkLoJPm9vdSnDwYqYRwtKWMdY/qcKZzSeB5xEgbjdC4/VS01d4cAg2EU/FddIofY5ZHAU7zSQuXtlNLR2u+x/CFgyP2O1bg9UllZjInntIoQhQ2kVeYCL8+qcG2fDk/qIVruSYcplG+y+Ttsm50+HBgGYsCRHV0UPQLe/94oUkmOCAT01oa8JyVWMPjUve9OAORTb035rIgdSNqtP1l/+3H36Sq0JFkwjxlpvzp2JsOgC71KzdATAxAsiAD2eq3lC0gpvAaZ+l+O4dOCcLZzQ2RJVwysvwwS+QWiRhrdsNu4SQlVdfesk6H4/k8RJpVZZ9oX4G7gYju6OsMSPrL5OEvugKxS37pOAgMcEv+tYDhW2MHX1XTu9eOHxjji8SNZTTYkgblNsv8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d610d605-0d99-4b89-d960-08d59daf6aaf X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:33.5872 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1046 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liu Bo [ Upstream commit 343e4fc1c60971b0734de26dbbd475d433950982 ] Setting plug can merge adjacent IOs before dispatching IOs to the disk driver. Without plug, it'd not be a problem for single disk usecases, but for multiple disks using raid profile, a large IO can be split to several IOs of stripe length, and plug can be helpful to bring them together for each disk so that we can save several disk access. Moreover, fsync issues synchronous writes, so plug can really take effect. Signed-off-by: Liu Bo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index eb1bac7c8553..4368033593be 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2019,10 +2019,19 @@ int btrfs_release_file(struct inode *inode, struct = file *filp) static int start_ordered_ops(struct inode *inode, loff_t start, loff_t end= ) { int ret; + struct blk_plug plug; =20 + /* + * This is only called in fsync, which would do synchronous writes, so + * a plug can merge adjacent IOs as much as possible. Esp. in case of + * multiple disks using raid profile, a large IO can be split to + * several segments of stripe length (currently 64K). + */ + blk_start_plug(&plug); atomic_inc(&BTRFS_I(inode)->sync_writers); ret =3D btrfs_fdatawrite_range(inode, start, end); atomic_dec(&BTRFS_I(inode)->sync_writers); + blk_finish_plug(&plug); =20 return ret; } --=20 2.15.1