ceph: don't clobber write return value when using O_SYNC
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 23 Feb 2010 18:16:23 +0000 (18:16 +0000)
committerSage Weil <sage@newdream.net>
Tue, 23 Feb 2010 22:26:36 +0000 (14:26 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/file.c

index 2c4ae4441caba3685520fc59941688b3f97f81f2..88932c9145e9ab9d726515bd179984d114532716 100644 (file)
@@ -807,7 +807,7 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
        struct ceph_osd_client *osdc = &ceph_client(inode->i_sb)->osdc;
        loff_t endoff = pos + iov->iov_len;
        int got = 0;
-       int ret;
+       int ret, err;
 
        if (ceph_snap(inode) != CEPH_NOSNAP)
                return -EROFS;
@@ -838,9 +838,12 @@ retry_snap:
 
                if ((ret >= 0 || ret == -EIOCBQUEUED) &&
                    ((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host)
-                    || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL)))
-                       ret = vfs_fsync_range(file, file->f_path.dentry,
+                    || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) {
+                       err = vfs_fsync_range(file, file->f_path.dentry,
                                              pos, pos + ret - 1, 1);
+                       if (err < 0)
+                               ret = err;
+               }
        }
        if (ret >= 0) {
                spin_lock(&inode->i_lock);