Skip to content

Commit be7f6a6

Browse files
author
Andreas Gruenbacher
committed
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>
1 parent 7fa4964 commit be7f6a6

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

fs/gfs2/aops.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,31 +477,29 @@ static int gfs2_read_folio(struct file *file, struct folio *folio)
477477
*
478478
*/
479479

480-
int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
481-
unsigned size)
480+
ssize_t gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
481+
size_t size)
482482
{
483483
struct address_space *mapping = ip->i_inode.i_mapping;
484484
unsigned long index = *pos >> PAGE_SHIFT;
485-
unsigned offset = *pos & (PAGE_SIZE - 1);
486-
unsigned copied = 0;
487-
unsigned amt;
488-
struct page *page;
485+
size_t copied = 0;
489486

490487
do {
491-
page = read_cache_page(mapping, index, gfs2_read_folio, NULL);
492-
if (IS_ERR(page)) {
493-
if (PTR_ERR(page) == -EINTR)
488+
size_t offset, chunk;
489+
struct folio *folio;
490+
491+
folio = read_cache_folio(mapping, index, gfs2_read_folio, NULL);
492+
if (IS_ERR(folio)) {
493+
if (PTR_ERR(folio) == -EINTR)
494494
continue;
495-
return PTR_ERR(page);
495+
return PTR_ERR(folio);
496496
}
497-
amt = size - copied;
498-
if (offset + size > PAGE_SIZE)
499-
amt = PAGE_SIZE - offset;
500-
memcpy_from_page(buf + copied, page, offset, amt);
501-
put_page(page);
502-
copied += amt;
503-
index++;
504-
offset = 0;
497+
offset = *pos + copied - folio_pos(folio);
498+
chunk = min(size - copied, folio_size(folio) - offset);
499+
memcpy_from_folio(buf + copied, folio, offset, chunk);
500+
index = folio_next_index(folio);
501+
folio_put(folio);
502+
copied += chunk;
505503
} while(copied < size);
506504
(*pos) += size;
507505
return size;

fs/gfs2/inode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "util.h"
1414

1515
bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask);
16-
extern int gfs2_internal_read(struct gfs2_inode *ip,
17-
char *buf, loff_t *pos, unsigned size);
16+
extern ssize_t gfs2_internal_read(struct gfs2_inode *ip,
17+
char *buf, loff_t *pos, size_t size);
1818
extern void gfs2_set_aops(struct inode *inode);
1919

2020
static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)

0 commit comments

Comments
 (0)