Journal extent mapping
PATCH 1/10 Journal extent mapping
Hi,
This patch saves a little time when gfs2 writes to the journals by keeping a mapping between logical and physical blocks on disk. That's better than constantly looking up indirect pointers in buffers, when the journals are several levels of indirection (which they typically are).
Regards,
Bob Peterson
Red Hat GFS
Signed-off-by Bob Peterson <[email protected]>
--
fs/gfs2/incore.h | 11 +++++++- fs/gfs2/log.c | 22 ++++++--------- fs/gfs2/ops_fstype.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++- fs/gfs2/super.c | 13 ++++++++- 4 files changed, 97 insertions(+), 17 deletions(-)
fs/gfs2/incore.h +10 -1
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2007 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
@@ -360,8 +360,17 @@ struct gfs2_ail {u64 ai_sync_gen; }; +struct gfs2_journal_extent { +struct list_head extent_list; + +unsigned int lblock;/* First logical block */ +u64 dblock;/* First disk block */ +u64 blocks; +}; +struct gfs2_jdesc {struct list_head jd_list; +struct list_head extent_list;struct inode *jd_inode;unsigned int jd_jid;
fs/gfs2/log.c +9 -13
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2007 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
@@ -332,18 +332,14 @@ retry:static u64 log_bmap (struct gfs2_sbd *sdp,unsigned int lbn) { -struct inode *inode = sdp->sd_jdesc->jd_inode; -int error; -struct buffer_head bh_map = { .b_state =0 , .b_blocknr =0 }; - - bh_map.b_size =1 << inode->i_blkbits; - error =gfs2_block_map (inode, lbn, &bh_map,0 ); -if (error || !bh_map.b_blocknr) -printk (KERN_INFO "error=%d, dbn=%llu lbn=%u" , error, - (unsigned long long )bh_map.b_blocknr, lbn); -gfs2_assert_withdraw (sdp, !error && bh_map.b_blocknr); - -return bh_map.b_blocknr; +struct gfs2_journal_extent *je; + +list_for_each_entry (je, &sdp->sd_jdesc->extent_list, extent_list) { +if (lbn >= je->lblock && lbn < je->lblock + je->blocks) +return je->dblock + lbn; + } + +return -1 ; }/**
fs/gfs2/ops_fstype.c +67 -1
91 lines not on this page · raw message
fs/gfs2/super.c +11 -2
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2007 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
@@ -414,8 +414,9 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)void gfs2_jindex_free (struct gfs2_sbd *sdp) { -struct list_head list; +struct list_head list, *head;struct gfs2_jdesc *jd; +struct gfs2_journal_extent *jext;spin_lock (&sdp->sd_jindex_spin);list_add (&list, &sdp->sd_jindex_list);
@@ -425,6 +426,14 @@ void gfs2_jindex_free(struct gfs2_sbd *sdp)while (!list_empty (&list)) { jd = list_entry(list.next, struct gfs2_jdesc, jd_list); + head = &jd->extent_list; +while (!list_empty (head)) { + jext =list_entry (head->next, + struct gfs2_journal_extent, + extent_list); +list_del (&jext->extent_list); +kfree (jext); + }list_del (&jd->jd_list);iput (jd->jd_inode);kfree (jd);