]> git.karo-electronics.de Git - linux-beck.git/commitdiff
GFS2: Move log buffer lists into transaction
authorSteven Whitehouse <swhiteho@redhat.com>
Fri, 21 Feb 2014 15:22:35 +0000 (15:22 +0000)
committerSteven Whitehouse <swhiteho@redhat.com>
Mon, 24 Feb 2014 16:54:54 +0000 (16:54 +0000)
Over time, we hope to be able to improve the concurrency available
in the log code. This is one small step towards that, by moving
the buffer lists from the super block, and into the transaction
structure, so that each transaction builds its own buffer lists.

At transaction commit time, the buffer lists are merged into
the currently accumulating transaction. That transaction then
is passed into the before and after commit functions at journal
flush time. Thus there should be no change in overall behaviour
yet.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/glops.c
fs/gfs2/incore.h
fs/gfs2/log.c
fs/gfs2/lops.c
fs/gfs2/lops.h
fs/gfs2/ops_fstype.c
fs/gfs2/trans.c

index 3bf0631b5d56d8a76a17b9f70e3fa1cc4b9ee2f0..54b66809e818e4fbffd46c186f7409948e35e3a2 100644 (file)
@@ -82,6 +82,8 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
        struct gfs2_trans tr;
 
        memset(&tr, 0, sizeof(tr));
+       INIT_LIST_HEAD(&tr.tr_buf);
+       INIT_LIST_HEAD(&tr.tr_databuf);
        tr.tr_revokes = atomic_read(&gl->gl_ail_count);
 
        if (!tr.tr_revokes)
