Whamcloud - gitweb
Branch b1_8
authorbobijam <bobijam>
Thu, 28 May 2009 09:02:03 +0000 (09:02 +0000)
committerbobijam <bobijam>
Thu, 28 May 2009 09:02:03 +0000 (09:02 +0000)
b=19380
i=andrew.perepechko (panda)
i=johann

Reduce some functions stack use.

lustre/ldlm/ldlm_lock.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/llite/rw.c
lustre/lov/lov_obd.c
lustre/obdecho/echo_client.c
lustre/ost/ost_handler.c

index 28ce12b..667fc50 100644 (file)
@@ -478,7 +478,6 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
          */
         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 */
@@ -487,8 +486,8 @@ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc)
                          "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) ||
index 87b3eeb..7ddb18c 100644 (file)
@@ -1588,6 +1588,7 @@ repeat:
 
         /* 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
@@ -1595,14 +1596,21 @@ repeat:
                  *
                  * 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 */
@@ -1798,6 +1806,7 @@ repeat:
         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
@@ -1806,16 +1815,19 @@ repeat:
                  *
                  * 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);
@@ -1978,7 +1990,7 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *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
index e4b3342..c0a377a 100644 (file)
@@ -1533,7 +1533,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         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;
@@ -1584,11 +1584,14 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         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) {
@@ -1602,8 +1605,10 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                                 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) {
@@ -1634,11 +1639,15 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         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));
 
@@ -1655,13 +1664,15 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
 
                                 /* 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
                                  *
@@ -1724,10 +1735,10 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
 
                         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);
 
@@ -1747,6 +1758,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                 } else {
                         rc = -ENOMEM;
                 }
+                OBD_FREE_PTR(oinfo);
         }
         RETURN(rc);
 }
index 6ef4d0b..88fd1be 100644 (file)
@@ -166,6 +166,7 @@ int ll_file_punch(struct inode * inode, loff_t new_size, int srvlock)
                 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
@@ -174,16 +175,19 @@ int ll_file_punch(struct inode * inode, loff_t new_size, int srvlock)
                  *
                  * 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;
         }
index 92f8a93..78a167c 100644 (file)
@@ -1184,7 +1184,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
                       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 };
@@ -1205,6 +1205,10 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         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) &&
@@ -1219,7 +1223,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         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);
 
@@ -1240,6 +1244,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         rc = lov_fini_create_set(set, ea);
 out:
         obd_putref(exp->exp_obd);
+        OBD_FREE_PTR(oinfo);
         RETURN(rc);
 }
 
@@ -1257,7 +1262,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
                        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;
@@ -1274,9 +1279,13 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
                 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);
 
@@ -1306,6 +1315,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
         err = lov_fini_destroy_set(set);
 out:
         obd_putref(exp->exp_obd);
+        OBD_FREE_PTR(oinfo);
         RETURN(rc ? rc : err);
 }
 
index c0c822e..37b51cf 100644 (file)
@@ -705,7 +705,7 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
 {
         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;
 
@@ -732,19 +732,23 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
         /* 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 */
@@ -762,31 +766,31 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
 
                 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) {
@@ -795,15 +799,15 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
                         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;
                 }
 
@@ -819,26 +823,26 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
                                         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) {
@@ -855,6 +859,8 @@ out:
                 }
                 OBD_FREE(aps, npages * sizeof aps[0]);
         }
+free_eas:
+        OBD_FREE_PTR(eas);
 
         RETURN(rc);
 }
index 40a56ac..f89bcdf 100644 (file)
@@ -135,7 +135,7 @@ static int ost_destroy(struct obd_export *exp, struct ptlrpc_request *req,
 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;
@@ -149,12 +149,18 @@ static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
         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);
 }
 
@@ -202,7 +208,7 @@ static int ost_create(struct obd_export *exp, struct ptlrpc_request *req,
                                  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);
@@ -273,7 +279,7 @@ static void ost_punch_lock_put(struct obd_export *exp, struct obdo *oa,
 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;
@@ -287,41 +293,48 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
         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;
@@ -336,13 +349,19 @@ static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
         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);
 }
 
@@ -352,7 +371,7 @@ static int ost_setattr(struct obd_export *exp, struct ptlrpc_request *req,
         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),
@@ -364,12 +383,18 @@ static int ost_setattr(struct obd_export *exp, struct ptlrpc_request *req,
         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);
 }