Skip to content

Commit 1086689

Browse files
author
Andreas Gruenbacher
committed
gfs2: Move gfs2_remove_from_journal to log.c
Move gfs2_remove_from_journal() from meta_io.c to log.c and fix a minor indentation glitch. With that, gfs2_remove_from_ail() is now only used inside log.c, so it can be made static. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 5a15907 commit 1086689

4 files changed

Lines changed: 37 additions & 38 deletions

File tree

fs/gfs2/log.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct)
7272
*
7373
*/
7474

75-
void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
75+
static void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
7676
{
7777
bd->bd_tr = NULL;
7878
list_del_init(&bd->bd_ail_st_list);
@@ -1017,6 +1017,41 @@ static void trans_drain(struct gfs2_trans *tr)
10171017
}
10181018
}
10191019

1020+
void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
1021+
{
1022+
struct address_space *mapping = bh->b_folio->mapping;
1023+
struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping);
1024+
struct gfs2_bufdata *bd = bh->b_private;
1025+
struct gfs2_trans *tr = current->journal_info;
1026+
int was_pinned = 0;
1027+
1028+
if (test_clear_buffer_pinned(bh)) {
1029+
trace_gfs2_pin(bd, 0);
1030+
atomic_dec(&sdp->sd_log_pinned);
1031+
list_del_init(&bd->bd_list);
1032+
if (meta == REMOVE_META)
1033+
tr->tr_num_buf_rm++;
1034+
else
1035+
tr->tr_num_databuf_rm++;
1036+
set_bit(TR_TOUCHED, &tr->tr_flags);
1037+
was_pinned = 1;
1038+
brelse(bh);
1039+
}
1040+
if (bd) {
1041+
if (bd->bd_tr) {
1042+
gfs2_trans_add_revoke(sdp, bd);
1043+
} else if (was_pinned) {
1044+
bh->b_private = NULL;
1045+
kmem_cache_free(gfs2_bufdata_cachep, bd);
1046+
} else if (!list_empty(&bd->bd_ail_st_list) &&
1047+
!list_empty(&bd->bd_ail_gl_list)) {
1048+
gfs2_remove_from_ail(bd);
1049+
}
1050+
}
1051+
clear_buffer_dirty(bh);
1052+
clear_buffer_uptodate(bh);
1053+
}
1054+
10201055
/**
10211056
* gfs2_log_flush - flush incore transaction(s)
10221057
* @sdp: The filesystem

fs/gfs2/log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
3737

3838
void gfs2_ordered_del_inode(struct gfs2_inode *ip);
3939
unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
40-
void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
4140
bool gfs2_log_is_empty(struct gfs2_sbd *sdp);
4241
void gfs2_log_release_revokes(struct gfs2_sbd *sdp, unsigned int revokes);
4342
void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
@@ -48,6 +47,7 @@ void gfs2_log_reserve(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
4847
void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
4948
u64 seq, u32 tail, u32 lblock, u32 flags,
5049
blk_opf_t op_flags);
50+
void gfs2_remove_from_journal(struct buffer_head *bh, int meta);
5151
void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
5252
u32 type);
5353
void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);

fs/gfs2/meta_io.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -338,41 +338,6 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh)
338338
return 0;
339339
}
340340

341-
void gfs2_remove_from_journal(struct buffer_head *bh, int meta)
342-
{
343-
struct address_space *mapping = bh->b_folio->mapping;
344-
struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping);
345-
struct gfs2_bufdata *bd = bh->b_private;
346-
struct gfs2_trans *tr = current->journal_info;
347-
int was_pinned = 0;
348-
349-
if (test_clear_buffer_pinned(bh)) {
350-
trace_gfs2_pin(bd, 0);
351-
atomic_dec(&sdp->sd_log_pinned);
352-
list_del_init(&bd->bd_list);
353-
if (meta == REMOVE_META)
354-
tr->tr_num_buf_rm++;
355-
else
356-
tr->tr_num_databuf_rm++;
357-
set_bit(TR_TOUCHED, &tr->tr_flags);
358-
was_pinned = 1;
359-
brelse(bh);
360-
}
361-
if (bd) {
362-
if (bd->bd_tr) {
363-
gfs2_trans_add_revoke(sdp, bd);
364-
} else if (was_pinned) {
365-
bh->b_private = NULL;
366-
kmem_cache_free(gfs2_bufdata_cachep, bd);
367-
} else if (!list_empty(&bd->bd_ail_st_list) &&
368-
!list_empty(&bd->bd_ail_gl_list)) {
369-
gfs2_remove_from_ail(bd);
370-
}
371-
}
372-
clear_buffer_dirty(bh);
373-
clear_buffer_uptodate(bh);
374-
}
375-
376341
/**
377342
* gfs2_ail1_wipe - remove deleted/freed buffers from the ail1 list
378343
* @sdp: superblock

fs/gfs2/meta_io.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ enum {
5959
REMOVE_META = 1,
6060
};
6161

62-
void gfs2_remove_from_journal(struct buffer_head *bh, int meta);
6362
void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen);
6463
int gfs2_meta_buffer(struct gfs2_inode *ip, u32 mtype, u64 num,
6564
struct buffer_head **bhp);

0 commit comments

Comments
 (0)