From: Jeff Mahoney Date: Sat, 25 Mar 2006 11:07:00 +0000 (-0800) Subject: [PATCH] reiserfs: reiserfs_file_write() will lose error code when a 0-length write... X-Git-Tag: v2.6.17-rc1~836 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=619d5d8a2b3f800ea3a0301a58ede570684956b0;p=linux-2.6 [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 Cc: Chris Mason Cc: Jeff Mahoney Cc: Alexander Zarochentsev Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index be12879bb1..044de8be39 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c @@ -1546,10 +1546,10 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t } } - if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) - res = - generic_osync_inode(inode, file->f_mapping, - OSYNC_METADATA | OSYNC_DATA); + if (likely(res >= 0) && + (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode)))) + res = generic_osync_inode(inode, file->f_mapping, + OSYNC_METADATA | OSYNC_DATA); mutex_unlock(&inode->i_mutex); reiserfs_async_progress_wait(inode->i_sb);