/*
* 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 <linux/sched.h>
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/gfs2_ondisk.h>
-#include <asm/semaphore.h>
#include "gfs2.h"
#include "lm_interface.h"
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 */
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;
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)
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);
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)
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));
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);
*(__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);
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;
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;
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);
if (!--revokes)
break;
- offset += sizeof(uint64_t);
+ offset += sizeof(u64);
}
brelse(bh);
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);
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++;
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);
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);
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 */
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)
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,
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);
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 = {
.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 = {
.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 = {
.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[] = {
&gfs2_revoke_lops,
&gfs2_rg_lops,
&gfs2_databuf_lops,
- NULL
+ NULL,
};