Whamcloud - gitweb
LU-4877 mdt: tolerate zero md_packed in mdt_fix_reply
[fs/lustre-release.git] / lustre / mdt / mdt_lib.c
index 1c60854..fa1d9ff 100644 (file)
@@ -95,28 +95,28 @@ static int match_nosquash_list(struct rw_semaphore *sem,
 static int mdt_root_squash(struct mdt_thread_info *info, lnet_nid_t peernid)
 {
        struct lu_ucred *ucred = mdt_ucred(info);
+       struct root_squash_info *squash = &info->mti_mdt->mdt_squash;
        ENTRY;
 
        LASSERT(ucred != NULL);
-       if (!info->mti_mdt->mdt_squash_uid || ucred->uc_fsuid)
+       if (!squash->rsi_uid || ucred->uc_fsuid)
                RETURN(0);
 
-        if (match_nosquash_list(&info->mti_mdt->mdt_squash_sem,
-                                &info->mti_mdt->mdt_nosquash_nids,
-                                peernid)) {
-                CDEBUG(D_OTHER, "%s is in nosquash_nids list\n",
-                       libcfs_nid2str(peernid));
-                RETURN(0);
-        }
+       if (match_nosquash_list(&squash->rsi_sem,
+                               &squash->rsi_nosquash_nids,
+                               peernid)) {
+               CDEBUG(D_OTHER, "%s is in nosquash_nids list\n",
+                      libcfs_nid2str(peernid));
+               RETURN(0);
+       }
 
        CDEBUG(D_OTHER, "squash req from %s, (%d:%d/%x)=>(%d:%d/%x)\n",
               libcfs_nid2str(peernid),
               ucred->uc_fsuid, ucred->uc_fsgid, ucred->uc_cap,
-              info->mti_mdt->mdt_squash_uid, info->mti_mdt->mdt_squash_gid,
-              0);
+              squash->rsi_uid, squash->rsi_gid, 0);
 
-       ucred->uc_fsuid = info->mti_mdt->mdt_squash_uid;
-       ucred->uc_fsgid = info->mti_mdt->mdt_squash_gid;
+       ucred->uc_fsuid = squash->rsi_uid;
+       ucred->uc_fsgid = squash->rsi_gid;
        ucred->uc_cap = 0;
        ucred->uc_suppgids[0] = -1;
        ucred->uc_suppgids[1] = -1;
@@ -631,15 +631,16 @@ int mdt_fix_reply(struct mdt_thread_info *info)
         /* MDT_MD buffer may be bigger than packed value, let's shrink all
          * buffers before growing it */
        if (info->mti_big_lmm_used) {
-                LASSERT(req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER));
+               /* big_lmm buffer may be used even without packing the result
+                * into reply, just for internal server needs */
+               if (req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER))
+                       md_packed = req_capsule_get_size(pill, &RMF_MDT_MD,
+                                                        RCL_SERVER);
 
-                /* free big lmm if md_size is not needed */
-               if (md_size == 0) {
+               /* free big lmm if md_size is not needed */
+               if (md_size == 0 || md_packed == 0) {
                        info->mti_big_lmm_used = 0;
                } else {
-                       md_packed = req_capsule_get_size(pill, &RMF_MDT_MD,
-                                                        RCL_SERVER);
-                       LASSERT(md_packed > 0);
                        /* buffer must be allocated separately */
                        LASSERT(info->mti_attr.ma_lmm !=
                                req_capsule_server_get(pill, &RMF_MDT_MD));