block: Convert read_part_sector() to use a folio

This relatively straightforward converion saves a call to compound_head()
hidden inside put_page().
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
parent 069fc464
...@@ -24,13 +24,13 @@ struct parsed_partitions { ...@@ -24,13 +24,13 @@ struct parsed_partitions {
}; };
typedef struct { typedef struct {
struct page *v; struct folio *v;
} Sector; } Sector;
void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p); void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p);
static inline void put_dev_sector(Sector p) static inline void put_dev_sector(Sector p)
{ {
put_page(p.v); folio_put(p.v);
} }
static inline void static inline void
......
...@@ -705,19 +705,19 @@ EXPORT_SYMBOL_GPL(bdev_disk_changed); ...@@ -705,19 +705,19 @@ EXPORT_SYMBOL_GPL(bdev_disk_changed);
void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p) void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p)
{ {
struct address_space *mapping = state->disk->part0->bd_inode->i_mapping; struct address_space *mapping = state->disk->part0->bd_inode->i_mapping;
struct page *page; struct folio *folio;
if (n >= get_capacity(state->disk)) { if (n >= get_capacity(state->disk)) {
state->access_beyond_eod = true; state->access_beyond_eod = true;
goto out; goto out;
} }
page = read_mapping_page(mapping, n >> PAGE_SECTORS_SHIFT, NULL); folio = read_mapping_folio(mapping, n >> PAGE_SECTORS_SHIFT, NULL);
if (IS_ERR(page)) if (IS_ERR(folio))
goto out; goto out;
p->v = page; p->v = folio;
return page_address(page) + offset_in_page(n * SECTOR_SIZE); return folio_address(folio) + offset_in_folio(folio, n * SECTOR_SIZE);
out: out:
p->v = NULL; p->v = NULL;
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment