Skip to content

Commit 675f02e

Browse files
Matthew Wilcox (Oracle)akpm00
Matthew Wilcox (Oracle)
authored andcommitted
squashfs: convert squashfs_symlink_read_folio to use folio APIs
Remove use of page APIs, return the errno instead of 0, switch from kmap_atomic to kmap_local and use folio_end_read() to unify the two exit paths. Link: https://lkml.kernel.org/r/20240420025029.2166544-23-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Tested-by: Phillip Lougher <phillip@squashfs.org.uk> Reviewed-by: Phillip Lougher <phillip@squashfs.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 40eea5a commit 675f02e

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

fs/squashfs/symlink.c

+16-19
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,19 @@
3232

3333
static int squashfs_symlink_read_folio(struct file *file, struct folio *folio)
3434
{
35-
struct page *page = &folio->page;
36-
struct inode *inode = page->mapping->host;
35+
struct inode *inode = folio->mapping->host;
3736
struct super_block *sb = inode->i_sb;
3837
struct squashfs_sb_info *msblk = sb->s_fs_info;
39-
int index = page->index << PAGE_SHIFT;
38+
int index = folio_pos(folio);
4039
u64 block = squashfs_i(inode)->start;
4140
int offset = squashfs_i(inode)->offset;
4241
int length = min_t(int, i_size_read(inode) - index, PAGE_SIZE);
43-
int bytes, copied;
42+
int bytes, copied, error;
4443
void *pageaddr;
4544
struct squashfs_cache_entry *entry;
4645

4746
TRACE("Entered squashfs_symlink_readpage, page index %ld, start block "
48-
"%llx, offset %x\n", page->index, block, offset);
47+
"%llx, offset %x\n", folio->index, block, offset);
4948

5049
/*
5150
* Skip index bytes into symlink metadata.
@@ -57,14 +56,15 @@ static int squashfs_symlink_read_folio(struct file *file, struct folio *folio)
5756
ERROR("Unable to read symlink [%llx:%x]\n",
5857
squashfs_i(inode)->start,
5958
squashfs_i(inode)->offset);
60-
goto error_out;
59+
error = bytes;
60+
goto out;
6161
}
6262
}
6363

6464
/*
6565
* Read length bytes from symlink metadata. Squashfs_read_metadata
6666
* is not used here because it can sleep and we want to use
67-
* kmap_atomic to map the page. Instead call the underlying
67+
* kmap_local to map the folio. Instead call the underlying
6868
* squashfs_cache_get routine. As length bytes may overlap metadata
6969
* blocks, we may need to call squashfs_cache_get multiple times.
7070
*/
@@ -75,29 +75,26 @@ static int squashfs_symlink_read_folio(struct file *file, struct folio *folio)
7575
squashfs_i(inode)->start,
7676
squashfs_i(inode)->offset);
7777
squashfs_cache_put(entry);
78-
goto error_out;
78+
error = entry->error;
79+
goto out;
7980
}
8081

81-
pageaddr = kmap_atomic(page);
82+
pageaddr = kmap_local_folio(folio, 0);
8283
copied = squashfs_copy_data(pageaddr + bytes, entry, offset,
8384
length - bytes);
8485
if (copied == length - bytes)
8586
memset(pageaddr + length, 0, PAGE_SIZE - length);
8687
else
8788
block = entry->next_index;
88-
kunmap_atomic(pageaddr);
89+
kunmap_local(pageaddr);
8990
squashfs_cache_put(entry);
9091
}
9192

92-
flush_dcache_page(page);
93-
SetPageUptodate(page);
94-
unlock_page(page);
95-
return 0;
96-
97-
error_out:
98-
SetPageError(page);
99-
unlock_page(page);
100-
return 0;
93+
flush_dcache_folio(folio);
94+
error = 0;
95+
out:
96+
folio_end_read(folio, error == 0);
97+
return error;
10198
}
10299

103100

0 commit comments

Comments
 (0)