X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fobdclass%2Fdt_object.c;h=f05c8092d428f822a673f4156de565371e785562;hp=83cf4fbb544ef435e0864ea1958bea7106b44e5b;hb=83efcf39e2f88ecd3cf5162c0f5cead2c39a5de3;hpb=a2245cbf99d15a24605e355f26b7612895ae2287 diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index 83cf4fb..f05c809 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -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);