From patchwork Tue Jun 5 16:33:04 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: 10448597 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 EB67760234 for ; Tue, 5 Jun 2018 16:33:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D990829828 for ; Tue, 5 Jun 2018 16:33:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE41F2991D; Tue, 5 Jun 2018 16:33:30 +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 858FC29828 for ; Tue, 5 Jun 2018 16:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751928AbeFEQd2 (ORCPT ); Tue, 5 Jun 2018 12:33:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38616 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751748AbeFEQd1 (ORCPT ); Tue, 5 Jun 2018 12:33:27 -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 w55GVnDj094689; Tue, 5 Jun 2018 16:33:08 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=HzTbzdsQVnpQYv1GXnvmXzA5wWPZ3sk0dV+OdPgJwEE=; b=In88o3q7ejJiwnM1mDY5VwqKI4dDuvnOcP2eE27BXlYm9wScPw3GVXa0bJ2isG4WZvK5 aqCD+U5rkh4VFpnPKKjby4neMmdk7gFoM3ev0h/BXWRN/u9q04zs3EKwaiEoiSpOX8Q8 u8hMravFJks42AT2drDgOFXRhZSKkxSDA7PtWyLEt9Sk7d9Bo8u9le4b7t43HeD5nAtb rCVg2MaxTPw/T1QWD8dHydIgJfyaiuaczgTvOLhsxDxtQdILjlJc1ZcThNX5AXh/22Qn QUog6NChWqvDa6YyX8OZAY85AwrOsVnFKOhSCEwf7rDUO8ynL4WP/VMo2tu2dGN0rUtf EQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2jbvyph2kc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Jun 2018 16:33:08 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w55GX6Yi006866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Jun 2018 16:33:07 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w55GX5ri002494; Tue, 5 Jun 2018 16:33:06 GMT Received: from localhost (/10.159.157.7) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jun 2018 09:33:05 -0700 Date: Tue, 5 Jun 2018 09:33:04 -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 v2] iomap: fsync swap files before iterating mappings Message-ID: <20180605163304.GH9437@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=914 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806050190 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 Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara --- v2: fdatasync semantics, per hch feedback --- fs/iomap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/iomap.c b/fs/iomap.c index 206539d369a8..2bd04f0451f2 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, 1); if (ret) return ret;