From patchwork Sat Oct 24 19:28:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 7481711 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 904D4BEEA4 for ; Sun, 25 Oct 2015 04:15:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 885602072F for ; Sun, 25 Oct 2015 04:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8BF5520720 for ; Sun, 25 Oct 2015 04:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750771AbbJYEOt (ORCPT ); Sun, 25 Oct 2015 00:14:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:59573 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750728AbbJYEOs (ORCPT ); Sun, 25 Oct 2015 00:14:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3ED67ACAB; Sun, 25 Oct 2015 04:14:22 +0000 (UTC) Received: by quack.suse.cz (Postfix, from userid 1000) id 2D1E282832; Sat, 24 Oct 2015 21:28:22 +0200 (CEST) From: Jan Kara To: linux-fsdevel@vger.kernel.org Cc: Andrew Morton , Andres Freund , Al Viro , Jan Kara Subject: [PATCH] fs: Make sync_file_range(2) use WB_SYNC_NONE writeback Date: Sat, 24 Oct 2015 21:28:17 +0200 Message-Id: <1445714897-26342-1-git-send-email-jack@suse.com> X-Mailer: git-send-email 2.1.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sync_file_range(2) is documented to issue writeback only for pages that are not currently being written. After all the system call has been created for userspace to be able to issue background writeout and so waiting for in-flight IO is undesirable there. However commit ee53a891f474 (mm: do_sync_mapping_range integrity fix) switched do_sync_mapping_range() and thus sync_file_range() to issue writeback in WB_SYNC_ALL mode since do_sync_mapping_range() was used by other code relying on WB_SYNC_ALL semantics. These days do_sync_mapping_range() went away and we can switch sync_file_range(2) back to issuing WB_SYNC_NONE writeback. That should help PostgreSQL avoid large latency spikes when flushing data in the background. Reported-by: Andres Freund Signed-off-by: Jan Kara Tested-By: Andres Freund --- fs/sync.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/sync.c b/fs/sync.c index fbc98ee62044..ef60e812d771 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -343,7 +343,8 @@ SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes, } if (flags & SYNC_FILE_RANGE_WRITE) { - ret = filemap_fdatawrite_range(mapping, offset, endbyte); + ret = __filemap_fdatawrite_range(mapping, offset, endbyte, + WB_SYNC_NONE); if (ret < 0) goto out_put; }