From 892605ecc33b601d68585e67d75ff192ba5586f3 Mon Sep 17 00:00:00 2001 From: braam Date: Thu, 7 Nov 2002 04:29:45 +0000 Subject: [PATCH] - add another sanity test - test if we have a lock already in revalidate2 --- lustre/llite/dcache.c | 35 +++++++++++++++++++++++++++++++++++ lustre/tests/sanity.sh | 18 ++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 0f89d8a..53c0ef4d4 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -28,6 +28,7 @@ #include #include +#include #include extern struct address_space_operations ll_aops; @@ -95,6 +96,36 @@ static int revalidate2_finish(int flag, struct ptlrpc_request *request, return 0; } +static int ll_have_lock(struct dentry *de) +{ + struct ll_sb_info *sbi = ll_s2sbi(de->d_sb); + struct lustre_handle lockh; + __u64 res_id[RES_NAME_SIZE] = {0}; + struct obd_device *obddev; + ENTRY; + + if (!de->d_inode) + RETURN(0); + + obddev = class_conn2obd(&sbi->ll_mdc_conn); + res_id[0] = de->d_inode->i_ino; + + CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id[0]); + + if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_PLAIN, + NULL, 0, LCK_PR, &lockh)) { + ldlm_lock_decref(&lockh, LCK_PR); + RETURN(1); + } + + if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_PLAIN, + NULL, 0, LCK_PW, &lockh)) { + ldlm_lock_decref(&lockh, LCK_PW); + RETURN(1); + } + RETURN(0); +} + int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it) { int rc; @@ -108,6 +139,9 @@ int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it) RETURN(0); } + if (ll_have_lock(de)) + GOTO(out, rc = 0); + rc = ll_intent_lock(de->d_parent->d_inode, &de, it, revalidate2_finish); if (rc < 0) { /* Something bad happened; overwrite it_status? */ @@ -120,6 +154,7 @@ int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it) spin_unlock(&dcache_lock); d_rehash(de); + out: if (!it) de->d_it = NULL; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index df7ccff..fabbedf 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -161,18 +161,32 @@ $CLEAN dmesg | grep -i destruct $START -echo '==== touch /mnt/lustre/f ; ls /mnt/lustre ==== test 17' +echo '==== touch /mnt/lustre/f ; ls /mnt/lustre ==== test 18' touch /mnt/lustre/f ls /mnt/lustre $CLEAN dmesg | grep -i destruct $START -echo '==== touch /mnt/lustre/f ; ls -l /mnt/lustre ==== test 18' +echo '==== touch /mnt/lustre/f ; ls -l /mnt/lustre ==== test 19' touch /mnt/lustre/f ls -l /mnt/lustre $CLEAN dmesg | grep -i destruct $START +echo '==== touch /mnt/lustre/f ; ls -l /mnt/lustre ==== test 19' +touch /mnt/lustre/f +rm /mnt/lustre/f +echo "1 done" +touch /mnt/lustre/f +rm /mnt/lustre/f +echo "2 done" +touch /mnt/lustre/f +rm /mnt/lustre/f +echo "3 done" +$CLEAN +dmesg | grep -i destruct +$START + exit -- 1.8.3.1