Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3457800yba; Mon, 8 Apr 2019 20:15:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBUgf154TCLzp0nivkdZzuqBuCqHQTsJnxoH+IxEzu5y9v2DLJjKIpNw92cclooJu0oF+G X-Received: by 2002:a17:902:778a:: with SMTP id o10mr22641572pll.135.1554779751747; Mon, 08 Apr 2019 20:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554779751; cv=none; d=google.com; s=arc-20160816; b=G1es5y1UaPIl4ndYkXG4Hdrr/nde3Wa5VJZCUa4m7+Q+kKc7rLapfVC/Xy5+IePjUv 2MkeZp7WfKPhGzzj6DZDF+PZ8BvHmhM2fSEMPH97wJVgog/O6iC0DtMQY6Cu91ZvGm9i oFGcfY1ou4VM29XbbH0m8YY2ADhIqC4QxrDWypXffcZgL+QYWcYJGpwm1BatnuhiIcKe Z0Dm7UWGVpkI7kO19se+HoGQG7g4BiiaUz6p0Ga96s7sTKDil2oFPpRrPYJYFFpn7R2m MWAojgVpUAiZ6JMtJNQ6WTTs1M5MV0wgLkyQrm1W8lDGgUujXGNcc0mynjfXJid2LcUT /F7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=LQxPJ/Lv8GalXQTm9AUus77o0+B6pHq4ALEA8WfynnE=; b=hL7PcUXkW2TR7SogmDNDlSWDLBeqWldBZbuDM4weFPMoybI/sXhV7KdqjaNzImomoO JfrCmScHzieO69W8nuNfLwD0dtLPXp3h+02lqnYpBJemZH5TJwwj5E6FElZ6WhzLIID0 +JlzpXwWo3Y7UTyVdxRB7tzRQXD1GKbFxKJV8fkWcm1BKxqDswTJ0WZ9AfqpWtF1CI7j pcnadUligRyl/ehP+hB8/bg/s41CrcH/B5to8DVmmF7qa1rXTeXO1J9MqeMbv3csOGyq rL/ru9HS1dEcreNHsW3INKh88O2BT/UDYTFdbN4L5qeo3pFBcvp9cTida80lyphlnIjb 9+bg== ARC-Authentication-Results: i=1; mx.google.com; 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 b23si21510894pls.430.2019.04.08.20.15.36; Mon, 08 Apr 2019 20:15:51 -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; 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 S1726646AbfDIC5j (ORCPT + 99 others); Mon, 8 Apr 2019 22:57:39 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:34756 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725953AbfDIC5j (ORCPT ); Mon, 8 Apr 2019 22:57:39 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2A410D22E15C10132E19; Tue, 9 Apr 2019 10:57:37 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Tue, 9 Apr 2019 10:57:32 +0800 From: Hou Tao To: CC: , , , Subject: [PATCH] fat: issue flush after the writeback of FAT Date: Tue, 9 Apr 2019 11:01:58 +0800 Message-ID: <20190409030158.136316-1-houtao1@huawei.com> X-Mailer: git-send-email 2.16.2.dirty MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Hou Tao --- 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.16.2.dirty