]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: return flush failures
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)
Modify platform_flush_device so that we can return error status when
device flushes fail.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libfrog/linux.c
libfrog/platform.h

index 41a168b47e77ac307d1bd94509635a5c5cedd292..60bc1dc4987cb9f4e1e38fb8fb8454662e8e23f5 100644 (file)
@@ -140,20 +140,29 @@ platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fata
        return error;
 }
 
-void
-platform_flush_device(int fd, dev_t device)
+/*
+ * Flush dirty pagecache and disk write cache to stable media.  Returns 0 for
+ * success or -1 (with errno set) for failure.
+ */
+int
+platform_flush_device(
+       int             fd,
+       dev_t           device)
 {
        struct stat     st;
+       int             ret;
+
        if (major(device) == RAMDISK_MAJOR)
-               return;
+               return 0;
 
-       if (fstat(fd, &st) < 0)
-               return;
+       ret = fstat(fd, &st);
+       if (ret)
+               return ret;
 
        if (S_ISREG(st.st_mode))
-               fsync(fd);
-       else
-               ioctl(fd, BLKFLSBUF, 0);
+               return fsync(fd);
+
+       return ioctl(fd, BLKFLSBUF, 0);
 }
 
 void
index 76887e5e22ba42f6612d3167085a4f462c6fbead..0aef318a81eeaea046a727608b99d35d294744b7 100644 (file)
@@ -12,7 +12,7 @@ int platform_check_ismounted(char *path, char *block, struct stat *sptr,
 int platform_check_iswritable(char *path, char *block, struct stat *sptr);
 int platform_set_blocksize(int fd, char *path, dev_t device, int bsz,
                int fatal);
-void platform_flush_device(int fd, dev_t device);
+int platform_flush_device(int fd, dev_t device);
 char *platform_findrawpath(char *path);
 char *platform_findblockpath(char *path);
 int platform_direct_blockdev(void);