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

Configure Feed

Select the types of activity you want to include in your feed.

gfs2: Remove trans_drain code duplication

Rename trans_drain() to gfs2_trans_drain().

Add a new gfs2_trans_drain_list() helper and use it in
gfs2_trans_drain() to reduce code duplication.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>

+18 -23
+18 -23
fs/gfs2/log.c
··· 983 983 } 984 984 } 985 985 986 + static void gfs2_trans_drain_list(struct list_head *list) 987 + { 988 + struct gfs2_bufdata *bd; 989 + 990 + while (!list_empty(list)) { 991 + bd = list_first_entry(list, struct gfs2_bufdata, bd_list); 992 + list_del_init(&bd->bd_list); 993 + if (!list_empty(&bd->bd_ail_st_list)) 994 + gfs2_remove_from_ail(bd); 995 + kmem_cache_free(gfs2_bufdata_cachep, bd); 996 + } 997 + } 998 + 986 999 /** 987 - * trans_drain - drain the buf and databuf queue for a failed transaction 1000 + * gfs2_trans_drain - drain the buf and databuf queue for a failed transaction 988 1001 * @tr: the transaction to drain 989 1002 * 990 1003 * When this is called, we're taking an error exit for a log write that failed 991 1004 * but since we bypassed the after_commit functions, we need to remove the 992 1005 * items from the buf and databuf queue. 993 1006 */ 994 - static void trans_drain(struct gfs2_trans *tr) 1007 + static void gfs2_trans_drain(struct gfs2_trans *tr) 995 1008 { 996 - struct gfs2_bufdata *bd; 997 - struct list_head *head; 998 - 999 1009 if (!tr) 1000 1010 return; 1001 - 1002 - head = &tr->tr_buf; 1003 - while (!list_empty(head)) { 1004 - bd = list_first_entry(head, struct gfs2_bufdata, bd_list); 1005 - list_del_init(&bd->bd_list); 1006 - if (!list_empty(&bd->bd_ail_st_list)) 1007 - gfs2_remove_from_ail(bd); 1008 - kmem_cache_free(gfs2_bufdata_cachep, bd); 1009 - } 1010 - head = &tr->tr_databuf; 1011 - while (!list_empty(head)) { 1012 - bd = list_first_entry(head, struct gfs2_bufdata, bd_list); 1013 - list_del_init(&bd->bd_list); 1014 - if (!list_empty(&bd->bd_ail_st_list)) 1015 - gfs2_remove_from_ail(bd); 1016 - kmem_cache_free(gfs2_bufdata_cachep, bd); 1017 - } 1011 + gfs2_trans_drain_list(&tr->tr_buf); 1012 + gfs2_trans_drain_list(&tr->tr_databuf); 1018 1013 } 1019 1014 1020 1015 void gfs2_remove_from_journal(struct buffer_head *bh, int meta) ··· 1181 1186 return; 1182 1187 1183 1188 out_withdraw: 1184 - trans_drain(tr); 1189 + gfs2_trans_drain(tr); 1185 1190 /** 1186 1191 * If the tr_list is empty, we're withdrawing during a log 1187 1192 * flush that targets a transaction, but the transaction was