From 0506364b28feeba2a3433cf4639e42e329eb38d9 Mon Sep 17 00:00:00 2001 From: yury Date: Wed, 17 Nov 2004 09:03:54 +0000 Subject: [PATCH] - lots of fixes about obdo allocating. By now, there are not obdos allocated on stack. This decreased stack consumption substantialy and 16K is enough. --- lustre/cmobd/cm_oss_reint.c | 2 +- lustre/llite/file.c | 30 +++++++++++--------- lustre/llite/llite_close.c | 32 +++++++++++++-------- lustre/llite/llite_lib.c | 22 +++++++++------ lustre/llite/rw.c | 68 +++++++++++++++++++++++++++------------------ lustre/llite/rw24.c | 29 +++++++++++-------- lustre/lov/lov_obd.c | 53 ++++++++++++++++++++++------------- lustre/mdc/mdc_request.c | 4 +-- lustre/mds/mds_lov.c | 29 +++++++++++-------- lustre/obdfilter/filter.c | 51 +++++++++++++++++++++------------- 10 files changed, 195 insertions(+), 125 deletions(-) diff --git a/lustre/cmobd/cm_oss_reint.c b/lustre/cmobd/cm_oss_reint.c index aec0557..88f9e6d 100644 --- a/lustre/cmobd/cm_oss_reint.c +++ b/lustre/cmobd/cm_oss_reint.c @@ -104,7 +104,7 @@ static int cmobd_create_reint(struct obd_device *obd, void *rec) struct obd_export *exp = cmobd->master_exp; struct lov_stripe_md *lsm; struct obd_trans_info oti = { 0 }; - struct obdo *oa=(struct obdo*)rec; + struct obdo *oa = (struct obdo *)rec; int rc; ENTRY; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 9bc687f..ba5695f 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -39,7 +39,7 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, struct ll_file_data *fd = file->private_data; struct ptlrpc_request *req = NULL; struct obd_client_handle *och = &fd->fd_mds_och; - struct obdo obdo; + struct obdo *obdo = NULL; int rc; ENTRY; @@ -51,18 +51,23 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, &fd->fd_cwlockh); } - obdo.o_id = inode->i_ino; - obdo.o_valid = OBD_MD_FLID; - obdo_from_inode(&obdo, inode, (OBD_MD_FLTYPE | OBD_MD_FLMODE | - OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | - OBD_MD_FLATIME | OBD_MD_FLMTIME | - OBD_MD_FLCTIME)); + obdo = obdo_alloc(); + if (obdo == NULL) + RETURN(-ENOMEM); + + obdo->o_id = inode->i_ino; + obdo->o_valid = OBD_MD_FLID; + obdo_from_inode(obdo, inode, (OBD_MD_FLTYPE | OBD_MD_FLMODE | + OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | + OBD_MD_FLATIME | OBD_MD_FLMTIME | + OBD_MD_FLCTIME)); if (0 /* ll_is_inode_dirty(inode) */) { - obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES; - obdo.o_valid |= OBD_MD_FLFLAGS; + obdo->o_flags = MDS_BFLAG_UNCOMMITTED_WRITES; + obdo->o_valid |= OBD_MD_FLFLAGS; } - obdo.o_mds = id_group(&ll_i2info(inode)->lli_id); - rc = md_close(lmv_exp, &obdo, och, &req); + obdo->o_mds = id_group(&ll_i2info(inode)->lli_id); + rc = md_close(lmv_exp, obdo, och, &req); + obdo_free(obdo); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get @@ -84,8 +89,7 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, ptlrpc_req_finished(req); och->och_fh.cookie = DEAD_HANDLE_MAGIC; file->private_data = NULL; - OBD_SLAB_FREE(fd, ll_file_data_slab, sizeof *fd); - + OBD_SLAB_FREE(fd, ll_file_data_slab, sizeof(*fd)); RETURN(rc); } diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 1500678..bfaa156 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -123,12 +123,19 @@ static void ll_close_done_writing(struct inode *inode) struct ll_inode_info *lli = ll_i2info(inode); ldlm_policy_data_t policy = { .l_extent = {0, OBD_OBJECT_EOF } }; struct lustre_handle lockh = { 0 }; - struct obdo obdo; - obd_valid valid; + struct obdo *obdo = NULL; int rc, ast_flags = 0; + obd_valid valid; ENTRY; - memset(&obdo, 0, sizeof(obdo)); + obdo = obdo_alloc(); + if (obdo == NULL) { + CERROR("cannot allocate obdo, error %d\n", + -ENOMEM); + EXIT; + return; + } + if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags)) goto rpc; @@ -141,7 +148,7 @@ static void ll_close_done_writing(struct inode *inode) GOTO(out, rc); } - rc = ll_lsm_getattr(ll_i2obdexp(inode), lli->lli_smd, &obdo); + rc = ll_lsm_getattr(ll_i2obdexp(inode), lli->lli_smd, obdo); if (rc) { CERROR("inode_getattr failed (%d): unable to send DONE_WRITING " "for inode %lu/%u\n", rc, inode->i_ino, @@ -150,7 +157,7 @@ static void ll_close_done_writing(struct inode *inode) GOTO(out, rc); } - obdo_refresh_inode(inode, &obdo, valid); + obdo_refresh_inode(inode, obdo, valid); CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %lu, blksize %lu\n", lli->lli_smd->lsm_object_id, inode->i_size, inode->i_blocks, @@ -162,14 +169,15 @@ static void ll_close_done_writing(struct inode *inode) if (rc != ELDLM_OK) CERROR("unlock failed (%d)? proceeding anyways...\n", rc); - rpc: - obdo.o_id = inode->i_ino; - obdo.o_size = inode->i_size; - obdo.o_blocks = inode->i_blocks; - obdo.o_valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; +rpc: + obdo->o_id = inode->i_ino; + obdo->o_size = inode->i_size; + obdo->o_blocks = inode->i_blocks; + obdo->o_valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; - rc = md_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &obdo); - out: + rc = md_done_writing(ll_i2sbi(inode)->ll_mdc_exp, obdo); +out: + obdo_free(obdo); } #endif diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index b6711a7..d7be33c 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1062,18 +1062,24 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) rc = err; } } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) { - struct obdo oa; + struct obdo *oa = NULL; CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n", inode->i_ino, LTIME_S(attr->ia_mtime)); - oa.o_id = lsm->lsm_object_id; - oa.o_gr = lsm->lsm_object_gr; - oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; - obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | - OBD_MD_FLMTIME | OBD_MD_FLCTIME); - rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL); + + oa = obdo_alloc(); + if (oa == NULL) + RETURN(-ENOMEM); + + oa->o_id = lsm->lsm_object_id; + oa->o_gr = lsm->lsm_object_gr; + oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; + obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | + OBD_MD_FLMTIME | OBD_MD_FLCTIME); + rc = obd_setattr(sbi->ll_lov_exp, oa, lsm, NULL); + obdo_free(oa); if (rc) - CERROR("obd_setattr fails: rc=%d\n", rc); + CERROR("obd_setattr fails: rc = %d\n", rc); } RETURN(rc); } diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 77c5173..9a52fab 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -110,9 +110,10 @@ static int ll_brw(int cmd, struct inode *inode, struct obdo *oa, void ll_truncate(struct inode *inode) { struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd; - struct obdo oa; + struct obdo *oa = NULL; int rc; ENTRY; + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -123,26 +124,34 @@ void ll_truncate(struct inode *inode) return; } - oa.o_id = lsm->lsm_object_id; - oa.o_gr = lsm->lsm_object_gr; - oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; - obdo_from_inode(&oa, inode, OBD_MD_FLTYPE|OBD_MD_FLMODE|OBD_MD_FLATIME| - OBD_MD_FLMTIME | OBD_MD_FLCTIME); + oa = obdo_alloc(); + if (oa == NULL) { + CERROR("cannot alloc oa, error %d\n", + -ENOMEM); + EXIT; + return; + } + + oa->o_id = lsm->lsm_object_id; + oa->o_gr = lsm->lsm_object_gr; + oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; + obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE | + OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME); CDEBUG(D_INFO, "calling punch for "LPX64" (all bytes after %Lu)\n", - oa.o_id, inode->i_size); + oa->o_id, inode->i_size); /* truncate == punch from new size to absolute end of file */ /* NB: obd_punch must be called with i_sem held! It updates the kms! */ - rc = obd_punch(ll_i2obdexp(inode), &oa, lsm, inode->i_size, + rc = obd_punch(ll_i2obdexp(inode), oa, lsm, inode->i_size, OBD_OBJECT_EOF, NULL); if (rc) CERROR("obd_truncate fails (%d) ino %lu\n", rc, inode->i_ino); else - obdo_to_inode(inode, &oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | - OBD_MD_FLATIME | OBD_MD_FLMTIME | - OBD_MD_FLCTIME); + obdo_to_inode(inode, oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | + OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME); + obdo_free(oa); EXIT; return; } /* ll_truncate */ @@ -155,8 +164,8 @@ int ll_prepare_write(struct file *file, struct page *page, unsigned from, struct ll_inode_info *lli = ll_i2info(inode); struct lov_stripe_md *lsm = lli->lli_smd; obd_off offset = ((obd_off)page->index) << PAGE_SHIFT; + struct obdo *oa = NULL; struct brw_page pga; - struct obdo oa; __u64 kms; int rc = 0; ENTRY; @@ -170,25 +179,29 @@ int ll_prepare_write(struct file *file, struct page *page, unsigned from, pga.count = PAGE_SIZE; pga.flag = 0; - oa.o_id = lsm->lsm_object_id; - oa.o_gr = lsm->lsm_object_gr; - oa.o_mode = inode->i_mode; - oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE - | OBD_MD_FLTYPE | OBD_MD_FLGROUP; + oa = obdo_alloc(); + if (oa == NULL) + RETURN(-ENOMEM); + + oa->o_id = lsm->lsm_object_id; + oa->o_gr = lsm->lsm_object_gr; + oa->o_mode = inode->i_mode; + oa->o_valid = OBD_MD_FLID | OBD_MD_FLMODE | + OBD_MD_FLTYPE | OBD_MD_FLGROUP; - rc = obd_brw(OBD_BRW_CHECK, ll_i2obdexp(inode), &oa, lsm, 1, &pga, - NULL); + rc = obd_brw(OBD_BRW_CHECK, ll_i2obdexp(inode), oa, lsm, + 1, &pga, NULL); if (rc) - RETURN(rc); + GOTO(out_free_oa, rc); if (PageUptodate(page)) - RETURN(0); + GOTO(out_free_oa, 0); /* We're completely overwriting an existing page, so _don't_ set it up * to date until commit_write */ if (from == 0 && to == PAGE_SIZE) { POISON_PAGE(page, 0x11); - RETURN(0); + GOTO(out_free_oa, 0); } /* If are writing to a new page, no need to read old data. The extent @@ -202,18 +215,19 @@ int ll_prepare_write(struct file *file, struct page *page, unsigned from, } /* XXX could be an async ocp read.. read-ahead? */ - rc = ll_brw(OBD_BRW_READ, inode, &oa, page, 0); + rc = ll_brw(OBD_BRW_READ, inode, oa, page, 0); if (rc == 0) { /* bug 1598: don't clobber blksize */ - oa.o_valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLKSZ); - obdo_refresh_inode(inode, &oa, oa.o_valid); + oa->o_valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLKSZ); + obdo_refresh_inode(inode, oa, oa->o_valid); } EXIT; - prepare_done: +prepare_done: if (rc == 0) SetPageUptodate(page); - +out_free_oa: + obdo_free(oa); return rc; } diff --git a/lustre/llite/rw24.c b/lustre/llite/rw24.c index df040c5..9c95c94 100644 --- a/lustre/llite/rw24.c +++ b/lustre/llite/rw24.c @@ -49,14 +49,13 @@ #include "llite_internal.h" #include -static int ll_direct_IO_24(int rw, #ifdef HAVE_DIO_FILE - struct file *file, +static int ll_direct_IO_24(int rw, struct file *file, struct kiobuf *iobuf, + unsigned long blocknr, int blocksize) #else - struct inode *inode, +static int ll_direct_IO_24(int rw, struct inode *inode, struct kiobuf *iobuf, + unsigned long blocknr, int blocksize) #endif - struct kiobuf *iobuf, unsigned long blocknr, - int blocksize) { #ifdef HAVE_DIO_FILE struct inode *inode = file->f_dentry->d_inode; @@ -65,7 +64,7 @@ static int ll_direct_IO_24(int rw, struct lov_stripe_md *lsm = lli->lli_smd; struct brw_page *pga; struct ptlrpc_request_set *set; - struct obdo oa; + struct obdo *oa = NULL; int length, i, flags, rc = 0; loff_t offset; ENTRY; @@ -101,7 +100,13 @@ static int ll_direct_IO_24(int rw, POISON_PAGE(iobuf->maplist[i], 0x0d); } - ll_inode_fill_obdo(inode, rw, &oa); + + oa = obdo_alloc(); + if (oa == NULL) { + ptlrpc_set_destroy(set); + GOTO(out_free_pga, -ENOMEM); + } + ll_inode_fill_obdo(inode, rw, oa); if (rw == WRITE) lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, @@ -110,7 +115,7 @@ static int ll_direct_IO_24(int rw, lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, LPROC_LL_DIRECT_READ, iobuf->length); rc = obd_brw_async(rw == WRITE ? OBD_BRW_WRITE : OBD_BRW_READ, - ll_i2obdexp(inode), &oa, lsm, iobuf->nr_pages, pga, + ll_i2obdexp(inode), oa, lsm, iobuf->nr_pages, pga, set, NULL); if (rc) { CDEBUG(rc == -ENOSPC ? D_INODE : D_ERROR, @@ -131,11 +136,13 @@ static int ll_direct_IO_24(int rw, } if (rc == 0) { rc = iobuf->length; - obdo_to_inode(inode, &oa, OBD_MD_FLBLOCKS); + obdo_to_inode(inode, oa, OBD_MD_FLBLOCKS); } - + obdo_free(oa); + EXIT; +out_free_pga: OBD_FREE(pga, sizeof(*pga) * iobuf->nr_pages); - RETURN(rc); + return rc; } struct address_space_operations ll_aops = { diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index e58d7162..2c91efc 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1185,9 +1185,9 @@ static int lov_revalidate_policy(struct lov_obd *lov, struct lov_stripe_md *lsm) static int lov_destroy(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *lsm, struct obd_trans_info *oti) { - struct obdo tmp; - struct lov_obd *lov; + struct obdo *tmp = NULL; struct lov_oinfo *loi; + struct lov_obd *lov; int rc = 0, i; ENTRY; @@ -1210,10 +1210,14 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, continue; } - memcpy(&tmp, oa, sizeof(tmp)); - tmp.o_id = loi->loi_id; - err = obd_destroy(lov->tgts[loi->loi_ost_idx].ltd_exp, &tmp, - NULL, oti); + tmp = obdo_alloc(); + if (tmp == NULL) + RETURN(-ENOMEM); + memcpy(tmp, oa, sizeof(*tmp)); + tmp->o_id = loi->loi_id; + err = obd_destroy(lov->tgts[loi->loi_ost_idx].ltd_exp, + tmp, NULL, oti); + obdo_free(tmp); if (err && lov->tgts[loi->loi_ost_idx].active) { CDEBUG(D_INODE, "error: destroying objid "LPX64" subobj " LPX64" on OST idx %d: rc = %d\n", @@ -1228,10 +1232,10 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa, static int lov_getattr(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *lsm) { - struct obdo tmp; - struct lov_obd *lov; - struct lov_oinfo *loi; + struct obdo *tmp = NULL; int i, rc = 0, set = 0; + struct lov_oinfo *loi; + struct lov_obd *lov; ENTRY; if (lsm_bad_magic(lsm)) @@ -1255,22 +1259,27 @@ static int lov_getattr(struct obd_export *exp, struct obdo *oa, CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx " "%u\n", oa->o_id, i, loi->loi_id, loi->loi_ost_idx); /* create data objects with "parent" OA */ - memcpy(&tmp, oa, sizeof(tmp)); - tmp.o_id = loi->loi_id; + tmp = obdo_alloc(); + if (tmp == NULL) + RETURN(-ENOMEM); + memcpy(tmp, oa, sizeof(*tmp)); + tmp->o_id = loi->loi_id; - err = obd_getattr(lov->tgts[loi->loi_ost_idx].ltd_exp, &tmp, - NULL); + err = obd_getattr(lov->tgts[loi->loi_ost_idx].ltd_exp, + tmp, NULL); if (err) { if (lov->tgts[loi->loi_ost_idx].active) { CERROR("error: getattr objid "LPX64" subobj " LPX64" on OST idx %d: rc = %d\n", oa->o_id, loi->loi_id, loi->loi_ost_idx, err); + obdo_free(tmp); RETURN(err); } } else { - lov_merge_attrs(oa, &tmp, tmp.o_valid, lsm, i, &set); + lov_merge_attrs(oa, tmp, tmp->o_valid, lsm, i, &set); } + obdo_free(tmp); } if (!set) rc = -EIO; @@ -1729,9 +1738,9 @@ static int lov_punch(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *lsm, obd_off start, obd_off end, struct obd_trans_info *oti) { - struct obdo tmp; - struct lov_obd *lov; + struct obdo *tmp = NULL; struct lov_oinfo *loi; + struct lov_obd *lov; int rc = 0, i; ENTRY; @@ -1755,11 +1764,15 @@ static int lov_punch(struct obd_export *exp, struct obdo *oa, continue; /* create data objects with "parent" OA */ - memcpy(&tmp, oa, sizeof(tmp)); - tmp.o_id = loi->loi_id; + tmp = obdo_alloc(); + if (tmp == NULL) + RETURN(-ENOMEM); + memcpy(tmp, oa, sizeof(*tmp)); + tmp->o_id = loi->loi_id; - err = obd_punch(lov->tgts[loi->loi_ost_idx].ltd_exp, &tmp, NULL, - starti, endi, NULL); + err = obd_punch(lov->tgts[loi->loi_ost_idx].ltd_exp, + tmp, NULL, starti, endi, NULL); + obdo_free(tmp); if (err) { if (lov->tgts[loi->loi_ost_idx].active) { CERROR("error: punch objid "LPX64" subobj "LPX64 diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 1632fcb..6701914 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1276,8 +1276,8 @@ out_req: } int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *ea, obd_count oa_bufs, - struct brw_page *pgarr, struct obd_trans_info *oti) + struct lov_stripe_md *ea, obd_count oa_bufs, + struct brw_page *pgarr, struct obd_trans_info *oti) { struct ptlrpc_bulk_desc *desc; struct niobuf_remote *niobuf; diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index c68b151..75261a5 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -121,26 +121,33 @@ int mds_lov_write_objids(struct obd_device *obd) int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid) { int rc; - struct obdo oa; + struct obdo *oa = NULL; struct obd_trans_info oti = {0}; struct lov_stripe_md *empty_ea = NULL; ENTRY; LASSERT(mds->mds_lov_objids != NULL); - /* This create will in fact either create or destroy: If the OST is + /* + * this create will in fact either create or destroy: If the OST is * missing objects below this ID, they will be created. If it finds - * objects above this ID, they will be removed. */ - memset(&oa, 0, sizeof(oa)); - oa.o_gr = FILTER_GROUP_FIRST_MDS + mds->mds_num; - oa.o_valid = OBD_MD_FLFLAGS | OBD_MD_FLGROUP; - oa.o_flags = OBD_FL_DELORPHAN; + * objects above this ID, they will be removed. + */ + OBD_ALLOC(oa, sizeof(*oa)); + if (oa == NULL) + RETURN(-ENOMEM); + + memset(oa, 0, sizeof(*oa)); + oa->o_gr = FILTER_GROUP_FIRST_MDS + mds->mds_num; + oa->o_valid = OBD_MD_FLFLAGS | OBD_MD_FLGROUP; + oa->o_flags = OBD_FL_DELORPHAN; + if (ost_uuid != NULL) { - memcpy(&oa.o_inline, ost_uuid, sizeof(*ost_uuid)); - oa.o_valid |= OBD_MD_FLINLINE; + memcpy(&oa->o_inline, ost_uuid, sizeof(*ost_uuid)); + oa->o_valid |= OBD_MD_FLINLINE; } - rc = obd_create(mds->mds_lov_exp, &oa, &empty_ea, &oti); - + rc = obd_create(mds->mds_lov_exp, oa, &empty_ea, &oti); + OBD_FREE(oa, sizeof(*oa)); RETURN(rc); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index a630efc..49e73aa 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2161,44 +2161,55 @@ static int filter_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, static void filter_destroy_precreated(struct obd_export *exp, struct obdo *oa, struct filter_obd *filter) { - struct obdo doa = { 0, }; /* XXX obdo on stack */ + struct obdo *doa = NULL; __u64 last, id; ENTRY; + LASSERT(oa); - - LASSERT(oa->o_valid & OBD_MD_FLGROUP); LASSERT(oa->o_gr != 0); - doa.o_mode = S_IFREG; - doa.o_gr = oa->o_gr; - doa.o_valid = oa->o_valid & (OBD_MD_FLGROUP | OBD_MD_FLID); + LASSERT(oa->o_valid & OBD_MD_FLGROUP); - set_bit(doa.o_gr, &filter->fo_destroys_in_progress); - down(&filter->fo_create_locks[doa.o_gr]); - if (!test_bit(doa.o_gr, &filter->fo_destroys_in_progress)) { - CERROR("%s:["LPU64"] destroy_in_progress already cleared\n", - exp->exp_obd->obd_name, doa.o_gr); - up(&filter->fo_create_locks[doa.o_gr]); + OBD_ALLOC(doa, sizeof(*doa)); + if (doa == NULL) { + CERROR("cannot allocate doa, error %d\n", + -ENOMEM); EXIT; return; } - last = filter_last_id(filter, doa.o_gr); + memset(doa, 0, sizeof(*doa)); + doa->o_mode = S_IFREG; + doa->o_gr = oa->o_gr; + doa->o_valid = oa->o_valid & (OBD_MD_FLGROUP | OBD_MD_FLID); + + set_bit(doa->o_gr, &filter->fo_destroys_in_progress); + down(&filter->fo_create_locks[doa->o_gr]); + if (!test_bit(doa->o_gr, &filter->fo_destroys_in_progress)) { + CERROR("%s:["LPU64"] destroy_in_progress already cleared\n", + exp->exp_obd->obd_name, doa->o_gr); + up(&filter->fo_create_locks[doa->o_gr]); + GOTO(out_free_doa, 0); + } + + last = filter_last_id(filter, doa->o_gr); CWARN("%s:["LPU64"] deleting orphan objects from "LPU64" to "LPU64"\n", - exp->exp_obd->obd_name, doa.o_gr, oa->o_id + 1, last); + exp->exp_obd->obd_name, doa->o_gr, oa->o_id + 1, last); for (id = oa->o_id + 1; id <= last; id++) { - doa.o_id = id; - filter_destroy(exp, &doa, NULL, NULL); + doa->o_id = id; + filter_destroy(exp, doa, NULL, NULL); } CDEBUG(D_HA, "%s:["LPU64"] after destroy: set last_objids = "LPU64"\n", - exp->exp_obd->obd_name, doa.o_gr, oa->o_id); + exp->exp_obd->obd_name, doa->o_gr, oa->o_id); - filter_set_last_id(filter, doa.o_gr, oa->o_id); + filter_set_last_id(filter, doa->o_gr, oa->o_id); - clear_bit(doa.o_gr, &filter->fo_destroys_in_progress); - up(&filter->fo_create_locks[doa.o_gr]); + clear_bit(doa->o_gr, &filter->fo_destroys_in_progress); + up(&filter->fo_create_locks[doa->o_gr]); EXIT; +out_free_doa: + OBD_FREE(doa, sizeof(*doa)); } /* returns a negative error or a nonnegative number of files to create */ -- 1.8.3.1