index 645655cccdc8ef34f960e26aebb782547658d88c..99aab64c771abf6ff8b0601ce271475da4d09b82 100644 (file)
@@ -52,7 +52,7 @@ struct gfs2_log_header_host {
  */
 
 struct gfs2_log_operations {
-       void (*lo_before_commit) (struct gfs2_sbd *sdp);
+       void (*lo_before_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
        void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
        void (*lo_before_scan) (struct gfs2_jdesc *jd,
                                struct gfs2_log_header_host *head, int pass);
@@ -476,6 +476,8 @@ struct gfs2_trans {
        unsigned int tr_num_revoke_rm;
 
        struct list_head tr_list;
+       struct list_head tr_databuf;
+       struct list_head tr_buf;
 
        unsigned int tr_first;
        struct list_head tr_ail1_list;
@@ -756,9 +758,7 @@ struct gfs2_sbd {
        unsigned int sd_log_num_rg;
        unsigned int sd_log_num_databuf;
 
-       struct list_head sd_log_le_buf;
        struct list_head sd_log_le_revoke;
-       struct list_head sd_log_le_databuf;
        struct list_head sd_log_le_ordered;
        spinlock_t sd_ordered_lock;
 
index 1e1bda0de43d7683d1d51209ff86b67ba536013c..975712c6660b9d6d2fb0fd37f6d0c98184a3d04e 100644 (file)
@@ -712,7 +712,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
                tr->tr_first = sdp->sd_log_flush_head;
 
        gfs2_ordered_write(sdp);
-       lops_before_commit(sdp);
+       lops_before_commit(sdp, tr);
        gfs2_log_flush_bio(sdp, WRITE);
 
        if (sdp->sd_log_head != sdp->sd_log_flush_head) {
@@ -744,6 +744,27 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
        kfree(tr);
 }
 
+/**
+ * gfs2_merge_trans - Merge a new transaction into a cached transaction
+ * @old: Original transaction to be expanded
+ * @new: New transaction to be merged
+ */
+
+static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
+{
+       WARN_ON_ONCE(old->tr_attached != 1);
+
+       old->tr_num_buf_new     += new->tr_num_buf_new;
+       old->tr_num_databuf_new += new->tr_num_databuf_new;
+       old->tr_num_buf_rm      += new->tr_num_buf_rm;
+       old->tr_num_databuf_rm  += new->tr_num_databuf_rm;
+       old->tr_num_revoke      += new->tr_num_revoke;
+       old->tr_num_revoke_rm   += new->tr_num_revoke_rm;
+
+       list_splice_tail_init(&new->tr_databuf, &old->tr_databuf);
+       list_splice_tail_init(&new->tr_buf, &old->tr_buf);
+}
+
 static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 {
        unsigned int reserved;
@@ -766,8 +787,9 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
                             sdp->sd_jdesc->jd_blocks);
        sdp->sd_log_blks_reserved = reserved;
 
-       if (sdp->sd_log_tr == NULL &&
-           (tr->tr_num_buf_new || tr->tr_num_databuf_new)) {
+       if (sdp->sd_log_tr) {
+               gfs2_merge_trans(sdp->sd_log_tr, tr);
+       } else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) {
                gfs2_assert_withdraw(sdp, tr->tr_t_gh.gh_gl);
                sdp->sd_log_tr = tr;
                tr->tr_attached = 1;
index 76693793ceddfe7f936c360a6c3494d1882a849a..ee9ec7fa3011324bede4ac008af78911d2e61438 100644 (file)
@@ -491,24 +491,23 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
        gfs2_log_unlock(sdp);
 }
 
-static void buf_lo_before_commit(struct gfs2_sbd *sdp)
+static void buf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 {
        unsigned int limit = buf_limit(sdp); /* 503 for 4k blocks */
-
-       gfs2_before_commit(sdp, limit, sdp->sd_log_num_buf,
-                          &sdp->sd_log_le_buf, 0);
+       if (tr == NULL)
+               return;
+       gfs2_before_commit(sdp, limit, sdp->sd_log_num_buf, &tr->tr_buf, 0);
 }
 
 static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 {
-       struct list_head *head = &sdp->sd_log_le_buf;
+       struct list_head *head;
        struct gfs2_bufdata *bd;
 
-       if (tr == NULL) {
-               gfs2_assert(sdp, list_empty(head));
+       if (tr == NULL)
                return;
-       }
 
+       head = &tr->tr_buf;
        while (!list_empty(head)) {
                bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
@@ -620,7 +619,7 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
                jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
 }
 
-static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
+static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 {
        struct gfs2_meta_header *mh;
        unsigned int offset;
@@ -760,12 +759,12 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
  *
  */
 
-static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
+static void databuf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 {
        unsigned int limit = buf_limit(sdp) / 2;
-
-       gfs2_before_commit(sdp, limit, sdp->sd_log_num_databuf,
-                          &sdp->sd_log_le_databuf, 1);
+       if (tr == NULL)
+               return;
+       gfs2_before_commit(sdp, limit, sdp->sd_log_num_databuf, &tr->tr_databuf, 1);
 }
 
 static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -840,14 +839,13 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 
 static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 {
-       struct list_head *head = &sdp->sd_log_le_databuf;
+       struct list_head *head;
        struct gfs2_bufdata *bd;
 
-       if (tr == NULL) {
-               gfs2_assert(sdp, list_empty(head));
+       if (tr == NULL)
                return;
-       }
 
+       head = &tr->tr_databuf;
        while (!list_empty(head)) {
                bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
index 9ca2e6438419a93f0100f16e26405a4e86097922..a65a7ba32ffdf5f9eaaa4be0d25bad4c67db3c74 100644 (file)
@@ -46,12 +46,13 @@ static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
        return limit;
 }
 
-static inline void lops_before_commit(struct gfs2_sbd *sdp)
+static inline void lops_before_commit(struct gfs2_sbd *sdp,
+                                     struct gfs2_trans *tr)
 {
        int x;
        for (x = 0; gfs2_log_ops[x]; x++)
                if (gfs2_log_ops[x]->lo_before_commit)
-                       gfs2_log_ops[x]->lo_before_commit(sdp);
+                       gfs2_log_ops[x]->lo_before_commit(sdp, tr);
 }
 
 static inline void lops_after_commit(struct gfs2_sbd *sdp,
index c6872d09561a2d53c8e57374eb700f4fb578ae78..1f855a74a4ecdc9b11f6cb061165d3ddb9910fbf 100644 (file)
@@ -114,9 +114,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 
        spin_lock_init(&sdp->sd_log_lock);
        atomic_set(&sdp->sd_log_pinned, 0);
-       INIT_LIST_HEAD(&sdp->sd_log_le_buf);
        INIT_LIST_HEAD(&sdp->sd_log_le_revoke);
-       INIT_LIST_HEAD(&sdp->sd_log_le_databuf);
        INIT_LIST_HEAD(&sdp->sd_log_le_ordered);
        spin_lock_init(&sdp->sd_ordered_lock);
 
index 963b28c50fd423f80d3ef218270b7f0f45fb178c..e0464a22908c1e7942c33ec1501cb1dc504cef50 100644 (file)
@@ -51,6 +51,9 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
        if (revokes)
                tr->tr_reserved += gfs2_struct2blk(sdp, revokes,
                                                   sizeof(u64));
+       INIT_LIST_HEAD(&tr->tr_databuf);
+       INIT_LIST_HEAD(&tr->tr_buf);
+
        sb_start_intwrite(sdp->sd_vfs);
        gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh);
 
@@ -211,7 +214,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
                gfs2_pin(sdp, bd->bd_bh);
                tr->tr_num_databuf_new++;
                sdp->sd_log_num_databuf++;
-               list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf);
+               list_add_tail(&bd->bd_list, &tr->tr_databuf);
        }
        gfs2_log_unlock(sdp);
        unlock_buffer(bh);
@@ -239,7 +242,7 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
        mh->__pad0 = cpu_to_be64(0);
        mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
        sdp->sd_log_num_buf++;
-       list_add(&bd->bd_list, &sdp->sd_log_le_buf);
+       list_add(&bd->bd_list, &tr->tr_buf);
        tr->tr_num_buf_new++;
 }