diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/lov')
19 files changed, 357 insertions, 702 deletions
diff --git a/drivers/staging/lustre/lustre/lov/Makefile b/drivers/staging/lustre/lustre/lov/Makefile index e4cc0db21014..3abfb4eab3d3 100644 --- a/drivers/staging/lustre/lustre/lov/Makefile +++ b/drivers/staging/lustre/lustre/lov/Makefile @@ -1,5 +1,8 @@ +subdir-ccflags-y += -I$(srctree)/drivers/staging/lustre/include +subdir-ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include + obj-$(CONFIG_LUSTRE_FS) += lov.o lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \ lov_request.o lov_ea.o lov_dev.o lov_object.o lov_page.o \ lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o \ - lovsub_lock.o lovsub_io.o lov_pool.o lproc_lov.o + lovsub_lock.o lov_pool.o lproc_lov.o diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index e889d3a7de9c..89d92b05b48c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -42,10 +42,10 @@ #ifndef LOV_CL_INTERNAL_H #define LOV_CL_INTERNAL_H -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/obd.h" -#include "../include/cl_object.h" +#include <obd.h> +#include <cl_object.h> #include "lov_internal.h" /** \defgroup lov lov @@ -92,35 +92,6 @@ enum lov_device_flags { * Upper half. */ -/** - * Resources that are used in memory-cleaning path, and whose allocation - * cannot fail even when memory is tight. They are preallocated in sufficient - * quantities in lov_device::ld_emerg[], and access to them is serialized - * lov_device::ld_mutex. - */ -struct lov_device_emerg { - /** - * Page list used to submit IO when memory is in pressure. - */ - struct cl_page_list emrg_page_list; - /** - * sub-io's shared by all threads accessing this device when memory is - * too low to allocate sub-io's dynamically. - */ - struct cl_io emrg_subio; - /** - * Environments used by sub-io's in - * lov_device_emerg::emrg_subio. - */ - struct lu_env *emrg_env; - /** - * Refchecks for lov_device_emerg::emrg_env. - * - * \see cl_env_get() - */ - u16 emrg_refcheck; -}; - struct lov_device { /* * XXX Locking of lov-private data is missing. @@ -131,14 +102,6 @@ struct lov_device { __u32 ld_target_nr; struct lovsub_device **ld_target; __u32 ld_flags; - - /** Emergency resources used in memory-cleansing paths. */ - struct lov_device_emerg **ld_emrg; - /** - * Serializes access to lov_device::ld_emrg in low-memory - * conditions. - */ - struct mutex ld_mutex; }; /** @@ -299,8 +262,6 @@ struct lov_page { struct lovsub_device { struct cl_device acid_cl; - struct lov_device *acid_super; - int acid_idx; struct cl_device *acid_next; }; @@ -312,42 +273,10 @@ struct lovsub_object { }; /** - * A link between a top-lock and a sub-lock. Separate data-structure is - * necessary, because top-locks and sub-locks are in M:N relationship. - * - * \todo This can be optimized for a (by far) most frequent case of a single - * top-lock per sub-lock. - */ -struct lov_lock_link { - struct lov_lock *lll_super; - /** An index within parent lock. */ - int lll_idx; - /** - * A linkage into per sub-lock list of all corresponding top-locks, - * hanging off lovsub_lock::lss_parents. - */ - struct list_head lll_list; -}; - -/** * Lock state at lovsub layer. */ struct lovsub_lock { struct cl_lock_slice lss_cl; - /** - * List of top-locks that have given sub-lock as their part. Protected - * by cl_lock::cll_guard mutex. - */ - struct list_head lss_parents; - /** - * Top-lock that initiated current operation on this sub-lock. This is - * only set during top-to-bottom lock operations like enqueue, and is - * used to optimize state change notification. Protected by - * cl_lock::cll_guard mutex. - * - * \see lovsub_lock_state_one(). - */ - struct cl_lock *lss_active; }; /** @@ -356,7 +285,6 @@ struct lovsub_lock { struct lov_sublock_env { const struct lu_env *lse_env; struct cl_io *lse_io; - struct lov_io_sub *lse_sub; }; struct lovsub_page { @@ -366,12 +294,10 @@ struct lovsub_page { struct lov_thread_info { struct cl_object_conf lti_stripe_conf; struct lu_fid lti_fid; - struct cl_lock_descr lti_ldescr; struct ost_lvb lti_lvb; struct cl_2queue lti_cl2q; struct cl_page_list lti_plist; wait_queue_entry_t lti_waiter; - struct cl_attr lti_attr; }; /** @@ -385,7 +311,6 @@ struct lov_io_sub { * \see cl_env_get() */ u16 sub_refcheck; - u16 sub_reenter; /** * true, iff cl_io_init() was successfully executed against * lov_io_sub::sub_io. @@ -445,7 +370,6 @@ struct lov_io { */ u64 lis_endpos; - int lis_mem_frozen; int lis_stripe_count; int lis_active_subios; @@ -485,8 +409,6 @@ extern struct kmem_cache *lov_session_kmem; extern struct kmem_cache *lovsub_lock_kmem; extern struct kmem_cache *lovsub_object_kmem; -extern struct kmem_cache *lov_lock_link_kmem; - int lov_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf); int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, @@ -508,15 +430,9 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, struct cl_io *io); int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, struct cl_io *io); -void lov_lock_unlink(const struct lu_env *env, struct lov_lock_link *link, - struct lovsub_lock *sub); struct lov_io_sub *lov_sub_get(const struct lu_env *env, struct lov_io *lio, int stripe); -void lov_sub_put(struct lov_io_sub *sub); -int lov_sublock_modify(const struct lu_env *env, struct lov_lock *lov, - struct lovsub_lock *sublock, - const struct cl_lock_descr *d, int idx); int lov_page_init(const struct lu_env *env, struct cl_object *ob, struct cl_page *page, pgoff_t index); @@ -533,12 +449,6 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, const struct lu_object_header *hdr, struct lu_device *dev); -struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, - struct lov_lock *lck, - struct lovsub_lock *sub); -struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, - const struct cl_page_slice *slice); - struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov); int lov_page_stripe(const struct cl_page *page); diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 7301f6e579a1..cea5f9dcd04e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -37,7 +37,7 @@ #define DEBUG_SUBSYSTEM S_LOV /* class_name2obd() */ -#include "../include/obd_class.h" +#include <obd_class.h> #include "lov_cl_internal.h" #include "lov_internal.h" @@ -50,11 +50,6 @@ struct kmem_cache *lov_session_kmem; struct kmem_cache *lovsub_lock_kmem; struct kmem_cache *lovsub_object_kmem; -struct kmem_cache *lov_lock_link_kmem; - -/** Lock class of lov_device::ld_mutex. */ -static struct lock_class_key cl_lov_device_mutex_class; - struct lu_kmem_descr lov_caches[] = { { .ckd_cache = &lov_lock_kmem, @@ -87,11 +82,6 @@ struct lu_kmem_descr lov_caches[] = { .ckd_size = sizeof(struct lovsub_object) }, { - .ckd_cache = &lov_lock_link_kmem, - .ckd_name = "lov_lock_link_kmem", - .ckd_size = sizeof(struct lov_lock_link) - }, - { .ckd_cache = NULL } }; @@ -204,8 +194,6 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, break; } lsd = cl2lovsub_dev(cl); - lsd->acid_idx = i; - lsd->acid_super = ld; ld->ld_target[i] = lsd; } @@ -217,34 +205,13 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, return rc; } -static void lov_emerg_free(struct lov_device_emerg **emrg, int nr) -{ - int i; - - for (i = 0; i < nr; ++i) { - struct lov_device_emerg *em; - - em = emrg[i]; - if (em) { - LASSERT(em->emrg_page_list.pl_nr == 0); - if (em->emrg_env) - cl_env_put(em->emrg_env, &em->emrg_refcheck); - kfree(em); - } - } - kfree(emrg); -} - static struct lu_device *lov_device_free(const struct lu_env *env, struct lu_device *d) { struct lov_device *ld = lu2lov_dev(d); - const int nr = ld->ld_target_nr; cl_device_fini(lu2cl_dev(d)); kfree(ld->ld_target); - if (ld->ld_emrg) - lov_emerg_free(ld->ld_emrg, nr); kfree(ld); return NULL; } @@ -260,41 +227,6 @@ static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev, } } -static struct lov_device_emerg **lov_emerg_alloc(int nr) -{ - struct lov_device_emerg **emerg; - int i; - int result; - - emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS); - if (!emerg) - return ERR_PTR(-ENOMEM); - for (result = i = 0; i < nr && result == 0; i++) { - struct lov_device_emerg *em; - - em = kzalloc(sizeof(*em), GFP_NOFS); - if (em) { - emerg[i] = em; - cl_page_list_init(&em->emrg_page_list); - em->emrg_env = cl_env_alloc(&em->emrg_refcheck, - LCT_REMEMBER | LCT_NOREF); - if (!IS_ERR(em->emrg_env)) { - em->emrg_env->le_ctx.lc_cookie = 0x2; - } else { - result = PTR_ERR(em->emrg_env); - em->emrg_env = NULL; - } - } else { - result = -ENOMEM; - } - } - if (result != 0) { - lov_emerg_free(emerg, nr); - emerg = ERR_PTR(result); - } - return emerg; -} - static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) { int result; @@ -306,29 +238,17 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) sub_size = dev->ld_target_nr; if (sub_size < tgt_size) { struct lovsub_device **newd; - struct lov_device_emerg **emerg; const size_t sz = sizeof(newd[0]); - emerg = lov_emerg_alloc(tgt_size); - if (IS_ERR(emerg)) - return PTR_ERR(emerg); - newd = kcalloc(tgt_size, sz, GFP_NOFS); if (newd) { - mutex_lock(&dev->ld_mutex); if (sub_size > 0) { memcpy(newd, dev->ld_target, sub_size * sz); kfree(dev->ld_target); } dev->ld_target = newd; dev->ld_target_nr = tgt_size; - - if (dev->ld_emrg) - lov_emerg_free(dev->ld_emrg, sub_size); - dev->ld_emrg = emerg; - mutex_unlock(&dev->ld_mutex); } else { - lov_emerg_free(emerg, tgt_size); result = -ENOMEM; } } @@ -362,8 +282,6 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, tgt->ltd_obd->obd_lu_dev); if (!IS_ERR(cl)) { lsd = cl2lovsub_dev(cl); - lsd->acid_idx = index; - lsd->acid_super = ld; ld->ld_target[index] = lsd; } else { CERROR("add failed (%d), deleting %s\n", rc, @@ -428,9 +346,6 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, d = lov2lu_dev(ld); d->ld_ops = &lov_lu_ops; - mutex_init(&ld->ld_mutex); - lockdep_set_class(&ld->ld_mutex, &cl_lov_device_mutex_class); - /* setup the LOV OBD */ obd = class_name2obd(lustre_cfg_string(cfg, 0)); LASSERT(obd); diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index ac0bf64c08c1..1124fd5ab32f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -37,10 +37,10 @@ #define DEBUG_SUBSYSTEM S_LOV #include <asm/div64.h> -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/obd_class.h" -#include "../include/lustre/lustre_idl.h" +#include <obd_class.h> +#include <uapi/linux/lustre/lustre_idl.h> #include "lov_internal.h" @@ -150,9 +150,10 @@ static int lsm_unpackmd_common(struct lov_obd *lov, struct lov_mds_md *lmm, struct lov_ost_data_v1 *objects) { - loff_t stripe_maxbytes = LLONG_MAX; + loff_t min_stripe_maxbytes = 0; unsigned int stripe_count; struct lov_oinfo *loi; + loff_t lov_bytes; unsigned int i; /* @@ -168,8 +169,6 @@ static int lsm_unpackmd_common(struct lov_obd *lov, stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; for (i = 0; i < stripe_count; i++) { - loff_t tgt_bytes; - loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&objects[i].l_ost_oi, &loi->loi_oi); loi->loi_ost_idx = le32_to_cpu(objects[i].l_ost_idx); @@ -194,17 +193,21 @@ static int lsm_unpackmd_common(struct lov_obd *lov, continue; } - tgt_bytes = lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx]); - stripe_maxbytes = min_t(loff_t, stripe_maxbytes, tgt_bytes); + lov_bytes = lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx]); + if (min_stripe_maxbytes == 0 || lov_bytes < min_stripe_maxbytes) + min_stripe_maxbytes = lov_bytes; } - if (stripe_maxbytes == LLONG_MAX) - stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES; + if (min_stripe_maxbytes == 0) + min_stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES; + + stripe_count = lsm->lsm_stripe_count ?: lov->desc.ld_tgt_count; + lov_bytes = min_stripe_maxbytes * stripe_count; - if (!lsm->lsm_stripe_count) - lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; + if (lov_bytes < min_stripe_maxbytes) /* handle overflow */ + lsm->lsm_maxbytes = MAX_LFS_FILESIZE; else - lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + lsm->lsm_maxbytes = lov_bytes; return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 774499c74daa..a21f074008af 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -33,8 +33,8 @@ #ifndef LOV_INTERNAL_H #define LOV_INTERNAL_H -#include "../include/obd_class.h" -#include "../include/lustre/lustre_user.h" +#include <obd_class.h> +#include <uapi/linux/lustre/lustre_idl.h> /* * If we are unable to get the maximum object size from the OST in @@ -161,42 +161,21 @@ struct lov_request { struct list_head rq_link; int rq_idx; /* index in lov->tgts array */ - int rq_stripe; /* stripe number */ - int rq_complete; - int rq_rc; - - u32 rq_oabufs; - u32 rq_pgaidx; }; struct lov_request_set { struct obd_info *set_oi; - atomic_t set_refcount; - struct obd_export *set_exp; - /* XXX: There is @set_exp already, however obd_statfs gets obd_device - * only. - */ struct obd_device *set_obd; int set_count; atomic_t set_completes; atomic_t set_success; - atomic_t set_finish_checked; struct list_head set_list; - wait_queue_head_t set_waitq; }; extern struct kmem_cache *lov_oinfo_slab; extern struct lu_kmem_descr lov_caches[]; -void lov_finish_set(struct lov_request_set *set); - -static inline void lov_put_reqset(struct lov_request_set *set) -{ - if (atomic_dec_and_test(&set->set_refcount)) - lov_finish_set(set); -} - #define lov_uuid2str(lv, index) \ (char *)((lv)->lov_tgts[index]->ltd_uuid.uuid) @@ -217,15 +196,9 @@ pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index, int stripe); /* lov_request.c */ -int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, - struct lov_request_set **reqset); -int lov_fini_getattr_set(struct lov_request_set *set); int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, struct lov_request_set **reqset); -int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs, - int success); int lov_fini_statfs_set(struct lov_request_set *set); -int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc); /* lov_obd.c */ void lov_stripe_lock(struct lov_stripe_md *md); diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index babf39adef85..9e3b150967b4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -43,24 +43,12 @@ * @{ */ -static inline void lov_sub_enter(struct lov_io_sub *sub) -{ - sub->sub_reenter++; -} - -static inline void lov_sub_exit(struct lov_io_sub *sub) -{ - sub->sub_reenter--; -} - static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub) { if (sub->sub_io) { if (sub->sub_io_initialized) { - lov_sub_enter(sub); cl_io_fini(sub->sub_env, sub->sub_io); - lov_sub_exit(sub); sub->sub_io_initialized = 0; lio->lis_active_subios--; } @@ -142,13 +130,11 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub) { struct lov_object *lov = lio->lis_object; - struct lov_device *ld = lu2lov_dev(lov2cl(lov)->co_lu.lo_dev); struct cl_io *sub_io; struct cl_object *sub_obj; struct cl_io *io = lio->lis_cl.cis_io; - int stripe = sub->sub_stripe; - int result; + int rc; LASSERT(!sub->sub_io); LASSERT(!sub->sub_env); @@ -157,63 +143,53 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, if (unlikely(!lov_r0(lov)->lo_sub[stripe])) return -EIO; - result = 0; sub->sub_io_initialized = 0; sub->sub_borrowed = 0; - 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; - sub->sub_borrowed = 1; - } else { - sub->sub_env = cl_env_get(&sub->sub_refcheck); - if (IS_ERR(sub->sub_env)) - result = PTR_ERR(sub->sub_env); + /* obtain new environment */ + sub->sub_env = cl_env_get(&sub->sub_refcheck); + if (IS_ERR(sub->sub_env)) { + rc = PTR_ERR(sub->sub_env); + goto fini_lov_io; + } - 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 { - sub->sub_io = kzalloc(sizeof(*sub->sub_io), - GFP_NOFS); - if (!sub->sub_io) - result = -ENOMEM; - } + /* + * 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 { + sub->sub_io = kzalloc(sizeof(*sub->sub_io), + GFP_NOFS); + if (!sub->sub_io) { + rc = -ENOMEM; + goto fini_lov_io; } } - if (result == 0) { - sub_obj = lovsub2cl(lov_r0(lov)->lo_sub[stripe]); - sub_io = sub->sub_io; - - sub_io->ci_obj = sub_obj; - sub_io->ci_result = 0; - - 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; - sub_io->ci_noatime = io->ci_noatime; - - lov_sub_enter(sub); - result = cl_io_sub_init(sub->sub_env, sub_io, - io->ci_type, sub_obj); - lov_sub_exit(sub); - if (result >= 0) { - lio->lis_active_subios++; - sub->sub_io_initialized = 1; - result = 0; - } + sub_obj = lovsub2cl(lov_r0(lov)->lo_sub[stripe]); + sub_io = sub->sub_io; + + sub_io->ci_obj = sub_obj; + sub_io->ci_result = 0; + 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; + sub_io->ci_noatime = io->ci_noatime; + + rc = cl_io_sub_init(sub->sub_env, sub_io, io->ci_type, sub_obj); + if (rc >= 0) { + lio->lis_active_subios++; + sub->sub_io_initialized = 1; + rc = 0; } - if (result != 0) +fini_lov_io: + if (rc) lov_io_sub_fini(env, lio, sub); - return result; + return rc; } struct lov_io_sub *lov_sub_get(const struct lu_env *env, @@ -230,16 +206,10 @@ struct lov_io_sub *lov_sub_get(const struct lu_env *env, } else { rc = 0; } - if (rc == 0) - lov_sub_enter(sub); - else + if (rc < 0) sub = ERR_PTR(rc); - return sub; -} -void lov_sub_put(struct lov_io_sub *sub) -{ - lov_sub_exit(sub); + return sub; } /***************************************************************************** @@ -258,22 +228,6 @@ int lov_page_stripe(const struct cl_page *page) return cl2lov_page(slice)->lps_stripe; } -struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, - const struct cl_page_slice *slice) -{ - struct lov_stripe_md *lsm = lio->lis_object->lo_lsm; - struct cl_page *page = slice->cpl_page; - int stripe; - - LASSERT(lio->lis_cl.cis_io); - LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object); - LASSERT(lsm); - LASSERT(lio->lis_nr_subios > 0); - - stripe = lov_page_stripe(page); - return lov_sub_get(env, lio, stripe); -} - static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, struct cl_io *io) { @@ -431,12 +385,10 @@ static int lov_io_iter_init(const struct lu_env *env, lov_io_sub_inherit(sub->sub_io, lio, stripe, start, end); rc = cl_io_iter_init(sub->sub_env, sub->sub_io); - if (rc) + if (rc) { cl_io_iter_fini(sub->sub_env, sub->sub_io); - lov_sub_put(sub); - if (rc) break; - + } CDEBUG(D_VFSTRACE, "shrink: %d [%llu, %llu)\n", stripe, start, end); @@ -488,9 +440,7 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, int rc = 0; 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); if (rc) break; @@ -610,7 +560,6 @@ static int lov_io_read_ahead(const struct lu_env *env, rc = cl_io_read_ahead(sub->sub_env, sub->sub_io, cl_index(lovsub2cl(r0->lo_sub[stripe]), suboff), ra); - lov_sub_put(sub); CDEBUG(D_READA, DFID " cra_end = %lu, stripes = %d, rc = %d\n", PFID(lu_object_fid(lov2lu(loo))), ra->cra_end, r0->lo_nr, rc); @@ -679,7 +628,6 @@ static int lov_io_submit(const struct lu_env *env, LASSERT(sub->sub_io == &lio->lis_single_subio); rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, crt, queue); - lov_sub_put(sub); return rc; } @@ -707,7 +655,6 @@ static int lov_io_submit(const struct lu_env *env, if (!IS_ERR(sub)) { rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, crt, cl2q); - lov_sub_put(sub); } else { rc = PTR_ERR(sub); } @@ -746,7 +693,6 @@ static int lov_io_commit_async(const struct lu_env *env, LASSERT(sub->sub_io == &lio->lis_single_subio); rc = cl_io_commit_async(sub->sub_env, sub->sub_io, queue, from, to, cb); - lov_sub_put(sub); return rc; } @@ -777,7 +723,6 @@ static int lov_io_commit_async(const struct lu_env *env, if (!IS_ERR(sub)) { rc = cl_io_commit_async(sub->sub_env, sub->sub_io, plist, from, stripe_to, cb); - lov_sub_put(sub); } else { rc = PTR_ERR(sub); break; @@ -813,7 +758,6 @@ static int lov_io_fault_start(const struct lu_env *env, if (IS_ERR(sub)) return PTR_ERR(sub); sub->sub_io->u.ci_fault.ft_nob = fio->ft_nob; - lov_sub_put(sub); return lov_io_start(env, ios); } @@ -828,9 +772,7 @@ static void lov_io_fsync_end(const struct lu_env *env, list_for_each_entry(sub, &lio->lis_active, sub_linkage) { struct cl_io *subio = sub->sub_io; - lov_sub_enter(sub); lov_io_end_wrapper(sub->sub_env, subio); - lov_sub_exit(sub); if (subio->ci_result == 0) *written += subio->u.ci_fsync.fi_nr_written; @@ -939,12 +881,6 @@ static const struct cl_io_operations lov_empty_io_ops = { .op = { [CIT_READ] = { .cio_fini = lov_empty_io_fini, -#if 0 - .cio_iter_init = LOV_EMPTY_IMPOSSIBLE, - .cio_lock = LOV_EMPTY_IMPOSSIBLE, - .cio_start = LOV_EMPTY_IMPOSSIBLE, - .cio_end = LOV_EMPTY_IMPOSSIBLE -#endif }, [CIT_WRITE] = { .cio_fini = lov_empty_io_fini, @@ -1047,6 +983,8 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, switch (io->ci_type) { default: LASSERTF(0, "invalid type %d\n", io->ci_type); + result = -EOPNOTSUPP; + break; case CIT_MISC: case CIT_FSYNC: case CIT_DATA_VERSION: diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 8502128e8248..e12dc5afc14f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -71,13 +71,11 @@ static struct lov_sublock_env *lov_sublock_env_get(const struct lu_env *env, 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; } else { sub = lov_sub_get(env, lio, lls->sub_stripe); if (!IS_ERR(sub)) { subenv->lse_env = sub->sub_env; subenv->lse_io = sub->sub_io; - subenv->lse_sub = sub; } else { subenv = (void *)sub; } @@ -85,12 +83,6 @@ static struct lov_sublock_env *lov_sublock_env_get(const struct lu_env *env, return subenv; } -static void lov_sublock_env_put(struct lov_sublock_env *subenv) -{ - if (subenv && subenv->lse_sub) - lov_sub_put(subenv->lse_sub); -} - static int lov_sublock_init(const struct lu_env *env, const struct cl_lock *parent, struct lov_lock_sub *lls) @@ -102,7 +94,6 @@ static int lov_sublock_init(const struct lu_env *env, if (!IS_ERR(subenv)) { result = cl_lock_init(subenv->lse_env, &lls->sub_lock, subenv->lse_io); - lov_sublock_env_put(subenv); } else { /* error occurs. */ result = PTR_ERR(subenv); @@ -244,7 +235,6 @@ static int lov_lock_enqueue(const struct lu_env *env, } rc = cl_lock_enqueue(subenv->lse_env, subenv->lse_io, &lls->sub_lock, anchor); - lov_sublock_env_put(subenv); if (rc != 0) break; @@ -272,11 +262,10 @@ static void lov_lock_cancel(const struct lu_env *env, subenv = lov_sublock_env_get(env, lock, lls); if (!IS_ERR(subenv)) { cl_lock_cancel(subenv->lse_env, sublock); - lov_sublock_env_put(subenv); } else { CL_LOCK_DEBUG(D_ERROR, env, slice->cls_lock, - "lov_lock_cancel fails with %ld.\n", - PTR_ERR(subenv)); + "%s fails with %ld.\n", + __func__, PTR_ERR(subenv)); } } } diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index 034b4fcb38f5..916336115989 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -32,9 +32,9 @@ #define DEBUG_SUBSYSTEM S_LOV -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/obd_class.h" +#include <obd_class.h> #include "lov_internal.h" /** Merge the lock value block(&lvb) attributes and KMS from each of the diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 25f15da6e189..fefd3c588681 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -38,22 +38,22 @@ */ #define DEBUG_SUBSYSTEM S_LOV -#include "../../include/linux/libcfs/libcfs.h" - -#include "../include/lustre/lustre_idl.h" -#include "../include/lustre/lustre_ioctl.h" - -#include "../include/cl_object.h" -#include "../include/lustre_dlm.h" -#include "../include/lustre_fid.h" -#include "../include/lustre_lib.h" -#include "../include/lustre_mds.h" -#include "../include/lustre_net.h" -#include "../include/lustre_param.h" -#include "../include/lustre_swab.h" -#include "../include/lprocfs_status.h" -#include "../include/obd_class.h" -#include "../include/obd_support.h" +#include <linux/libcfs/libcfs.h> + +#include <uapi/linux/lustre/lustre_idl.h> +#include <uapi/linux/lustre/lustre_ioctl.h> + +#include <cl_object.h> +#include <lustre_dlm.h> +#include <lustre_fid.h> +#include <lustre_lib.h> +#include <lustre_mds.h> +#include <lustre_net.h> +#include <uapi/linux/lustre/lustre_param.h> +#include <lustre_swab.h> +#include <lprocfs_status.h> +#include <obd_class.h> +#include <obd_support.h> #include "lov_internal.h" @@ -947,7 +947,8 @@ out: return rc; } -int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) +static int +lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; @@ -1086,17 +1087,17 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, data = (struct obd_ioctl_data *)buf; if (sizeof(*desc) > data->ioc_inllen1) { - obd_ioctl_freedata(buf, len); + kvfree(buf); return -EINVAL; } if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { - obd_ioctl_freedata(buf, len); + kvfree(buf); return -EINVAL; } if (sizeof(__u32) * count > data->ioc_inllen3) { - obd_ioctl_freedata(buf, len); + kvfree(buf); return -EINVAL; } @@ -1115,7 +1116,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (copy_to_user(uarg, buf, len)) rc = -EFAULT; - obd_ioctl_freedata(buf, len); + kvfree(buf); break; } case OBD_IOC_QUOTACTL: { diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 14f38268d414..334ecb1bc049 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -638,7 +638,7 @@ static const struct lov_layout_operations lov_dispatch[] = { enum lov_layout_type __llt; \ \ __llt = __obj->lo_type; \ - LASSERT(0 <= __llt && __llt < ARRAY_SIZE(lov_dispatch)); \ + LASSERT(__llt < ARRAY_SIZE(lov_dispatch)); \ lov_dispatch[__llt].op(__VA_ARGS__); \ }) @@ -697,7 +697,7 @@ do { \ \ lov_conf_freeze(__obj); \ __llt = __obj->lo_type; \ - LASSERT(0 <= __llt && __llt < ARRAY_SIZE(lov_dispatch)); \ + LASSERT(__llt < ARRAY_SIZE(lov_dispatch)); \ lov_dispatch[__llt].op(__VA_ARGS__); \ lov_conf_thaw(__obj); \ } while (0) @@ -748,13 +748,13 @@ static int lov_layout_change(const struct lu_env *unused, u16 refcheck; int rc; - LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch)); + LASSERT(lov->lo_type < ARRAY_SIZE(lov_dispatch)); env = cl_env_get(&refcheck); if (IS_ERR(env)) return PTR_ERR(env); - LASSERT(0 <= llt && llt < ARRAY_SIZE(lov_dispatch)); + LASSERT(llt < ARRAY_SIZE(lov_dispatch)); CDEBUG(D_INODE, DFID " from %s to %s\n", PFID(lu_object_fid(lov2lu(lov))), @@ -1003,12 +1003,12 @@ int lov_lock_init(const struct lu_env *env, struct cl_object *obj, * \retval last_stripe return the last stripe of the mapping */ static int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, - loff_t fm_start, loff_t fm_end, + u64 fm_start, u64 fm_end, int start_stripe, int *stripe_count) { int last_stripe; - loff_t obd_start; - loff_t obd_end; + u64 obd_start; + u64 obd_end; int i, j; if (fm_end - fm_start > lsm->lsm_stripe_size * lsm->lsm_stripe_count) { @@ -1076,14 +1076,14 @@ static void fiemap_prepare_and_copy_exts(struct fiemap *fiemap, * \param fm_end [in] logical end of mapping * \param start_stripe [out] starting stripe will be returned in this */ -static loff_t fiemap_calc_fm_end_offset(struct fiemap *fiemap, - struct lov_stripe_md *lsm, - loff_t fm_start, loff_t fm_end, - int *start_stripe) +static u64 fiemap_calc_fm_end_offset(struct fiemap *fiemap, + struct lov_stripe_md *lsm, + u64 fm_start, u64 fm_end, + int *start_stripe) { - loff_t local_end = fiemap->fm_extents[0].fe_logical; - loff_t lun_start, lun_end; - loff_t fm_end_offset; + u64 local_end = fiemap->fm_extents[0].fe_logical; + u64 lun_start, lun_end; + u64 fm_end_offset; int stripe_no = -1; int i; @@ -1126,6 +1126,190 @@ static loff_t fiemap_calc_fm_end_offset(struct fiemap *fiemap, return fm_end_offset; } +struct fiemap_state { + struct fiemap *fs_fm; + u64 fs_start; + u64 fs_length; + u64 fs_end; + u64 fs_end_offset; + int fs_cur_extent; + int fs_cnt_need; + int fs_start_stripe; + int fs_last_stripe; + bool fs_device_done; + bool fs_finish; + bool fs_enough; +}; + +static int fiemap_for_stripe(const struct lu_env *env, struct cl_object *obj, + struct lov_stripe_md *lsm, + struct fiemap *fiemap, size_t *buflen, + struct ll_fiemap_info_key *fmkey, int stripeno, + struct fiemap_state *fs) +{ + struct cl_object *subobj; + struct lov_obd *lov = lu2lov_dev(obj->co_lu.lo_dev)->ld_lov; + struct fiemap_extent *fm_ext = &fs->fs_fm->fm_extents[0]; + u64 req_fm_len; /* Stores length of required mapping */ + u64 len_mapped_single_call; + u64 lun_start; + u64 lun_end; + u64 obd_object_end; + unsigned int ext_count; + /* EOF for object */ + bool ost_eof = false; + /* done with required mapping for this OST? */ + bool ost_done = false; + int ost_index; + int rc = 0; + + fs->fs_device_done = false; + /* Find out range of mapping on this stripe */ + if ((lov_stripe_intersects(lsm, stripeno, fs->fs_start, fs->fs_end, + &lun_start, &obd_object_end)) == 0) + return 0; + + if (lov_oinfo_is_dummy(lsm->lsm_oinfo[stripeno])) + return -EIO; + + /* If this is a continuation FIEMAP call and we are on + * starting stripe then lun_start needs to be set to + * end_offset */ + if (fs->fs_end_offset != 0 && stripeno == fs->fs_start_stripe) + lun_start = fs->fs_end_offset; + + lun_end = fs->fs_length; + if (lun_end != ~0ULL) { + /* Handle fs->fs_start + fs->fs_length overflow */ + if (fs->fs_start + fs->fs_length < fs->fs_start) + fs->fs_length = ~0ULL - fs->fs_start; + lun_end = lov_size_to_stripe(lsm, fs->fs_start + fs->fs_length, + stripeno); + } + + if (lun_start == lun_end) + return 0; + + req_fm_len = obd_object_end - lun_start; + fs->fs_fm->fm_length = 0; + len_mapped_single_call = 0; + + /* find lobsub object */ + subobj = lov_find_subobj(env, cl2lov(obj), lsm, stripeno); + if (IS_ERR(subobj)) + return PTR_ERR(subobj); + /* If the output buffer is very large and the objects have many + * extents we may need to loop on a single OST repeatedly */ + do { + if (fiemap->fm_extent_count > 0) { + /* Don't get too many extents. */ + if (fs->fs_cur_extent + fs->fs_cnt_need > + fiemap->fm_extent_count) + fs->fs_cnt_need = fiemap->fm_extent_count - + fs->fs_cur_extent; + } + + lun_start += len_mapped_single_call; + fs->fs_fm->fm_length = req_fm_len - len_mapped_single_call; + req_fm_len = fs->fs_fm->fm_length; + fs->fs_fm->fm_extent_count = fs->fs_enough ? + 1 : fs->fs_cnt_need; + fs->fs_fm->fm_mapped_extents = 0; + fs->fs_fm->fm_flags = fiemap->fm_flags; + + ost_index = lsm->lsm_oinfo[stripeno]->loi_ost_idx; + + if (ost_index < 0 || ost_index >= lov->desc.ld_tgt_count) { + rc = -EINVAL; + goto obj_put; + } + /* If OST is inactive, return extent with UNKNOWN flag. */ + if (!lov->lov_tgts[ost_index]->ltd_active) { + fs->fs_fm->fm_flags |= FIEMAP_EXTENT_LAST; + fs->fs_fm->fm_mapped_extents = 1; + + fm_ext[0].fe_logical = lun_start; + fm_ext[0].fe_length = obd_object_end - lun_start; + fm_ext[0].fe_flags |= FIEMAP_EXTENT_UNKNOWN; + + goto inactive_tgt; + } + + fs->fs_fm->fm_start = lun_start; + fs->fs_fm->fm_flags &= ~FIEMAP_FLAG_DEVICE_ORDER; + memcpy(&fmkey->lfik_fiemap, fs->fs_fm, sizeof(*fs->fs_fm)); + *buflen = fiemap_count_to_size(fs->fs_fm->fm_extent_count); + + rc = cl_object_fiemap(env, subobj, fmkey, fs->fs_fm, buflen); + if (rc) + goto obj_put; +inactive_tgt: + ext_count = fs->fs_fm->fm_mapped_extents; + if (ext_count == 0) { + ost_done = true; + fs->fs_device_done = true; + /* If last stripe has hold at the end, + * we need to return */ + if (stripeno == fs->fs_last_stripe) { + fiemap->fm_mapped_extents = 0; + fs->fs_finish = true; + goto obj_put; + } + break; + } else if (fs->fs_enough) { + /* + * We've collected enough extents and there are + * more extents after it. + */ + fs->fs_finish = true; + goto obj_put; + } + + /* If we just need num of extents, got to next device */ + if (fiemap->fm_extent_count == 0) { + fs->fs_cur_extent += ext_count; + break; + } + + /* prepare to copy retrived map extents */ + len_mapped_single_call = fm_ext[ext_count - 1].fe_logical + + fm_ext[ext_count - 1].fe_length - + lun_start; + + /* Have we finished mapping on this device? */ + if (req_fm_len <= len_mapped_single_call) { + ost_done = true; + fs->fs_device_done = true; + } + + /* Clear the EXTENT_LAST flag which can be present on + * the last extent */ + if (fm_ext[ext_count - 1].fe_flags & FIEMAP_EXTENT_LAST) + fm_ext[ext_count - 1].fe_flags &= ~FIEMAP_EXTENT_LAST; + if (lov_stripe_size(lsm, fm_ext[ext_count - 1].fe_logical + + fm_ext[ext_count - 1].fe_length, + stripeno) >= fmkey->lfik_oa.o_size) { + ost_eof = true; + fs->fs_device_done = true; + } + + fiemap_prepare_and_copy_exts(fiemap, fm_ext, ost_index, + ext_count, fs->fs_cur_extent); + fs->fs_cur_extent += ext_count; + + /* Ran out of available extents? */ + if (fs->fs_cur_extent >= fiemap->fm_extent_count) + fs->fs_enough = true; + } while (!ost_done && !ost_eof); + + if (stripeno == fs->fs_last_stripe) + fs->fs_finish = true; +obj_put: + cl_object_put(env, subobj); + + return rc; +} + /** * Break down the FIEMAP request and send appropriate calls to individual OSTs. * This also handles the restarting of FIEMAP calls in case mapping overflows @@ -1144,31 +1328,13 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj, struct ll_fiemap_info_key *fmkey, struct fiemap *fiemap, size_t *buflen) { - struct lov_obd *lov = lu2lov_dev(obj->co_lu.lo_dev)->ld_lov; unsigned int buffer_size = FIEMAP_BUFFER_SIZE; - struct fiemap_extent *lcl_fm_ext; - struct cl_object *subobj = NULL; struct fiemap *fm_local = NULL; struct lov_stripe_md *lsm; - loff_t fm_start; - loff_t fm_end; - loff_t fm_length; - loff_t fm_end_offset; - int count_local; - int ost_index = 0; - int start_stripe; - int current_extent = 0; int rc = 0; - int last_stripe; - int cur_stripe = 0; - int cur_stripe_wrap = 0; + int cur_stripe; int stripe_count; - /* Whether have we collected enough extents */ - bool enough = false; - /* EOF for object */ - bool ost_eof = false; - /* done with required mapping for this OST? */ - bool ost_done = false; + struct fiemap_state fs = { 0 }; lsm = lov_lsm_addref(cl2lov(obj)); if (!lsm) @@ -1215,28 +1381,37 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj, rc = -ENOMEM; goto out; } - lcl_fm_ext = &fm_local->fm_extents[0]; - count_local = fiemap_size_to_count(buffer_size); + fs.fs_fm = fm_local; + fs.fs_cnt_need = fiemap_size_to_count(buffer_size); - fm_start = fiemap->fm_start; - fm_length = fiemap->fm_length; + fs.fs_start = fiemap->fm_start; + /* fs_start is beyond the end of the file */ + if (fs.fs_start > fmkey->lfik_oa.o_size) { + rc = -EINVAL; + goto out; + } /* Calculate start stripe, last stripe and length of mapping */ - start_stripe = lov_stripe_number(lsm, fm_start); - fm_end = (fm_length == ~0ULL) ? fmkey->lfik_oa.o_size : - fm_start + fm_length - 1; - /* If fm_length != ~0ULL but fm_start_fm_length-1 exceeds file size */ - if (fm_end > fmkey->lfik_oa.o_size) - fm_end = fmkey->lfik_oa.o_size; - - last_stripe = fiemap_calc_last_stripe(lsm, fm_start, fm_end, - start_stripe, &stripe_count); - fm_end_offset = fiemap_calc_fm_end_offset(fiemap, lsm, fm_start, fm_end, - &start_stripe); - if (fm_end_offset == -EINVAL) { + fs.fs_start_stripe = lov_stripe_number(lsm, fs.fs_start); + fs.fs_end = (fs.fs_length == ~0ULL) ? fmkey->lfik_oa.o_size : + fs.fs_start + fs.fs_length - 1; + /* If fs_length != ~0ULL but fs_start+fs_length-1 exceeds file size */ + if (fs.fs_end > fmkey->lfik_oa.o_size) { + fs.fs_end = fmkey->lfik_oa.o_size; + fs.fs_length = fs.fs_end - fs.fs_start; + } + + fs.fs_last_stripe = fiemap_calc_last_stripe(lsm, fs.fs_start, fs.fs_end, + fs.fs_start_stripe, + &stripe_count); + fs.fs_end_offset = fiemap_calc_fm_end_offset(fiemap, lsm, fs.fs_start, + fs.fs_end, + &fs.fs_start_stripe); + if (fs.fs_end_offset == -EINVAL) { rc = -EINVAL; goto out; } + /** * Requested extent count exceeds the fiemap buffer size, shrink our * ambition. @@ -1244,186 +1419,23 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj, if (fiemap_count_to_size(fiemap->fm_extent_count) > *buflen) fiemap->fm_extent_count = fiemap_size_to_count(*buflen); if (!fiemap->fm_extent_count) - count_local = 0; + fs.fs_cnt_need = 0; + + fs.fs_finish = false; + fs.fs_enough = false; + fs.fs_cur_extent = 0; /* Check each stripe */ - for (cur_stripe = start_stripe; stripe_count > 0; + for (cur_stripe = fs.fs_start_stripe; stripe_count > 0; --stripe_count, cur_stripe = (cur_stripe + 1) % lsm->lsm_stripe_count) { - loff_t req_fm_len; /* Stores length of required mapping */ - loff_t len_mapped_single_call; - loff_t lun_start; - loff_t lun_end; - loff_t obd_object_end; - unsigned int ext_count; - - cur_stripe_wrap = cur_stripe; - - /* Find out range of mapping on this stripe */ - if (!(lov_stripe_intersects(lsm, cur_stripe, fm_start, fm_end, - &lun_start, &obd_object_end))) - continue; - - if (lov_oinfo_is_dummy(lsm->lsm_oinfo[cur_stripe])) { - rc = -EIO; - goto out; - } - - /* - * If this is a continuation FIEMAP call and we are on - * starting stripe then lun_start needs to be set to - * fm_end_offset - */ - if (fm_end_offset && cur_stripe == start_stripe) - lun_start = fm_end_offset; - - if (fm_length != ~0ULL) { - /* Handle fm_start + fm_length overflow */ - if (fm_start + fm_length < fm_start) - fm_length = ~0ULL - fm_start; - lun_end = lov_size_to_stripe(lsm, fm_start + fm_length, - cur_stripe); - } else { - lun_end = ~0ULL; - } - - if (lun_start == lun_end) - continue; - - req_fm_len = obd_object_end - lun_start; - fm_local->fm_length = 0; - len_mapped_single_call = 0; - - /* find lobsub object */ - subobj = lov_find_subobj(env, cl2lov(obj), lsm, - cur_stripe); - if (IS_ERR(subobj)) { - rc = PTR_ERR(subobj); + rc = fiemap_for_stripe(env, obj, lsm, fiemap, buflen, fmkey, + cur_stripe, &fs); + if (rc < 0) goto out; - } - /* - * If the output buffer is very large and the objects have many - * extents we may need to loop on a single OST repeatedly - */ - ost_eof = false; - ost_done = false; - do { - if (fiemap->fm_extent_count > 0) { - /* Don't get too many extents. */ - if (current_extent + count_local > - fiemap->fm_extent_count) - count_local = fiemap->fm_extent_count - - current_extent; - } - - lun_start += len_mapped_single_call; - fm_local->fm_length = req_fm_len - - len_mapped_single_call; - req_fm_len = fm_local->fm_length; - fm_local->fm_extent_count = enough ? 1 : count_local; - fm_local->fm_mapped_extents = 0; - fm_local->fm_flags = fiemap->fm_flags; - - ost_index = lsm->lsm_oinfo[cur_stripe]->loi_ost_idx; - - if (ost_index < 0 || - ost_index >= lov->desc.ld_tgt_count) { - rc = -EINVAL; - goto obj_put; - } - /* - * If OST is inactive, return extent with UNKNOWN - * flag. - */ - if (!lov->lov_tgts[ost_index]->ltd_active) { - fm_local->fm_flags |= FIEMAP_EXTENT_LAST; - fm_local->fm_mapped_extents = 1; - - lcl_fm_ext[0].fe_logical = lun_start; - lcl_fm_ext[0].fe_length = obd_object_end - - lun_start; - lcl_fm_ext[0].fe_flags |= FIEMAP_EXTENT_UNKNOWN; - - goto inactive_tgt; - } - - fm_local->fm_start = lun_start; - fm_local->fm_flags &= ~FIEMAP_FLAG_DEVICE_ORDER; - memcpy(&fmkey->lfik_fiemap, fm_local, sizeof(*fm_local)); - *buflen = fiemap_count_to_size(fm_local->fm_extent_count); - - rc = cl_object_fiemap(env, subobj, fmkey, fm_local, - buflen); - if (rc) - goto obj_put; -inactive_tgt: - ext_count = fm_local->fm_mapped_extents; - if (!ext_count) { - ost_done = true; - /* - * If last stripe has hold at the end, - * we need to return - */ - if (cur_stripe_wrap == last_stripe) { - fiemap->fm_mapped_extents = 0; - goto finish; - } - break; - } else if (enough) { - /* - * We've collected enough extents and there are - * more extents after it. - */ - goto finish; - } - - /* If we just need num of extents, got to next device */ - if (!fiemap->fm_extent_count) { - current_extent += ext_count; - break; - } - - /* prepare to copy retrived map extents */ - len_mapped_single_call = - lcl_fm_ext[ext_count - 1].fe_logical - - lun_start + lcl_fm_ext[ext_count - 1].fe_length; - - /* Have we finished mapping on this device? */ - if (req_fm_len <= len_mapped_single_call) - ost_done = true; - - /* - * Clear the EXTENT_LAST flag which can be present on - * the last extent - */ - if (lcl_fm_ext[ext_count - 1].fe_flags & - FIEMAP_EXTENT_LAST) - lcl_fm_ext[ext_count - 1].fe_flags &= - ~FIEMAP_EXTENT_LAST; - - if (lov_stripe_size(lsm, - lcl_fm_ext[ext_count - 1].fe_logical + - lcl_fm_ext[ext_count - 1].fe_length, - cur_stripe) >= fmkey->lfik_oa.o_size) - ost_eof = true; - - fiemap_prepare_and_copy_exts(fiemap, lcl_fm_ext, - ost_index, ext_count, - current_extent); - current_extent += ext_count; - - /* Ran out of available extents? */ - if (current_extent >= fiemap->fm_extent_count) - enough = true; - } while (!ost_done && !ost_eof); - - cl_object_put(env, subobj); - subobj = NULL; - - if (cur_stripe_wrap == last_stripe) - goto finish; + if (fs.fs_finish) + break; } /* for each stripe */ -finish: /* * Indicate that we are returning device offsets unless file just has * single stripe @@ -1438,14 +1450,11 @@ finish: * Check if we have reached the last stripe and whether mapping for that * stripe is done. */ - if ((cur_stripe_wrap == last_stripe) && (ost_done || ost_eof)) - fiemap->fm_extents[current_extent - 1].fe_flags |= + if ((cur_stripe == fs.fs_last_stripe) && fs.fs_device_done) + fiemap->fm_extents[fs.fs_cur_extent - 1].fe_flags |= FIEMAP_EXTENT_LAST; skip_last_device_calc: - fiemap->fm_mapped_extents = current_extent; -obj_put: - if (subobj) - cl_object_put(env, subobj); + fiemap->fm_mapped_extents = fs.fs_cur_extent; out: kvfree(fm_local); lov_lsm_put(lsm); diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index ecca74fbff00..899d12c41aab 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -32,9 +32,9 @@ #define DEBUG_SUBSYSTEM S_LOV -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/obd_class.h" +#include <obd_class.h> #include "lov_internal.h" diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 638b7646ca2c..24fb2a97532b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -38,14 +38,11 @@ #define DEBUG_SUBSYSTEM S_LOV -#include "../include/lustre/lustre_idl.h" -#include "../include/lustre/lustre_user.h" - -#include "../include/lustre_net.h" -#include "../include/lustre_swab.h" -#include "../include/obd.h" -#include "../include/obd_class.h" -#include "../include/obd_support.h" +#include <lustre_net.h> +#include <lustre_swab.h> +#include <obd.h> +#include <obd_class.h> +#include <obd_support.h> #include "lov_cl_internal.h" #include "lov_internal.h" diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 62ceb6dfdfdf..de43c609cf3d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -100,7 +100,6 @@ int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, break; } } - lov_sub_put(sub); return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 39daa17e0736..d774ee2a3675 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -40,9 +40,9 @@ #define DEBUG_SUBSYSTEM S_LOV -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/obd.h" +#include <obd.h> #include "lov_internal.h" #define pool_tgt(_p, _i) \ diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 3a747913fb4f..9d3b3f3e9f10 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -32,10 +32,10 @@ #define DEBUG_SUBSYSTEM S_LOV -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/obd_class.h" -#include "../include/lustre/lustre_idl.h" +#include <obd_class.h> +#include <uapi/linux/lustre/lustre_idl.h> #include "lov_internal.h" static void lov_init_set(struct lov_request_set *set) @@ -43,13 +43,10 @@ static void lov_init_set(struct lov_request_set *set) set->set_count = 0; atomic_set(&set->set_completes, 0); atomic_set(&set->set_success, 0); - atomic_set(&set->set_finish_checked, 0); INIT_LIST_HEAD(&set->set_list); - atomic_set(&set->set_refcount, 1); - init_waitqueue_head(&set->set_waitq); } -void lov_finish_set(struct lov_request_set *set) +static void lov_finish_set(struct lov_request_set *set) { struct list_head *pos, *n; @@ -66,32 +63,12 @@ void lov_finish_set(struct lov_request_set *set) kfree(set); } -static int lov_set_finished(struct lov_request_set *set, int idempotent) -{ - int completes = atomic_read(&set->set_completes); - - CDEBUG(D_INFO, "check set %d/%d\n", completes, set->set_count); - - if (completes == set->set_count) { - if (idempotent) - return 1; - if (atomic_inc_return(&set->set_finish_checked) == 1) - return 1; - } - return 0; -} - static void lov_update_set(struct lov_request_set *set, struct lov_request *req, int rc) { - req->rq_complete = 1; - req->rq_rc = rc; - atomic_inc(&set->set_completes); if (rc == 0) atomic_inc(&set->set_success); - - wake_up(&set->set_waitq); } static void lov_set_add_req(struct lov_request *req, @@ -173,8 +150,8 @@ out: (tot) += (add); \ } while (0) -int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs, - int success) +static int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs, + int success) { if (success) { __u32 expected_stripes = lov_get_stripecnt(&obd->u.lov, @@ -205,7 +182,9 @@ int lov_fini_statfs_set(struct lov_request_set *set) rc = lov_fini_statfs(set->set_obd, set->set_oi->oi_osfs, atomic_read(&set->set_success)); } - lov_put_reqset(set); + + lov_finish_set(set); + return rc; } @@ -307,14 +286,7 @@ static int cb_statfs_update(void *cookie, int rc) out_update: lov_update_statfs(osfs, lov_sfs, success); obd_putref(lovobd); - out: - if (set->set_oi->oi_flags & OBD_STATFS_PTLRPCD && - lov_set_finished(set, 0)) { - lov_statfs_interpret(NULL, set, set->set_count != - atomic_read(&set->set_success)); - } - return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 5d6536f8a4f7..d4646a0949d2 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -77,7 +77,6 @@ static struct lu_device *lovsub_device_fini(const struct lu_env *env, lsd = lu2lovsub_dev(d); next = cl2lu_dev(lsd->acid_next); - lsd->acid_super = NULL; lsd->acid_next = NULL; return next; } diff --git a/drivers/staging/lustre/lustre/lov/lovsub_io.c b/drivers/staging/lustre/lustre/lov/lovsub_io.c deleted file mode 100644 index 6a9820218a3e..000000000000 --- a/drivers/staging/lustre/lustre/lov/lovsub_io.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * Implementation of cl_io for LOVSUB layer. - * - * Author: Nikita Danilov <nikita.danilov@sun.com> - */ - -#define DEBUG_SUBSYSTEM S_LOV - -#include "lov_cl_internal.h" - -/** \addtogroup lov - * @{ - */ - -/***************************************************************************** - * - * Lovsub io operations. - * - */ - -/* All trivial */ - -/** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 38f9b735c241..d29f0bb33980 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -54,7 +54,6 @@ static void lovsub_lock_fini(const struct lu_env *env, struct lovsub_lock *lsl; lsl = cl2lovsub_lock(slice); - LASSERT(list_empty(&lsl->lss_parents)); kmem_cache_free(lovsub_lock_kmem, lsl); } @@ -70,7 +69,6 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, lsk = kmem_cache_zalloc(lovsub_lock_kmem, GFP_NOFS); if (lsk) { - INIT_LIST_HEAD(&lsk->lss_parents); cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); result = 0; } else { diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index eb6d30d34e3a..9bb7e9ea0a6a 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -32,8 +32,8 @@ #define DEBUG_SUBSYSTEM S_CLASS #include <linux/statfs.h> -#include "../include/lprocfs_status.h" -#include "../include/obd_class.h" +#include <lprocfs_status.h> +#include <obd_class.h> #include <linux/seq_file.h> #include "lov_internal.h" @@ -279,7 +279,7 @@ static struct attribute *lov_attrs[] = { NULL, }; -static struct attribute_group lov_attr_group = { +static const struct attribute_group lov_attr_group = { .attrs = lov_attrs, }; |