[PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>

---

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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux