mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 00:48:50 +00:00
gfs2: Convert gfs2_internal_read to folios
Change gfs2_internal_read() to use folios. Convert sizes to size_t. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
parent
7fa4964b35
commit
be7f6a6b0b
2 changed files with 18 additions and 20 deletions
|
@ -477,31 +477,29 @@ static int gfs2_read_folio(struct file *file, struct folio *folio)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
|
ssize_t gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
|
||||||
unsigned size)
|
size_t size)
|
||||||
{
|
{
|
||||||
struct address_space *mapping = ip->i_inode.i_mapping;
|
struct address_space *mapping = ip->i_inode.i_mapping;
|
||||||
unsigned long index = *pos >> PAGE_SHIFT;
|
unsigned long index = *pos >> PAGE_SHIFT;
|
||||||
unsigned offset = *pos & (PAGE_SIZE - 1);
|
size_t copied = 0;
|
||||||
unsigned copied = 0;
|
|
||||||
unsigned amt;
|
|
||||||
struct page *page;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
page = read_cache_page(mapping, index, gfs2_read_folio, NULL);
|
size_t offset, chunk;
|
||||||
if (IS_ERR(page)) {
|
struct folio *folio;
|
||||||
if (PTR_ERR(page) == -EINTR)
|
|
||||||
|
folio = read_cache_folio(mapping, index, gfs2_read_folio, NULL);
|
||||||
|
if (IS_ERR(folio)) {
|
||||||
|
if (PTR_ERR(folio) == -EINTR)
|
||||||
continue;
|
continue;
|
||||||
return PTR_ERR(page);
|
return PTR_ERR(folio);
|
||||||
}
|
}
|
||||||
amt = size - copied;
|
offset = *pos + copied - folio_pos(folio);
|
||||||
if (offset + size > PAGE_SIZE)
|
chunk = min(size - copied, folio_size(folio) - offset);
|
||||||
amt = PAGE_SIZE - offset;
|
memcpy_from_folio(buf + copied, folio, offset, chunk);
|
||||||
memcpy_from_page(buf + copied, page, offset, amt);
|
index = folio_next_index(folio);
|
||||||
put_page(page);
|
folio_put(folio);
|
||||||
copied += amt;
|
copied += chunk;
|
||||||
index++;
|
|
||||||
offset = 0;
|
|
||||||
} while(copied < size);
|
} while(copied < size);
|
||||||
(*pos) += size;
|
(*pos) += size;
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask);
|
bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask);
|
||||||
extern int gfs2_internal_read(struct gfs2_inode *ip,
|
extern ssize_t gfs2_internal_read(struct gfs2_inode *ip,
|
||||||
char *buf, loff_t *pos, unsigned size);
|
char *buf, loff_t *pos, size_t size);
|
||||||
extern void gfs2_set_aops(struct inode *inode);
|
extern void gfs2_set_aops(struct inode *inode);
|
||||||
|
|
||||||
static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
|
static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
|
||||||
|
|
Loading…
Reference in a new issue