]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libfrog: always fsync when flushing a device
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 1 Mar 2020 17:33:38 +0000 (12:33 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Sun, 1 Mar 2020 17:33:38 +0000 (12:33 -0500)
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 <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libfrog/linux.c

index 60bc1dc4987cb9f4e1e38fb8fb8454662e8e23f5..40a839d18e4f30a898e88248658fd3dbf1e45828 100644 (file)
@@ -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