mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-29 02:59:13 +00:00
ext2_get_page(): saner type
We need to pass to caller both the page reference and pointer to the first byte in the now-mapped page. The former always has the same type, the latter varies from caller to caller. So make it void *ext2_get_page(...., struct page **page) rather than struct page *ext2_get_page(..., void **page_addr) and avoid the casts... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Tested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
8600839269
commit
46022375ab
@ -186,23 +186,25 @@ static bool ext2_check_page(struct page *page, int quiet, char *kaddr)
|
|||||||
* NOTE: ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page()
|
* NOTE: ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page()
|
||||||
* and should be treated as a call to ext2_get_page() for nesting purposes.
|
* and should be treated as a call to ext2_get_page() for nesting purposes.
|
||||||
*/
|
*/
|
||||||
static struct page * ext2_get_page(struct inode *dir, unsigned long n,
|
static void *ext2_get_page(struct inode *dir, unsigned long n,
|
||||||
int quiet, void **page_addr)
|
int quiet, struct page **page)
|
||||||
{
|
{
|
||||||
struct address_space *mapping = dir->i_mapping;
|
struct address_space *mapping = dir->i_mapping;
|
||||||
struct folio *folio = read_mapping_folio(mapping, n, NULL);
|
struct folio *folio = read_mapping_folio(mapping, n, NULL);
|
||||||
|
void *page_addr;
|
||||||
|
|
||||||
if (IS_ERR(folio))
|
if (IS_ERR(folio))
|
||||||
return &folio->page;
|
return ERR_CAST(folio);
|
||||||
*page_addr = kmap_local_folio(folio, n & (folio_nr_pages(folio) - 1));
|
page_addr = kmap_local_folio(folio, n & (folio_nr_pages(folio) - 1));
|
||||||
if (unlikely(!folio_test_checked(folio))) {
|
if (unlikely(!folio_test_checked(folio))) {
|
||||||
if (!ext2_check_page(&folio->page, quiet, *page_addr))
|
if (!ext2_check_page(&folio->page, quiet, page_addr))
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
return &folio->page;
|
*page = &folio->page;
|
||||||
|
return page_addr;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
ext2_put_page(&folio->page, *page_addr);
|
ext2_put_page(&folio->page, page_addr);
|
||||||
return ERR_PTR(-EIO);
|
return ERR_PTR(-EIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,16 +273,17 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
|
|||||||
EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_FILETYPE);
|
EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_FILETYPE);
|
||||||
|
|
||||||
for ( ; n < npages; n++, offset = 0) {
|
for ( ; n < npages; n++, offset = 0) {
|
||||||
char *kaddr, *limit;
|
|
||||||
ext2_dirent *de;
|
ext2_dirent *de;
|
||||||
struct page *page = ext2_get_page(inode, n, 0, (void **)&kaddr);
|
struct page *page;
|
||||||
|
char *kaddr = ext2_get_page(inode, n, 0, &page);
|
||||||
|
char *limit;
|
||||||
|
|
||||||
if (IS_ERR(page)) {
|
if (IS_ERR(kaddr)) {
|
||||||
ext2_error(sb, __func__,
|
ext2_error(sb, __func__,
|
||||||
"bad page in #%lu",
|
"bad page in #%lu",
|
||||||
inode->i_ino);
|
inode->i_ino);
|
||||||
ctx->pos += PAGE_SIZE - offset;
|
ctx->pos += PAGE_SIZE - offset;
|
||||||
return PTR_ERR(page);
|
return PTR_ERR(kaddr);
|
||||||
}
|
}
|
||||||
if (unlikely(need_revalidate)) {
|
if (unlikely(need_revalidate)) {
|
||||||
if (offset) {
|
if (offset) {
|
||||||
@ -362,9 +365,10 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
|
|||||||
n = start;
|
n = start;
|
||||||
do {
|
do {
|
||||||
char *kaddr;
|
char *kaddr;
|
||||||
page = ext2_get_page(dir, n, 0, &page_addr);
|
|
||||||
if (IS_ERR(page))
|
page_addr = ext2_get_page(dir, n, 0, &page);
|
||||||
return ERR_CAST(page);
|
if (IS_ERR(page_addr))
|
||||||
|
return ERR_CAST(page_addr);
|
||||||
|
|
||||||
kaddr = page_addr;
|
kaddr = page_addr;
|
||||||
de = (ext2_dirent *) kaddr;
|
de = (ext2_dirent *) kaddr;
|
||||||
@ -418,13 +422,11 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
|
|||||||
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p,
|
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p,
|
||||||
void **pa)
|
void **pa)
|
||||||
{
|
{
|
||||||
void *page_addr;
|
void *page_addr = ext2_get_page(dir, 0, 0, p);
|
||||||
struct page *page = ext2_get_page(dir, 0, 0, &page_addr);
|
|
||||||
ext2_dirent *de = NULL;
|
ext2_dirent *de = NULL;
|
||||||
|
|
||||||
if (!IS_ERR(page)) {
|
if (!IS_ERR(page_addr)) {
|
||||||
de = ext2_next_entry((ext2_dirent *) page_addr);
|
de = ext2_next_entry((ext2_dirent *) page_addr);
|
||||||
*p = page;
|
|
||||||
*pa = page_addr;
|
*pa = page_addr;
|
||||||
}
|
}
|
||||||
return de;
|
return de;
|
||||||
@ -513,10 +515,9 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
|
|||||||
char *kaddr;
|
char *kaddr;
|
||||||
char *dir_end;
|
char *dir_end;
|
||||||
|
|
||||||
page = ext2_get_page(dir, n, 0, &page_addr);
|
page_addr = ext2_get_page(dir, n, 0, &page);
|
||||||
err = PTR_ERR(page);
|
if (IS_ERR(page_addr))
|
||||||
if (IS_ERR(page))
|
return PTR_ERR(page_addr);
|
||||||
goto out;
|
|
||||||
lock_page(page);
|
lock_page(page);
|
||||||
kaddr = page_addr;
|
kaddr = page_addr;
|
||||||
dir_end = kaddr + ext2_last_byte(dir, n);
|
dir_end = kaddr + ext2_last_byte(dir, n);
|
||||||
@ -577,7 +578,6 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
|
|||||||
/* OFFSET_CACHE */
|
/* OFFSET_CACHE */
|
||||||
out_put:
|
out_put:
|
||||||
ext2_put_page(page, page_addr);
|
ext2_put_page(page, page_addr);
|
||||||
out:
|
|
||||||
return err;
|
return err;
|
||||||
out_unlock:
|
out_unlock:
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
@ -682,9 +682,9 @@ int ext2_empty_dir (struct inode * inode)
|
|||||||
for (i = 0; i < npages; i++) {
|
for (i = 0; i < npages; i++) {
|
||||||
char *kaddr;
|
char *kaddr;
|
||||||
ext2_dirent * de;
|
ext2_dirent * de;
|
||||||
page = ext2_get_page(inode, i, 0, &page_addr);
|
page_addr = ext2_get_page(inode, i, 0, &page);
|
||||||
|
|
||||||
if (IS_ERR(page))
|
if (IS_ERR(page_addr))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
kaddr = page_addr;
|
kaddr = page_addr;
|
||||||
|
Loading…
Reference in New Issue
Block a user