X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flov_io.c;h=2d61ee18809c339df35a622efb650da9b74091d9;hb=08ac163a04f0a9c5e4348174aa835796e2190e28;hp=4ab7d2515389ba5344d89db590331ed6ebb9089c;hpb=89f659febd4220cc517a181f8ac6cc52235b76ca;p=fs%2Flustre-release.git diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 4ab7d25..2d61ee1 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -42,26 +42,17 @@ #include "lov_cl_internal.h" -/** \addtogroup lov lov @{ */ +/** \addtogroup lov + * @{ + */ -static void lov_sub_enter(struct lov_io_sub *sub) +static inline void lov_sub_enter(struct lov_io_sub *sub) { - ENTRY; - if (sub->sub_reenter++ == 0) { - sub->sub_cookie = cl_env_reenter(); - cl_env_implant(sub->sub_env, &sub->sub_refcheck2); - } - EXIT; + sub->sub_reenter++; } - -static void lov_sub_exit(struct lov_io_sub *sub) +static inline void lov_sub_exit(struct lov_io_sub *sub) { - ENTRY; - if (--sub->sub_reenter == 0) { - cl_env_unplant(sub->sub_env, &sub->sub_refcheck2); - cl_env_reexit(sub->sub_cookie); - } - EXIT; + sub->sub_reenter--; } static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, @@ -97,12 +88,16 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, struct cl_io *parent = lio->lis_cl.cis_io; switch(io->ci_type) { - case CIT_TRUNC: { - size_t new_size = parent->u.ci_truncate.tr_size; - - new_size = lov_size_to_stripe(lsm, new_size, stripe); - io->u.ci_truncate.tr_capa = parent->u.ci_truncate.tr_capa; - io->u.ci_truncate.tr_size = new_size; + case CIT_SETATTR: { + io->u.ci_setattr.sa_attr = parent->u.ci_setattr.sa_attr; + io->u.ci_setattr.sa_valid = parent->u.ci_setattr.sa_valid; + io->u.ci_setattr.sa_capa = parent->u.ci_setattr.sa_capa; + if (cl_io_is_trunc(io)) { + loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size; + + new_size = lov_size_to_stripe(lsm, new_size, stripe); + io->u.ci_setattr.sa_attr.lvb_size = new_size; + } break; } case CIT_FAULT: { @@ -116,8 +111,12 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, } case CIT_READ: case CIT_WRITE: { - io->u.ci_rw.crw_pos = start; - io->u.ci_rw.crw_count = end - start; + if (cl_io_is_append(parent)) { + io->u.ci_wr.wr_append = 1; + } else { + io->u.ci_rw.crw_pos = start; + io->u.ci_rw.crw_count = end - start; + } break; } default: @@ -146,17 +145,8 @@ 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) { - LASSERT(mutex_is_locked(&ld->ld_mutex)); + if (lio->lis_mem_frozen) { + LASSERT(cfs_mutex_is_locked(&ld->ld_mutex)); sub->sub_io = &ld->ld_emrg[stripe]->emrg_subio; sub->sub_env = ld->ld_emrg[stripe]->emrg_env; sub->sub_borrowed = 1; @@ -167,12 +157,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) { @@ -185,6 +186,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, sub_io->ci_parent = io; sub_io->ci_lockreq = io->ci_lockreq; sub_io->ci_type = io->ci_type; + sub_io->ci_no_srvlock = io->ci_no_srvlock; lov_sub_enter(sub); result = cl_io_sub_init(sub->sub_env, sub_io, @@ -277,8 +279,8 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, * 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; @@ -314,8 +316,11 @@ static void lov_io_slice_init(struct lov_io *lio, } break; - case CIT_TRUNC: - lio->lis_pos = io->u.ci_truncate.tr_size; + case CIT_SETATTR: + if (cl_io_is_trunc(io)) + lio->lis_pos = io->u.ci_setattr.sa_attr.lvb_size; + else + lio->lis_pos = 0; lio->lis_endpos = OBD_OBJECT_EOF; break; @@ -347,7 +352,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) 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; } @@ -387,13 +392,13 @@ static int lov_io_iter_init(const struct lu_env *env, start, end); rc = cl_io_iter_init(sub->sub_env, sub->sub_io); lov_sub_put(sub); - CDEBUG(D_VFSTRACE, "shrink: %i [%llu, %llu)\n", + CDEBUG(D_VFSTRACE, "shrink: %d ["LPU64", "LPU64")\n", stripe, start, end); } else rc = PTR_ERR(sub); if (!rc) - list_add_tail(&sub->sub_linkage, &lio->lis_active); + cfs_list_add_tail(&sub->sub_linkage, &lio->lis_active); else break; } @@ -408,7 +413,7 @@ static int lov_io_rw_iter_init(const struct lu_env *env, struct lov_stripe_md *lsm = lov_r0(cl2lov(ios->cis_obj))->lo_lsm; loff_t start = io->u.ci_rw.crw_pos; loff_t next; - int ssize = lsm->lsm_stripe_size; + unsigned long ssize = lsm->lsm_stripe_size; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); ENTRY; @@ -426,7 +431,7 @@ static int lov_io_rw_iter_init(const struct lu_env *env, next) - io->u.ci_rw.crw_pos; lio->lis_pos = io->u.ci_rw.crw_pos; lio->lis_endpos = io->u.ci_rw.crw_pos + io->u.ci_rw.crw_count; - CDEBUG(D_VFSTRACE, "stripe: %llu chunk: [%llu, %llu) %llu\n", + CDEBUG(D_VFSTRACE, "stripe: "LPU64" chunk: ["LPU64", "LPU64") "LPU64"\n", (__u64)start, lio->lis_pos, lio->lis_endpos, (__u64)lio->lis_io_endpos); } @@ -444,7 +449,7 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, int rc = 0; ENTRY; - list_for_each_entry(sub, &lio->lis_active, sub_linkage) { + cfs_list_for_each_entry(sub, &lio->lis_active, sub_linkage) { lov_sub_enter(sub); rc = iofunc(sub->sub_env, sub->sub_io); lov_sub_exit(sub); @@ -510,8 +515,8 @@ static void lov_io_iter_fini(const struct lu_env *env, ENTRY; rc = lov_io_call(env, lio, lov_io_iter_fini_wrapper); LASSERT(rc == 0); - while (!list_empty(&lio->lis_active)) - list_del_init(lio->lis_active.next); + while (!cfs_list_empty(&lio->lis_active)) + cfs_list_del_init(lio->lis_active.next); EXIT; } @@ -551,7 +556,8 @@ static struct cl_page_list *lov_io_submit_qin(struct lov_device *ld, */ static int lov_io_submit(const struct lu_env *env, const struct cl_io_slice *ios, - enum cl_req_type crt, struct cl_2queue *queue) + enum cl_req_type crt, struct cl_2queue *queue, + enum cl_req_priority priority) { struct lov_io *lio = cl2lov_io(env, ios); struct lov_object *obj = lio->lis_object; @@ -581,15 +587,16 @@ static int lov_io_submit(const struct lu_env *env, sub = lov_sub_get(env, lio, idx); LASSERT(!IS_ERR(sub)); LASSERT(sub->sub_io == &lio->lis_single_subio); - rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, crt, queue); + rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, + crt, queue, priority); lov_sub_put(sub); RETURN(rc); } 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); @@ -601,7 +608,7 @@ static int lov_io_submit(const struct lu_env *env, * In order to not make things worse, even don't try to * allocate the memory with __GFP_NOWARN. -jay */ - mutex_lock(&ld->ld_mutex); + cfs_mutex_lock(&ld->ld_mutex); lio->lis_mem_frozen = 1; } @@ -615,14 +622,14 @@ static int lov_io_submit(const struct lu_env *env, struct lov_io_sub *sub; struct cl_page_list *sub_qin = QIN(stripe); - if (list_empty(&sub_qin->pl_pages)) + if (cfs_list_empty(&sub_qin->pl_pages)) continue; cl_page_list_splice(sub_qin, &cl2q->c2_qin); sub = lov_sub_get(env, lio, stripe); if (!IS_ERR(sub)) { rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, - crt, cl2q); + crt, cl2q, priority); lov_sub_put(sub); } else rc = PTR_ERR(sub); @@ -635,14 +642,14 @@ static int lov_io_submit(const struct lu_env *env, for (stripe = 0; stripe < lio->lis_nr_subios; stripe++) { struct cl_page_list *sub_qin = QIN(stripe); - if (list_empty(&sub_qin->pl_pages)) + if (cfs_list_empty(&sub_qin->pl_pages)) continue; cl_page_list_splice(sub_qin, qin); } if (alloc) { - OBD_FREE(stripes_qin, + OBD_FREE_LARGE(stripes_qin, sizeof(*stripes_qin) * lio->lis_nr_subios); } else { int i; @@ -654,7 +661,7 @@ static int lov_io_submit(const struct lu_env *env, lov_io_sub_fini(env, lio, &lio->lis_subs[i]); } lio->lis_mem_frozen = 0; - mutex_unlock(&ld->ld_mutex); + cfs_mutex_unlock(&ld->ld_mutex); } RETURN(rc); @@ -739,7 +746,7 @@ static const struct cl_io_operations lov_io_ops = { .cio_start = lov_io_start, .cio_end = lov_io_end }, - [CIT_TRUNC] = { + [CIT_SETATTR] = { .cio_fini = lov_io_fini, .cio_iter_init = lov_io_iter_init, .cio_iter_fini = lov_io_iter_fini, @@ -815,7 +822,7 @@ static const struct cl_io_operations lov_empty_io_ops = { .cio_start = LOV_EMPTY_IMPOSSIBLE, .cio_end = LOV_EMPTY_IMPOSSIBLE }, - [CIT_TRUNC] = { + [CIT_SETATTR] = { .cio_fini = lov_empty_io_fini, .cio_iter_init = LOV_EMPTY_IMPOSSIBLE, .cio_lock = LOV_EMPTY_IMPOSSIBLE, @@ -877,7 +884,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, result = 0; break; case CIT_WRITE: - case CIT_TRUNC: + case CIT_SETATTR: result = -EBADF; break; case CIT_FAULT: