Received: by 10.192.165.148 with SMTP id m20csp526067imm; Wed, 25 Apr 2018 03:40:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PmbyL/xFPE03A/kbqtWvaT2xqmQtFqhc05YVNVRcTvwhAaoWcO06JV011mQIyB6Hr96YF X-Received: by 2002:a17:902:189:: with SMTP id b9-v6mr27069785plb.204.1524652857724; Wed, 25 Apr 2018 03:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524652857; cv=none; d=google.com; s=arc-20160816; b=pbYYq09T7y0yuiI4TzB7g/P+1nnQDo0PwjNNDzWP2rhDsKl8gvq7pOuINhlS9je1Zr lu8gSn5KDYt71yD4xOCJvnwx/3GyIRF5cXYTE1F/2AydrUC8J6nObnj+ZbjaTD/oPfPI e2vuOTSm3qcchzVP6ODOiBM+YgqJT75C4DPLR9eMU2TDFgi3mkseNz0q7phBhjxw/Blc FIzfCAAiFBVof7vC2iJ+U+JGiT3XobajBN/siq0slEUc8jMWg4/hp/0mKGkrSvsJeQHF 0blVVy9QxVREMCQp7gD4ZWOL+9YMDDyasJE7E8ZRX9Hq2q6aR8wj0ZCqcza4dYzsU5Tv iRNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=jmJ3/whBXSJggkDbcSAtt66CNE1dx4bqLqbsTrk9OkQ=; b=UVyGB7op35xdObPqoPCAr3FhSjd7Arf2tfLVlhrwFwdS1gMdSXjqlu8e1iOWpywddu w4AtRKr0RDASn9fVCFB+dOAsrRRBk+uDLujhsuZ7KAa2BKs88X8QzZfiz3mS+bIgFcGe cCoCaCVqJbJiWkakt2LFYLExQLrA9MqKGW8iOiJ84tczDagLkhjMm+HniFXoEfThdwBM qCV5wV5yvagTZFMCu4K694vHcuA+3k53Bwt3LgaFjdu+lJC5yovFwxbqzuVLbf14BOye dWCFEeVI2ymDYFsMJXnBMrpdgROBcU2P1mrFmGZ1IF2fj5NkE6vXHh44daQAVUohpXsG vxEA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si9199213pfe.79.2018.04.25.03.40.43; Wed, 25 Apr 2018 03:40:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753641AbeDYKjj (ORCPT + 99 others); Wed, 25 Apr 2018 06:39:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51892 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753626AbeDYKje (ORCPT ); Wed, 25 Apr 2018 06:39:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 572BB36; Wed, 25 Apr 2018 10:39:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Bo , David Sterba , Sasha Levin Subject: [PATCH 4.14 063/183] Btrfs: set plug for fsync Date: Wed, 25 Apr 2018 12:34:43 +0200 Message-Id: <20180425103245.059479448@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2018,10 +2018,19 @@ int btrfs_release_file(struct inode *ino static int start_ordered_ops(struct inode *inode, loff_t start, loff_t end) { int ret; + struct blk_plug plug; + /* + * 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 = btrfs_fdatawrite_range(inode, start, end); atomic_dec(&BTRFS_I(inode)->sync_writers); + blk_finish_plug(&plug); return ret; }