From 6c693d126197bc818b9e642c6b8db3d244265ec4 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Thu, 9 Sep 2021 14:47:47 +0800 Subject: [PATCH] EX-3764 pcc: avoid panic in asynchronous attach thread When PCC attach a file asynchronously, it wrongly uses @pccx->pccx_file after put the file in @pcc_attach_context_free(). This may casue panic in pcc_readonly_attach_thread(). This patch fixes it by using @pccx->pccx_file before put it. Signed-off-by: Qian Yingjin Change-Id: Iaa93403e4db7497923033d327e689627790fa6a0 Reviewed-on: https://review.whamcloud.com/44881 Tested-by: jenkins Reviewed-by: Yang Sheng Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/llite/pcc.c | 9 +++++---- lustre/tests/sanity-pcc.sh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 7846d68..9ff8727 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -1774,13 +1774,13 @@ static int pcc_readonly_attach_thread(void *arg) rc = pcc_readonly_attach(file, pccx->pccx_inode, pccx->pccx_attach_id); pcc_readonly_attach_fini(pccx->pccx_inode); - pcc_attach_context_free(pccx); - fput(file); -out: + CDEBUG(D_CACHE, "PCC-RO attach in background for %pd "DFID" rc = %d\n", file_dentry(pccx->pccx_file), PFID(ll_inode2fid(pccx->pccx_inode)), rc); - + pcc_attach_context_free(pccx); + fput(file); +out: RETURN(rc); } @@ -3576,6 +3576,7 @@ static int pcc_attach_data_archive(struct file *file, struct inode *inode, if (ret < 0) GOTO(out_fput, rc = ret); + CDEBUG(D_CACHE, "Copy data from OSTs to PCC for %pd\n", *dentry); /* * It must to truncate the PCC copy to the same size of the Lustre * copy after copy data. Otherwise, it may get wrong file size after diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index e459fcc..50b4f9e 100644 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -3359,7 +3359,7 @@ test_44() { setup_pcc_mapping client \ "projid={0}\ roid=$HSM_ARCHIVE_NUMBER\ ropcc=1\ mmap_conv=0" $LCTL pcc list $MOUNT - $LCTL set_param llite.*.pcc_async_threshold=1G + $LCTL set_param llite.*.pcc_async_threshold=0 dd if=/dev/zero of=$file bs=$bs count=$count || error "Write $file failed" -- 1.8.3.1