]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
libxfs: check return value of device flush when closing device
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 8 Apr 2020 13:48:15 +0000 (09:48 -0400)
Although the libxfs_umount function flushes all devices when unmounting
the incore filesystem, the libxfs io code will flush the device again
when the application close them.  Check and report any errors that might
happen, though this is unlikely.

Coverity-id: 1460464
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/init.c

index 3e6436c140bcfd7bb6787d10f683021b21d8613a..cb8967bc77d44f47e390e62f6f916f1fd2d5c4f5 100644 (file)
@@ -166,13 +166,18 @@ libxfs_device_close(dev_t dev)
 
        for (d = 0; d < MAX_DEVS; d++)
                if (dev_map[d].dev == dev) {
-                       int     fd;
+                       int     fd, ret;
 
                        fd = dev_map[d].fd;
                        dev_map[d].dev = dev_map[d].fd = 0;
 
-                       fsync(fd);
-                       platform_flush_device(fd, dev);
+                       ret = platform_flush_device(fd, dev);
+                       if (ret) {
+                               ret = -errno;
+                               fprintf(stderr,
+       _("%s: flush of device %lld failed, err=%d"),
+                                               progname, (long long)dev, ret);
+                       }
                        close(fd);
 
                        return;