Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

GFS2: Move two functions from log.c to lops.c

gfs2_log_get_buf() and gfs2_log_fake_buf() are both used
only in lops.c, so move them next to their callers and they
can then become static.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

+97 -101
+4 -97
fs/gfs2/log.c
··· 358 358 return 0; 359 359 } 360 360 361 - static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) 361 + u64 gfs2_log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) 362 362 { 363 363 struct gfs2_journal_extent *je; 364 364 ··· 467 467 468 468 void gfs2_log_incr_head(struct gfs2_sbd *sdp) 469 469 { 470 - if (sdp->sd_log_flush_head == sdp->sd_log_tail) 471 - BUG_ON(sdp->sd_log_flush_head != sdp->sd_log_head); 470 + BUG_ON((sdp->sd_log_flush_head == sdp->sd_log_tail) && 471 + (sdp->sd_log_flush_head != sdp->sd_log_head)); 472 472 473 473 if (++sdp->sd_log_flush_head == sdp->sd_jdesc->jd_blocks) { 474 474 sdp->sd_log_flush_head = 0; 475 475 sdp->sd_log_flush_wrapped = 1; 476 476 } 477 - } 478 - 479 - /** 480 - * gfs2_log_write_endio - End of I/O for a log buffer 481 - * @bh: The buffer head 482 - * @uptodate: I/O Status 483 - * 484 - */ 485 - 486 - static void gfs2_log_write_endio(struct buffer_head *bh, int uptodate) 487 - { 488 - struct gfs2_sbd *sdp = bh->b_private; 489 - bh->b_private = NULL; 490 - 491 - end_buffer_write_sync(bh, uptodate); 492 - if (atomic_dec_and_test(&sdp->sd_log_in_flight)) 493 - wake_up(&sdp->sd_log_flush_wait); 494 - } 495 - 496 - /** 497 - * gfs2_log_get_buf - Get and initialize a buffer to use for log control data 498 - * @sdp: The GFS2 superblock 499 - * 500 - * Returns: the buffer_head 501 - */ 502 - 503 - struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp) 504 - { 505 - u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); 506 - struct buffer_head *bh; 507 - 508 - bh = sb_getblk(sdp->sd_vfs, blkno); 509 - lock_buffer(bh); 510 - memset(bh->b_data, 0, bh->b_size); 511 - set_buffer_uptodate(bh); 512 - clear_buffer_dirty(bh); 513 - gfs2_log_incr_head(sdp); 514 - atomic_inc(&sdp->sd_log_in_flight); 515 - bh->b_private = sdp; 516 - bh->b_end_io = gfs2_log_write_endio; 517 - 518 - return bh; 519 - } 520 - 521 - /** 522 - * gfs2_fake_write_endio - 523 - * @bh: The buffer head 524 - * @uptodate: The I/O Status 525 - * 526 - */ 527 - 528 - static void gfs2_fake_write_endio(struct buffer_head *bh, int uptodate) 529 - { 530 - struct buffer_head *real_bh = bh->b_private; 531 - struct gfs2_bufdata *bd = real_bh->b_private; 532 - struct gfs2_sbd *sdp = bd->bd_gl->gl_sbd; 533 - 534 - end_buffer_write_sync(bh, uptodate); 535 - free_buffer_head(bh); 536 - unlock_buffer(real_bh); 537 - brelse(real_bh); 538 - if (atomic_dec_and_test(&sdp->sd_log_in_flight)) 539 - wake_up(&sdp->sd_log_flush_wait); 540 - } 541 - 542 - /** 543 - * gfs2_log_fake_buf - Build a fake buffer head to write metadata buffer to log 544 - * @sdp: the filesystem 545 - * @data: the data the buffer_head should point to 546 - * 547 - * Returns: the log buffer descriptor 548 - */ 549 - 550 - struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp, 551 - struct buffer_head *real) 552 - { 553 - u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); 554 - struct buffer_head *bh; 555 - 556 - bh = alloc_buffer_head(GFP_NOFS | __GFP_NOFAIL); 557 - atomic_set(&bh->b_count, 1); 558 - bh->b_state = (1 << BH_Mapped) | (1 << BH_Uptodate) | (1 << BH_Lock); 559 - set_bh_page(bh, real->b_page, bh_offset(real)); 560 - bh->b_blocknr = blkno; 561 - bh->b_size = sdp->sd_sb.sb_bsize; 562 - bh->b_bdev = sdp->sd_vfs->s_bdev; 563 - bh->b_private = real; 564 - bh->b_end_io = gfs2_fake_write_endio; 565 - 566 - gfs2_log_incr_head(sdp); 567 - atomic_inc(&sdp->sd_log_in_flight); 568 - 569 - return bh; 570 477 } 571 478 572 479 static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail) ··· 499 592 500 593 static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull) 501 594 { 502 - u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); 595 + u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head); 503 596 struct buffer_head *bh; 504 597 struct gfs2_log_header *lh; 505 598 unsigned int tail;
+1 -4
fs/gfs2/log.h
··· 53 53 54 54 extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks); 55 55 extern void gfs2_log_incr_head(struct gfs2_sbd *sdp); 56 - 57 - extern struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp); 58 - extern struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp, 59 - struct buffer_head *real); 56 + extern u64 gfs2_log_bmap(struct gfs2_sbd *sdp, unsigned int lbn); 60 57 extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl); 61 58 extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans); 62 59 extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
+92
fs/gfs2/lops.c
··· 143 143 return (__force __be64 *)(bh->b_data + bh->b_size); 144 144 } 145 145 146 + /** 147 + * gfs2_log_write_endio - End of I/O for a log buffer 148 + * @bh: The buffer head 149 + * @uptodate: I/O Status 150 + * 151 + */ 152 + 153 + static void gfs2_log_write_endio(struct buffer_head *bh, int uptodate) 154 + { 155 + struct gfs2_sbd *sdp = bh->b_private; 156 + bh->b_private = NULL; 157 + 158 + end_buffer_write_sync(bh, uptodate); 159 + if (atomic_dec_and_test(&sdp->sd_log_in_flight)) 160 + wake_up(&sdp->sd_log_flush_wait); 161 + } 162 + 163 + /** 164 + * gfs2_log_get_buf - Get and initialize a buffer to use for log control data 165 + * @sdp: The GFS2 superblock 166 + * 167 + * tReturns: the buffer_head 168 + */ 169 + 170 + static struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp) 171 + { 172 + u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head); 173 + struct buffer_head *bh; 174 + 175 + bh = sb_getblk(sdp->sd_vfs, blkno); 176 + lock_buffer(bh); 177 + memset(bh->b_data, 0, bh->b_size); 178 + set_buffer_uptodate(bh); 179 + clear_buffer_dirty(bh); 180 + gfs2_log_incr_head(sdp); 181 + atomic_inc(&sdp->sd_log_in_flight); 182 + bh->b_private = sdp; 183 + bh->b_end_io = gfs2_log_write_endio; 184 + 185 + return bh; 186 + } 187 + 188 + /** 189 + * gfs2_fake_write_endio - 190 + * @bh: The buffer head 191 + * @uptodate: The I/O Status 192 + * 193 + */ 194 + 195 + static void gfs2_fake_write_endio(struct buffer_head *bh, int uptodate) 196 + { 197 + struct buffer_head *real_bh = bh->b_private; 198 + struct gfs2_bufdata *bd = real_bh->b_private; 199 + struct gfs2_sbd *sdp = bd->bd_gl->gl_sbd; 200 + 201 + end_buffer_write_sync(bh, uptodate); 202 + free_buffer_head(bh); 203 + unlock_buffer(real_bh); 204 + brelse(real_bh); 205 + if (atomic_dec_and_test(&sdp->sd_log_in_flight)) 206 + wake_up(&sdp->sd_log_flush_wait); 207 + } 208 + 209 + /** 210 + * gfs2_log_fake_buf - Build a fake buffer head to write metadata buffer to log 211 + * @sdp: the filesystem 212 + * @data: the data the buffer_head should point to 213 + * 214 + * Returns: the log buffer descriptor 215 + */ 216 + 217 + static struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp, 218 + struct buffer_head *real) 219 + { 220 + u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head); 221 + struct buffer_head *bh; 222 + 223 + bh = alloc_buffer_head(GFP_NOFS | __GFP_NOFAIL); 224 + atomic_set(&bh->b_count, 1); 225 + bh->b_state = (1 << BH_Mapped) | (1 << BH_Uptodate) | (1 << BH_Lock); 226 + set_bh_page(bh, real->b_page, bh_offset(real)); 227 + bh->b_blocknr = blkno; 228 + bh->b_size = sdp->sd_sb.sb_bsize; 229 + bh->b_bdev = sdp->sd_vfs->s_bdev; 230 + bh->b_private = real; 231 + bh->b_end_io = gfs2_fake_write_endio; 232 + 233 + gfs2_log_incr_head(sdp); 234 + atomic_inc(&sdp->sd_log_in_flight); 235 + 236 + return bh; 237 + } 146 238 147 239 static struct buffer_head *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type) 148 240 {