X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_object.c;h=e1b75afd65df2b55127424a201d77abf7425e187;hp=2851a70de5125a73e323e791b30dcdab3c168fe0;hb=0ddcb9b4671365d6cfd2d5ef2b4dd3f78d2610bb;hpb=d3972843ae3ba829f821bd135d5ba97d4b0356f3 diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 2851a70..e1b75af 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -119,11 +119,10 @@ struct lu_buf *mdd_buf_get(const struct lu_env *env, void *area, ssize_t len) void mdd_buf_put(struct lu_buf *buf) { - if (buf == NULL || buf->lb_buf == NULL) - return; - OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); - buf->lb_buf = NULL; - buf->lb_len = 0; + if (buf == NULL || buf->lb_buf == NULL) + return; + OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); + *buf = LU_BUF_NULL; } const struct lu_buf *mdd_buf_get_const(const struct lu_env *env, @@ -139,19 +138,19 @@ const struct lu_buf *mdd_buf_get_const(const struct lu_env *env, struct lu_buf *mdd_buf_alloc(const struct lu_env *env, ssize_t len) { - struct lu_buf *buf = &mdd_env_info(env)->mti_big_buf; + struct lu_buf *buf = &mdd_env_info(env)->mti_big_buf; - if ((len > buf->lb_len) && (buf->lb_buf != NULL)) { - OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); - buf->lb_buf = NULL; - } - if (buf->lb_buf == NULL) { - buf->lb_len = len; - OBD_ALLOC_LARGE(buf->lb_buf, buf->lb_len); - if (buf->lb_buf == NULL) - buf->lb_len = 0; - } - return buf; + if ((len > buf->lb_len) && (buf->lb_buf != NULL)) { + OBD_FREE_LARGE(buf->lb_buf, buf->lb_len); + *buf = LU_BUF_NULL; + } + if (memcmp(buf, &LU_BUF_NULL, sizeof(*buf)) == 0) { + buf->lb_len = len; + OBD_ALLOC_LARGE(buf->lb_buf, buf->lb_len); + if (buf->lb_buf == NULL) + *buf = LU_BUF_NULL; + } + return buf; } /** Increase the size of the \a mti_big_buf.