Commit 619d5d8a2b3f800ea3a0301a58ede570684956b0

Authored by Jeff Mahoney
Committed by Linus Torvalds
1 parent a44c94a7b8

[PATCH] reiserfs: reiserfs_file_write() will lose error code when a 0-length write occurs w/ O_SYNC

When an error occurs in reiserfs_file_write before any data is written, and
O_SYNC is set, the return code of generic_osync_write will overwrite the
error code, losing it.

This patch ensures that generic_osync_inode() doesn't run under an error
condition, losing the error.  This duplicates the logic from
generic_file_buffered_write().

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Cc: Chris Mason <mason@suse.com>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Alexander Zarochentsev <zam@namesys.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff

... ... @@ -1546,10 +1546,10 @@
1546 1546 }
1547 1547 }
1548 1548  
1549   - if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
1550   - res =
1551   - generic_osync_inode(inode, file->f_mapping,
1552   - OSYNC_METADATA | OSYNC_DATA);
  1549 + if (likely(res >= 0) &&
  1550 + (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode))))
  1551 + res = generic_osync_inode(inode, file->f_mapping,
  1552 + OSYNC_METADATA | OSYNC_DATA);
1553 1553  
1554 1554 mutex_unlock(&inode->i_mutex);
1555 1555 reiserfs_async_progress_wait(inode->i_sb);