X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fofd%2Fofd_lvb.c;h=edadc699d9186a849af37efe43c80fab80541554;hb=b0f08a4e902411a8fbdb660e5b32c5821ca7159f;hp=208198ce93b5199af2e932519f52d0dd2cbea1d3;hpb=6c19f5437f2b089b8f27c3855408d098b01e63d9;p=fs%2Flustre-release.git diff --git a/lustre/ofd/ofd_lvb.c b/lustre/ofd/ofd_lvb.c index 208198c..edadc69 100644 --- a/lustre/ofd/ofd_lvb.c +++ b/lustre/ofd/ofd_lvb.c @@ -27,7 +27,7 @@ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Whamcloud, Inc. + * Copyright (c) 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -154,13 +154,34 @@ static int ofd_lvbo_update(struct ldlm_resource *res, /* Update the LVB from the network message */ if (req != NULL) { struct ost_lvb *rpc_lvb; + bool lvb_type; - /* XXX update always from reply buffer */ - rpc_lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB); - if (rpc_lvb == NULL) { - CERROR("lustre_swab_buf failed\n"); - goto disk_update; + if (req->rq_import != NULL) + lvb_type = imp_connect_lvb_type(req->rq_import); + else + lvb_type = exp_connect_lvb_type(req->rq_export); + + if (!lvb_type) { + struct ost_lvb_v1 *lvb_v1; + + lvb_v1 = req_capsule_server_swab_get(&req->rq_pill, + &RMF_DLM_LVB, lustre_swab_ost_lvb_v1); + if (lvb_v1 == NULL) + goto disk_update; + + rpc_lvb = &info->fti_lvb; + memcpy(rpc_lvb, lvb_v1, sizeof *lvb_v1); + rpc_lvb->lvb_mtime_ns = 0; + rpc_lvb->lvb_atime_ns = 0; + rpc_lvb->lvb_ctime_ns = 0; + } else { + rpc_lvb = req_capsule_server_swab_get(&req->rq_pill, + &RMF_DLM_LVB, + lustre_swab_ost_lvb); + if (rpc_lvb == NULL) + goto disk_update; } + lock_res(res); if (rpc_lvb->lvb_size > lvb->lvb_size || !increase_only) { CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb size: " @@ -186,6 +207,12 @@ static int ofd_lvbo_update(struct ldlm_resource *res, lvb->lvb_ctime, rpc_lvb->lvb_ctime); lvb->lvb_ctime = rpc_lvb->lvb_ctime; } + if (rpc_lvb->lvb_blocks > lvb->lvb_blocks || !increase_only) { + CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb blocks: " + LPU64" -> "LPU64"\n", res->lr_name.name[0], + lvb->lvb_blocks, rpc_lvb->lvb_blocks); + lvb->lvb_blocks = rpc_lvb->lvb_blocks; + } unlock_res(res); } @@ -226,7 +253,7 @@ disk_update: lvb->lvb_ctime, info->fti_attr.la_ctime); lvb->lvb_ctime = info->fti_attr.la_ctime; } - if (lvb->lvb_blocks != info->fti_attr.la_blocks) { + if (info->fti_attr.la_blocks > lvb->lvb_blocks || !increase_only) { CDEBUG(D_DLMTRACE,"res: "LPU64" updating lvb blocks from disk: " LPU64" -> %llu\n", res->lr_name.name[0], lvb->lvb_blocks, @@ -243,8 +270,30 @@ out_unlock: return rc; } +static int ofd_lvbo_size(struct ldlm_lock *lock) +{ + if (lock->l_export != NULL && exp_connect_lvb_type(lock->l_export)) + return sizeof(struct ost_lvb); + else + return sizeof(struct ost_lvb_v1); +} + +static int ofd_lvbo_fill(struct ldlm_lock *lock, void *buf, int buflen) +{ + struct ldlm_resource *res = lock->l_resource; + int lvb_len = min_t(int, res->lr_lvb_len, buflen); + + lock_res(res); + memcpy(buf, res->lr_lvb_data, lvb_len); + unlock_res(res); + + return lvb_len; +} + struct ldlm_valblock_ops ofd_lvbo = { lvbo_init: ofd_lvbo_init, lvbo_update: ofd_lvbo_update, lvbo_free: ofd_lvbo_free, + lvbo_size: ofd_lvbo_size, + lvbo_fill: ofd_lvbo_fill };