Skip to content

Commit 75377ae

Browse files
Matthew Wilcox (Oracle)Andreas Gruenbacher
authored andcommitted
gfs2: Simplify gfs2_read_super
Use submit_bio_wait() instead of hand-rolling our own synchronous wait. Also allocate the BIO on the stack since we're not deep in the call stack at this point. There's no need to kmap the page, since it isn't allocated from HIGHMEM. Turn the GFP_NOFS allocation into GFP_KERNEL; if the page allocator enters reclaim, we cannot be called as the filesystem has not yet been initialised and so has no pages to reclaim. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent f3851fe commit 75377ae

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

fs/gfs2/ops_fstype.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,10 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)
185185
return 0;
186186
}
187187

188-
static void end_bio_io_page(struct bio *bio)
189-
{
190-
struct page *page = bio->bi_private;
191-
192-
if (!bio->bi_status)
193-
SetPageUptodate(page);
194-
else
195-
pr_warn("error %d reading superblock\n", bio->bi_status);
196-
unlock_page(page);
197-
}
198-
199-
static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)
188+
static void gfs2_sb_in(struct gfs2_sbd *sdp, const struct gfs2_sb *str)
200189
{
201190
struct gfs2_sb_host *sb = &sdp->sd_sb;
202191
struct super_block *s = sdp->sd_vfs;
203-
const struct gfs2_sb *str = buf;
204192

205193
sb->sb_magic = be32_to_cpu(str->sb_header.mh_magic);
206194
sb->sb_type = be32_to_cpu(str->sb_header.mh_type);
@@ -240,34 +228,26 @@ static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)
240228
static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector, int silent)
241229
{
242230
struct super_block *sb = sdp->sd_vfs;
243-
struct gfs2_sb *p;
244231
struct page *page;
245-
struct bio *bio;
232+
struct bio_vec bvec;
233+
struct bio bio;
234+
int err;
246235

247-
page = alloc_page(GFP_NOFS);
236+
page = alloc_page(GFP_KERNEL);
248237
if (unlikely(!page))
249238
return -ENOMEM;
250239

251-
ClearPageUptodate(page);
252-
ClearPageDirty(page);
253-
lock_page(page);
254-
255-
bio = bio_alloc(sb->s_bdev, 1, REQ_OP_READ | REQ_META, GFP_NOFS);
256-
bio->bi_iter.bi_sector = sector * (sb->s_blocksize >> 9);
257-
__bio_add_page(bio, page, PAGE_SIZE, 0);
240+
bio_init(&bio, sb->s_bdev, &bvec, 1, REQ_OP_READ | REQ_META);
241+
bio.bi_iter.bi_sector = sector * (sb->s_blocksize >> 9);
242+
__bio_add_page(&bio, page, PAGE_SIZE, 0);
258243

259-
bio->bi_end_io = end_bio_io_page;
260-
bio->bi_private = page;
261-
submit_bio(bio);
262-
wait_on_page_locked(page);
263-
bio_put(bio);
264-
if (!PageUptodate(page)) {
244+
err = submit_bio_wait(&bio);
245+
if (err) {
246+
pr_warn("error %d reading superblock\n", err);
265247
__free_page(page);
266-
return -EIO;
248+
return err;
267249
}
268-
p = kmap(page);
269-
gfs2_sb_in(sdp, p);
270-
kunmap(page);
250+
gfs2_sb_in(sdp, page_address(page));
271251
__free_page(page);
272252
return gfs2_check_sb(sdp, silent);
273253
}

0 commit comments

Comments
 (0)