From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DB08C4363A for ; Tue, 27 Oct 2020 17:17:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AE40204FD for ; Tue, 27 Oct 2020 17:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603819052; bh=bspOKSrUGSo8AnXtBdhJask40ndEeZ/DSxXRch7Q8r4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xolVYOBQyNitvLJR+alYmfvwAdKR86rFhcOFRa8rAqzATZClR7p3SUI+jv4Q6tcyU Na+0B2iGA2dPUm9HLM0yio+qFdHHRx0WMt/DhFTrK2gODPHP/s5NXsgiLlgj0x56HI Cc/W9XbQR4X+KFHf5u6eq4s62eUiWI7JR31EinFM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818104AbgJ0RRa (ORCPT ); Tue, 27 Oct 2020 13:17:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1783062AbgJ0O5t (ORCPT ); Tue, 27 Oct 2020 10:57:49 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BCD06204FD; Tue, 27 Oct 2020 14:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810669; bh=bspOKSrUGSo8AnXtBdhJask40ndEeZ/DSxXRch7Q8r4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxA99vXgF/dA6Pk3uQLoYYkFn53HjO8/e/HzLGKaNE1V40V5F5GERF5hz3pHtsED3 9v2KbwbEqWo19q7deA8fEnnqlHFNi76z5h/lfe5qQtLTNZUSp+ZQIFAGcTsaEIlFkX kvXPXn6/b08Bu1OGtdDfeZ13Fmd/yqKftWR+3HzA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Brian Foster , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.8 222/633] xfs: force the log after remapping a synchronous-writes file Date: Tue, 27 Oct 2020 14:49:25 +0100 Message-Id: <20201027135533.094198077@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Darrick J. Wong [ Upstream commit 5ffce3cc22a0e89813ed0c7162a68b639aef9ab6 ] Commit 5833112df7e9 tried to make it so that a remap operation would force the log out to disk if the filesystem is mounted with mandatory synchronous writes. Unfortunately, that commit failed to handle the case where the inode or the file descriptor require mandatory synchronous writes. Refactor the check into into a helper that will look for all three conditions, and now we can treat reflink just like any other synchronous write. Fixes: 5833112df7e9 ("xfs: reflink should force the log out if mounted with wsync") Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/xfs/xfs_file.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4d7385426149c..3ebc73ccc1337 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1005,6 +1005,21 @@ xfs_file_fadvise( return ret; } +/* Does this file, inode, or mount want synchronous writes? */ +static inline bool xfs_file_sync_writes(struct file *filp) +{ + struct xfs_inode *ip = XFS_I(file_inode(filp)); + + if (ip->i_mount->m_flags & XFS_MOUNT_WSYNC) + return true; + if (filp->f_flags & (__O_SYNC | O_DSYNC)) + return true; + if (IS_SYNC(file_inode(filp))) + return true; + + return false; +} + STATIC loff_t xfs_file_remap_range( struct file *file_in, @@ -1062,7 +1077,7 @@ xfs_file_remap_range( if (ret) goto out_unlock; - if (mp->m_flags & XFS_MOUNT_WSYNC) + if (xfs_file_sync_writes(file_in) || xfs_file_sync_writes(file_out)) xfs_log_force_inode(dest); out_unlock: xfs_reflink_remap_unlock(file_in, file_out); -- 2.25.1