From 037bbd62aae33db3141aa2ec807092a5c07ad0b9 Mon Sep 17 00:00:00 2001 From: jxiong Date: Thu, 19 Nov 2009 03:06:29 +0000 Subject: [PATCH] b=19906 r=wangdi,ericm IO segfault fix --- lustre/lov/lov_io.c | 30 ++++++++++++++++-------------- lustre/lov/lov_lock.c | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 783daca..3634b4b 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -148,16 +148,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, sub->sub_io_initialized = 0; sub->sub_borrowed = 0; - /* - * First sub-io. Use ->lis_single_subio and current environment, to - * avoid dynamic allocation. - */ - if (lio->lis_active_subios == 0) { - sub->sub_io = &lio->lis_single_subio; - lio->lis_single_subio_index = stripe; - sub->sub_env = cl_env_get(&sub->sub_refcheck); - LASSERT(sub->sub_env == env); - } else if (lio->lis_mem_frozen) { + if (lio->lis_mem_frozen) { LASSERT(mutex_is_locked(&ld->ld_mutex)); sub->sub_io = &ld->ld_emrg[stripe]->emrg_subio; sub->sub_env = ld->ld_emrg[stripe]->emrg_env; @@ -169,12 +160,23 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, cookie = cl_env_reenter(); sub->sub_env = cl_env_get(&sub->sub_refcheck); cl_env_reexit(cookie); - - OBD_ALLOC_PTR(sub->sub_io); if (IS_ERR(sub->sub_env)) result = PTR_ERR(sub->sub_env); - else if (sub->sub_io == NULL) - result = -ENOMEM; + + if (result == 0) { + /* + * First sub-io. Use ->lis_single_subio to + * avoid dynamic allocation. + */ + if (lio->lis_active_subios == 0) { + sub->sub_io = &lio->lis_single_subio; + lio->lis_single_subio_index = stripe; + } else { + OBD_ALLOC_PTR(sub->sub_io); + if (sub->sub_io == NULL) + result = -ENOMEM; + } + } } if (result == 0) { diff --git a/lustre/lov/lov_lock.c b/lustre/lov/lov_lock.c index bc6ab44..4a02d03 100644 --- a/lustre/lov/lov_lock.c +++ b/lustre/lov/lov_lock.c @@ -77,7 +77,7 @@ static struct lov_sublock_env *lov_sublock_env_get(const struct lu_env *env, * they are not initialized at all. As a temp fix, in this case, * we still borrow the parent's env to call sublock operations. */ - if (!cl_object_same(io->ci_obj, parent->cll_descr.cld_obj)) { + if (!io || !cl_object_same(io->ci_obj, parent->cll_descr.cld_obj)) { subenv->lse_env = env; subenv->lse_io = io; subenv->lse_sub = NULL; -- 1.8.3.1