diff options
Diffstat (limited to 'fs/gfs2/meta_io.c')
-rw-r--r-- | fs/gfs2/meta_io.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 7f69ae2595f0..6c1e5d1c404a 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -374,33 +374,24 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen) | |||
374 | * @ip: The GFS2 inode | 374 | * @ip: The GFS2 inode |
375 | * @height: The level of this buf in the metadata (indir addr) tree (if any) | 375 | * @height: The level of this buf in the metadata (indir addr) tree (if any) |
376 | * @num: The block number (device relative) of the buffer | 376 | * @num: The block number (device relative) of the buffer |
377 | * @new: Non-zero if we may create a new buffer | ||
378 | * @bhp: the buffer is returned here | 377 | * @bhp: the buffer is returned here |
379 | * | 378 | * |
380 | * Returns: errno | 379 | * Returns: errno |
381 | */ | 380 | */ |
382 | 381 | ||
383 | int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num, | 382 | int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num, |
384 | int new, struct buffer_head **bhp) | 383 | struct buffer_head **bhp) |
385 | { | 384 | { |
386 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 385 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
387 | struct gfs2_glock *gl = ip->i_gl; | 386 | struct gfs2_glock *gl = ip->i_gl; |
388 | struct buffer_head *bh; | 387 | struct buffer_head *bh; |
389 | int ret = 0; | 388 | int ret = 0; |
389 | u32 mtype = height ? GFS2_METATYPE_IN : GFS2_METATYPE_DI; | ||
390 | 390 | ||
391 | if (new) { | 391 | ret = gfs2_meta_read(gl, num, DIO_WAIT, &bh); |
392 | BUG_ON(height == 0); | 392 | if (ret == 0 && gfs2_metatype_check(sdp, bh, mtype)) { |
393 | bh = gfs2_meta_new(gl, num); | 393 | brelse(bh); |
394 | gfs2_trans_add_bh(ip->i_gl, bh, 1); | 394 | ret = -EIO; |
395 | gfs2_metatype_set(bh, GFS2_METATYPE_IN, GFS2_FORMAT_IN); | ||
396 | gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header)); | ||
397 | } else { | ||
398 | u32 mtype = height ? GFS2_METATYPE_IN : GFS2_METATYPE_DI; | ||
399 | ret = gfs2_meta_read(gl, num, DIO_WAIT, &bh); | ||
400 | if (ret == 0 && gfs2_metatype_check(sdp, bh, mtype)) { | ||
401 | brelse(bh); | ||
402 | ret = -EIO; | ||
403 | } | ||
404 | } | 395 | } |
405 | *bhp = bh; | 396 | *bhp = bh; |
406 | return ret; | 397 | return ret; |