From: Darrick J. Wong Date: Sun, 1 Mar 2020 17:33:38 +0000 (-0500) Subject: libfrog: always fsync when flushing a device X-Git-Tag: v5.5.0-rc1~28 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7c8e6ac778c99620d7b67c4067cba26c72c81549;p=users%2Fhch%2Fxfsprogs.git libfrog: always fsync when flushing a device Always call fsync() when we're flushing a device, even if it is a block device. It's probably redundant to call fsync /and/ BLKFLSBUF, but the latter has odd behavior so we want to make sure the standard flush methods have a chance to run first. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/libfrog/linux.c b/libfrog/linux.c index 60bc1dc49..40a839d18 100644 --- a/libfrog/linux.c +++ b/libfrog/linux.c @@ -155,14 +155,18 @@ platform_flush_device( if (major(device) == RAMDISK_MAJOR) return 0; + ret = fsync(fd); + if (ret) + return ret; + ret = fstat(fd, &st); if (ret) return ret; - if (S_ISREG(st.st_mode)) - return fsync(fd); + if (S_ISBLK(st.st_mode)) + return ioctl(fd, BLKFLSBUF, 0); - return ioctl(fd, BLKFLSBUF, 0); + return 0; } void