X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fgfs2%2Flops.c;h=f8f6d4b56a0195fb546f669c1e5a227c9e607c70;hb=a67cdbd4579c387c021a17c7447da8b88f2a94f4;hp=4d90eb3114977372e45f855c3c7cb9119dcee02c;hpb=7d63b54a65ce902f9aaa8efe8192aa3b983264d4;p=linux-2.6 diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 4d90eb3114..f8f6d4b56a 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -1,10 +1,10 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include @@ -13,7 +13,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" @@ -119,7 +118,7 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) unsigned n; __be64 *ptr; - offset += (sizeof(__be64) - 1); + offset += sizeof(__be64) - 1; offset &= ~(sizeof(__be64) - 1); limit = (sdp->sd_sb.sb_bsize - offset)/sizeof(__be64); /* for 4k blocks, limit = 503 */ @@ -185,8 +184,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) static void buf_lo_before_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (pass != 0) return; @@ -199,12 +197,12 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; - uint64_t blkno; + u64 blkno; int error = 0; if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_METADATA) @@ -221,8 +219,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, continue; error = gfs2_replay_read_block(jd, start, &bh_log); - if (error) - return error; + if (error) + return error; bh_ip = gfs2_meta_new(gl, blkno); memcpy(bh_ip->b_data, bh_log->b_data, bh_log->b_size); @@ -246,12 +244,11 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (error) { - gfs2_meta_sync(ip->i_gl, - DIO_START | DIO_WAIT); + gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT); return; } if (pass != 1) @@ -296,7 +293,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD); ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE); ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, - sizeof(uint64_t))); + sizeof(u64))); ld->ld_data1 = cpu_to_be32(sdp->sd_log_num_revoke); ld->ld_data2 = cpu_to_be32(0); memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved)); @@ -307,7 +304,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) list_del_init(&rv->rv_le.le_list); sdp->sd_log_num_revoke--; - if (offset + sizeof(uint64_t) > sdp->sd_sb.sb_bsize) { + if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) { set_buffer_dirty(bh); ll_rw_block(WRITE, 1, &bh); @@ -322,7 +319,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) *(__be64 *)(bh->b_data + offset) = cpu_to_be64(rv->rv_blkno); kfree(rv); - offset += sizeof(uint64_t); + offset += sizeof(u64); } gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); @@ -333,8 +330,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) static void revoke_lo_before_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (pass != 0) return; @@ -347,13 +343,12 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); unsigned int blks = be32_to_cpu(ld->ld_length); unsigned int revokes = be32_to_cpu(ld->ld_data1); struct buffer_head *bh; unsigned int offset; - uint64_t blkno; + u64 blkno; int first = 1; int error; @@ -370,7 +365,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, if (!first) gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB); - while (offset + sizeof(uint64_t) <= sdp->sd_sb.sb_bsize) { + while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) { blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset)); error = gfs2_revoke_add(sdp, blkno, start); @@ -381,7 +376,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, if (!--revokes) break; - offset += sizeof(uint64_t); + offset += sizeof(u64); } brelse(bh); @@ -394,8 +389,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (error) { gfs2_revoke_clean(sdp); @@ -466,19 +460,19 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le); struct gfs2_trans *tr = current->journal_info; struct address_space *mapping = bd->bd_bh->b_page->mapping; - struct gfs2_inode *ip = mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(mapping->host); tr->tr_touched = 1; - if (!list_empty(&bd->bd_list_tr) && + if (list_empty(&bd->bd_list_tr) && (ip->i_di.di_flags & GFS2_DIF_JDATA)) { tr->tr_num_buf++; - gfs2_trans_add_gl(bd->bd_gl); list_add(&bd->bd_list_tr, &tr->tr_list_buf); gfs2_pin(sdp, bd->bd_bh); tr->tr_num_buf_new++; } + gfs2_trans_add_gl(bd->bd_gl); gfs2_log_lock(sdp); - if (!list_empty(&le->le_list)) { + if (list_empty(&le->le_list)) { if (ip->i_di.di_flags & GFS2_DIF_JDATA) sdp->sd_log_num_jdata++; sdp->sd_log_num_databuf++; @@ -524,7 +518,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) unsigned int num, n; __be64 *ptr = NULL; - offset += (2*sizeof(__be64) - 1); + offset += 2*sizeof(__be64) - 1; offset &= ~(2*sizeof(__be64) - 1); limit = (sdp->sd_sb.sb_bsize - offset)/sizeof(__be64); @@ -597,6 +591,17 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) gfs2_log_lock(sdp); if (n++ > num) break; + } else if (!bd1->bd_bh) { + total_dbuf--; + sdp->sd_log_num_databuf--; + list_del_init(&bd1->bd_le.le_list); + if (bd1 == bd2) { + bd2 = NULL; + bd2 = list_prepare_entry(bd2, + &sdp->sd_log_le_databuf, + bd_le.le_list); + } + kmem_cache_free(gfs2_bufdata_cachep, bd1); } } gfs2_log_unlock(sdp); @@ -643,19 +648,19 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) gfs2_log_lock(sdp); bd1 = list_entry(started.next, struct gfs2_bufdata, bd_le.le_list); - list_del(&bd1->bd_le.le_list); + list_del_init(&bd1->bd_le.le_list); sdp->sd_log_num_databuf--; - bh = bd1->bd_bh; if (bh) { bh->b_private = NULL; + get_bh(bh); gfs2_log_unlock(sdp); wait_on_buffer(bh); brelse(bh); } else gfs2_log_unlock(sdp); - kfree(bd1); + kmem_cache_free(gfs2_bufdata_cachep, bd1); } /* We've removed all the ordered write bufs here, so only jdata left */ @@ -666,13 +671,13 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; - uint64_t blkno; - uint64_t esc; + u64 blkno; + u64 esc; int error = 0; if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_JDATA) @@ -717,8 +722,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (error) { gfs2_meta_sync(ip->i_gl, @@ -742,7 +747,7 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) while (!list_empty(head)) { bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); - list_del(&bd->bd_le.le_list); + list_del_init(&bd->bd_le.le_list); sdp->sd_log_num_databuf--; sdp->sd_log_num_jdata--; gfs2_unpin(sdp, bd->bd_bh, ai); @@ -755,7 +760,7 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) const struct gfs2_log_operations gfs2_glock_lops = { .lo_add = glock_lo_add, .lo_after_commit = glock_lo_after_commit, - .lo_name = "glock" + .lo_name = "glock", }; const struct gfs2_log_operations gfs2_buf_lops = { @@ -766,7 +771,7 @@ const struct gfs2_log_operations gfs2_buf_lops = { .lo_before_scan = buf_lo_before_scan, .lo_scan_elements = buf_lo_scan_elements, .lo_after_scan = buf_lo_after_scan, - .lo_name = "buf" + .lo_name = "buf", }; const struct gfs2_log_operations gfs2_revoke_lops = { @@ -775,13 +780,13 @@ const struct gfs2_log_operations gfs2_revoke_lops = { .lo_before_scan = revoke_lo_before_scan, .lo_scan_elements = revoke_lo_scan_elements, .lo_after_scan = revoke_lo_after_scan, - .lo_name = "revoke" + .lo_name = "revoke", }; const struct gfs2_log_operations gfs2_rg_lops = { .lo_add = rg_lo_add, .lo_after_commit = rg_lo_after_commit, - .lo_name = "rg" + .lo_name = "rg", }; const struct gfs2_log_operations gfs2_databuf_lops = { @@ -791,7 +796,7 @@ const struct gfs2_log_operations gfs2_databuf_lops = { .lo_after_commit = databuf_lo_after_commit, .lo_scan_elements = databuf_lo_scan_elements, .lo_after_scan = databuf_lo_after_scan, - .lo_name = "databuf" + .lo_name = "databuf", }; const struct gfs2_log_operations *gfs2_log_ops[] = { @@ -800,6 +805,6 @@ const struct gfs2_log_operations *gfs2_log_ops[] = { &gfs2_revoke_lops, &gfs2_rg_lops, &gfs2_databuf_lops, - NULL + NULL, };