1) Add unlock_ioctl support.
2) Land OBD_ALLOC_LARGE() patch from b4424 to avoid vmalloc in ioctl path.
3) Minor fix in class_handle_ioctl() to avoid double free.
Issue: LU-66
Change-Id: Id965cd13fdaeb63197c30e557708afbfa9ee9f39
Signed-off-by: Niu Yawei <niu@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/247
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
struct lu_buf {
void *lb_buf;
ssize_t lb_len;
- int lb_vmalloc:1;
};
/** null buffer */
RETURN(-EINVAL);
}
- /* XXX allocate this more intelligently, using kmalloc when
- * appropriate */
- OBD_VMALLOC(*buf, hdr.ioc_len);
+ OBD_ALLOC_LARGE(*buf, hdr.ioc_len);
if (*buf == NULL) {
CERROR("Cannot allocate control buffer of len %d\n",
hdr.ioc_len);
err = cfs_copy_from_user(*buf, (void *)arg, hdr.ioc_len);
if (err) {
- OBD_VFREE(*buf, hdr.ioc_len);
+ OBD_FREE_LARGE(*buf, hdr.ioc_len);
RETURN(err);
}
if (obd_ioctl_is_invalid(data)) {
CERROR("ioctl not correctly formatted\n");
- OBD_VFREE(*buf, hdr.ioc_len);
+ OBD_FREE_LARGE(*buf, hdr.ioc_len);
RETURN(-EINVAL);
}
{
ENTRY;
- OBD_VFREE(buf, len);
+ OBD_FREE_LARGE(buf, len);
EXIT;
return;
}
# endif
#endif /* __KERNEL__ */
-/* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
- * buffers */
-#define SVC_BUF_VMALLOC_THRESHOLD (2 * CFS_PAGE_SIZE)
-
/**
* The following constants determine how memory is used to buffer incoming
* service requests.
if (num_cookies == 1)
oti->oti_logcookies = &oti->oti_onecookie;
else
- OBD_ALLOC(oti->oti_logcookies,
- num_cookies * sizeof(oti->oti_onecookie));
+ OBD_ALLOC_LARGE(oti->oti_logcookies,
+ num_cookies * sizeof(oti->oti_onecookie));
oti->oti_numcookies = num_cookies;
}
if (oti->oti_logcookies == &oti->oti_onecookie)
LASSERT(oti->oti_numcookies == 1);
else
- OBD_FREE(oti->oti_logcookies,
- oti->oti_numcookies * sizeof(oti->oti_onecookie));
+ OBD_FREE_LARGE(oti->oti_logcookies,
+ oti->oti_numcookies*sizeof(oti->oti_onecookie));
oti->oti_logcookies = NULL;
oti->oti_numcookies = 0;
}
} while(0)
#endif
+#ifdef __KERNEL__
+
+/* Allocations above this size are considered too big and could not be done
+ * atomically.
+ *
+ * Be very careful when changing this value, especially when decreasing it,
+ * since vmalloc in Linux doesn't perform well on multi-cores system, calling
+ * vmalloc in critical path would hurt peformance badly. See LU-66.
+ */
+#define OBD_ALLOC_BIG (4 * CFS_PAGE_SIZE)
+
+#define OBD_ALLOC_LARGE(ptr, size) \
+do { \
+ if (size > OBD_ALLOC_BIG) \
+ OBD_VMALLOC(ptr, size); \
+ else \
+ OBD_ALLOC(ptr, size); \
+} while (0)
+
+#define OBD_FREE_LARGE(ptr, size) \
+do { \
+ if (size > OBD_ALLOC_BIG) \
+ OBD_VFREE(ptr, size); \
+ else \
+ OBD_FREE(ptr, size); \
+} while (0)
+#else
+#define OBD_ALLOC_LARGE(ptr, size) OBD_ALLOC(ptr, size)
+#define OBD_FREE_LARGE(ptr, size) OBD_FREE(ptr,size)
+#endif
+
#ifdef CONFIG_DEBUG_SLAB
#define POISON(ptr, c, s) do {} while (0)
#define POISON_PTR(ptr) ((void)0)
if (rc)
RETURN(rc);
- OBD_ALLOC(lmm, lmmsize);
+ OBD_ALLOC_LARGE(lmm, lmmsize);
if (cfs_copy_from_user(lmm, lum, lmmsize))
GOTO(free_lmm, rc = -EFAULT);
free_lsm:
obd_free_memmd(sbi->ll_dt_exp, &lsm);
free_lmm:
- OBD_FREE(lmm, lmmsize);
+ OBD_FREE_LARGE(lmm, lmmsize);
return rc;
}
case OBD_IOC_LLOG_CATINFO: {
lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) *
(lsm->lsm_stripe_count));
- OBD_ALLOC(lsm2, lsm_size);
+ OBD_ALLOC_LARGE(lsm2, lsm_size);
if (lsm2 == NULL)
GOTO(out, rc = -ENOMEM);
memcpy(lsm2, lsm, lsm_size);
rc = obd_create(exp, oa, &lsm2, &oti);
- OBD_FREE(lsm2, lsm_size);
+ OBD_FREE_LARGE(lsm2, lsm_size);
GOTO(out, rc);
out:
ll_inode_size_unlock(inode, 0);
if (!cfs_capable(CFS_CAP_SYS_ADMIN))
RETURN(-EPERM);
- OBD_ALLOC(lump, lum_size);
+ OBD_ALLOC_LARGE(lump, lum_size);
if (lump == NULL) {
RETURN(-ENOMEM);
}
if (cfs_copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) {
- OBD_FREE(lump, lum_size);
+ OBD_FREE_LARGE(lump, lum_size);
RETURN(-EFAULT);
}
rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size);
- OBD_FREE(lump, lum_size);
+ OBD_FREE_LARGE(lump, lum_size);
RETURN(rc);
}
num_bytes = sizeof(*fiemap_s) + (extent_count *
sizeof(struct ll_fiemap_extent));
- OBD_VMALLOC(fiemap_s, num_bytes);
+ OBD_ALLOC_LARGE(fiemap_s, num_bytes);
if (fiemap_s == NULL)
RETURN(-ENOMEM);
rc = -EFAULT;
error:
- OBD_VFREE(fiemap_s, num_bytes);
+ OBD_FREE_LARGE(fiemap_s, num_bytes);
RETURN(rc);
}
+#ifdef HAVE_UNLOCKED_IOCTL
+long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+#else
int ll_file_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{
+#endif
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
int flags;
ENTRY;
num_bytes = sizeof(*fiemap) + (extent_count *
sizeof(struct ll_fiemap_extent));
- OBD_VMALLOC(fiemap, num_bytes);
+ OBD_ALLOC_LARGE(fiemap, num_bytes);
if (fiemap == NULL)
RETURN(-ENOMEM);
memcpy(fieinfo->fi_extents_start, &fiemap->fm_extents[0],
fiemap->fm_mapped_extents * sizeof(struct ll_fiemap_extent));
- OBD_VFREE(fiemap, num_bytes);
+ OBD_FREE_LARGE(fiemap, num_bytes);
return rc;
}
#endif
.READ_METHOD = READ_FUNCTION,
.write = ll_file_write,
.WRITE_METHOD = WRITE_FUNCTION,
+#ifdef HAVE_UNLOCKED_IOCTL
+ .unlocked_ioctl = ll_file_ioctl,
+#else
.ioctl = ll_file_ioctl,
+#endif
.open = ll_file_open,
.release = ll_file_release,
.mmap = ll_file_mmap,
.READ_METHOD = READ_FUNCTION,
.write = ll_file_write,
.WRITE_METHOD = WRITE_FUNCTION,
+#ifdef HAVE_UNLOCKED_IOCTL
+ .unlocked_ioctl = ll_file_ioctl,
+#else
.ioctl = ll_file_ioctl,
+#endif
.open = ll_file_open,
.release = ll_file_release,
.mmap = ll_file_mmap,
.READ_METHOD = READ_FUNCTION,
.write = ll_file_write,
.WRITE_METHOD = WRITE_FUNCTION,
+#ifdef HAVE_UNLOCKED_IOCTL
+ .unlocked_ioctl = ll_file_ioctl,
+#else
.ioctl = ll_file_ioctl,
+#endif
.open = ll_file_open,
.release = ll_file_release,
.mmap = ll_file_mmap,
*max_pages = (user_addr + size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
*max_pages -= user_addr >> CFS_PAGE_SHIFT;
- OBD_ALLOC_WAIT(*pages, *max_pages * sizeof(**pages));
+ OBD_ALLOC_LARGE(*pages, *max_pages * sizeof(**pages));
if (*pages) {
down_read(¤t->mm->mmap_sem);
result = get_user_pages(current, current->mm, user_addr,
NULL);
up_read(¤t->mm->mmap_sem);
if (unlikely(result <= 0))
- OBD_FREE(*pages, *max_pages * sizeof(**pages));
+ OBD_FREE_LARGE(*pages, *max_pages * sizeof(**pages));
}
return result;
page_cache_release(pages[i]);
}
- OBD_FREE(pages, npages * sizeof(*pages));
+ OBD_FREE_LARGE(pages, npages * sizeof(*pages));
}
ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
RETURN(mea_size);
if (*lmmp && !lsm) {
- OBD_FREE(*lmmp, mea_size);
+ OBD_FREE_LARGE(*lmmp, mea_size);
*lmmp = NULL;
RETURN(0);
}
if (*lmmp == NULL) {
- OBD_ALLOC(*lmmp, mea_size);
+ OBD_ALLOC_LARGE(*lmmp, mea_size);
if (*lmmp == NULL)
RETURN(-ENOMEM);
}
return mea_size;
if (*lsmp != NULL && lmm == NULL) {
- OBD_FREE(*tmea, mea_size);
+ OBD_FREE_LARGE(*tmea, mea_size);
*lsmp = NULL;
RETURN(0);
}
LASSERT(mea_size == lmm_size);
- OBD_ALLOC(*tmea, mea_size);
+ OBD_ALLOC_LARGE(*tmea, mea_size);
if (*tmea == NULL)
RETURN(-ENOMEM);
obj_size = sizeof(struct lmv_stripe) *
lmv->desc.ld_tgt_count;
- OBD_ALLOC(obj->lo_stripes, obj_size);
+ OBD_ALLOC_LARGE(obj->lo_stripes, obj_size);
if (!obj->lo_stripes)
goto err_obj;
- memset(obj->lo_stripes, 0, obj_size);
-
CDEBUG(D_INODE, "Allocate object for "DFID"\n",
PFID(fid));
for (i = 0; i < mea->mea_count; i++) {
obj_size = sizeof(struct lmv_stripe) *
lmv->desc.ld_tgt_count;
- OBD_FREE(obj->lo_stripes, obj_size);
+ OBD_FREE_LARGE(obj->lo_stripes, obj_size);
OBD_SLAB_FREE(obj, lmv_object_cache, sizeof(*obj));
cfs_atomic_dec(&lmv_object_count);
}
oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count;
*size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size;
- OBD_ALLOC(lsm, *size);
+ OBD_ALLOC_LARGE(lsm, *size);
if (!lsm)
return NULL;;
err:
while (--i >= 0)
OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi));
- OBD_FREE(lsm, *size);
+ OBD_FREE_LARGE(lsm, *size);
return NULL;
}
for (i = 0; i < stripe_count; i++)
OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab,
sizeof(struct lov_oinfo));
- OBD_FREE(lsm, sizeof(struct lov_stripe_md) +
- stripe_count * sizeof(struct lov_oinfo *));
+ OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
+ stripe_count * sizeof(struct lov_oinfo *));
}
static void lsm_unpackmd_common(struct lov_stripe_md *lsm,
* Need to be optimized, we can't afford to allocate a piece of memory
* when writing a page. -jay
*/
- OBD_ALLOC(lio->lis_subs,
- lsm->lsm_stripe_count * sizeof lio->lis_subs[0]);
+ OBD_ALLOC_LARGE(lio->lis_subs,
+ lsm->lsm_stripe_count * sizeof lio->lis_subs[0]);
if (lio->lis_subs != NULL) {
lio->lis_nr_subios = lio->lis_stripe_count;
lio->lis_single_subio_index = -1;
if (lio->lis_subs != NULL) {
for (i = 0; i < lio->lis_nr_subios; i++)
lov_io_sub_fini(env, lio, &lio->lis_subs[i]);
- OBD_FREE(lio->lis_subs,
+ OBD_FREE_LARGE(lio->lis_subs,
lio->lis_nr_subios * sizeof lio->lis_subs[0]);
lio->lis_nr_subios = 0;
}
LASSERT(lio->lis_subs != NULL);
if (alloc) {
- OBD_ALLOC(stripes_qin,
- sizeof(*stripes_qin) * lio->lis_nr_subios);
+ OBD_ALLOC_LARGE(stripes_qin,
+ sizeof(*stripes_qin) * lio->lis_nr_subios);
if (stripes_qin == NULL)
RETURN(-ENOMEM);
}
if (alloc) {
- OBD_FREE(stripes_qin,
+ OBD_FREE_LARGE(stripes_qin,
sizeof(*stripes_qin) * lio->lis_nr_subios);
} else {
int i;
nr++;
}
LASSERT(nr > 0);
- OBD_ALLOC(lck->lls_sub, nr * sizeof lck->lls_sub[0]);
+ OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof lck->lls_sub[0]);
if (lck->lls_sub == NULL)
RETURN(-ENOMEM);
* a reference on its parent.
*/
LASSERT(lck->lls_sub[i].sub_lock == NULL);
- OBD_FREE(lck->lls_sub, lck->lls_nr * sizeof lck->lls_sub[0]);
+ OBD_FREE_LARGE(lck->lls_sub,
+ lck->lls_nr * sizeof lck->lls_sub[0]);
}
OBD_SLAB_FREE_PTR(lck, lov_lock_kmem);
EXIT;
if (fiemap_count_to_size(fm_key->fiemap.fm_extent_count) < buffer_size)
buffer_size = fiemap_count_to_size(fm_key->fiemap.fm_extent_count);
- OBD_ALLOC(fm_local, buffer_size);
+ OBD_ALLOC_LARGE(fm_local, buffer_size);
if (fm_local == NULL)
GOTO(out, rc = -ENOMEM);
lcl_fm_ext = &fm_local->fm_extents[0];
fiemap->fm_mapped_extents = current_extent;
out:
- OBD_FREE(fm_local, buffer_size);
+ OBD_FREE_LARGE(fm_local, buffer_size);
return rc;
}
r0->lo_lsm = conf->u.coc_md->lsm;
LASSERT(r0->lo_nr <= lov_targets_nr(dev));
- OBD_ALLOC(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]);
+ OBD_ALLOC_LARGE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]);
if (r0->lo_sub != NULL) {
result = 0;
subconf->coc_inode = conf->coc_inode;
ENTRY;
if (r0->lo_sub != NULL) {
- OBD_FREE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]);
+ OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]);
r0->lo_sub = NULL;
}
EXIT;
if (*lmmp && !lsm) {
stripe_count = le32_to_cpu((*lmmp)->lmm_stripe_count);
lmm_size = lov_mds_md_size(stripe_count, lmm_magic);
- OBD_FREE(*lmmp, lmm_size);
+ OBD_FREE_LARGE(*lmmp, lmm_size);
*lmmp = NULL;
RETURN(0);
}
if (!*lmmp) {
- OBD_ALLOC(*lmmp, lmm_size);
+ OBD_ALLOC_LARGE(*lmmp, lmm_size);
if (!*lmmp)
RETURN(-ENOMEM);
}
CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n",
le32_to_cpu(*(__u32 *)lmm), lmm_bytes);
sz = lmm_bytes * 2 + 1;
- OBD_ALLOC(buffer, sz);
+ OBD_ALLOC_LARGE(buffer, sz);
if (buffer != NULL) {
int i;
sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]);
buffer[sz] = '\0';
CERROR("%s\n", buffer);
- OBD_FREE(buffer, sz);
+ OBD_FREE_LARGE(buffer, sz);
}
return -EINVAL;
}
oti_alloc_cookies(set->set_oti, set->set_count);
if (set->set_oti->oti_logcookies) {
memcpy(set->set_oti->oti_logcookies, cookies, newsize);
- OBD_FREE(cookies, oldsize);
+ OBD_FREE_LARGE(cookies, oldsize);
set->set_cookies = set->set_oti->oti_logcookies;
} else {
CWARN("'leaking' %d bytes\n", oldsize - newsize);
LASSERT(lsm->lsm_stripe_count >= set->set_count);
newsize = lov_stripe_md_size(set->set_count);
- OBD_ALLOC(lsm_new, newsize);
+ OBD_ALLOC_LARGE(lsm_new, newsize);
if (lsm_new != NULL) {
int i;
memcpy(lsm_new, lsm, sizeof(*lsm));
sizeof(struct lov_oinfo));
}
lsm_new->lsm_stripe_count = set->set_count;
- OBD_FREE(lsm, sizeof(struct lov_stripe_md) +
- lsm->lsm_stripe_count * sizeof(struct lov_oinfo *));
+ OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
+ lsm->lsm_stripe_count*sizeof(struct lov_oinfo*));
set->set_oi->oi_md = lsm_new;
} else {
CWARN("'leaking' few bytes\n");
lov_set_add_req(req, set);
req->rq_buflen = sizeof(*req->rq_oi.oi_md);
- OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_ALLOC_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL)
GOTO(out_err, rc = -ENOMEM);
if (req->rq_oi.oi_oa)
OBDO_FREE(req->rq_oi.oi_oa);
if (req->rq_oi.oi_md)
- OBD_FREE(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_osfs)
OBD_FREE(req->rq_oi.oi_osfs,
sizeof(*req->rq_oi.oi_osfs));
if (set->set_pga) {
int len = set->set_oabufs * sizeof(*set->set_pga);
- OBD_FREE(set->set_pga, len);
+ OBD_FREE_LARGE(set->set_pga, len);
}
if (set->set_lockh)
lov_llh_put(set->set_lockh);
req->rq_buflen = sizeof(*req->rq_oi.oi_md) +
sizeof(struct lov_oinfo *) +
sizeof(struct lov_oinfo);
- OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_ALLOC_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
GOTO(out_set, rc = -ENOMEM);
req->rq_buflen = sizeof(*req->rq_oi.oi_md);
- OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_ALLOC_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
GOTO(out_set, rc = -ENOMEM);
req->rq_buflen = sizeof(*req->rq_oi.oi_md);
- OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_ALLOC_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL) {
OBD_FREE(req, sizeof(*req));
GOTO(out_set, rc = -ENOMEM);
set->set_oti = oti;
set->set_oi = oinfo;
set->set_oabufs = oa_bufs;
- OBD_ALLOC(set->set_pga, oa_bufs * sizeof(*set->set_pga));
+ OBD_ALLOC_LARGE(set->set_pga, oa_bufs * sizeof(*set->set_pga));
if (!set->set_pga)
GOTO(out, rc = -ENOMEM);
- OBD_ALLOC(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
+ OBD_ALLOC_LARGE(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
if (!info)
GOTO(out, rc = -ENOMEM);
req->rq_oi.oi_oa->o_stripe_idx = i;
req->rq_buflen = sizeof(*req->rq_oi.oi_md);
- OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_ALLOC_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL) {
OBDO_FREE(req->rq_oi.oi_oa);
OBD_FREE(req, sizeof(*req));
}
out:
if (info)
- OBD_FREE(info, sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
+ OBD_FREE_LARGE(info,
+ sizeof(*info) * oinfo->oi_md->lsm_stripe_count);
if (rc == 0)
*reqset = set;
PFID(mdd_object_fid(mdd_obj)));
}
- if (buf->lb_vmalloc)
+ if (buf->lb_len > OBD_ALLOC_BIG)
/* if we vmalloced a large buffer drop it */
mdd_buf_put(buf);
oldlname->ln_namelen, oldlname->ln_name, rc,
PFID(mdd_object_fid(mdd_obj)));
- if (buf->lb_vmalloc)
+ if (buf->lb_len > OBD_ALLOC_BIG)
/* if we vmalloced a large buffer drop it */
mdd_buf_put(buf);
{
if (buf == NULL || buf->lb_buf == NULL)
return;
- if (buf->lb_vmalloc)
- OBD_VFREE(buf->lb_buf, buf->lb_len);
- else
- OBD_FREE(buf->lb_buf, buf->lb_len);
+ OBD_FREE_LARGE(buf->lb_buf, buf->lb_len);
buf->lb_buf = NULL;
buf->lb_len = 0;
}
return buf;
}
-#define BUF_VMALLOC_SIZE (CFS_PAGE_SIZE<<2) /* 16k */
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;
if ((len > buf->lb_len) && (buf->lb_buf != NULL)) {
- if (buf->lb_vmalloc)
- OBD_VFREE(buf->lb_buf, buf->lb_len);
- else
- OBD_FREE(buf->lb_buf, buf->lb_len);
+ OBD_FREE_LARGE(buf->lb_buf, buf->lb_len);
buf->lb_buf = NULL;
}
if (buf->lb_buf == NULL) {
buf->lb_len = len;
- if (buf->lb_len <= BUF_VMALLOC_SIZE) {
- OBD_ALLOC(buf->lb_buf, buf->lb_len);
- buf->lb_vmalloc = 0;
- }
- if (buf->lb_buf == NULL) {
- OBD_VMALLOC(buf->lb_buf, buf->lb_len);
- buf->lb_vmalloc = 1;
- }
+ OBD_ALLOC_LARGE(buf->lb_buf, buf->lb_len);
if (buf->lb_buf == NULL)
buf->lb_len = 0;
}
struct lu_buf buf;
LASSERT(len >= oldbuf->lb_len);
- if (len > BUF_VMALLOC_SIZE) {
- OBD_VMALLOC(buf.lb_buf, len);
- buf.lb_vmalloc = 1;
- } else {
- OBD_ALLOC(buf.lb_buf, len);
- buf.lb_vmalloc = 0;
- }
+ OBD_ALLOC_LARGE(buf.lb_buf, len);
+
if (buf.lb_buf == NULL)
return -ENOMEM;
buf.lb_len = len;
memcpy(buf.lb_buf, oldbuf->lb_buf, oldbuf->lb_len);
- if (oldbuf->lb_vmalloc)
- OBD_VFREE(oldbuf->lb_buf, oldbuf->lb_len);
- else
- OBD_FREE(oldbuf->lb_buf, oldbuf->lb_len);
+ OBD_FREE_LARGE(oldbuf->lb_buf, oldbuf->lb_len);
memcpy(oldbuf, &buf, sizeof(buf));
max_cookie_size = mdd_lov_cookiesize(env, mdd);
if (unlikely(mti->mti_max_cookie_size < max_cookie_size)) {
if (mti->mti_max_cookie)
- OBD_FREE(mti->mti_max_cookie, mti->mti_max_cookie_size);
+ OBD_FREE_LARGE(mti->mti_max_cookie,
+ mti->mti_max_cookie_size);
mti->mti_max_cookie = NULL;
mti->mti_max_cookie_size = 0;
}
if (unlikely(mti->mti_max_cookie == NULL)) {
- OBD_ALLOC(mti->mti_max_cookie, max_cookie_size);
+ OBD_ALLOC_LARGE(mti->mti_max_cookie, max_cookie_size);
if (likely(mti->mti_max_cookie != NULL))
mti->mti_max_cookie_size = max_cookie_size;
}
max_lmm_size = mdd_lov_mdsize(env, mdd);
if (unlikely(mti->mti_max_lmm_size < max_lmm_size)) {
if (mti->mti_max_lmm)
- OBD_FREE(mti->mti_max_lmm, mti->mti_max_lmm_size);
+ OBD_FREE_LARGE(mti->mti_max_lmm, mti->mti_max_lmm_size);
mti->mti_max_lmm = NULL;
mti->mti_max_lmm_size = 0;
}
if (unlikely(mti->mti_max_lmm == NULL)) {
- OBD_ALLOC(mti->mti_max_lmm, max_lmm_size);
+ OBD_ALLOC_LARGE(mti->mti_max_lmm, max_lmm_size);
if (likely(mti->mti_max_lmm != NULL))
mti->mti_max_lmm_size = max_lmm_size;
}
EXIT;
out:
- if (buf && !IS_ERR(buf) && buf->lb_vmalloc)
+ if (buf && !IS_ERR(buf) && buf->lb_len > OBD_ALLOC_BIG)
/* if we vmalloced a large buffer drop it */
mdd_buf_put(buf);
int cookie_size;
lmm_size = mdt->mdt_max_mdsize;
- OBD_ALLOC(ma->ma_lmm, lmm_size);
+ OBD_ALLOC_LARGE(ma->ma_lmm, lmm_size);
if (ma->ma_lmm == NULL)
GOTO(out_lmm, rc = -ENOMEM);
cookie_size = mdt->mdt_max_cookiesize;
- OBD_ALLOC(ma->ma_cookie, cookie_size);
+ OBD_ALLOC_LARGE(ma->ma_cookie, cookie_size);
if (ma->ma_cookie == NULL)
GOTO(out_cookie, rc = -ENOMEM);
ma->ma_valid = MA_FLAGS;
mdt_mfd_close(info, mfd);
}
- OBD_FREE(ma->ma_cookie, cookie_size);
+ OBD_FREE_LARGE(ma->ma_cookie, cookie_size);
ma->ma_cookie = NULL;
out_cookie:
- OBD_FREE(ma->ma_lmm, lmm_size);
+ OBD_FREE_LARGE(ma->ma_lmm, lmm_size);
ma->ma_lmm = NULL;
}
out_lmm:
info->mti_attr.ma_valid = 0;
info->mti_attr.ma_lmm_size = info->mti_mdt->mdt_max_mdsize;
- OBD_ALLOC(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize);
+ OBD_ALLOC_LARGE(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize);
if (info->mti_attr.ma_lmm == NULL)
RETURN(-ENOMEM);
rc = mdt_mfd_close(info, mfd);
- OBD_FREE(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize);
+ OBD_FREE_LARGE(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize);
mdt_empty_transno(info);
RETURN(rc);
}
/* Close the found mfd, update attributes. */
ma->ma_lmm_size = info->mti_mdt->mdt_max_mdsize;
- OBD_ALLOC(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
+ OBD_ALLOC_LARGE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
if (ma->ma_lmm == NULL)
GOTO(out_put, rc = -ENOMEM);
mdt_mfd_close(info, mfd);
- OBD_FREE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
+ OBD_FREE_LARGE(ma->ma_lmm, info->mti_mdt->mdt_max_mdsize);
} else {
rc = mdt_attr_set(info, mo, ma, rr->rr_flags);
if (rc)
buf->lb_len = rc;
if (buf->lb_len > 0) {
- OBD_ALLOC(buf->lb_buf, buf->lb_len);
+ OBD_ALLOC_LARGE(buf->lb_buf, buf->lb_len);
if (unlikely(buf->lb_buf == NULL))
RETURN(-ENOMEM);
_out:
if (rc <= 0 && buf->lb_buf != NULL)
- OBD_FREE(buf->lb_buf, buf->lb_len);
+ OBD_FREE_LARGE(buf->lb_buf, buf->lb_len);
return rc;
}
CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
if (obd_ioctl_getdata(&buf, &len, (void *)arg)) {
CERROR("OBD ioctl: data error\n");
- GOTO(out, err = -EINVAL);
+ RETURN(-EINVAL);
}
data = (struct obd_ioctl_data *)buf;
RETURN(-EINVAL);
}
- /* XXX allocate this more intelligently, using kmalloc when
- * appropriate */
- OBD_VMALLOC(*buf, hdr->ioc_len);
+ OBD_ALLOC_LARGE(*buf, hdr->ioc_len);
if (*buf == NULL) {
CERROR("Cannot allocate control buffer of len %d\n",
hdr->ioc_len);
if (obd_ioctl_is_invalid(data)) {
CERROR("ioctl not correctly formatted\n");
+ OBD_FREE_LARGE(*buf, hdr->ioc_len);
return -EINVAL;
}
RETURN(-EINVAL);
}
- /* XXX allocate this more intelligently, using kmalloc when
- * appropriate */
- OBD_VMALLOC(*buf, hdr.ioc_len);
+ /* When there are lots of processes calling vmalloc on multi-core
+ * system, the high lock contention will hurt performance badly,
+ * obdfilter-survey is an example, which relies on ioctl. So we'd
+ * better avoid vmalloc on ioctl path. LU-66 */
+ OBD_ALLOC_LARGE(*buf, hdr.ioc_len);
if (*buf == NULL) {
CERROR("Cannot allocate control buffer of len %d\n",
hdr.ioc_len);
err = cfs_copy_from_user(*buf, (void *)arg, hdr.ioc_len);
if ( err ) {
- OBD_VFREE(*buf, hdr.ioc_len);
+ OBD_FREE_LARGE(*buf, hdr.ioc_len);
RETURN(err);
}
if (obd_ioctl_is_invalid(data)) {
CERROR("ioctl not correctly formatted\n");
- OBD_VFREE(*buf, hdr.ioc_len);
+ OBD_FREE_LARGE(*buf, hdr.ioc_len);
RETURN(-EINVAL);
}
}
/* to control /dev/obd */
+#ifdef HAVE_UNLOCKED_IOCTL
+static long obd_class_ioctl(struct file *filp, unsigned int cmd,
+ unsigned long arg)
+#else
static int obd_class_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
+#endif
{
int err = 0;
ENTRY;
/* declare character device */
static struct file_operations obd_psdev_fops = {
.owner = THIS_MODULE,
+#if HAVE_UNLOCKED_IOCTL
+ .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */
+#else
.ioctl = obd_class_ioctl, /* ioctl */
+#endif
.open = obd_class_open, /* open */
.release = obd_class_release, /* release */
};
ENTRY;
size = sizeof(*idarray) * count;
- OBD_VMALLOC(idarray, size);
+ OBD_ALLOC_LARGE(idarray, size);
if (!idarray)
RETURN(-ENOMEM);
/* release semaphore */
cfs_mutex_up(&obd->obd_olg.olg_cat_processing);
- OBD_VFREE(idarray, size);
+ OBD_FREE_LARGE(idarray, size);
RETURN(rc);
}
LASSERT(handle_hash == NULL);
- OBD_VMALLOC(handle_hash, sizeof(*bucket) * HANDLE_HASH_SIZE);
+ OBD_ALLOC_LARGE(handle_hash, sizeof(*bucket) * HANDLE_HASH_SIZE);
if (handle_hash == NULL)
return -ENOMEM;
count = cleanup_all_handles();
- OBD_VFREE(handle_hash, sizeof(*handle_hash) * HANDLE_HASH_SIZE);
+ OBD_FREE_LARGE(handle_hash, sizeof(*handle_hash) * HANDLE_HASH_SIZE);
handle_hash = NULL;
if (count != 0)
int i;
ENTRY;
+#ifndef HAVE_UNLOCKED_IOCTL
cfs_unlock_kernel();
+#endif
memset(&dummy_oti, 0, sizeof(dummy_oti));
ldlm_lock_decref(&ack_lock->lock, ack_lock->mode);
}
+#ifndef HAVE_UNLOCKED_IOCTL
cfs_lock_kernel();
+#endif
return rc;
}
cfs_list_del(&req->rq_list);
LASSERT(req->rq_reqbuf);
LASSERT(req->rq_reqbuf_len == pool->prp_rq_size);
- OBD_FREE(req->rq_reqbuf, pool->prp_rq_size);
+ OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size);
OBD_FREE(req, sizeof(*req));
}
cfs_spin_unlock(&pool->prp_lock);
OBD_ALLOC(req, sizeof(struct ptlrpc_request));
if (!req)
return;
- OBD_ALLOC_GFP(msg, size, CFS_ALLOC_STD);
+ OBD_ALLOC_LARGE(msg, size);
if (!msg) {
OBD_FREE(req, sizeof(struct ptlrpc_request));
return;
if ((len -= mech->len) < 0)
return (G_BAD_TOK_HEADER);
- OBD_ALLOC(mech->data, mech->len);
+ OBD_ALLOC_LARGE(mech->data, mech->len);
if (!mech->data)
return (G_BUFFER_ALLOC);
memcpy(mech->data, buf, mech->len);
if (q > end || q < p)
return -1;
- OBD_ALLOC(res->data, len);
+ OBD_ALLOC_LARGE(res->data, len);
if (!res->data)
return -1;
{
char *buf;
- OBD_ALLOC(buf, keysize);
+ OBD_ALLOC_LARGE(buf, keysize);
if (buf == NULL)
return -1;
if (get_bytes(ptr, end, buf, keysize)) {
- OBD_FREE(buf, keysize);
+ OBD_FREE_LARGE(buf, keysize);
return -1;
}
}
cksum->len = ll_crypto_hash_digestsize(tfm);
- OBD_ALLOC(cksum->data, cksum->len);
+ OBD_ALLOC_LARGE(cksum->data, cksum->len);
if (!cksum->data) {
cksum->len = 0;
goto out_tfm;
}
/* decrypting */
- OBD_ALLOC(tmpbuf, bodysize);
+ OBD_ALLOC_LARGE(tmpbuf, bodysize);
if (!tmpbuf)
return GSS_S_FAILURE;
major = GSS_S_COMPLETE;
out_free:
- OBD_FREE(tmpbuf, bodysize);
+ OBD_FREE_LARGE(tmpbuf, bodysize);
rawobj_free(&cksum);
return major;
}
obj->len = len;
if (len) {
- OBD_ALLOC(obj->data, len);
+ OBD_ALLOC_LARGE(obj->data, len);
if (!obj->data) {
obj->len = 0;
RETURN(-ENOMEM);
if (obj->len) {
LASSERT(obj->data);
- OBD_FREE(obj->data, obj->len);
+ OBD_FREE_LARGE(obj->data, obj->len);
obj->len = 0;
obj->data = NULL;
} else
dest->len = src->len;
if (dest->len) {
- OBD_ALLOC(dest->data, dest->len);
+ OBD_ALLOC_LARGE(dest->data, dest->len);
if (!dest->data) {
dest->len = 0;
return -ENOMEM;
if (!alloc)
obj->data = (__u8 *) *buf;
else {
- OBD_ALLOC(obj->data, obj->len);
+ OBD_ALLOC_LARGE(obj->data, obj->len);
if (!obj->data) {
CERROR("fail to alloc %u bytes\n", obj->len);
obj->len = 0;
if (netobj->len == 0)
return 0;
- OBD_ALLOC(rawobj->data, netobj->len);
+ OBD_ALLOC_LARGE(rawobj->data, netobj->len);
if (rawobj->data == NULL)
return -ENOMEM;
/* allocate a temporary clear text buffer, same sized as token,
* we assume the final clear text size <= token size */
clear_buflen = lustre_msg_buflen(msgbuf, 1);
- OBD_ALLOC(clear_buf, clear_buflen);
+ OBD_ALLOC_LARGE(clear_buf, clear_buflen);
if (!clear_buf)
RETURN(GSS_S_FAILURE);
major = GSS_S_COMPLETE;
out_free:
- OBD_FREE(clear_buf, clear_buflen);
+ OBD_FREE_LARGE(clear_buf, clear_buflen);
RETURN(major);
}
LASSERT(req->rq_reqbuf != req->rq_clrbuf);
LASSERT(req->rq_reqbuf_len >= wiresize);
} else {
- OBD_ALLOC(req->rq_reqbuf, wiresize);
+ OBD_ALLOC_LARGE(req->rq_reqbuf, wiresize);
if (!req->rq_reqbuf)
RETURN(-ENOMEM);
req->rq_reqbuf_len = wiresize;
err_free:
if (!req->rq_pool) {
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
if (!req->rq_reqbuf) {
bufsize = size_roundup_power2(bufsize);
- OBD_ALLOC(req->rq_reqbuf, bufsize);
+ OBD_ALLOC_LARGE(req->rq_reqbuf, bufsize);
if (!req->rq_reqbuf)
RETURN(-ENOMEM);
if (!req->rq_clrbuf) {
clearsize = size_roundup_power2(clearsize);
- OBD_ALLOC(req->rq_clrbuf, clearsize);
+ OBD_ALLOC_LARGE(req->rq_clrbuf, clearsize);
if (!req->rq_clrbuf)
RETURN(-ENOMEM);
}
req->rq_clrbuf < req->rq_reqbuf ||
(char *) req->rq_clrbuf >=
(char *) req->rq_reqbuf + req->rq_reqbuf_len)
- OBD_FREE(req->rq_clrbuf, req->rq_clrbuf_len);
+ OBD_FREE_LARGE(req->rq_clrbuf, req->rq_clrbuf_len);
req->rq_clrbuf = NULL;
req->rq_clrbuf_len = 0;
if (!req->rq_pool && req->rq_reqbuf) {
LASSERT(req->rq_reqbuf_len);
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
{
bufsize = size_roundup_power2(bufsize);
- OBD_ALLOC(req->rq_repbuf, bufsize);
+ OBD_ALLOC_LARGE(req->rq_repbuf, bufsize);
if (!req->rq_repbuf)
return -ENOMEM;
void gss_free_repbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
- OBD_FREE(req->rq_repbuf, req->rq_repbuf_len);
+ OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
req->rq_repdata = NULL;
if (req->rq_reqbuf_len < newbuf_size) {
newbuf_size = size_roundup_power2(newbuf_size);
- OBD_ALLOC(newbuf, newbuf_size);
+ OBD_ALLOC_LARGE(newbuf, newbuf_size);
if (newbuf == NULL)
RETURN(-ENOMEM);
memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = newbuf;
req->rq_reqbuf_len = newbuf_size;
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 1, 0);
if (req->rq_clrbuf_len < newclrbuf_size) {
newclrbuf_size = size_roundup_power2(newclrbuf_size);
- OBD_ALLOC(newclrbuf, newclrbuf_size);
+ OBD_ALLOC_LARGE(newclrbuf, newclrbuf_size);
if (newclrbuf == NULL)
RETURN(-ENOMEM);
req->rq_clrbuf < req->rq_reqbuf ||
(char *) req->rq_clrbuf >=
(char *) req->rq_reqbuf + req->rq_reqbuf_len) {
- OBD_FREE(req->rq_clrbuf, req->rq_clrbuf_len);
+ OBD_FREE_LARGE(req->rq_clrbuf, req->rq_clrbuf_len);
}
req->rq_clrbuf = newclrbuf;
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
- OBD_ALLOC(rs, rs_size);
+ OBD_ALLOC_LARGE(rs, rs_size);
if (rs == NULL)
RETURN(-ENOMEM);
/* allocate temporary cipher buffer */
token_buflen = gss_mech_payload(gctx->gsc_mechctx, msglen, 1);
- OBD_ALLOC(token_buf, token_buflen);
+ OBD_ALLOC_LARGE(token_buf, token_buflen);
if (token_buf == NULL)
RETURN(-ENOMEM);
rc = 0;
out_free:
- OBD_FREE(token_buf, token_buflen);
+ OBD_FREE_LARGE(token_buf, token_buflen);
RETURN(rc);
}
rs->rs_svc_ctx = NULL;
if (!rs->rs_prealloc)
- OBD_FREE(rs, rs->rs_size);
+ OBD_FREE_LARGE(rs, rs->rs_size);
}
void gss_svc_free_ctx(struct ptlrpc_svc_ctx *ctx)
count = mds->mds_lov_desc.ld_tgt_count;
size = sizeof(*idarray) * count;
- OBD_VMALLOC(idarray, size);
+ OBD_ALLOC_LARGE(idarray, size);
if (!idarray)
GOTO(release_ctxt, rc = -ENOMEM);
pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
out_free:
cfs_mutex_up(&obd->obd_olg.olg_cat_processing);
- OBD_VFREE(idarray, size);
+ OBD_FREE_LARGE(idarray, size);
release_ctxt:
llog_ctxt_put(ctxt);
return rc;
/* save request message */
reqmsg_size = req->rq_reqlen;
if (reqmsg_size != 0) {
- OBD_ALLOC(reqmsg, reqmsg_size);
+ OBD_ALLOC_LARGE(reqmsg, reqmsg_size);
if (reqmsg == NULL)
return -ENOMEM;
memcpy(reqmsg, req->rq_reqmsg, reqmsg_size);
req->rq_flvr = old_flvr;
}
- OBD_FREE(reqmsg, reqmsg_size);
+ OBD_FREE_LARGE(reqmsg, reqmsg_size);
}
return rc;
}
early_size = req->rq_nob_received;
early_bufsz = size_roundup_power2(early_size);
- OBD_ALLOC(early_buf, early_bufsz);
+ OBD_ALLOC_LARGE(early_buf, early_bufsz);
if (early_buf == NULL)
GOTO(err_req, rc = -ENOMEM);
err_ctx:
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
err_buf:
- OBD_FREE(early_buf, early_bufsz);
+ OBD_FREE_LARGE(early_buf, early_bufsz);
err_req:
OBD_FREE_PTR(early_req);
RETURN(rc);
LASSERT(early_req->rq_repmsg);
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
- OBD_FREE(early_req->rq_repbuf, early_req->rq_repbuf_len);
+ OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len);
OBD_FREE_PTR(early_req);
}
int alloc_size = size_roundup_power2(msgsize);
LASSERT(!req->rq_pool);
- OBD_ALLOC(req->rq_reqbuf, alloc_size);
+ OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size);
if (!req->rq_reqbuf)
return -ENOMEM;
"req %p: reqlen %d should smaller than buflen %d\n",
req, req->rq_reqlen, req->rq_reqbuf_len);
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
msgsize = size_roundup_power2(msgsize);
- OBD_ALLOC(req->rq_repbuf, msgsize);
+ OBD_ALLOC_LARGE(req->rq_repbuf, msgsize);
if (!req->rq_repbuf)
return -ENOMEM;
{
LASSERT(req->rq_repbuf);
- OBD_FREE(req->rq_repbuf, req->rq_repbuf_len);
+ OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
if (req->rq_reqbuf_len < newmsg_size) {
alloc_size = size_roundup_power2(newmsg_size);
- OBD_ALLOC(newbuf, alloc_size);
+ OBD_ALLOC_LARGE(newbuf, alloc_size);
if (newbuf == NULL)
return -ENOMEM;
memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = req->rq_reqmsg = newbuf;
req->rq_reqbuf_len = alloc_size;
}
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
- OBD_ALLOC(rs, rs_size);
+ OBD_ALLOC_LARGE(rs, rs_size);
if (rs == NULL)
return -ENOMEM;
cfs_atomic_dec(&rs->rs_svc_ctx->sc_refcount);
if (!rs->rs_prealloc)
- OBD_FREE(rs, rs->rs_size);
+ OBD_FREE_LARGE(rs, rs->rs_size);
}
static
LASSERT(!req->rq_pool);
alloc_len = size_roundup_power2(alloc_len);
- OBD_ALLOC(req->rq_reqbuf, alloc_len);
+ OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len);
if (!req->rq_reqbuf)
RETURN(-ENOMEM);
{
ENTRY;
if (!req->rq_pool) {
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
alloc_len = size_roundup_power2(alloc_len);
- OBD_ALLOC(req->rq_repbuf, alloc_len);
+ OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len);
if (!req->rq_repbuf)
RETURN(-ENOMEM);
struct ptlrpc_request *req)
{
ENTRY;
- OBD_FREE(req->rq_repbuf, req->rq_repbuf_len);
+ OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
EXIT;
if (req->rq_reqbuf_len < newbuf_size) {
newbuf_size = size_roundup_power2(newbuf_size);
- OBD_ALLOC(newbuf, newbuf_size);
+ OBD_ALLOC_LARGE(newbuf, newbuf_size);
if (newbuf == NULL)
RETURN(-ENOMEM);
memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
req->rq_reqbuf = newbuf;
req->rq_reqbuf_len = newbuf_size;
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf,
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
- OBD_ALLOC(rs, rs_size);
+ OBD_ALLOC_LARGE(rs, rs_size);
if (rs == NULL)
RETURN(-ENOMEM);
cfs_atomic_dec(&rs->rs_svc_ctx->sc_refcount);
if (!rs->rs_prealloc)
- OBD_FREE(rs, rs->rs_size);
+ OBD_FREE_LARGE(rs, rs->rs_size);
EXIT;
}
static CFS_LIST_HEAD(ptlrpc_all_services);
cfs_spinlock_t ptlrpc_all_services_lock;
-static char *
-ptlrpc_alloc_request_buffer (int size)
-{
- char *ptr;
-
- if (size > SVC_BUF_VMALLOC_THRESHOLD)
- OBD_VMALLOC(ptr, size);
- else
- OBD_ALLOC(ptr, size);
-
- return (ptr);
-}
-
-static void
-ptlrpc_free_request_buffer (char *ptr, int size)
-{
- if (size > SVC_BUF_VMALLOC_THRESHOLD)
- OBD_VFREE(ptr, size);
- else
- OBD_FREE(ptr, size);
-}
-
struct ptlrpc_request_buffer_desc *
ptlrpc_alloc_rqbd (struct ptlrpc_service *svc)
{
rqbd->rqbd_cbid.cbid_fn = request_in_callback;
rqbd->rqbd_cbid.cbid_arg = rqbd;
CFS_INIT_LIST_HEAD(&rqbd->rqbd_reqs);
- rqbd->rqbd_buffer = ptlrpc_alloc_request_buffer(svc->srv_buf_size);
+ OBD_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_buf_size);
if (rqbd->rqbd_buffer == NULL) {
OBD_FREE_PTR(rqbd);
svc->srv_nbufs--;
cfs_spin_unlock(&svc->srv_lock);
- ptlrpc_free_request_buffer (rqbd->rqbd_buffer, svc->srv_buf_size);
+ OBD_FREE_LARGE(rqbd->rqbd_buffer, svc->srv_buf_size);
OBD_FREE_PTR(rqbd);
}
OBD_ALLOC(reqcopy, sizeof *reqcopy);
if (reqcopy == NULL)
RETURN(-ENOMEM);
- OBD_ALLOC(reqmsg, req->rq_reqlen);
+ OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen);
if (!reqmsg) {
OBD_FREE(reqcopy, sizeof *reqcopy);
RETURN(-ENOMEM);
class_export_put(reqcopy->rq_export);
out:
sptlrpc_svc_ctx_decref(reqcopy);
- OBD_FREE(reqmsg, req->rq_reqlen);
+ OBD_FREE_LARGE(reqmsg, req->rq_reqlen);
OBD_FREE(reqcopy, sizeof *reqcopy);
RETURN(rc);
}
env.le_ctx.lc_cookie = 0x6;
/* Alloc reply state structure for this one */
- OBD_ALLOC_GFP(rs, svc->srv_max_reply_size, CFS_ALLOC_STD);
+ OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size);
if (!rs) {
rc = -ENOMEM;
goto out_srv_fini;
cfs_list_for_each_entry_safe(rs, t, &service->srv_free_rs_list,
rs_list) {
cfs_list_del(&rs->rs_list);
- OBD_FREE(rs, service->srv_max_reply_size);
+ OBD_FREE_LARGE(rs, service->srv_max_reply_size);
}
/* In case somebody rearmed this in the meantime */
LUSTRE=${LUSTRE:-`dirname $0`/..}
. $LUSTRE/tests/test-framework.sh
init_test_env $@
+init_logging
nobjhi=${nobjhi:-1}
thrhi=${thrhi:-16}