Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp497190pxx; Wed, 28 Oct 2020 09:39:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTmJ22VlG1J2UDYKrUPuqwrnx+rtxYzqAEIZnUIVTcgQJRiE2hzOD5y2lvMHsNyo2rbfEA X-Received: by 2002:a05:6402:1ad9:: with SMTP id ba25mr8871760edb.120.1603903158661; Wed, 28 Oct 2020 09:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603903158; cv=none; d=google.com; s=arc-20160816; b=R4BlD6EjDbeeJiIUkbH0UT2KkODLkH9QmvtL4a5Wxb1Fsk2LSOJMP7gAzhMg3Gxv5n Eb3tG8sq+xnFmEyU1dlYAiI8RmlM+w/bt+C8UbAwKQ+NvMgPa7Fe6z/yXL8aIOe8DoRg mRo0EjPWTjNar2MXfE34bjrTcKGI1qymv8f1KwQ/Ii05zUFj9nKhTYnMRdkdzzcw+Uk3 vx280USQUaDGNd/KuiiI2kzU1JEEIs3p7aWTGsAb5hXbUwGyujKE/y41CntIu1Pq/6Q7 7Mh0iC4B6Hqr5anmsLJSMg87ZUbK3G1YInErZGEBst2vGUXgLvrMXLUF9fvs0Y3lC4sK UZkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WswtmeDgck7rJvwqvbs5zbZ1qHeesLEk0v6YE32WFho=; b=q+FTYLhiSEFiJAiqHrzfqXi9LSJLsYBFRp3/p+kfdbAke5yL/favKpBz7mltBUwJ23 zkPIVaaO/8B8uAdMYOHFkZ6oqfxi2gS+us8T8NkiVyJNfTIbiS1MbiE1jbqMn464jNZy dY4T2xNYFcje2/WvSFbqArwSUV/B5qGG97hrQjbDQhw9K7b8H1e/SyhzQwITUWtnPoDk wLRzF3Am9ziSb4WNdVWvoXThKI68mwU2XZjfGANp6w+NRSET2bXrlKyC8mt/Pxaoluqh Pdo//9ldLClXewasS2+1QkS1rQP/q1Ggaz0nW9WQX/YYLXhNaDStfucwMAKgTP0ktEbK dU0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CxA99vXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si2268edr.541.2020.10.28.09.38.56; Wed, 28 Oct 2020 09:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CxA99vXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818096AbgJ0RR1 (ORCPT + 99 others); Tue, 27 Oct 2020 13:17:27 -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