From patchwork Tue Jun 5 16:16:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10448585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 830CB60375 for ; Tue, 5 Jun 2018 16:16:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 724CC297B3 for ; Tue, 5 Jun 2018 16:16:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66F70298BD; Tue, 5 Jun 2018 16:16:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BB4F297B3 for ; Tue, 5 Jun 2018 16:16:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751819AbeFEQQb (ORCPT ); Tue, 5 Jun 2018 12:16:31 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51434 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774AbeFEQQa (ORCPT ); Tue, 5 Jun 2018 12:16:30 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w55GGAOl083100; Tue, 5 Jun 2018 16:16:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=nlW6rKMDAFCWUF0Ai5Qa/8b+juVYITqZPSmndmrzmTY=; b=Q3IrFiMVpKDFV7T80GIquEBVzEbiURrAUlkuus7RD8c0XlopjJWdbu2dh1JHokFchJfV /DU2PjGKGJIGxl9dOGTvagIqb5IFjJciW9EKg0FNggKBAp8RjMSX56Poh7hFno2ldVHP F5m6uLyua/nizNH18rFUPCiPXejhu9oyEYADJUSeifYwv0VNckczsQmmKd6akDsm6Ysg 9HG6blW6GUnBmy7ojYtUNyEe8DroO2Q5DE0hvIm25NowuR3mxNg7wvtCG3+ACaS2wf0y 4onI8FqclT6MupHss8TsNoyPL9CR9kCFa2KXGLTlQgqHXLdTQkLZxDqKLs/Bh3lKsWHw GQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2jbvyph09x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Jun 2018 16:16:10 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w55GG8I5003755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Jun 2018 16:16:08 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w55GG67f024195; Tue, 5 Jun 2018 16:16:06 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jun 2018 09:16:06 -0700 Date: Tue, 5 Jun 2018 09:16:05 -0700 From: "Darrick J. Wong" To: linux-xfs@vger.kernel.org Cc: Omar Sandoval , linux-fsdevel@vger.kernel.org, Jan Kara , Christoph Hellwig , Aleksei Besogonov Subject: [PATCH] iomap: fsync swap files before iterating mappings Message-ID: <20180605161605.GG9437@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8915 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=878 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806050187 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Swap files require that all the file mapping metadata be stable on disk. It is insufficient to flush dirty pages in the page cache because that won't necessarily result in filesystems pushing all their metadata out to disk. Therefore, call fsync from iomap_swapfile_activate. Signed-off-by: Darrick J. Wong --- fs/iomap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/iomap.c b/fs/iomap.c index 206539d369a8..48622bbbd751 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1387,7 +1387,11 @@ int iomap_swapfile_activate(struct swap_info_struct *sis, loff_t len = ALIGN_DOWN(i_size_read(inode), PAGE_SIZE); loff_t ret; - ret = filemap_write_and_wait(inode->i_mapping); + /* + * Persist all file mapping metadata so that we won't have any + * IOMAP_F_DIRTY iomaps. + */ + ret = vfs_fsync(swap_file, 0); if (ret) return ret;