Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7075992ybi; Thu, 13 Jun 2019 09:09:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXRFgylGEBI0q6xquU34Z1tf1mFg18rbuDBSF69Vl2V9iHCHY+xrhzfcgeFrv2RUy0HdSA X-Received: by 2002:a63:295:: with SMTP id 143mr30339815pgc.279.1560442186861; Thu, 13 Jun 2019 09:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560442186; cv=none; d=google.com; s=arc-20160816; b=nb/5SpdgiDbbPG3kGsWu0uT7bv5qT0wbAdw07kBtbHe6qZBfX7daBhzWZ51Rpuerwg 3szj6CwA64Fn2Y4787PAG8XNOmATLbCbsU+G2y9l7WJ0UZGrQj1/o8ptmSO+zZAhu1w9 alj2eFuKzC1QjS08XZwMvBnLeorQZRJPBwsD+xNCsym5EPa+AL9IbTbnoW/2br3aCHj1 c3csH4OtLREdUaoAGOjKfwS36mj/V2ZGOqOmJQlmGWMCbWN/yMrkh6X9yBX7EscXdqL/ ZeAm3mGEYKSLi0nc/H+8ADnGQlBj12xN6sHA0oEA41bHxOxcRvc97KNnGmWujtEj4zDw YhDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/5ES4DM16D1ifzqUtusIIXm8403g7I8krjlcbDvLGsg=; b=CpToobQsjj49cUPm2we4mL7kABCgfgC8KFbEaF1A9b57fYHWBkl7YDRs0mxVIbm56+ TurXtJ+75DfUNL5t7wuBHbvimnJ+cdadB/Q5iIfZF4sNbssK+Kj2qQe7aN+KiEnIoUoS /fWFYqQJangQXf8qk9+RPcDiXuvM71suv/MnDFHgJjL3dtjL6rah7QeZpcjK2kCc7sVn vo0rplHNfWMS0U6WPkh2D4YI+0tQEKaF5tFRNQlu+rGbkhGB0o0O04Jjb71Ok1HBawjQ SaX9pG7WUtDUxkmZFRMfB1wcmppdUEgN90ClyuaoDuiETDm1mcQ71mIGLGquZHhbYBbv meOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Aezvutnf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b40si14577pla.49.2019.06.13.09.09.32; Thu, 13 Jun 2019 09:09:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Aezvutnf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731780AbfFMQJW (ORCPT + 99 others); Thu, 13 Jun 2019 12:09:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:33400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731263AbfFMIoa (ORCPT ); Thu, 13 Jun 2019 04:44:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 49A022147A; Thu, 13 Jun 2019 08:44:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415469; bh=2j2nNFeEvJfR8A94FGAbKg5WvFeo9GKd8Z1U+EKYuGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AezvutnfAkaziZ01lt+JtO0kPU/JZM1XlMeJn0844ArjMyRNiGO7TgIQdBTfHjF/k /FmVIaQt2bs2ibM4u6X7HdYiNTC+K7/o0AXuHkcAlbATR+S36h3MlweD2Z3ICclVSv qc7CfDsjrV1QA4snRFGu7Ww/0nOK7u19a0hjsNOQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Tao , OGAWA Hirofumi , Al Viro , Jan Kara , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.1 005/155] fs/fat/file.c: issue flush after the writeback of FAT Date: Thu, 13 Jun 2019 10:31:57 +0200 Message-Id: <20190613075653.020809893@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075652.691765927@linuxfoundation.org> References: <20190613075652.691765927@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit bd8309de0d60838eef6fb575b0c4c7e95841cf73 ] fsync() needs to make sure the data & meta-data of file are persistent after the return of fsync(), even when a power-failure occurs later. In the case of fat-fs, the FAT belongs to the meta-data of file, so we need to issue a flush after the writeback of FAT instead before. Also bail out early when any stage of fsync fails. Link: http://lkml.kernel.org/r/20190409030158.136316-1-houtao1@huawei.com Signed-off-by: Hou Tao Acked-by: OGAWA Hirofumi Cc: Al Viro Cc: Jan Kara Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/fat/file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/fat/file.c b/fs/fat/file.c index b3bed32946b1..0e3ed79fcc3f 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -193,12 +193,17 @@ static int fat_file_release(struct inode *inode, struct file *filp) int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) { struct inode *inode = filp->f_mapping->host; - int res, err; + int err; + + err = __generic_file_fsync(filp, start, end, datasync); + if (err) + return err; - res = generic_file_fsync(filp, start, end, datasync); err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping); + if (err) + return err; - return res ? res : err; + return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); } -- 2.20.1