RETURN(-ENOMEM);
if (copy_from_user(buf, buffer, count))
- RETURN(-EFAULT);
+ GOTO(out, rc = -EFAULT);
+
buf[count] = '\0';
start = buf;
sz = PAGE_SIZE;
OBD_ALLOC(msg, sz);
if (!msg)
- RETURN(-ENOMEM);
+ GOTO(out, rc = -ENOMEM);
hsm_policy_bit2str(0, false, msg, sz);
CWARN("%s: '%s' is unknown, "
strcpy(name, dev);
p = strstr(name, "-MDT");
if (p == NULL)
- GOTO(cleanup_mem, rc = -ENOMEM);
+ GOTO(free_bufs, rc = -ENOMEM);
p[3] = 'D';
snprintf(uuid, MAX_OBD_NAME, "%s_UUID", name);
if (lprof == NULL || lprof->lp_dt == NULL) {
CERROR("can't find the profile: %s\n",
lustre_cfg_string(cfg, 0));
- GOTO(cleanup_mem, rc = -EINVAL);
+ GOTO(free_bufs, rc = -EINVAL);
}
lustre_cfg_bufs_reset(bufs, name);
/* connect to MDD we just setup */
rc = mdt_connect_to_next(env, mdt, name, &mdt->mdt_child_exp);
if (rc)
- RETURN(rc);
+ GOTO(class_detach, rc);
site = mdt->mdt_child_exp->exp_obd->obd_lu_dev->ld_site;
LASSERT(site);
snprintf(name, MAX_OBD_NAME, "%s-osd", dev);
rc = mdt_connect_to_next(env, mdt, name, &mdt->mdt_bottom_exp);
if (rc)
- RETURN(rc);
+ GOTO(class_detach, rc);
mdt->mdt_bottom =
lu2dt_dev(mdt->mdt_bottom_exp->exp_obd->obd_lu_dev);
if (strlcpy(mml->mml_marker.cm_comment, comment,
sizeof(mml->mml_marker.cm_comment)) >=
sizeof(mml->mml_marker.cm_comment))
- GOTO(out_close, rc = -E2BIG);
+ GOTO(out_free, rc = -E2BIG);
if (strlcpy(mml->mml_marker.cm_tgtname, devname,
sizeof(mml->mml_marker.cm_tgtname)) >=
sizeof(mml->mml_marker.cm_tgtname))
- GOTO(out_close, rc = -E2BIG);
+ GOTO(out_free, rc = -E2BIG);
/* Modify mostly means cancel */
mml->mml_marker.cm_flags = flags;
mml->mml_marker.cm_canceltime = flags ? cfs_time_current_sec() : 0;
NULL);
if (!rc && !mml->mml_modified)
rc = 1;
+
+out_free:
OBD_FREE_PTR(mml);
out_close:
__u64 offset = hai->hai_extent.offset;
struct stat src_st;
struct stat dst_st;
- char *buf;
+ char *buf = NULL;
__u64 write_total = 0;
__u64 length;
time_t last_print_time = time(NULL);
CT_TRACE("going to copy data from '%s' to '%s'", src, dst);
- buf = malloc(opt.o_chunk_size);
- if (buf == NULL)
- return -ENOMEM;
-
if (fstat(src_fd, &src_st) < 0) {
rc = -errno;
CT_ERROR(rc, "cannot stat '%s'", src);
rc = lseek(src_fd, hai->hai_extent.offset, SEEK_SET);
if (rc < 0) {
- CT_ERROR(errno,
+ rc = -errno;
+ CT_ERROR(rc,
"cannot seek for read to "LPU64" (len %jd) in '%s'",
hai->hai_extent.offset, (intmax_t)src_st.st_size, src);
- rc = -errno;
- goto out;
+ return rc;
}
he.offset = offset;
/* Don't read beyond a given extent */
length = min(hai->hai_extent.length, src_st.st_size);
+ buf = malloc(opt.o_chunk_size);
+ if (buf == NULL) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
CT_DEBUG("Going to copy "LPU64" bytes %s -> %s\n", length, src, dst);
while (write_total < length) {
rc = ftruncate(dst_fd, src_st.st_size);
if (rc < 0) {
rc = -errno;
- CT_ERROR(rc,
- "cannot truncate '%s' to size %jd",
+ CT_ERROR(rc, "cannot truncate '%s' to size %jd",
dst, (intmax_t)src_st.st_size);
err_major++;
}
}
- free(buf);
+ if (buf != NULL)
+ free(buf);
return rc;
}