All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nate Diller <nate.diller@gmail.com>
To: Andrew Morton <akpm@osdl.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Roman Zippel <zippel@linux-m68k.org>,
	Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>,
	David Woodhouse <dwmw2@infradead.org>,
	Dave Kleikamp <shaggy@austin.ibm.com>,
	Anton Altaparmakov <aia21@cantab.net>,
	Evgeniy Dushistov <dushistov@mail.ru>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	reiserfs-dev@namesys.com
Subject: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
Date: Wed, 11 Apr 2007 19:49:38 -0700	[thread overview]
Message-ID: <20070412024938.27380.44677.patchbomb.py@localhost> (raw)
In-Reply-To: <20070412024938.27380.54538.patchbomb.py@localhost>

Replace afs_dir_get_page() and afs_dir_put_page() using the new
read_kmap_page() and put_kmapped_page() calls, and eliminate unnecessary
PageError checks.  Also, change the afs_dir_check_page() call to return
the page's error status, and update the call site accordingly.

Signed-off-by: Nate Diller <nate.diller@gmail.com>

---

diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/afs/dir.c linux-2.6.21-rc5-mm4-test/fs/afs/dir.c
--- linux-2.6.21-rc5-mm4/fs/afs/dir.c	2007-04-06 12:27:03.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/afs/dir.c	2007-04-06 14:30:22.000000000 -0700
@@ -115,12 +115,15 @@ struct afs_dir_lookup_cookie {
 /*
  * check that a directory page is valid
  */
-static inline void afs_dir_check_page(struct inode *dir, struct page *page)
+static inline int afs_dir_check_page(struct inode *dir, struct page *page)
 {
 	struct afs_dir_page *dbuf;
 	loff_t latter;
 	int tmp, qty;
 
+	if (likely(PageChecked(page)))
+		return PageError(page);
+
 #if 0
 	/* check the page count */
 	qty = desc.size / sizeof(dbuf->blocks[0]);
@@ -154,52 +157,16 @@ static inline void afs_dir_check_page(st
 	}
 
 	SetPageChecked(page);
-	return;
+	return 0;
 
  error:
 	SetPageChecked(page);
 	SetPageError(page);
-
+	return 1;
 } /* end afs_dir_check_page() */
 
 /*****************************************************************************/
 /*
- * discard a page cached in the pagecache
- */
-static inline void afs_dir_put_page(struct page *page)
-{
-	kunmap(page);
-	page_cache_release(page);
-
-} /* end afs_dir_put_page() */
-
-/*****************************************************************************/
-/*
- * get a page into the pagecache
- */
-static struct page *afs_dir_get_page(struct inode *dir, unsigned long index)
-{
-	struct page *page;
-
-	_enter("{%lu},%lu", dir->i_ino, index);
-
-	page = read_mapping_page(dir->i_mapping, index, NULL);
-	if (!IS_ERR(page)) {
-		kmap(page);
-		if (!PageChecked(page))
-			afs_dir_check_page(dir, page);
-		if (PageError(page))
-			goto fail;
-	}
-	return page;
-
- fail:
-	afs_dir_put_page(page);
-	return ERR_PTR(-EIO);
-} /* end afs_dir_get_page() */
-
-/*****************************************************************************/
-/*
  * open an AFS directory file
  */
 static int afs_dir_open(struct inode *inode, struct file *file)
@@ -344,11 +311,16 @@ static int afs_dir_iterate(struct inode 
 		blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
 
 		/* fetch the appropriate page from the directory */
-		page = afs_dir_get_page(dir, blkoff / PAGE_SIZE);
+		page = read_kmap_page(dir->i_mapping, blkoff / PAGE_SIZE);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
 			break;
 		}
+		if (afs_check_page(dir, page)) {
+			err = -EIO;
+			put_kmapped_page(page);
+			break;
+		}
 
 		limit = blkoff & ~(PAGE_SIZE - 1);
 
@@ -361,7 +333,7 @@ static int afs_dir_iterate(struct inode 
 			ret = afs_dir_iterate_block(fpos, dblock, blkoff,
 						    cookie, filldir);
 			if (ret != 1) {
-				afs_dir_put_page(page);
+				put_kmapped_page(page);
 				goto out;
 			}
 
@@ -369,7 +341,7 @@ static int afs_dir_iterate(struct inode 
 
 		} while (*fpos < dir->i_size && blkoff < limit);
 
-		afs_dir_put_page(page);
+		put_kmapped_page(page);
 		ret = 0;
 	}
 
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/afs/mntpt.c linux-2.6.21-rc6-mm1-test/fs/afs/mntpt.c
--- linux-2.6.21-rc6-mm1/fs/afs/mntpt.c	2007-04-09 17:24:03.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/afs/mntpt.c	2007-04-10 21:22:07.000000000 -0700
@@ -74,11 +74,6 @@ int afs_mntpt_check_symlink(struct afs_v
 		ret = PTR_ERR(page);
 		goto out;
 	}
-
-	ret = -EIO;
-	if (PageError(page))
-		goto out_free;
-
 	buf = kmap(page);
 
 	/* examine the symlink's contents */
@@ -98,7 +93,6 @@ int afs_mntpt_check_symlink(struct afs_v
 	ret = 0;
 
 	kunmap(page);
- out_free:
 	page_cache_release(page);
  out:
 	_leave(" = %d", ret);
@@ -180,10 +174,6 @@ static struct vfsmount *afs_mntpt_do_aut
 		goto error;
 	}
 
-	ret = -EIO;
-	if (PageError(page))
-		goto error;
-
 	buf = kmap(page);
 	memcpy(devname, buf, size);
 	kunmap(page);

  parent reply	other threads:[~2007-04-12  2:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-12  2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
2007-04-12  2:49 ` [PATCH 17/17] vxfs: convert vxfs_get_page to read_kmap_page Nate Diller
2007-04-12  2:49 ` [PATCH 13/17] reiser4: remove redundant read_mapping_page error checks Nate Diller
2007-04-12  2:49 ` [PATCH 1/17] cramfs: use read_mapping_page Nate Diller
2007-04-12  9:54   ` Christoph Hellwig
2007-04-12 11:26     ` Roman Zippel
2007-04-12 18:36       ` Nate Diller
2007-04-12  2:49 ` [PATCH 5/17] hfsplus: remove redundant read_mapping_page error check Nate Diller
2007-04-12  2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
2007-04-12 11:40   ` Phillip Lougher
2007-04-12 18:29     ` Nate Diller
2007-04-12 18:53       ` Phillip Lougher
2007-04-15 10:52   ` David Woodhouse
2007-04-12  2:49 ` [PATCH 10/17] mtd: convert page_read to read_kmap_page Nate Diller
2007-04-12  2:49 ` [PATCH 8/17] jfs: use locking read_mapping_page Nate Diller
2007-04-12  2:49 ` [PATCH 11/17] ntfs: convert ntfs_map_page to read_kmap_page Nate Diller
2007-04-12  2:49 ` [PATCH 12/17] partition: remove redundant read_mapping_page error checks Nate Diller
2007-04-12  2:49 ` [PATCH 6/17] hfs: remove redundant read_mapping_page error check Nate Diller
2007-04-12  2:49 ` [PATCH 2/17] fs: introduce new read_cache_page interface Nate Diller
2007-04-12  2:49 ` [PATCH 4/17] ext2: convert ext2_get_page to read_kmap_page Nate Diller
2007-04-12  2:49 ` [PATCH 16/17] ufs: convert ufs_get_page " Nate Diller
2007-04-12  2:49 ` Nate Diller [this message]
2007-04-12 10:58   ` [PATCH 3/17] afs: convert afs_dir_get_page " David Howells
2007-04-12 18:23     ` Nate Diller
2007-04-12 18:57       ` David Howells
2007-04-12 19:21         ` Andrew Morton
2007-04-12 19:29           ` David Howells
2007-07-16  6:05           ` Drop patch update-isdn-tree-to-use-pci_get_device.patch from -mm tree Surya Prabhakar N
2007-04-12 19:27         ` [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page Nate Diller
2007-04-12 19:43           ` David Howells
2007-04-12  2:49 ` [PATCH 14/17] reiserfs: convert reiserfs_get_page " Nate Diller
2007-04-12  2:49 ` [PATCH 9/17] minix: convert dir_get_page " Nate Diller
2007-04-12  2:49 ` [PATCH 15/17] sysv: " Nate Diller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070412024938.27380.44677.patchbomb.py@localhost \
    --to=nate.diller@gmail.com \
    --cc=aia21@cantab.net \
    --cc=akpm@osdl.org \
    --cc=dushistov@mail.ru \
    --cc=dwmw2@infradead.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=reiserfs-dev@namesys.com \
    --cc=shaggy@austin.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.