aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2012-02-03 10:21:59 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2012-02-28 12:09:59 -0500
commit47ac5537a794fc71f89d51af492a945bd233f70c (patch)
tree65c9c68c8b14ceb0fae31f5a03ec4d811fdbec99 /fs
parenta245769f254bbbea868e2cf8dc42daa061cd276f (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/log.c101
-rw-r--r--fs/gfs2/log.h5
-rw-r--r--fs/gfs2/lops.c92
3 files changed, 97 insertions, 101 deletions
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 756fae9eaf8f..4d31379265cb 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -358,7 +358,7 @@ retry:
358 return 0; 358 return 0;
359} 359}
360 360
361static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) 361u64 gfs2_log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
362{ 362{
363 struct gfs2_journal_extent *je; 363 struct gfs2_journal_extent *je;
364 364
@@ -467,8 +467,8 @@ static unsigned int current_tail(struct gfs2_sbd *sdp)
467 467
468void gfs2_log_incr_head(struct gfs2_sbd *sdp) 468void gfs2_log_incr_head(struct gfs2_sbd *sdp)
469{ 469{
470 if (sdp->sd_log_flush_head == sdp->sd_log_tail) 470 BUG_ON((sdp->sd_log_flush_head == sdp->sd_log_tail) &&
471 BUG_ON(sdp->sd_log_flush_head != sdp->sd_log_head); 471 (sdp->sd_log_flush_head != sdp->sd_log_head));
472 472
473 if (++sdp->sd_log_flush_head == sdp->sd_jdesc->jd_blocks) { 473 if (++sdp->sd_log_flush_head == sdp->sd_jdesc->jd_blocks) {
474 sdp->sd_log_flush_head = 0; 474 sdp->sd_log_flush_head = 0;
@@ -476,99 +476,6 @@ void gfs2_log_incr_head(struct gfs2_sbd *sdp)
476 } 476 }
477} 477}
478 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
486static 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
503struct 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
528static 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
550struct 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}
571
572static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail) 479static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)
573{ 480{
574 unsigned int dist = log_distance(sdp, new_tail, sdp->sd_log_tail); 481 unsigned int dist = log_distance(sdp, new_tail, sdp->sd_log_tail);
@@ -592,7 +499,7 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)
592 499
593static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull) 500static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull)
594{ 501{
595 u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); 502 u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head);
596 struct buffer_head *bh; 503 struct buffer_head *bh;
597 struct gfs2_log_header *lh; 504 struct gfs2_log_header *lh;
598 unsigned int tail; 505 unsigned int tail;
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index ab0621698b73..ff07454b582c 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -53,10 +53,7 @@ extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
53 53
54extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks); 54extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
55extern void gfs2_log_incr_head(struct gfs2_sbd *sdp); 55extern void gfs2_log_incr_head(struct gfs2_sbd *sdp);
56 56extern u64 gfs2_log_bmap(struct gfs2_sbd *sdp, unsigned int lbn);
57extern struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp);
58extern struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp,
59 struct buffer_head *real);
60extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl); 57extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl);
61extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans); 58extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
62extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd); 59extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 0301be655b12..8e323c4b7983 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -143,6 +143,98 @@ static inline __be64 *bh_ptr_end(struct buffer_head *bh)
143 return (__force __be64 *)(bh->b_data + bh->b_size); 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
153static 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
170static 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
195static 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
217static 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
147static struct buffer_head *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type) 239static struct buffer_head *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type)
148{ 240{