diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2007-09-03 06:01:33 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-10-10 03:56:12 -0400 |
commit | 1ad38c437fa33f85ba4b6a85ea8c5478ee72d5bd (patch) | |
tree | 11a5fc7993ba9ae343fc72f03f9a11f312fd6128 /fs/gfs2/meta_io.c | |
parent | 0820ab517e1b100ee3f9584ec27f93309689ebe7 (diff) |
[GFS2] Clean up gfs2_trans_add_revoke()
The following alters gfs2_trans_add_revoke() to take a struct
gfs2_bufdata as an argument. This eliminates the memory allocation which
was previously required by making use of the already existing struct
gfs2_bufdata. It makes some sanity checks to ensure that the
gfs2_bufdata has been removed from all the lists before its recycled as
a revoke structure. This saves one memory allocation and one free per
revoke structure.
Also as a result, and to simplify the locking, since there is no longer
any blocking code in gfs2_trans_add_revoke() we must hold the log lock
whenever this function is called. This reduces the amount of times we
take and unlock the log lock.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/meta_io.c')
-rw-r--r-- | fs/gfs2/meta_io.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index d762e4f7044e..19097bc7c81d 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -313,42 +313,31 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen) | |||
313 | while (blen) { | 313 | while (blen) { |
314 | bh = getbuf(ip->i_gl, bstart, NO_CREATE); | 314 | bh = getbuf(ip->i_gl, bstart, NO_CREATE); |
315 | if (bh) { | 315 | if (bh) { |
316 | struct gfs2_bufdata *bd = bh->b_private; | 316 | struct gfs2_bufdata *bd; |
317 | 317 | ||
318 | lock_buffer(bh); | ||
319 | gfs2_log_lock(sdp); | ||
320 | bd = bh->b_private; | ||
318 | if (test_clear_buffer_pinned(bh)) { | 321 | if (test_clear_buffer_pinned(bh)) { |
319 | struct gfs2_trans *tr = current->journal_info; | 322 | struct gfs2_trans *tr = current->journal_info; |
320 | struct gfs2_inode *bh_ip = | ||
321 | GFS2_I(bh->b_page->mapping->host); | ||
322 | |||
323 | gfs2_log_lock(sdp); | ||
324 | list_del_init(&bd->bd_le.le_list); | 323 | list_del_init(&bd->bd_le.le_list); |
325 | gfs2_assert_warn(sdp, sdp->sd_log_num_buf); | 324 | gfs2_assert_warn(sdp, sdp->sd_log_num_buf); |
326 | sdp->sd_log_num_buf--; | 325 | sdp->sd_log_num_buf--; |
327 | gfs2_log_unlock(sdp); | 326 | tr->tr_num_buf_rm++; |
328 | if (bh_ip->i_inode.i_private != NULL) | ||
329 | tr->tr_num_databuf_rm++; | ||
330 | else | ||
331 | tr->tr_num_buf_rm++; | ||
332 | brelse(bh); | 327 | brelse(bh); |
333 | } | 328 | } |
334 | if (bd) { | 329 | if (bd) { |
335 | gfs2_log_lock(sdp); | ||
336 | if (bd->bd_ail) { | 330 | if (bd->bd_ail) { |
337 | u64 blkno = bh->b_blocknr; | 331 | gfs2_remove_from_ail(NULL, bd); |
338 | bd->bd_ail = NULL; | 332 | bh->b_private = NULL; |
339 | list_del(&bd->bd_ail_st_list); | 333 | bd->bd_bh = NULL; |
340 | list_del(&bd->bd_ail_gl_list); | 334 | bd->bd_blkno = bh->b_blocknr; |
341 | atomic_dec(&bd->bd_gl->gl_ail_count); | 335 | gfs2_trans_add_revoke(sdp, bd); |
342 | brelse(bh); | 336 | } |
343 | gfs2_log_unlock(sdp); | ||
344 | gfs2_trans_add_revoke(sdp, blkno); | ||
345 | } else | ||
346 | gfs2_log_unlock(sdp); | ||
347 | } | 337 | } |
348 | |||
349 | lock_buffer(bh); | ||
350 | clear_buffer_dirty(bh); | 338 | clear_buffer_dirty(bh); |
351 | clear_buffer_uptodate(bh); | 339 | clear_buffer_uptodate(bh); |
340 | gfs2_log_unlock(sdp); | ||
352 | unlock_buffer(bh); | 341 | unlock_buffer(bh); |
353 | 342 | ||
354 | brelse(bh); | 343 | brelse(bh); |