Whamcloud - gitweb
LU-15761 obdclass: fix locking in llog_cat_refresh() 85/47185/3
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 2 May 2022 18:38:47 +0000 (21:38 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 May 2022 18:48:10 +0000 (18:48 +0000)
the patch fixes two problems:
1) pairing up_write() should be used with cathandle
2) llog_read_header() manipulates loghandle's internal
   structures (header, last_idx, etc) which are supposed
   to stay consistent from another user's point of view
   (like llog_add_rec())

Fixes: 71f409c9b31b ("LU-11418 llog: refresh remote llog upon -ESTALE")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ib86e10a925b541d02c22d74e6ddbc4368345ac11
Reviewed-on: https://review.whamcloud.com/47185
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/llog_cat.c

index 97f15e4..3f53dab 100644 (file)
@@ -246,14 +246,16 @@ static int llog_cat_refresh(const struct lu_env *env,
                if (!llog_exist(loghandle))
                        continue;
 
+               down_write(&loghandle->lgh_lock);
                rc = llog_read_header(env, loghandle, NULL);
+               up_write(&loghandle->lgh_lock);
                if (rc)
                        goto unlock;
        }
 
        rc = llog_read_header(env, cathandle, NULL);
 unlock:
-       up_write(&loghandle->lgh_lock);
+       up_write(&cathandle->lgh_lock);
 
        return rc;
 }