From patchwork Tue Jan 18 05:34:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 485401 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 p0I5YpSn021925 for ; Tue, 18 Jan 2011 05:34:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751537Ab1ARFem (ORCPT ); Tue, 18 Jan 2011 00:34:42 -0500 Received: from mga09.intel.com ([134.134.136.24]:34398 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751485Ab1ARFel (ORCPT ); Tue, 18 Jan 2011 00:34:41 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 17 Jan 2011 21:34:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,337,1291622400"; d="scan'208";a="697834741" Received: from unknown (HELO [10.239.36.37]) ([10.239.36.37]) by orsmga001.jf.intel.com with ESMTP; 17 Jan 2011 21:34:41 -0800 Message-ID: <4D352670.4040603@linux.intel.com> Date: Tue, 18 Jan 2011 13:34:40 +0800 From: "Yan, Zheng" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 MIME-Version: 1.0 To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: Fix page count calculation 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]); Tue, 18 Jan 2011 05:34:52 +0000 (UTC) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 66836d8..ef94e46 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -970,8 +970,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, size_t write_bytes = min(iov_iter_count(&i), nrptrs * (size_t)PAGE_CACHE_SIZE - offset); - size_t num_pages = (write_bytes + PAGE_CACHE_SIZE - 1) >> - PAGE_CACHE_SHIFT; + size_t num_pages = (write_bytes + offset + + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; WARN_ON(num_pages > nrptrs); memset(pages, 0, sizeof(struct page *) * nrptrs); @@ -1001,8 +1001,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, copied = btrfs_copy_from_user(pos, num_pages, write_bytes, pages, &i); - dirty_pages = (copied + PAGE_CACHE_SIZE - 1) >> - PAGE_CACHE_SHIFT; + dirty_pages = (copied + offset + PAGE_CACHE_SIZE - 1) >> + PAGE_CACHE_SHIFT; if (num_pages > dirty_pages) { if (copied > 0)