From 356fc1e703503bbf0bc33b8117ed04fbd5937edf Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Mon, 23 Dec 2019 14:07:25 +0300 Subject: [PATCH] LU-13099 lmv: disable statahead for remote objects Statahead for remote objects is supposed to be disabled by LU-11681 lmv: disable remote file statahead. However due to typo it is not and statahead for remote objects is accompanied by warnings like: ll_set_inode()) Can not initialize inode .. without object type.. ll_prep_inode()) new_inode -fatal: rc -12 Fix the typo. Test to illustrate the issue is added. Lustre-change: https://review.whamcloud.com/37089 Lustre-commit: 68330379b01cb6bf9b24235a80a4666d24c0e343 Fixes: 02b5a407081c ("LU-11681 lmv: disable remote file statahead") Signed-off-by: Vladimir Saveliev Signed-off-by: Lai Siyao Cray-bug-id: LUS-8262 Change-Id: Id9cc7f30ba75918658bf8eb1c8f3249993da6699 Reviewed-on: https://review.whamcloud.com/37370 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/lmv/lmv_obd.c | 28 ++++++++++++++++------------ lustre/tests/multiop.c | 40 +++++++++++++++++++++++++++++++++++++++- lustre/tests/sanity.sh | 21 +++++++++++++++++++++ lustre/tests/test-framework.sh | 2 +- 4 files changed, 77 insertions(+), 14 deletions(-) mode change 100644 => 100755 lustre/tests/sanity.sh diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 3b62fcd..91c7a3f 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -3334,27 +3334,31 @@ int lmv_intent_getattr_async(struct obd_export *exp, struct md_op_data *op_data = &minfo->mi_data; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt = NULL; + struct lmv_tgt_desc *ptgt; + struct lmv_tgt_desc *ctgt; int rc; + ENTRY; if (!fid_is_sane(&op_data->op_fid2)) RETURN(-EINVAL); - tgt = lmv_find_target(lmv, &op_data->op_fid1); - if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + ptgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1); + if (IS_ERR(ptgt)) + RETURN(PTR_ERR(ptgt)); - /* - * no special handle for remote dir, which needs to fetch both LOOKUP - * lock on parent, and then UPDATE lock on child MDT, which makes all - * complicated because this is done async. So only LOOKUP lock is - * fetched for remote dir, but considering remote dir is rare case, - * and not supporting it in statahead won't cause any issue, just leave - * it as is. + ctgt = lmv_find_target(lmv, &op_data->op_fid2); + if (IS_ERR(ctgt)) + RETURN(PTR_ERR(ctgt)); + + /* remote object needs two RPCs to lookup and getattr, considering the + * complexity, don't support statahead for now. */ + if (ptgt != ctgt) + RETURN(-EREMOTE); + + rc = md_intent_getattr_async(ptgt->ltd_exp, minfo); - rc = md_intent_getattr_async(tgt->ltd_exp, minfo); RETURN(rc); } diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index 44bbd4f..8a6001c 100644 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -78,9 +79,9 @@ char usage[] = " E[+|-] get lease. +/-: expect lease to (not) exist\n" " f statfs\n" " F print FID\n" -" H[num] create HSM released file with num stripes\n" " G gid get grouplock\n" " g gid put grouplock\n" +" H[num] create HSM released file with num stripes\n" " K link path to filename\n" " L link\n" " l symlink filename to path\n" @@ -91,6 +92,7 @@ char usage[] = " o open(O_RDONLY)\n" " O open(O_CREAT|O_RDWR)\n" " p print return value of last command\n" +" Q open filename (should be dir), stat first entry to init statahead" " r[num] read [optional length]\n" " R reference entire mmap-ed region\n" " s stat\n" @@ -203,6 +205,35 @@ int get_flags(char *data, int *rflags) return size; } +static int statahead(char *dname) +{ + DIR *d; + struct dirent *dent; + struct stat st; + char *buf; + int rc; + + rc = 0; + d = opendir(dname); + if (!d) + return errno; + dent = readdir(d); + if (!dent) { + rc = errno; + goto out_closedir; + } + if (asprintf(&buf, "%s/%s", dname, dent->d_name) == -1) { + rc = errno; + goto out_closedir; + } + if (stat(buf, &st)) + rc = errno; + free(buf); +out_closedir: + closedir(d); + return rc; +} + #define POP_ARG() (pop_arg(argc, argv)) int main(int argc, char **argv) @@ -542,6 +573,13 @@ int main(int argc, char **argv) case 'p': printf("%lld\n", last_rc); break; + case 'Q': + save_errno = statahead(fname); + if (save_errno) { + perror("statahead"); + exit(save_errno); + } + break; case 'r': len = atoi(commands+1); if (len <= 0) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh old mode 100644 new mode 100755 index 23d69b4..4c8b9a2 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -10477,6 +10477,27 @@ test_123b () { # statahead(bug 15027) } run_test 123b "not panic with network error in statahead enqueue (bug 15027)" +test_123c() { + [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs" + + test_mkdir -i 0 -c 1 $DIR/$tdir.0 + test_mkdir -i 1 -c 1 $DIR/$tdir.1 + touch $DIR/$tdir.1/{1..3} + mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0 + + remount_client $MOUNT + + $MULTIOP $DIR/$tdir.0 Q + + # let statahead to complete + ls -l $DIR/$tdir.0 > /dev/null + + testid=$(echo $TESTNAME | tr '_' ' ') + dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" && + error "statahead warning" || true +} +run_test 123c "Can not initialize inode warning on DNE statahead" + test_124a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize || diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 51b6089..846e083 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -6206,7 +6206,7 @@ run_one() { check_node_health check_dmesg_for_errors || error "Error in dmesg detected" if [ "$PARALLEL" != "yes" ]; then - ps auxww | grep -v grep | grep -q multiop && + ps auxww | grep -v grep | grep -q "multiop " && error "multiop still running" fi unset TESTNAME -- 1.8.3.1