Whamcloud - gitweb
LU-17625 statahead: avoid to use @sai after its has been freed 26/54826/3
authorQian Yingjin <qian@ddn.com>
Wed, 17 Apr 2024 08:22:02 +0000 (04:22 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 May 2024 18:25:05 +0000 (18:25 +0000)
There is a race between a statahead thread startup and another
statahead reqeust trying to access the same statahead structure.
But the statahead thread startup was failed and free the statahead
structure too earlier. The user stat() request will use the
statahead structure which memory has been freed already wrongly...

In this patch, we repace the @ll_sai_free/@ll_sax_free with
@ll_sai_put/@ll_sax_put to avoid freeing the statahead structure
too eariler when they were still being used by user stat()
request.

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I3840be959160aed2887a91be81da05f796306cd9
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54826
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/statahead.c

index 94923a3..77b2c02 100644 (file)
@@ -2436,10 +2436,10 @@ out:
        spin_unlock(&lli->lli_sa_lock);
 
        if (sai)
-               ll_sai_free(sai);
+               ll_sai_put(sai);
 
        if (ctx)
-               ll_sax_free(ctx);
+               ll_sax_put(dir, ctx);
 
        if (rc)
                atomic_dec(&sbi->ll_sa_running);
@@ -2659,10 +2659,10 @@ out:
        }
 
        if (sai)
-               ll_sai_free(sai);
+               ll_sai_put(sai);
 
        if (ctx)
-               ll_sax_free(ctx);
+               ll_sax_put(dir, ctx);
 
        atomic_dec(&sbi->ll_sa_running);
        RETURN(rc);