Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp367654pxx; Wed, 28 Oct 2020 06:52:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4kEWptL+KYzasl6bkKTuCGM9jn9oMJEDYg4UzxGV5GqP/sxmUuC4qU87pIMJJyv5t5/7p X-Received: by 2002:a50:e08e:: with SMTP id f14mr7640352edl.374.1603893130658; Wed, 28 Oct 2020 06:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603893130; cv=none; d=google.com; s=arc-20160816; b=sISpixHrighrRUXrhSVFxIAYlU7dqdmuooQGc+8vQRparcMpa21382L/jZlcztCibI EUMygGZppJQoFPUhBQLEPLaYgC2noR2QymXBHCjlcNgxq5vsQHO26I2/YIdi4d4tsl0A DUiStbFkpCW8LeHkWYb79jdtjTyLCtHOst+QK8I7F5yzsi0AmfA7yiX6g104W3PzIXak K0u5RJJHcC3voR6DOF3znM33odJ/dW2PViNZJEYSUgHaLGzmu2uAlRbxQtRky+qFg5L4 2GN8BOChTx8pMWCPnuzyvbhF6UNETd6Um6uokrHKC0BzkE/Ei7AGbzwXjElwpldK6pGJ /lzA== 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=guAzERwxTF46Qhf2FyqX9q0JE10Y88+DQs9R5r2O1hA=; b=oFwCxp2Otp20ysCxVYUTsgN7VX3X0n8wtZcc3z2eqLOrL1P61gdSVFfnALKKETzkOz rHYgQquaVW6yyE90Wdv8fT99dykbcVQuRULcSRQ0O4h0qXXWLZ2POhPuG6D23cF5NAjv +CxEk2goZdTbaiRdzVAF2/e/Cnrn0fuDftP1zkePTccH73Fn6h1cNkv/YDxkO3fP46mz y9vJNOv7vvjc6IAxjZghjgZR6SmtQAvD0rWCbBmfnIXgHh6cUA/ELhDzSadPMoJFf7+O XVtQ+Ff09IOijG40jgWvkA8NTKg8RrWKNomOpA21ngkCdxxfw3p/tT+PawVNnWawafsr 5Pzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Otdr5KrN; 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 o10si2705925ejr.482.2020.10.28.06.51.46; Wed, 28 Oct 2020 06:52:10 -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=Otdr5KrN; 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 S1803262AbgJ0Pw3 (ORCPT + 99 others); Tue, 27 Oct 2020 11:52:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:46412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1799142AbgJ0P34 (ORCPT ); Tue, 27 Oct 2020 11:29:56 -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 6B7F422202; Tue, 27 Oct 2020 15:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812596; bh=uP0mFmsBuucW/wXdwa2/U/lYha58qUUdDJG37uDy85E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Otdr5KrNf+trahKh68KDE7PZ5ZpBzs+p/JLoceBM+ChUBe8wYj0x1COaRFYD5L4Uz MbggdRXsnCuCl/4XNh/REVHBUGtUJlvjsqdp68BLfOs7SIYGy8y52b+tJcGbnWZIvr rR3egII4MG3zbd+VIzg6R/pUZeEJxU3BxPmMWAPQ= 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.9 264/757] xfs: force the log after remapping a synchronous-writes file Date: Tue, 27 Oct 2020 14:48:34 +0100 Message-Id: <20201027135502.958259080@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@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 a29f78a663ca5..3d1b951247440 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1008,6 +1008,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, @@ -1065,7 +1080,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_iunlock2_io_mmap(src, dest); -- 2.25.1