From patchwork Mon Apr 22 13:14:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2471841 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EAE9BDF23A for ; Mon, 22 Apr 2013 13:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753053Ab3DVNOb (ORCPT ); Mon, 22 Apr 2013 09:14:31 -0400 Received: from dkim2.fusionio.com ([66.114.96.54]:39559 "EHLO dkim2.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751919Ab3DVNOa (ORCPT ); Mon, 22 Apr 2013 09:14:30 -0400 Received: from mx1.fusionio.com (unknown [10.101.1.160]) by dkim2.fusionio.com (Postfix) with ESMTP id 14FE99A0406 for ; Mon, 22 Apr 2013 07:14:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1366636470; bh=WIy7Sizr0JKhL0qfedImNZ+keQTWu57hYkTb004QZEU=; h=From:To:Subject:Date; b=FIEh/Ld+xlruIxu+WwgCdXOBxUZJATAY8HXACuwwLaOEkMa9wbxIh+Vh43uZqB7Gb DJDmOyARxJ7w5uDsbBZ858jk0gTxDSazhOlIQuoDhrYQ96Mn9H1AJU+m65ytq/t54k SzP7mh5+CODpAUUfUxdRbcYDGJN/hXKqs01fO0so= X-ASG-Debug-ID: 1366636469-03d6a52abf323630001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx1.fusionio.com with ESMTP id lnhmCCkLp13pl9xJ (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Mon, 22 Apr 2013 07:14:29 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (76.182.72.146) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 22 Apr 2013 07:14:28 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs: don't call readahead hook until we have read the entire eb Date: Mon, 22 Apr 2013 09:14:27 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs: don't call readahead hook until we have read the entire eb Message-ID: <1366636467-2187-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1366636469 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.180:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.128837 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Martin Steigerwald reported a BUG_ON() where we were given a bogus bytenr to map. Turns out he is using > PAGESIZE leafsizes. The readahead stuff is called every time we do a completion, but we may not have finished reading in all the pages, so the bytenr we read off the node could be completely bogus. Fix this by only calling the readahead hook once all pages have been read in. Thanks, Reported-by: Martin Steigerwald Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index fa8438f..f4628c7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -674,10 +674,9 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end, if (!ret) set_extent_buffer_uptodate(eb); err: - if (test_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags)) { - clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags); + if (reads_done && + test_and_clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags)) btree_readahead_hook(root, eb, eb->start, ret); - } if (ret) { /*