Received: by 10.213.65.68 with SMTP id h4csp2128046imn; Sun, 8 Apr 2018 20:25:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/q5AS81MgtxiFU18nF6ykYen10nSnTCR3BJ/NJi7IYnM+/+YAFqVARbaX/S2YqHe6WJ4Ww X-Received: by 10.101.102.3 with SMTP id w3mr23262900pgv.200.1523244345990; Sun, 08 Apr 2018 20:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523244345; cv=none; d=google.com; s=arc-20160816; b=NVUHhaYAE3/XsYxAOno4F1GT2LMWpEe9BL5W5ZsAauNPd/5S7rdH57q5WN+Vq0ISua F5lEXf3wJrdTfaoVeDeOBs4hpWUywzmcrjogigwXFnwitDmR1RCv6QCY/M3/0HVnR1OP eU07GLtqQbUrJCFWLANZXhmUN6OPiwNCW/FcZ5h3o+BCfWKho02O/GpLzFNYFeHsJQ7O KvUZ4O+70EkM6de9ThRJy0gfsCxgK8Lft+UjQe4TuxRUhs8jJ/Cys4FwVrFptVT0yGKA 6KLP8eRI4nFTCy6EnPMMzSVXXI8d8Jx/S724JOVJqEoVlZ3kQGFy4hN1HtAfyZ0fHC37 pqrw== 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=m6hsOats1sMSyrWQZSDQqEoMNjQDkn1RFO9nUycKQDU=; b=y42/+Ol8LMUOtwTuwlSeq2ZZ+qmscQ5eEbQr0dE/0sJLrE6inJmlyKln7xsmu/rPac gfu1QDcjFfQs5yZslEqh9oF6xdPsChdPbfDqwoWfxPd4dGGDF6eWm+Xx5z3I78GKXck0 gaOudQCxQscTHymUDEvyY+IdA+B1MmYNcH/ucYEjXzNrWK34u083R8W1HJkxkuOhPafG DzW85Svpfiep88XMy4UXW1qnvW/VyT1nkrZJjskJITn7qQWRMxkxGLHxvJQkDvp8fPkB kFN1KgwcIvDgoYbHXuIid5VYl7TFCj0hearnGTvssiOd1/lqzspIPaWDgJJ5UhXte098 fCtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=DOJmiYRx; 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 d11si4690393pgf.219.2018.04.08.20.25.08; Sun, 08 Apr 2018 20:25:45 -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=DOJmiYRx; 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 S1752948AbeDIDT3 (ORCPT + 99 others); Sun, 8 Apr 2018 23:19:29 -0400 Received: from mail-sn1nam01on0134.outbound.protection.outlook.com ([104.47.32.134]:37792 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754814AbeDIAXE (ORCPT ); Sun, 8 Apr 2018 20:23:04 -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=m6hsOats1sMSyrWQZSDQqEoMNjQDkn1RFO9nUycKQDU=; b=DOJmiYRx13uQu2TOXZtIZU7FLDof/g0vUS0KuHuNasxUaxpPpWQ/sixrKLIyD3Bf/ZNwles8Y9ImYKLGaqLQoRcT4UtaOZpor+DUOcYQE59fFyTfHaTyyQoZvJ2pIjXqZ+3G1p33w3xJ6pr+BHjoL10wOJqf0+Hr5uhBq68oyW8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1014.namprd21.prod.outlook.com (52.132.133.36) 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:22:58 +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:22:58 +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.14 051/161] Btrfs: set plug for fsync Thread-Topic: [PATCH AUTOSEL for 4.14 051/161] Btrfs: set plug for fsync Thread-Index: AQHTz5iP4dzzTaEonkG84+kCCMIHlQ== Date: Mon, 9 Apr 2018 00:20:27 +0000 Message-ID: <20180409001936.162706-51-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB1014;7:yyejgH5+BPjo4CvfXq+5gBzZfNaXWh9ZVeGBY0qkE8snzhgroZoZa84r3rj2WnmmHx0LY6F3XZXS543Bnukhl6LNuCjdB7wj+mRBbLAJ1hB4Pa4T1GcS09r4dAlME/O7LX8i6hEIpdmulkWEomGwqr8KQ4F696nbAVBG/Cph2CjE37rjcY7hT8XQLslsfU37f0mQp1PGZepd4zjtaZFE93qsd78r0Ap52PtRdrkICkHbNlDqVcvanQaNhrXupJFa;20:oV5JLs6sWE7j559xVHs9lxG66/aTWiu3hEjMIF9ApGH0bzcXsGzwdxKnMa8SfMfYuOZm3o+SCG7VGe1AOY3A04QosqrhVXJ228lDUxFW9Jnkn5uZa26eVRNNUA5b8kLMvw/reSV+JUSAi9AdfSiotpjRl4yMvnz/rPpRGC3phUs= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 2a7eeead-d1b5-4950-677f-08d59db00bdc x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1014; x-ms-traffictypediagnostic: DM5PR2101MB1014: 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)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1014;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1014; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(39860400002)(39380400002)(396003)(376002)(189003)(199004)(81166006)(81156014)(478600001)(6436002)(72206003)(575784001)(8936002)(10290500003)(106356001)(99286004)(86362001)(2616005)(7736002)(2501003)(6666003)(446003)(476003)(8676002)(11346002)(105586002)(305945005)(5250100002)(6512007)(53936002)(68736007)(107886003)(66066001)(86612001)(2906002)(14454004)(186003)(22452003)(25786009)(4326008)(2900100001)(486006)(36756003)(6486002)(3660700001)(59450400001)(54906003)(26005)(3280700002)(110136005)(1076002)(10090500001)(76176011)(6506007)(97736004)(316002)(3846002)(6116002)(102836004)(5660300001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1014;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: f4MmOPChXZdec4lJL34N6qlP5akFyk0AJw1iosG82pnxaW9D/JR+uExN5VnfkiQmYZt3m+aBD3BubnyFZ0PXMh7c7pspSdVqAhGSIpzIp3UIKZfjk9Nu1qzrz4nU7I/CJ9Nphr5dBdqdXNq+nOSSSYZgT8haRbF2I10DIeNhzE16HtbKUMQoGmqeOQiT3pnC9dVcnyHrogIz7Zzzlnp1ggfVbJIWRonXX9Xa5YX9Raq/kz3IOj47zEUTZ88uzVQ5K07M7pJZEA8VhDvFDQ9Z5bpC7jUMlb9cHOHpfnDDFIW5QnM1/r2DXSuK8CnHOxRHOkNqBv8tbTYtua/yCkAtz0FHw9eHnmYk3JSfA8xLHb1im91KyTNJP4Onkp0JnGtLNO000o/uNb0C9RJJSTXZcAwnJlz+WKCZn2I8j+q8IWc= 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: 2a7eeead-d1b5-4950-677f-08d59db00bdc X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:27.9100 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1014 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 d564a7049d7f..5690feded0de 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2018,10 +2018,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