summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d397284)
Fix DLUBUF define and use LU_BUF_NULL to clear a lu_buf
Change-Id: I742308616d9c39196e56bf4983523152d26e1245
Signed-off-by: jcl <jacques-charles.lafoucriere@cea.fr>
Reviewed-on: http://review.whamcloud.com/3589
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
/** null buffer */
extern struct lu_buf LU_BUF_NULL;
/** null buffer */
extern struct lu_buf LU_BUF_NULL;
-#define DLUBUF "(%p %z)"
+#define DLUBUF "(%p %zu)"
#define PLUBUF(buf) (buf)->lb_buf, (buf)->lb_len
/**
* One-time initializers, called at obdclass module initialization, not
#define PLUBUF(buf) (buf)->lb_buf, (buf)->lb_len
/**
* One-time initializers, called at obdclass module initialization, not
void mdd_buf_put(struct lu_buf *buf)
{
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,
}
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 *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.
}
/** Increase the size of the \a mti_big_buf.