diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-07-27 13:53:53 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-07-27 13:53:53 -0400 |
commit | f45b7ddd2bae1dc98e35c3611b55cba6d2a8da9e (patch) | |
tree | b2c498fc65855cb0f7ec17b9e2a42200aae633af /fs/gfs2/super.c | |
parent | ae4a382004fc6cf229c51deaf69910410d313e0b (diff) |
[GFS2] Use a bio to read the superblock
This means that we don't need to create a special inode just to contain
a struct address_space in order to read a single disk block. Instead
we read the disk block directly. Its slightly faster, and uses slightly
less memory, but the real reason for doing this is that it removes a
special case from the glock code.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/super.c')
-rw-r--r-- | fs/gfs2/super.c | 69 |
1 files changed, 59 insertions, 10 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f2d287660cc9..48fd4cb49c1e 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/crc32.h> | 15 | #include <linux/crc32.h> |
16 | #include <linux/gfs2_ondisk.h> | 16 | #include <linux/gfs2_ondisk.h> |
17 | #include <linux/bio.h> | ||
17 | 18 | ||
18 | #include "gfs2.h" | 19 | #include "gfs2.h" |
19 | #include "lm_interface.h" | 20 | #include "lm_interface.h" |
@@ -157,6 +158,54 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) | |||
157 | return 0; | 158 | return 0; |
158 | } | 159 | } |
159 | 160 | ||
161 | |||
162 | static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error) | ||
163 | { | ||
164 | struct page *page = bio->bi_private; | ||
165 | if (bio->bi_size) | ||
166 | return 1; | ||
167 | |||
168 | if (!error) | ||
169 | SetPageUptodate(page); | ||
170 | unlock_page(page); | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static struct page *gfs2_read_super(struct super_block *sb, sector_t sector) | ||
175 | { | ||
176 | struct page *page; | ||
177 | struct bio *bio; | ||
178 | |||
179 | page = alloc_page(GFP_KERNEL); | ||
180 | if (unlikely(!page)) | ||
181 | return NULL; | ||
182 | |||
183 | ClearPageUptodate(page); | ||
184 | ClearPageDirty(page); | ||
185 | lock_page(page); | ||
186 | |||
187 | bio = bio_alloc(GFP_KERNEL, 1); | ||
188 | if (unlikely(!bio)) { | ||
189 | __free_page(page); | ||
190 | return NULL; | ||
191 | } | ||
192 | |||
193 | bio->bi_sector = sector; | ||
194 | bio->bi_bdev = sb->s_bdev; | ||
195 | bio_add_page(bio, page, PAGE_SIZE, 0); | ||
196 | |||
197 | bio->bi_end_io = end_bio_io_page; | ||
198 | bio->bi_private = page; | ||
199 | submit_bio(READ | BIO_RW_SYNC, bio); | ||
200 | wait_on_page_locked(page); | ||
201 | bio_put(bio); | ||
202 | if (!PageUptodate(page)) { | ||
203 | __free_page(page); | ||
204 | return NULL; | ||
205 | } | ||
206 | return page; | ||
207 | } | ||
208 | |||
160 | /** | 209 | /** |
161 | * gfs2_read_sb - Read super block | 210 | * gfs2_read_sb - Read super block |
162 | * @sdp: The GFS2 superblock | 211 | * @sdp: The GFS2 superblock |
@@ -167,23 +216,23 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) | |||
167 | 216 | ||
168 | int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) | 217 | int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) |
169 | { | 218 | { |
170 | struct buffer_head *bh; | ||
171 | uint32_t hash_blocks, ind_blocks, leaf_blocks; | 219 | uint32_t hash_blocks, ind_blocks, leaf_blocks; |
172 | uint32_t tmp_blocks; | 220 | uint32_t tmp_blocks; |
173 | unsigned int x; | 221 | unsigned int x; |
174 | int error; | 222 | int error; |
223 | struct page *page; | ||
224 | char *sb; | ||
175 | 225 | ||
176 | error = gfs2_meta_read(gl, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift, | 226 | page = gfs2_read_super(sdp->sd_vfs, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); |
177 | DIO_FORCE | DIO_START | DIO_WAIT, &bh); | 227 | if (!page) { |
178 | if (error) { | ||
179 | if (!silent) | 228 | if (!silent) |
180 | fs_err(sdp, "can't read superblock\n"); | 229 | fs_err(sdp, "can't read superblock\n"); |
181 | return error; | 230 | return -EIO; |
182 | } | 231 | } |
183 | 232 | sb = kmap(page); | |
184 | gfs2_assert(sdp, sizeof(struct gfs2_sb) <= bh->b_size); | 233 | gfs2_sb_in(&sdp->sd_sb, sb); |
185 | gfs2_sb_in(&sdp->sd_sb, bh->b_data); | 234 | kunmap(page); |
186 | brelse(bh); | 235 | __free_page(page); |
187 | 236 | ||
188 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); | 237 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); |
189 | if (error) | 238 | if (error) |
@@ -202,7 +251,7 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) | |||
202 | sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t); | 251 | sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t); |
203 | sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - | 252 | sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - |
204 | sizeof(struct gfs2_meta_header)) / | 253 | sizeof(struct gfs2_meta_header)) / |
205 | sizeof(struct gfs2_quota_change); | 254 | sizeof(struct gfs2_quota_change); |
206 | 255 | ||
207 | /* Compute maximum reservation required to add a entry to a directory */ | 256 | /* Compute maximum reservation required to add a entry to a directory */ |
208 | 257 | ||