From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01744C55178 for ; Tue, 3 Nov 2020 14:30:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC0DC22370 for ; Tue, 3 Nov 2020 14:30:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qN3KSIZC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729568AbgKCOah (ORCPT ); Tue, 3 Nov 2020 09:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729455AbgKCO24 (ORCPT ); Tue, 3 Nov 2020 09:28:56 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BA9FC0613D1 for ; Tue, 3 Nov 2020 06:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=KTTZDmcpQ4d9/HeznDn2I0WFscOoJ8hJXoewGktnwEA=; b=qN3KSIZCuLCHof6lILGUn3CPPU ajweGMem1wz2yeC58cdTFEyA1J5ZfHJu5BE8qx2f7NlU2Fs/9w3yD7iaqa32jk0l2gQQBxKqvZ+xR U7IbiwuP0VQ7RSJ2myaelq9bd9WQJlTvW4V/woN1IUO8Y/UyhFiSJBFqA9kou5SNaVtrfy5TjT4rW 7VmLM2ryVwotHOv/AmBpx83NDfGhOs20UyrkKCDbIaBaXxlJECrR3WZJl93JjO4ZCaDxSELjDF+0B x+R3GtzR9LXczQlJ+NMIw7qYsKybyYGCcNuND34wqN4RhTgMtwRkFyF60qTxwuElWz4O8kZ8nUanb nXiKQljw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZxIs-0002FD-4i; Tue, 03 Nov 2020 14:28:54 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , linux-fsdevel@vger.kernel.org Cc: Matthew Wilcox , David Sterba , Wonhyuk Yang Subject: [PATCH] mm: Fix readahead_page_batch for retry entries Date: Tue, 3 Nov 2020 14:28:52 +0000 Message-Id: <20201103142852.8543-1-willy@infradead.org> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Both btrfs and fuse have reported faults caused by seeing a retry entry instead of the page they were looking for. This was caused by a missing check in the iterator. Reported-by: David Sterba Reported-by: Wonhyuk Yang Fixes: 042124cc64c3 ("mm: add new readahead_control API") Signed-off-by: Matthew Wilcox (Oracle) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index b921581a7dcf..2ea741c2bb16 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -751,6 +751,8 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac, xas_set(&xas, rac->_index); rcu_read_lock(); xas_for_each(&xas, page, rac->_index + rac->_nr_pages - 1) { + if (xas_retry(&xas, page)) + continue; VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageTail(page), page); array[i++] = page;