Whamcloud - gitweb
LU-11654 mdd: check ucred before using it 38/33638/2
authorJinshan Xiong <jinshan.xiong@gmail.com>
Sat, 10 Nov 2018 20:06:16 +0000 (12:06 -0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 17 Nov 2018 01:25:42 +0000 (01:25 +0000)
On the code path of client eviction, lu_ucred in mdd_close() is not
initialized so we need to check it before trying to dereference it.

Signed-off-by: Jinshan Xiong <jinshan.xiong@uber.com>
Change-Id: I51b2a30e651761d66470fedf39da8e99b47ea6b4
Reviewed-on: https://review.whamcloud.com/33638
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_object.c

index c04c685..4b81988 100644 (file)
@@ -3129,7 +3129,7 @@ static int mdd_close(const struct lu_env *env, struct md_object *obj,
        int is_orphan = 0;
        int rc;
        bool blocked = false;
-       int last_close_by_uid = 0;
+       bool last_close_by_uid = false;
        const struct lu_ucred *uc = lu_ucred(env);
        ENTRY;
 
@@ -3211,8 +3211,9 @@ cont:
        mdd_obj->mod_count--; /*release open count */
 
        /* under mdd write lock */
-       /* If recording, see if we need to remove UID from list */
-       if (mdd_changelog_enabled(env, mdd, CL_OPEN)) {
+       /* If recording, see if we need to remove UID from list. uc is not
+        * initialized if the client has been evicted. */
+       if (mdd_changelog_enabled(env, mdd, CL_OPEN) && uc) {
                struct mdd_object_user *mou;
 
                /* look for UID in list */
@@ -3226,7 +3227,7 @@ cont:
                        mou->mou_opencount--;
                        if (mou->mou_opencount == 0) {
                                mdd_obj_user_remove(mdd_obj, mou);
-                               last_close_by_uid = 1;
+                               last_close_by_uid = true;
                        }
                }
        }