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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 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 <[email protected]>

diff -ruNpX dontdiff linux-2.6.15/fs/reiserfs/file.c linux-2.6.15.reiserfs/fs/reiserfs/file.c
--- linux-2.6.15/fs/reiserfs/file.c	2006-03-02 12:10:04.000000000 -0500
+++ linux-2.6.15.reiserfs/fs/reiserfs/file.c	2006-03-02 16:08:49.000000000 -0500
@@ -1563,10 +1563,10 @@ static ssize_t reiserfs_file_write(struc
 		}
 	}
 
-	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);
-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux