X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosc%2Fosc_object.c;h=aa878d275c30393bffff42682c407c6800d9a561;hb=7a814e94e065551ab79e2ba75df9626e4940efc5;hp=16bb564354fe03fac3e0c59d9955cd15de8a82ba;hpb=8f01f8b51d114b0d2d54a5ab7db3161782e52447;p=fs%2Flustre-release.git diff --git a/lustre/osc/osc_object.c b/lustre/osc/osc_object.c index 16bb564..aa878d2 100644 --- a/lustre/osc/osc_object.c +++ b/lustre/osc/osc_object.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2014, Intel Corporation. + * Copyright (c) 2011, 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -131,8 +127,8 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) int osc_lvb_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct ost_lvb *lvb) { - return (*p)(env, cookie, "size: "LPU64" mtime: "LPU64" atime: "LPU64" " - "ctime: "LPU64" blocks: "LPU64, + return (*p)(env, cookie, "size: %llu mtime: %llu atime: %llu " + "ctime: %llu blocks: %llu", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); } @@ -145,8 +141,8 @@ static int osc_object_print(const struct lu_env *env, void *cookie, struct osc_async_rc *ar = &oinfo->loi_ar; (*p)(env, cookie, "id: "DOSTID" " - "idx: %d gen: %d kms_valid: %u kms "LPU64" " - "rc: %d force_sync: %d min_xid: "LPU64" ", + "idx: %d gen: %d kms_valid: %u kms %llu " + "rc: %d force_sync: %d min_xid: %llu ", POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, oinfo->loi_ost_gen, oinfo->loi_kms_valid, oinfo->loi_kms, ar->ar_rc, ar->ar_force_sync, ar->ar_min_xid); @@ -182,7 +178,7 @@ static int osc_attr_update(const struct lu_env *env, struct cl_object *obj, if (valid & CAT_BLOCKS) lvb->lvb_blocks = attr->cat_blocks; if (valid & CAT_KMS) { - CDEBUG(D_CACHE, "set kms from "LPU64"to "LPU64"\n", + CDEBUG(D_CACHE, "set kms from %lluto %llu\n", oinfo->loi_kms, (__u64)attr->cat_kms); loi_kms_set(oinfo, attr->cat_kms); } @@ -214,10 +210,6 @@ static int osc_object_prune(const struct lu_env *env, struct cl_object *obj) struct osc_object *osc = cl2osc(obj); struct ldlm_res_id *resname = &osc_env_info(env)->oti_resname; - LASSERTF(osc->oo_npages == 0, - DFID "still have %lu pages, obj: %p, osc: %p\n", - PFID(lu_object_fid(&obj->co_lu)), osc->oo_npages, obj, osc); - /* DLM locks don't hold a reference of osc_object so we have to * clear it before the object is being destroyed. */ ostid_build_res_name(&osc->oo_oinfo->loi_oi, resname); @@ -225,31 +217,6 @@ static int osc_object_prune(const struct lu_env *env, struct cl_object *obj) osc_object_ast_clear, osc); return 0; } -/** - * Find any ldlm lock covers the osc object. - * \retval 0 not found - * \retval 1 find one - * \retval < 0 error - */ -static int osc_object_find_cbdata(const struct lu_env *env, - struct cl_object *obj, ldlm_iterator_t iter, - void *data) -{ - struct ldlm_res_id res_id; - struct obd_device *obd; - int rc = 0; - - ostid_build_res_name(&cl2osc(obj)->oo_oinfo->loi_oi, &res_id); - obd = obj->co_lu.lo_dev->ld_obd; - rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, iter, data); - if (rc == LDLM_ITER_STOP) - return 1; - - if (rc == LDLM_ITER_CONTINUE) - return 0; - - return rc; -} static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj, struct ll_fiemap_info_key *fmkey, @@ -270,15 +237,15 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj, if (!(fmkey->lfik_fiemap.fm_flags & FIEMAP_FLAG_SYNC)) goto skip_locking; - policy.l_extent.start = fmkey->lfik_fiemap.fm_start & PAGE_CACHE_MASK; + policy.l_extent.start = fmkey->lfik_fiemap.fm_start & PAGE_MASK; if (OBD_OBJECT_EOF - fmkey->lfik_fiemap.fm_length <= - fmkey->lfik_fiemap.fm_start + PAGE_CACHE_SIZE - 1) + fmkey->lfik_fiemap.fm_start + PAGE_SIZE - 1) policy.l_extent.end = OBD_OBJECT_EOF; else policy.l_extent.end = (fmkey->lfik_fiemap.fm_start + fmkey->lfik_fiemap.fm_length + - PAGE_CACHE_SIZE - 1) & PAGE_CACHE_MASK; + PAGE_SIZE - 1) & PAGE_MASK; ostid_build_res_name(&fmkey->lfik_oa.o_oi, &resid); mode = ldlm_lock_match(exp->exp_obd->obd_namespace, @@ -374,6 +341,77 @@ int osc_object_is_contended(struct osc_object *obj) return 1; } +/** + * Implementation of struct cl_object_operations::coo_req_attr_set() for osc + * layer. osc is responsible for struct obdo::o_id and struct obdo::o_seq + * fields. + */ +static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj, + struct cl_req_attr *attr) +{ + struct lov_oinfo *oinfo; + struct obdo *oa; + struct ost_lvb *lvb; + u64 flags = attr->cra_flags; + + oinfo = cl2osc(obj)->oo_oinfo; + lvb = &oinfo->loi_lvb; + oa = attr->cra_oa; + + if ((flags & OBD_MD_FLMTIME) != 0) { + oa->o_mtime = lvb->lvb_mtime; + oa->o_valid |= OBD_MD_FLMTIME; + } + if ((flags & OBD_MD_FLATIME) != 0) { + oa->o_atime = lvb->lvb_atime; + oa->o_valid |= OBD_MD_FLATIME; + } + if ((flags & OBD_MD_FLCTIME) != 0) { + oa->o_ctime = lvb->lvb_ctime; + oa->o_valid |= OBD_MD_FLCTIME; + } + if (flags & OBD_MD_FLGROUP) { + ostid_set_seq(&oa->o_oi, ostid_seq(&oinfo->loi_oi)); + oa->o_valid |= OBD_MD_FLGROUP; + } + if (flags & OBD_MD_FLID) { + ostid_set_id(&oa->o_oi, ostid_id(&oinfo->loi_oi)); + oa->o_valid |= OBD_MD_FLID; + } + if (flags & OBD_MD_FLHANDLE) { + struct ldlm_lock *lock; + struct osc_page *opg; + + opg = osc_cl_page_osc(attr->cra_page, cl2osc(obj)); + lock = osc_dlmlock_at_pgoff(env, cl2osc(obj), osc_index(opg), + OSC_DAP_FL_TEST_LOCK | OSC_DAP_FL_CANCELING); + if (lock == NULL && !opg->ops_srvlock) { + struct ldlm_resource *res; + struct ldlm_res_id *resname; + + CL_PAGE_DEBUG(D_ERROR, env, attr->cra_page, + "uncovered page!\n"); + + resname = &osc_env_info(env)->oti_resname; + ostid_build_res_name(&oinfo->loi_oi, resname); + res = ldlm_resource_get( + osc_export(cl2osc(obj))->exp_obd->obd_namespace, + NULL, resname, LDLM_EXTENT, 0); + ldlm_resource_dump(D_ERROR, res); + + libcfs_debug_dumpstack(NULL); + LBUG(); + } + + /* check for lockless io. */ + if (lock != NULL) { + oa->o_handle = lock->l_remote_handle; + oa->o_valid |= OBD_MD_FLHANDLE; + LDLM_LOCK_PUT(lock); + } + } +} + static const struct cl_object_operations osc_ops = { .coo_page_init = osc_page_init, .coo_lock_init = osc_lock_init, @@ -382,8 +420,8 @@ static const struct cl_object_operations osc_ops = { .coo_attr_update = osc_attr_update, .coo_glimpse = osc_object_glimpse, .coo_prune = osc_object_prune, - .coo_find_cbdata = osc_object_find_cbdata, .coo_fiemap = osc_object_fiemap, + .coo_req_attr_set = osc_req_attr_set }; static const struct lu_object_operations osc_lu_obj_ops = { @@ -422,9 +460,15 @@ int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc) l_wait_event(osc->oo_io_waitq, atomic_read(&osc->oo_nr_ios) == 0, &lwi); - /* Discard all pages of this object. */ + /* Discard all dirty pages of this object. */ osc_cache_truncate_start(env, osc, 0, NULL); + /* Discard all caching pages */ + osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF, CLM_WRITE); + + /* Clear ast data of dlm lock. Do this after discarding all pages */ + osc_object_prune(env, osc2cl(osc)); + RETURN(0); }