aboutsummaryrefslogtreecommitdiffstats
path: root/libfrog
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-03-01 12:33:38 -0500
committerEric Sandeen <sandeen@sandeen.net>2020-03-01 12:33:38 -0500
commit7c8e6ac778c99620d7b67c4067cba26c72c81549 (patch)
tree831f733a0258ce0221b92d9b2284843234b1a27f /libfrog
parent14fb361365078a9950dcb919a652c3f5b60b4fff (diff)
downloadxfsprogs-dev-7c8e6ac778c99620d7b67c4067cba26c72c81549.tar.gz
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 <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>
Diffstat (limited to 'libfrog')
-rw-r--r--libfrog/linux.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libfrog/linux.c b/libfrog/linux.c
index 60bc1dc498..40a839d18e 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