Whamcloud - gitweb
LU-6075 osd: race for check/chance od_dirent_journal
[fs/lustre-release.git] / lustre / obdclass / dt_object.c
index 83cf4fb..8a7372c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -472,35 +472,33 @@ EXPORT_SYMBOL(dt_read);
 int dt_record_read(const struct lu_env *env, struct dt_object *dt,
                    struct lu_buf *buf, loff_t *pos)
 {
-        int rc;
+       ssize_t size;
 
-        LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
+       LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
 
-        rc = dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
+       size = dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
 
-        if (rc == buf->lb_len)
-                rc = 0;
-        else if (rc >= 0)
-                rc = -EFAULT;
-        return rc;
+       if (size < 0)
+               return size;
+       return (size == (ssize_t)buf->lb_len) ? 0 : -EFAULT;
 }
 EXPORT_SYMBOL(dt_record_read);
 
 int dt_record_write(const struct lu_env *env, struct dt_object *dt,
                     const struct lu_buf *buf, loff_t *pos, struct thandle *th)
 {
-        int rc;
+       ssize_t size;
 
-        LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
-        LASSERT(th != NULL);
-        LASSERT(dt->do_body_ops);
-        LASSERT(dt->do_body_ops->dbo_write);
-        rc = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, BYPASS_CAPA, 1);
-        if (rc == buf->lb_len)
-                rc = 0;
-        else if (rc >= 0)
-                rc = -EFAULT;
-        return rc;
+       LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
+       LASSERT(th != NULL);
+       LASSERT(dt->do_body_ops);
+       LASSERT(dt->do_body_ops->dbo_write);
+
+       size = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, BYPASS_CAPA, 1);
+
+       if (size < 0)
+               return size;
+       return (size == (ssize_t)buf->lb_len) ? 0 : -EFAULT;
 }
 EXPORT_SYMBOL(dt_record_write);