All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: remove duplicate memset in prepare_pages
@ 2011-01-25 20:11 Josef Bacik
  2011-01-25 22:09 ` [PATCH] Btrfs: fix how we deal with the pages array in the write path Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2011-01-25 20:11 UTC (permalink / raw)
  To: linux-btrfs

We already memset the pages array in __btrfs_buffered_write, there's no need to
do it again in prepare_pages.

Signed-off-by: Josef Bacik <josef@redhat.com>
---
 fs/btrfs/file.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c0f312a..fd89c5c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -788,7 +788,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);
-- 
1.6.6.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] Btrfs: fix how we deal with the pages array in the write path
  2011-01-25 20:11 [PATCH] Btrfs: remove duplicate memset in prepare_pages Josef Bacik
@ 2011-01-25 22:09 ` Josef Bacik
  0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2011-01-25 22:09 UTC (permalink / raw)
  To: linux-btrfs

Really we don't need to memset the pages array at all, since we know how many
pages we're going to use in the array and pass that around.  So don't memset,
just trust we're not idiots and we pass num_pages around properly.

Signed-off-by: Josef Bacik <josef@redhat.com>
---
 fs/btrfs/file.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

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);
-- 
1.6.6.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-25 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 20:11 [PATCH] Btrfs: remove duplicate memset in prepare_pages Josef Bacik
2011-01-25 22:09 ` [PATCH] Btrfs: fix how we deal with the pages array in the write path Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.