Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933083Ab3GVQQN (ORCPT ); Mon, 22 Jul 2013 12:16:13 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:56345 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932867Ab3GVQNB (ORCPT ); Mon, 22 Jul 2013 12:13:01 -0400 From: Peng Tao To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Ned Bass , Peng Tao , Andreas Dilger Subject: [PATCH 38/48] staging/lustre/lmv: fix duplicate directory entries Date: Tue, 23 Jul 2013 00:06:59 +0800 Message-Id: <1374509230-3324-39-git-send-email-bergwolf@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374509230-3324-1-git-send-email-bergwolf@gmail.com> References: <1374509230-3324-1-git-send-email-bergwolf@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2172 Lines: 54 From: Ned Bass Previously, I accidentally introduced a new way for duplicate directory entries to be returned from readdir(). That patch fails to properly decrement the nlupgs counter when breaking out of the inner-for loop. This accounting error causes an extra iteration of the inner-for loop when processing the next cfs page and a bad ldp_hash_end value is then saved in the lu_dirpage. To fix this, always decrement the nlupgs counter on entry into the inner loop. Note: this bug only affects architectures with > 4k-sized pages, e.g. PowerPC. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3182 Lustre-change: http://review.whamcloud.com/6405 Signed-off-by: Ned Bass Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 9e68eea..11c8d64 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -2157,7 +2157,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) __u64 hash_end = dp->ldp_hash_end; __u32 flags = dp->ldp_flags; - for (; nlupgs > 1; nlupgs--) { + while (--nlupgs > 0) { ent = lu_dirent_start(dp); for (end_dirent = ent; ent != NULL; end_dirent = ent, ent = lu_dirent_next(ent)); @@ -2191,6 +2191,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) kunmap(pages[i]); } + LASSERTF(nlupgs == 0, "left = %d", nlupgs); } #else #define lmv_adjust_dirpages(pages, ncfspgs, nlupgs) do {} while (0) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/