diff mbox series

[13/24] ufs: Remove checks for PageError

Message ID 20220527155036.524743-14-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Begin removing PageError | expand

Commit Message

Matthew Wilcox May 27, 2022, 3:50 p.m. UTC
If read_mapping_page() encounters an error, it returns an errno, not
a page with PageError set, or a page that is not Uptodate, so this is
dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ufs/dir.c  |  2 +-
 fs/ufs/util.c | 11 -----------
 2 files changed, 1 insertion(+), 12 deletions(-)

Comments

Christoph Hellwig May 28, 2022, 5:56 a.m. UTC | #1
> --- a/fs/ufs/dir.c
> +++ b/fs/ufs/dir.c
> @@ -193,7 +193,7 @@ static struct page *ufs_get_page(struct inode *dir, unsigned long n)
>  	if (!IS_ERR(page)) {
>  		kmap(page);
>  		if (unlikely(!PageChecked(page))) {
> -			if (PageError(page) || !ufs_check_page(page))
> +			if (!ufs_check_page(page))
>  				goto fail;
>  		}

Unrelated note:  doing the PageChecked check inside of ufs_check_page
wuld really help readability for the casual reader.

>  	}
> diff --git a/fs/ufs/util.c b/fs/ufs/util.c
> index 4fa633f84274..08ddf41eaaad 100644
> --- a/fs/ufs/util.c
> +++ b/fs/ufs/util.c
> @@ -264,17 +264,6 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
>  			put_page(page);
>  			return NULL;
>  		}
> -
> -		if (!PageUptodate(page) || PageError(page)) {
> -			unlock_page(page);
> -			put_page(page);
> -
> -			printk(KERN_ERR "ufs_change_blocknr: "
> -			       "can not read page: ino %lu, index: %lu\n",
> -			       inode->i_ino, index);
> -
> -			return ERR_PTR(-EIO);
> -		}

This looks good.  But this code could use some more love nd a removal
of the find_lock_page call by always just using read_mapping_page.
Especially a the truncate protection should apply equally to cached
pages and not just those freshly read off the disk.

But I guess for now this looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index b721d0bda5e5..391efaf1d528 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -193,7 +193,7 @@  static struct page *ufs_get_page(struct inode *dir, unsigned long n)
 	if (!IS_ERR(page)) {
 		kmap(page);
 		if (unlikely(!PageChecked(page))) {
-			if (PageError(page) || !ufs_check_page(page))
+			if (!ufs_check_page(page))
 				goto fail;
 		}
 	}
diff --git a/fs/ufs/util.c b/fs/ufs/util.c
index 4fa633f84274..08ddf41eaaad 100644
--- a/fs/ufs/util.c
+++ b/fs/ufs/util.c
@@ -264,17 +264,6 @@  struct page *ufs_get_locked_page(struct address_space *mapping,
 			put_page(page);
 			return NULL;
 		}
-
-		if (!PageUptodate(page) || PageError(page)) {
-			unlock_page(page);
-			put_page(page);
-
-			printk(KERN_ERR "ufs_change_blocknr: "
-			       "can not read page: ino %lu, index: %lu\n",
-			       inode->i_ino, index);
-
-			return ERR_PTR(-EIO);
-		}
 	}
 	if (!page_has_buffers(page))
 		create_empty_buffers(page, 1 << inode->i_blkbits, 0);