From patchwork Tue Jan 25 22:09:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 507241 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 p0PMJQXj020965 for ; Tue, 25 Jan 2011 22:19:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753557Ab1AYWTn (ORCPT ); Tue, 25 Jan 2011 17:19:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11641 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721Ab1AYWTm (ORCPT ); Tue, 25 Jan 2011 17:19:42 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0PMJfcq005447 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Jan 2011 17:19:41 -0500 Received: from localhost.localdomain (test1244.test.redhat.com [10.10.10.244]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0PMJfd4023658 for ; Tue, 25 Jan 2011 17:19:41 -0500 From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: fix how we deal with the pages array in the write path Date: Tue, 25 Jan 2011 17:09:16 -0500 Message-Id: <1295993356-28963-1-git-send-email-josef@redhat.com> In-Reply-To: <1295986273-30308-1-git-send-email-josef@redhat.com> References: <1295986273-30308-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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, 25 Jan 2011 22:19:54 +0000 (UTC) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index c0f312a..f4eef63 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -95,8 +95,6 @@ static noinline void btrfs_drop_pages(struct page **pages, size_t num_pages) { size_t i; for (i = 0; i < num_pages; i++) { - if (!pages[i]) - break; /* page checked is some magic around finding pages that * have been modified without going through btrfs_set_page_dirty * clear it here @@ -788,7 +786,6 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, return err; } - memset(pages, 0, num_pages * sizeof(struct page *)); again: for (i = 0; i < num_pages; i++) { pages[i] = grab_cache_page(inode->i_mapping, index + i); @@ -910,8 +907,6 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, WARN_ON(num_pages > nrptrs); again: - memset(pages, 0, sizeof(struct page *) * nrptrs); - /* * Fault pages before locking them in prepare_pages * to avoid recursive lock @@ -926,6 +921,11 @@ again: if (ret) break; + /* + * This is going to setup the pages array with the number of + * pages we want, so we don't really need to worry about the + * contents of pages from loop to loop + */ ret = prepare_pages(root, file, pages, num_pages, pos, first_index, last_index, write_bytes);