*/
if ((lock->l_resource->lr_type == LDLM_IBITS) &&
(exp && !(exp->exp_connect_flags & OBD_CONNECT_IBITS))) {
- struct ldlm_resource res = *lock->l_resource;
/* Make sure all the right bits are set in this lock we
are going to pass to client */
"Inappropriate inode lock bits during "
"conversion " LPU64 "\n",
lock->l_policy_data.l_inodebits.bits);
- res.lr_type = LDLM_PLAIN;
- ldlm_res2desc(&res, &desc->l_resource);
+ ldlm_res2desc(lock->l_resource, &desc->l_resource);
+ desc->l_resource.lr_type = LDLM_PLAIN;
/* Convert "new" lock mode to something old client can
understand */
if ((lock->l_req_mode == LCK_CR) ||
/* turn off the kernel's read-ahead */
if (lock_style != LL_LOCK_STYLE_NOLOCK) {
+ struct ost_lvb *xtimes;
/* read under locks
*
* 1. update inode's atime as long as concurrent stat
*
* 2. update lsm so that next stat (via
* ll_glimpse_size) could get correct values in lsm */
- struct ost_lvb xtimes;
+ OBD_ALLOC_PTR(xtimes);
+ if (NULL == xtimes) {
+ ll_file_put_lock(inode, end, lock_style, cookie,
+ &tree, OBD_BRW_READ);
+ up_read(&lli->lli_truncate_rwsem);
+ GOTO(out, retval = -ENOMEM);
+ }
lov_stripe_lock(lsm);
LTIME_S(inode->i_atime) = LTIME_S(CURRENT_TIME);
- xtimes.lvb_atime = LTIME_S(inode->i_atime);
- obd_update_lvb(sbi->ll_osc_exp, lsm, &xtimes,
+ xtimes->lvb_atime = LTIME_S(inode->i_atime);
+ obd_update_lvb(sbi->ll_osc_exp, lsm, xtimes,
OBD_MD_FLATIME);
lov_stripe_unlock(lsm);
+ OBD_FREE_PTR(xtimes);
file->f_ra.ra_pages = 0;
/* initialize read-ahead window once per syscall */
CDEBUG(D_INFO, "Writing inode %lu, "LPSZ" bytes, offset %Lu\n",
inode->i_ino, chunk, *ppos);
if (tree_locked) {
+ struct ost_lvb *xtimes;
/* write under locks
*
* 1. update inode's mtime and ctime as long as
*
* 2. update lsm so that next stat (via
* ll_glimpse_size) could get correct values in lsm */
- struct ost_lvb xtimes;
+ OBD_ALLOC_PTR(xtimes);
+ if (NULL == xtimes)
+ GOTO(out_unlock, retval = -ENOMEM);
lov_stripe_lock(lsm);
LTIME_S(inode->i_mtime) = LTIME_S(CURRENT_TIME);
LTIME_S(inode->i_ctime) = LTIME_S(CURRENT_TIME);
- xtimes.lvb_mtime = LTIME_S(inode->i_mtime);
- xtimes.lvb_ctime = LTIME_S(inode->i_ctime);
- obd_update_lvb(sbi->ll_osc_exp, lsm, &xtimes,
+ xtimes->lvb_mtime = LTIME_S(inode->i_mtime);
+ xtimes->lvb_ctime = LTIME_S(inode->i_ctime);
+ obd_update_lvb(sbi->ll_osc_exp, lsm, xtimes,
OBD_MD_FLMTIME | OBD_MD_FLCTIME);
lov_stripe_unlock(lsm);
+ OBD_FREE_PTR(xtimes);
#ifdef HAVE_FILE_WRITEV
retval = generic_file_writev(file, iov_copy, nrsegs_copy, ppos);
}
#endif
-/* change based on
+/* change based on
* http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f0930fffa99e7fe0a0c4b6c7d9a244dc88288c27
*/
#ifdef HAVE_KERNEL_SPLICE_READ
struct lov_stripe_md *lsm = lli->lli_smd;
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data = { { 0 } };
+ struct mdc_op_data *op_data;
struct lustre_md md;
int ia_valid = attr->ia_valid;
int rc = 0;
if (lsm)
attr->ia_valid &= ~ATTR_SIZE;
+ OBD_ALLOC_PTR(op_data);
+ if (NULL == op_data)
+ RETURN(-ENOMEM);
/* We always do an MDS RPC, even if we're only changing the size;
* only the MDS knows whether truncate() should fail with -ETXTBUSY */
- ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0, NULL);
+ ll_prepare_mdc_op_data(op_data, inode, NULL, NULL, 0, 0, NULL);
- rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
+ rc = mdc_setattr(sbi->ll_mdc_exp, op_data,
attr, NULL, 0, NULL, 0, &request);
if (rc) {
rc = inode_setattr(inode, attr);
} else if (rc != -EPERM && rc != -EACCES && rc != -ETXTBSY)
CERROR("mdc_setattr fails: rc = %d\n", rc);
+ OBD_FREE_PTR(op_data);
RETURN(rc);
}
+ OBD_FREE_PTR(op_data);
rc = mdc_req2lustre_md(request, REPLY_REC_OFF, sbi->ll_osc_exp, &md);
if (rc) {
if (ia_valid & ATTR_SIZE) {
rc = ll_setattr_do_truncate(inode, attr->ia_size);
} else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info *oinfo;
struct obdo *oa;
struct lustre_handle lockh = { 0 };
obd_valid valid;
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
inode->i_ino, LTIME_S(attr->ia_mtime));
/* setting mtime to past is performed under PW
* EOF extent lock */
- oinfo.oi_policy.l_extent.start = 0;
- oinfo.oi_policy.l_extent.end = OBD_OBJECT_EOF;
+ oinfo->oi_policy.l_extent.start = 0;
+ oinfo->oi_policy.l_extent.end = OBD_OBJECT_EOF;
rc = ll_extent_lock(NULL, inode, lsm, LCK_PW,
- &oinfo.oi_policy,
+ &oinfo->oi_policy,
&lockh, 0);
- if (rc)
+ if (rc) {
+ OBD_FREE_PTR(oinfo);
RETURN(rc);
+ }
/* setattr under locks
*
obdo_from_inode(oa, inode, valid);
- oinfo.oi_oa = oa;
- oinfo.oi_md = lsm;
+ oinfo->oi_oa = oa;
+ oinfo->oi_md = lsm;
- rc = obd_setattr_rqset(sbi->ll_osc_exp, &oinfo, NULL);
+ rc = obd_setattr_rqset(sbi->ll_osc_exp, oinfo, NULL);
if (rc)
CERROR("obd_setattr_async fails: rc=%d\n", rc);
} else {
rc = -ENOMEM;
}
+ OBD_FREE_PTR(oinfo);
}
RETURN(rc);
}
oa.o_mtime = oa.o_ctime = LTIME_S(CURRENT_TIME);
oa.o_valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
} else {
+ struct ost_lvb *xtimes;
/* truncate under locks
*
* 1. update inode's mtime and ctime as long as
*
* 2. update lsm so that next stat (via
* ll_glimpse_size) could get correct values in lsm */
- struct ost_lvb xtimes;
+ OBD_ALLOC_PTR(xtimes);
+ if (NULL == xtimes)
+ RETURN(-ENOMEM);
lov_stripe_lock(lli->lli_smd);
LTIME_S(inode->i_mtime) = LTIME_S(CURRENT_TIME);
LTIME_S(inode->i_ctime) = LTIME_S(CURRENT_TIME);
- xtimes.lvb_mtime = LTIME_S(inode->i_mtime);
- xtimes.lvb_ctime = LTIME_S(inode->i_ctime);
- obd_update_lvb(ll_i2obdexp(inode), lli->lli_smd, &xtimes,
+ xtimes->lvb_mtime = LTIME_S(inode->i_mtime);
+ xtimes->lvb_ctime = LTIME_S(inode->i_ctime);
+ obd_update_lvb(ll_i2obdexp(inode), lli->lli_smd, xtimes,
OBD_MD_FLMTIME | OBD_MD_FLCTIME);
lov_stripe_unlock(lli->lli_smd);
+ OBD_FREE_PTR(xtimes);
valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
}
struct lov_stripe_md **ea, struct obd_trans_info *oti)
{
struct lov_obd *lov;
- struct obd_info oinfo;
+ struct obd_info *oinfo;
struct lov_request_set *set = NULL;
struct lov_request *req;
struct l_wait_info lwi = { 0 };
if (!lov->desc.ld_active_tgt_count)
RETURN(-EIO);
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
obd_getref(exp->exp_obd);
/* Recreate a specific object id at the given OST index */
if ((src_oa->o_valid & OBD_MD_FLFLAGS) &&
qos_statfs_update(exp->exp_obd,
cfs_time_shift_64(-lov->desc.ld_qos_maxage) + HZ, 0);
- rc = lov_prep_create_set(exp, &oinfo, ea, src_oa, oti, &set);
+ rc = lov_prep_create_set(exp, oinfo, ea, src_oa, oti, &set);
if (rc)
GOTO(out, rc);
rc = lov_fini_create_set(set, ea);
out:
obd_putref(exp->exp_obd);
+ OBD_FREE_PTR(oinfo);
RETURN(rc);
}
struct obd_export *md_exp)
{
struct lov_request_set *set;
- struct obd_info oinfo;
+ struct obd_info *oinfo;
struct lov_request *req;
struct list_head *pos;
struct lov_obd *lov;
LASSERT(oti->oti_logcookies);
}
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
lov = &exp->exp_obd->u.lov;
obd_getref(exp->exp_obd);
- rc = lov_prep_destroy_set(exp, &oinfo, oa, lsm, oti, &set);
+ rc = lov_prep_destroy_set(exp, oinfo, oa, lsm, oti, &set);
if (rc)
GOTO(out, rc);
err = lov_fini_destroy_set(set);
out:
obd_putref(exp->exp_obd);
+ OBD_FREE_PTR(oinfo);
RETURN(rc ? rc : err);
}
{
obd_count npages, i;
struct echo_async_page *eap;
- struct echo_async_state eas;
+ struct echo_async_state *eas;
int rc = 0;
struct echo_async_page **aps = NULL;
/* XXX think again with misaligned I/O */
npages = batching >> CFS_PAGE_SHIFT;
- memcpy(&eas.eas_oa, oa, sizeof(*oa));
- eas.eas_next_offset = offset;
- eas.eas_end_offset = offset + count;
- spin_lock_init(&eas.eas_lock);
- cfs_waitq_init(&eas.eas_waitq);
- eas.eas_in_flight = 0;
- eas.eas_rc = 0;
- eas.eas_lsm = lsm;
- CFS_INIT_LIST_HEAD(&eas.eas_avail);
+ OBD_ALLOC_PTR(eas);
+ if (NULL == eas)
+ return(-ENOMEM);
+
+ memcpy(&eas->eas_oa, oa, sizeof(*oa));
+ eas->eas_next_offset = offset;
+ eas->eas_end_offset = offset + count;
+ spin_lock_init(&eas->eas_lock);
+ cfs_waitq_init(&eas->eas_waitq);
+ eas->eas_in_flight = 0;
+ eas->eas_rc = 0;
+ eas->eas_lsm = lsm;
+ CFS_INIT_LIST_HEAD(&eas->eas_avail);
OBD_ALLOC(aps, npages * sizeof aps[0]);
if (aps == NULL)
- return (-ENOMEM);
+ GOTO(free_eas, rc = -ENOMEM);
/* prepare the group of pages that we're going to be keeping
* in flight */
eap->eap_magic = EAP_MAGIC;
eap->eap_page = page;
- eap->eap_eas = &eas;
- list_add_tail(&eap->eap_item, &eas.eas_avail);
+ eap->eap_eas = eas;
+ list_add_tail(&eap->eap_item, &eas->eas_avail);
aps[i] = eap;
}
/* first we spin queueing io and being woken by its completion */
- spin_lock(&eas.eas_lock);
+ spin_lock(&eas->eas_lock);
for(;;) {
int rc;
/* sleep until we have a page to send */
- spin_unlock(&eas.eas_lock);
- rc = wait_event_interruptible(eas.eas_waitq,
- eas_should_wake(&eas));
- spin_lock(&eas.eas_lock);
- if (rc && !eas.eas_rc)
- eas.eas_rc = rc;
- if (eas.eas_rc)
+ spin_unlock(&eas->eas_lock);
+ rc = wait_event_interruptible(eas->eas_waitq,
+ eas_should_wake(eas));
+ spin_lock(&eas->eas_lock);
+ if (rc && !eas->eas_rc)
+ eas->eas_rc = rc;
+ if (eas->eas_rc)
break;
- if (list_empty(&eas.eas_avail))
+ if (list_empty(&eas->eas_avail))
continue;
- eap = list_entry(eas.eas_avail.next, struct echo_async_page,
+ eap = list_entry(eas->eas_avail.next, struct echo_async_page,
eap_item);
list_del(&eap->eap_item);
- spin_unlock(&eas.eas_lock);
+ spin_unlock(&eas->eas_lock);
/* unbind the eap from its old page offset */
if (eap->eap_cookie != NULL) {
eap->eap_cookie = NULL;
}
- eas.eas_next_offset += CFS_PAGE_SIZE;
- eap->eap_off = eas.eas_next_offset;
+ eas->eas_next_offset += CFS_PAGE_SIZE;
+ eap->eap_off = eas->eas_next_offset;
rc = obd_prep_async_page(exp, lsm, NULL, eap->eap_page,
eap->eap_off, &ec_async_page_ops,
eap, &eap->eap_cookie, 1, NULL);
if (rc) {
- spin_lock(&eas.eas_lock);
- eas.eas_rc = rc;
+ spin_lock(&eas->eas_lock);
+ eas->eas_rc = rc;
break;
}
rw, 0, CFS_PAGE_SIZE, 0,
ASYNC_READY | ASYNC_URGENT |
ASYNC_COUNT_STABLE);
- spin_lock(&eas.eas_lock);
- if (rc && !eas.eas_rc) {
- eas.eas_rc = rc;
+ spin_lock(&eas->eas_lock);
+ if (rc && !eas->eas_rc) {
+ eas->eas_rc = rc;
break;
}
- eas.eas_in_flight++;
- if (eas.eas_next_offset == eas.eas_end_offset)
+ eas->eas_in_flight++;
+ if (eas->eas_next_offset == eas->eas_end_offset)
break;
}
/* still hold the eas_lock here.. */
/* now we just spin waiting for all the rpcs to complete */
- while(eas.eas_in_flight) {
- spin_unlock(&eas.eas_lock);
- wait_event_interruptible(eas.eas_waitq,
- eas.eas_in_flight == 0);
- spin_lock(&eas.eas_lock);
+ while(eas->eas_in_flight) {
+ spin_unlock(&eas->eas_lock);
+ wait_event_interruptible(eas->eas_waitq,
+ eas->eas_in_flight == 0);
+ spin_lock(&eas->eas_lock);
}
- spin_unlock(&eas.eas_lock);
+ spin_unlock(&eas->eas_lock);
out:
if (aps != NULL) {
}
OBD_FREE(aps, npages * sizeof aps[0]);
}
+free_eas:
+ OBD_FREE_PTR(eas);
RETURN(rc);
}
static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
{
struct ost_body *body, *repbody;
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info *oinfo;
__u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
int rc;
ENTRY;
if (rc)
RETURN(rc);
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
- oinfo.oi_oa = &repbody->oa;
- req->rq_status = obd_getattr(exp, &oinfo);
+ oinfo->oi_oa = &repbody->oa;
+ req->rq_status = obd_getattr(exp, oinfo);
+
+ OBD_FREE_PTR(oinfo);
RETURN(0);
}
sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
oti->oti_logcookies = &repbody->oa.o_lcookie;
-
+
req->rq_status = obd_create(exp, &repbody->oa, NULL, oti);
//obd_log_cancel(conn, NULL, 1, oti->oti_logcookies, 0);
RETURN(0);
static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
struct obd_trans_info *oti)
{
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info *oinfo;
struct ost_body *body, *repbody;
__u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
int rc;
body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
LASSERT(body != NULL);
- oinfo.oi_oa = &body->oa;
- oinfo.oi_policy.l_extent.start = oinfo.oi_oa->o_size;
- oinfo.oi_policy.l_extent.end = oinfo.oi_oa->o_blocks;
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
+ oinfo->oi_oa = &body->oa;
+ oinfo->oi_policy.l_extent.start = oinfo->oi_oa->o_size;
+ oinfo->oi_policy.l_extent.end = oinfo->oi_oa->o_blocks;
- if ((oinfo.oi_oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
+ if ((oinfo->oi_oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
- RETURN(-EINVAL);
+ GOTO(out, rc = -EINVAL);
rc = lustre_pack_reply(req, 2, size, NULL);
if (rc)
- RETURN(rc);
+ GOTO(out, rc);
repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*repbody));
- rc = ost_punch_lock_get(exp, oinfo.oi_oa, &lh);
+ rc = ost_punch_lock_get(exp, oinfo->oi_oa, &lh);
if (rc == 0) {
- if (oinfo.oi_oa->o_valid & OBD_MD_FLFLAGS &&
- oinfo.oi_oa->o_flags == OBD_FL_TRUNCLOCK)
+ if (oinfo->oi_oa->o_valid & OBD_MD_FLFLAGS &&
+ oinfo->oi_oa->o_flags == OBD_FL_TRUNCLOCK)
/*
* If OBD_FL_TRUNCLOCK is the only bit set in
* ->o_flags, clear OBD_MD_FLFLAGS to avoid falling
* through filter_setattr() to filter_iocontrol().
*/
- oinfo.oi_oa->o_valid &= ~OBD_MD_FLFLAGS;
+ oinfo->oi_oa->o_valid &= ~OBD_MD_FLFLAGS;
- req->rq_status = obd_punch(exp, &oinfo, oti, NULL);
- ost_punch_lock_put(exp, oinfo.oi_oa, &lh);
+ req->rq_status = obd_punch(exp, oinfo, oti, NULL);
+ ost_punch_lock_put(exp, oinfo->oi_oa, &lh);
}
- repbody->oa = *oinfo.oi_oa;
+
+ repbody->oa = *oinfo->oi_oa;
+out:
+ OBD_FREE_PTR(oinfo);
RETURN(rc);
}
static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
{
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info *oinfo;
struct ost_body *body, *repbody;
__u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
int rc;
if (rc)
RETURN(rc);
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*repbody));
- oinfo.oi_oa = &body->oa;
- req->rq_status = obd_sync(exp, &oinfo, repbody->oa.o_size,
+ oinfo->oi_oa = &body->oa;
+ req->rq_status = obd_sync(exp, oinfo, repbody->oa.o_size,
repbody->oa.o_blocks, NULL);
- repbody->oa = *oinfo.oi_oa;
+ repbody->oa = *oinfo->oi_oa;
+
+ OBD_FREE_PTR(oinfo);
RETURN(0);
}
struct ost_body *body, *repbody;
__u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
int rc;
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info *oinfo = NULL;
ENTRY;
body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
if (rc)
RETURN(rc);
+ OBD_ALLOC_PTR(oinfo);
+ if (NULL == oinfo)
+ RETURN(-ENOMEM);
+
repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*repbody));
memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
- oinfo.oi_oa = &repbody->oa;
- req->rq_status = obd_setattr(exp, &oinfo, oti);
+ oinfo->oi_oa = &repbody->oa;
+ req->rq_status = obd_setattr(exp, oinfo, oti);
+
+ OBD_FREE_PTR(oinfo);
RETURN(0);
}