]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: report io error for pwrite -W and -w
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 9 Nov 2017 17:35:20 +0000 (11:35 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 9 Nov 2017 17:35:20 +0000 (11:35 -0600)
When IO error occurs, xfs_io -c "pwrite -W/w" doesn't report errors
while xfs_io -c "pwrite" -c "fsync" does.

This changes "pwrite -W/w" to report errors when it should.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
io/pwrite.c

index 1c5dfca1e075d3764dbc83cc80bd3655876bda7c..71bccccfd6b04febe547a7f3d579c0a142da63a2 100644 (file)
@@ -379,10 +379,18 @@ pwrite_f(
        }
        if (c < 0)
                goto done;
-       if (Wflag)
-               fsync(file->fd);
-       if (wflag)
-               fdatasync(file->fd);
+       if (Wflag) {
+               if (fsync(file->fd) < 0) {
+                       perror("fsync");
+                       goto done;
+               }
+       }
+       if (wflag) {
+               if (fdatasync(file->fd) < 0) {
+                       perror("fdatasync");
+                       goto done;
+               }
+       }
        if (qflag)
                goto done;
        gettimeofday(&t2, NULL);