From patchwork Mon Mar 22 02:31:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 87325 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2M2VUU3006626 for ; Mon, 22 Mar 2010 02:31:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753542Ab0CVCb2 (ORCPT ); Sun, 21 Mar 2010 22:31:28 -0400 Received: from mail-iw0-f182.google.com ([209.85.223.182]:51329 "EHLO mail-iw0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753489Ab0CVCb2 (ORCPT ); Sun, 21 Mar 2010 22:31:28 -0400 Received: by iwn12 with SMTP id 12so3954129iwn.21 for ; Sun, 21 Mar 2010 19:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=3+kDG2cA83Stm/9Y9tMTrpQ5hlKZDwgBm/k3gpg7rv8=; b=Sx50nS4Hym3eMUzvnrtpnhOTJ9LRdetHx4OdR66PNRbY4z2ojBV4bf8Sr6iTwHbGnn smUEC/rsMBgGebyHNMeqFjx1enUW7dIF+H6B3CxvsJu//LXO9dz4NtA8H7usTLSxuOWA JNH0H3L9477HE0dxglvOmb5AGGQiQ63ZH8UMU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=ko/+c3/KWDP7W+ElG8d7iuzSqOeeRowqK4mVc/nW15dB2uOVojMTMe0Tbq3lExyToa U3jDOFjzv+ZxRdNedcIfY1wDt9H+NPH3aEdGEoC100p1opZGdrKpwr1c1ENDUIAyyVqq PfUohnW7Oh7OuhE/d9+fVftCO8q5e0GnFAzsE= Received: by 10.231.174.142 with SMTP id t14mr763980ibz.69.1269225087344; Sun, 21 Mar 2010 19:31:27 -0700 (PDT) Received: from [192.168.0.97] (c-24-147-40-65.hsd1.nh.comcast.net [24.147.40.65]) by mx.google.com with ESMTPS id a1sm1371906ibs.12.2010.03.21.19.31.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Mar 2010 19:31:26 -0700 (PDT) Message-ID: <4BA6D67D.4050200@gmail.com> Date: Sun, 21 Mar 2010 22:31:25 -0400 From: jim owens User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH] Btrfs: fix direct I/O handling of extent map errors. Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 22 Mar 2010 02:31:31 +0000 (UTC) diff --git a/fs/btrfs/dio.c b/fs/btrfs/dio.c index b76b227..b6934be 100644 --- a/fs/btrfs/dio.c +++ b/fs/btrfs/dio.c @@ -486,8 +486,13 @@ getlock: em = btrfs_get_extent(diocb->inode, NULL, 0, diocb->start, len, 0); - if (!em) { - err = -EIO; + if (IS_ERR(em)) { + err = PTR_ERR(em); + printk(KERN_ERR + "btrfs directIO fail btrfs_get_extent ino %lu " + "extent start %llu len %llu error %d\n", + diocb->inode->i_ino, diocb->start, + data_len, err); goto fail; } @@ -1432,8 +1437,8 @@ static int btrfs_dio_hole_read(struct btrfs_diocb *diocb, u64 hole_len) } fail: unlock_extent(&BTRFS_I(diocb->inode)->io_tree, diocb->lockstart, - diocb->lockstart + hole_len - 1, GFP_NOFS); - diocb->lockstart += hole_len; + diocb->start - 1, GFP_NOFS); + diocb->lockstart = diocb->start; return err; } @@ -1577,8 +1582,8 @@ notfound: btrfs_free_path(path); if (!err && *data_len) { unlock_extent(&BTRFS_I(diocb->inode)->io_tree, diocb->lockstart, - diocb->lockstart + *data_len - 1, GFP_NOFS); - diocb->lockstart += *data_len; + diocb->start - 1, GFP_NOFS); + diocb->lockstart = diocb->start; } return err; } @@ -1601,8 +1606,9 @@ static int btrfs_dio_read_csum(struct btrfs_dio_extcb *extcb) if (extcb->iolen & (blocksize - 1)) { printk(KERN_WARNING - "btrfs directIO unaligned checksum for ino %lu\n", - extcb->diocb->inode->i_ino); + "btrfs directIO unaligned checksum for ino %lu " + "start %lld len %d\n", extcb->diocb->inode->i_ino, + extcb->iostart, extcb->iolen); extcb->iolen &= ~(blocksize - 1); }