Whamcloud - gitweb
LU-4222 mdt: extra checking for getattr RPC. 50/8550/8 b2_4
authorwang di <di.wang@intel.com>
Thu, 12 Dec 2013 18:33:56 +0000 (10:33 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 27 Mar 2014 18:12:32 +0000 (14:12 -0400)
It should check whether getattr RPC can hold
layout MD(RMF_MDT_MD), in case the client sends
some invalid RPC, which can cause panic on MDT.

Client will retrieve cl_max_md_size/cl_default_md_size
from MDS during mount process, so it will initialize
cl_max_md_size/cl_default_md_size before sending getattr
to MDS.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Ic12f281d574e7138ee0e1d5aae6161b7607837cc

lustre/llite/llite_lib.c
lustre/mdc/mdc_request.c
lustre/mdt/mdt_handler.c

index b2332fc..75426ff 100644 (file)
@@ -494,7 +494,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
 
        /* make root inode
         * XXX: move this to after cbd setup? */
-       valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | OBD_MD_FLMDSCAPA;
+       valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | OBD_MD_FLMDSCAPA |
+               OBD_MD_FLMODEASIZE;
        if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
                valid |= OBD_MD_FLRMTPERM;
        else if (sbi->ll_flags & LL_SBI_ACL)
index cc592a7..f9ef390 100644 (file)
@@ -189,14 +189,13 @@ static int mdc_getattr_common(struct obd_export *exp,
 
         CDEBUG(D_NET, "mode: %o\n", body->mode);
 
-        if (body->eadatasize != 0) {
-                mdc_update_max_ea_from_body(exp, body);
-
-                eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
-                                                      body->eadatasize);
-                if (eadata == NULL)
-                        RETURN(-EPROTO);
-        }
+       mdc_update_max_ea_from_body(exp, body);
+       if (body->eadatasize != 0) {
+               eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
+                                                     body->eadatasize);
+               if (eadata == NULL)
+                       RETURN(-EPROTO);
+       }
 
         if (body->valid & OBD_MD_FLRMTPERM) {
                 struct mdt_remote_perm *perm;
index 05c830e..a74062a 100644 (file)
@@ -697,23 +697,34 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
        }
 
        buffer->lb_len = reqbody->eadatasize;
-       if (buffer->lb_len > 0)
+       if (buffer->lb_len > 0) {
                buffer->lb_buf = req_capsule_server_get(pill, &RMF_MDT_MD);
-       else
+               if (buffer->lb_buf == NULL)
+                       GOTO(out, rc = -EPROTO);
+       } else {
                buffer->lb_buf = NULL;
+               ma_need &= ~(MA_LOV | MA_LMV);
+               CDEBUG(D_INFO, "%s: RPC from %s: does not need LOVEA.\n",
+                      mdt_obd_name(info->mti_mdt),
+                      req->rq_export->exp_client_uuid.uuid);
+       }
 
-        /* If it is dir object and client require MEA, then we got MEA */
-        if (S_ISDIR(lu_object_attr(&next->mo_lu)) &&
-            reqbody->valid & OBD_MD_MEA) {
-                /* Assumption: MDT_MD size is enough for lmv size. */
-                ma->ma_lmv = buffer->lb_buf;
-                ma->ma_lmv_size = buffer->lb_len;
-                ma->ma_need = MA_LMV | MA_INODE;
-        } else {
-                ma->ma_lmm = buffer->lb_buf;
-                ma->ma_lmm_size = buffer->lb_len;
-               ma->ma_need = MA_LOV | MA_INODE | MA_HSM;
-        }
+       /* If it is dir object and client require MEA, then we got MEA */
+       if (S_ISDIR(lu_object_attr(&next->mo_lu)) &&
+           reqbody->valid & OBD_MD_MEA) {
+               /* Assumption: MDT_MD size is enough for lmv size. */
+               ma->ma_lmv = buffer->lb_buf;
+               ma->ma_lmv_size = buffer->lb_len;
+               ma->ma_need = MA_INODE;
+               if (ma->ma_lmm_size > 0)
+                       ma->ma_need |= MA_LMV;
+       } else {
+               ma->ma_lmm = buffer->lb_buf;
+               ma->ma_lmm_size = buffer->lb_len;
+               ma->ma_need = MA_INODE | MA_HSM;
+               if (ma->ma_lmm_size > 0)
+                       ma->ma_need |= MA_LOV;
+       }
 
         if (S_ISDIR(lu_object_attr(&next->mo_lu)) &&
             reqbody->valid & OBD_MD_FLDIREA  &&