ceph: allow sync_read/write return partial successed size of read/write.
authormajianpeng <majianpeng@gmail.com>
Wed, 21 Aug 2013 07:02:51 +0000 (15:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2014 20:24:25 +0000 (12:24 -0800)
commit ee7289bfadda5f4ef60884547ebc9989c8fb314a upstream.

For sync_read/write, it may do multi stripe operations.If one of those
met erro, we return the former successed size rather than a error value.
There is a exception for write-operation met -EOLDSNAPC.If this occur,we
retry the whole write again.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ceph/file.c

index 1ac0a59..5de16f5 100644 (file)
@@ -373,7 +373,7 @@ more:
                        goto more;
        }
 
-       if (ret >= 0) {
+       if (read > 0) {
                ret = read;
                /* did we bounce off eof? */
                if (pos + left > inode->i_size)
@@ -611,6 +611,8 @@ out:
                if (check_caps)
                        ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY,
                                        NULL);
+       } else if (ret != -EOLDSNAPC && written > 0) {
+               ret = written;
        }
        return ret;
 }