From patchwork Mon Sep 30 18:54:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11167073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFBFA16C1 for ; Mon, 30 Sep 2019 18:57:56 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6F79224F0 for ; Mon, 30 Sep 2019 18:57:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6F79224F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 8197B5C3B61; Mon, 30 Sep 2019 11:57:31 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 166485C357A for ; Mon, 30 Sep 2019 11:57:07 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 7A711100541D; Mon, 30 Sep 2019 14:56:56 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 7936EA9; Mon, 30 Sep 2019 14:56:56 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 30 Sep 2019 14:54:47 -0400 Message-Id: <1569869810-23848-29-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569869810-23848-1-git-send-email-jsimmons@infradead.org> References: <1569869810-23848-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 028/151] lustre: lmv: stripe dir page may be released mistakenly X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lai Siyao , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Lai Siyao stripe_dirent_next() may put_stripe_dirent() while its dirent is still in use, e.g. lmv_dirent_next() popped stripe last dirent, when it can't point sd_ent to next, but it shouldn't release stripe dir page. stripe_dirent->sd_ent should be set NULL when its dir page is released, which can avoid misuse. WC-bug-id: https://jira.whamcloud.com/browse/LU-9857 Lustre-commit: beadbad429ae ("LU-9857 lmv: stripe dir page may be released mistakenly") Signed-off-by: Lai Siyao Reviewed-on: https://review.whamcloud.com/28548 Reviewed-by: Fan Yong Reviewed-by: John L. Hammond Tested-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/lmv/lmv_obd.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c index d71d077..bcbda30 100644 --- a/fs/lustre/lmv/lmv_obd.c +++ b/fs/lustre/lmv/lmv_obd.c @@ -2023,6 +2023,7 @@ static inline void put_stripe_dirent(struct stripe_dirent *stripe) kunmap(stripe->sd_page); put_page(stripe->sd_page); stripe->sd_page = NULL; + stripe->sd_ent = NULL; } } @@ -2045,20 +2046,24 @@ static struct lu_dirent *stripe_dirent_next(struct lmv_dir_ctxt *ctxt, LASSERT(stripe == &ctxt->ldc_stripes[stripe_index]); + if (stripe->sd_eof) + return NULL; + if (ent) { ent = lu_dirent_next(ent); if (!ent) { check_eof: end = le64_to_cpu(stripe->sd_dp->ldp_hash_end); - put_stripe_dirent(stripe); - + LASSERTF(hash <= end, "hash %llx end %llx\n", + hash, end); if (end == MDS_DIR_END_OFF) { stripe->sd_ent = NULL; stripe->sd_eof = true; return NULL; } - LASSERT(hash <= end); + + put_stripe_dirent(stripe); hash = end; } } @@ -2114,10 +2119,8 @@ static struct lu_dirent *stripe_dirent_next(struct lmv_dir_ctxt *ctxt, le16_to_cpu(ent->lde_namelen)) == 0)) continue; - if (le64_to_cpu(ent->lde_hash) < hash) - continue; - - break; + if (le64_to_cpu(ent->lde_hash) >= hash) + break; } if (!ent)