From patchwork Sat Mar 5 16:50:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mitch Harder X-Patchwork-Id: 612591 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p25GoRBI032632 for ; Sat, 5 Mar 2011 16:50:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753632Ab1CEQuQ (ORCPT ); Sat, 5 Mar 2011 11:50:16 -0500 Received: from mail-vx0-f174.google.com ([209.85.220.174]:51382 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753485Ab1CEQuP (ORCPT ); Sat, 5 Mar 2011 11:50:15 -0500 Received: by vxi39 with SMTP id 39so2813039vxi.19 for ; Sat, 05 Mar 2011 08:50:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.73.3 with SMTP id h3mr2913045vdv.114.1299343814542; Sat, 05 Mar 2011 08:50:14 -0800 (PST) Received: by 10.220.119.69 with HTTP; Sat, 5 Mar 2011 08:50:14 -0800 (PST) In-Reply-To: References: <1865303E0DED764181A9D882DEF65FB68662CD02C8@shsmsx502.ccr.corp.intel.com> <1299203447-sup-9359@think> <1299241124-sup-3502@think> Date: Sat, 5 Mar 2011 10:50:14 -0600 Message-ID: Subject: Re: [PATCH] btrfs file write debugging patch From: Mitch Harder To: Xin Zhong Cc: chris.mason@oracle.com, xin.zhong@intel.com, linux-btrfs@vger.kernel.org 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.6 (demeter1.kernel.org [140.211.167.41]); Sat, 05 Mar 2011 16:50:29 +0000 (UTC) --- fs/btrfs/file.c 2011-03-05 07:34:43.025131607 -0600 +++ /usr/src/linux/fs/btrfs/file.c 2011-03-05 07:41:45.001260294 -0600 @@ -1023,8 +1023,20 @@ copied = btrfs_copy_from_user(pos, num_pages, write_bytes, pages, &i); - dirty_pages = (copied + offset + PAGE_CACHE_SIZE - 1) >> - PAGE_CACHE_SHIFT; + + /* + * if we have trouble faulting in the pages, fall + * back to one page at a time + */ + if (copied < write_bytes) + nrptrs = 1; + + if (copied == 0) + dirty_pages = 0; + else + dirty_pages = (copied + offset + + PAGE_CACHE_SIZE - 1) >> + PAGE_CACHE_SHIFT; if (num_pages > dirty_pages) { if (copied > 0)