]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] Fix the error handling in direct I/O
authorHifumi Hisashi <hifumi.hisashi@lab.ntt.co.jp>
Sat, 25 Jun 2005 21:54:32 +0000 (14:54 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 25 Jun 2005 23:24:25 +0000 (16:24 -0700)
Fix a bug on error handling in the direct I/O function.

Currently, if a file is opened with the O_DIRECT|O_SYNC flag, the write()
syscall cannot receive the EIO error after an I/O error (SCSI cable is
disconnected etc.).

Return values of other points that call generic_osync_inode() are treated
appropriately.

Signed-off-by: Hisashi Hifumi <hifumi.hisashi@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/filemap.c

index 7332194d7afddfd816e27eaec2eebb17a4059a24..b573607b7112228142e77323f5f461593f7c36bb 100644 (file)
@@ -1851,8 +1851,11 @@ generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
         * i_sem is held, which protects generic_osync_inode() from
         * livelocking.
         */
-       if (written >= 0 && file->f_flags & O_SYNC)
-               generic_osync_inode(inode, mapping, OSYNC_METADATA);
+       if (written >= 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
+               int err = generic_osync_inode(inode, mapping, OSYNC_METADATA);
+               if (err < 0)
+                       written = err;
+       }
        if (written == count && !is_sync_kiocb(iocb))
                written = -EIOCBQUEUED;
        return written;