Skip to contentSkip to conversation

ext2: improve ext2_readdir() return value

PATCH In review Akinobu Mita 2 participants 3 messages Feb 17, 2008 ext2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ext2: improve ext2_readdir() return value

This patch improves ext2_readdir() return value for ext2_get_page() failure by using the actual result of ext2_get_page().

---
 fs/ext2/dir.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext2/dir.c +1 -1
Index: 2.6-rc/fs/ext2/dir.c
===================================================================
@@ -299,7 +299,7 @@ ext2_readdir (struct file * filp, void *
 				   "bad page in #%lu",
 				   inode->i_ino);
 			filp->f_pos += PAGE_CACHE_SIZE - offset;
-			return -EIO;
+			return PTR_ERR(page);
 		}
 		kaddr = page_address(page);
 		if (unlikely(need_revalidate)) {
#1 lore raw

fs/ext2/dir.c ext2_readdir (struct file * filp, void * · line 302

Quoted 5 lines · Akinobu Mita

This patch improves ext2_readdir() return value for ext2_get_page() failure by using the actual result of ext2_get_page().

fs/ext2/dir.c +1 -1
-			return -EIO;
+			return PTR_ERR(page);

The patch is harmless, and maybe even a good thing from an abstract point of view, but you realize that EIO is the only thing that ext2_get_page() can return, right?

- Ted

#2 lore raw

2008/2/17, Theodore Tso <[email protected]>:

Quoted 10 lines · Akinobu Mita

fs/ext2/dir.c ext2_readdir (struct file * filp, void * · line 302

Quoted 5 lines

This patch improves ext2_readdir() return value for ext2_get_page() failure by using the actual result of ext2_get_page().

fs/ext2/dir.c +1 -1
-                     return -EIO;
+                     return PTR_ERR(page);

The patch is harmless, and maybe even a good thing from an abstract point of view, but you realize that EIO is the only thing that ext2_get_page() can return, right?

There are some cases that ext2_get_page() returns -ENOMEM logically. (--> read_mapping_page --> read_cache_page --> read_cache_page_async -->

     __read_cache_page --> page_cache_alloc_cold, or add_to_page_cache_lru)

But this is not likely to happen in reality.