From 340eddbaa317d7765da476f0bf0037b072cf04f6 Mon Sep 17 00:00:00 2001 From: huanghua Date: Sun, 17 Sep 2006 15:52:06 +0000 Subject: [PATCH] small fix about RQF_MDT_EPOCH: check buffer len first. --- lustre/mdc/mdc_lib.c | 7 +++++-- lustre/mdt/mdt_lib.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index 1e957f2..2ad40ba 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -220,10 +220,13 @@ void mdc_setattr_pack(struct ptlrpc_request *req, int offset, struct mdt_epoch *epoch; rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec)); - epoch = lustre_msg_buf(req->rq_reqmsg, offset + 1, sizeof(*epoch)); mdc_setattr_pack_rec(rec, op_data); - if (epoch) + + if (op_data->flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN)) { + epoch = lustre_msg_buf(req->rq_reqmsg, offset + 1, + sizeof(*epoch)); mdc_epoch_pack(epoch, op_data); + } if (ealen == 0) return; diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index a0cb3a7..a1e5baf 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -199,7 +199,13 @@ static int mdt_epoch_unpack(struct mdt_thread_info *info) struct req_capsule *pill = &info->mti_pill; ENTRY; - info->mti_epoch = req_capsule_client_get(pill, &RMF_MDT_EPOCH); + if (req_capsule_get_size(pill, &RMF_MDT_EPOCH, RCL_CLIENT)) + info->mti_epoch = req_capsule_client_get(pill, &RMF_MDT_EPOCH); + else + /* it is set to NULL already. + info->mti_epoch = NULL; + */ + ; RETURN(info->mti_epoch == NULL ? -EFAULT : 0); } @@ -214,7 +220,7 @@ static int mdt_setattr_unpack(struct mdt_thread_info *info) if (rc) RETURN(rc); - /* Epoch may be absent, skip errors. */ + /* Epoch may be absent */ mdt_epoch_unpack(info); if (req_capsule_field_present(pill, &RMF_EADATA, RCL_CLIENT)) { -- 1.8.3.1