Skip to contentSkip to conversation

Speed up journal head lookup

PATCH Superseded Abhi Das 3 participants 9 messages Sep 10, 2018 GFS2 file system

lore
Share & tools
lore

Abhi Das

author
#0 lore raw

v2 cover Speed up journal head lookup

This is a revised version of the patchset I'd posted a few days ago. It contains fixes and some cleanup suggested by Andreas and Bob.

It is slightly different in parts from the rhel7 patchset I'd posted originally, owing to some bits already being present and the hash/crc computation code being different due to the updated log header structure.

Cheers!
--Abhi

Abhi Das (4):
gfs2: add timing info to map_journal_extents
gfs2: changes to gfs2_log_XXX_bio
gfs2: add a helper function to get_log_header that can be used
elsewhere
gfs2: read journal in large chunks to locate the head

 fs/gfs2/bmap.c       |   8 ++-
 fs/gfs2/incore.h     |   8 ++-
 fs/gfs2/log.c        |   4 +-
 fs/gfs2/lops.c       | 180 +++++++++++++++++++++++++++++++++++++--------------
 fs/gfs2/lops.h       |   3 +-
 fs/gfs2/ops_fstype.c |   1 +
 fs/gfs2/recovery.c   | 168 ++++++++++++-----------------------------------
 fs/gfs2/recovery.h   |   2 +
 8 files changed, 194 insertions(+), 180 deletions(-)
Signature · 1 line
2.4.11
author
#1 lore raw

PATCH v2 1/4 gfs2: add timing info to map_journal_extents

Tells you how many milliseconds map_journal_extents takes.

---
 fs/gfs2/bmap.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/gfs2/bmap.c +6 -2
index 03128ed..dddb5a4 100644
@@ -14,6 +14,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/iomap.h>
+#include <linux/ktime.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -2248,7 +2249,9 @@ int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd)
 	unsigned int shift = sdp->sd_sb.sb_bsize_shift;
 	u64 size;
 	int rc;
+	ktime_t start, end;
 
+	start = ktime_get();
 	lblock_stop = i_size_read(jd->jd_inode) >> shift;
 	size = (lblock_stop - lblock) << shift;
 	jd->nr_extents = 0;
@@ -2268,8 +2271,9 @@ int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd)
 		lblock += (bh.b_size >> ip->i_inode.i_blkbits);
 	} while(size > 0);
 
-	fs_info(sdp, "journal %d mapped with %u extents\n", jd->jd_jid,
-		jd->nr_extents);
+	end = ktime_get();
+	fs_info(sdp, "journal %d mapped with %u extents in %lldms\n", jd->jd_jid,
+		jd->nr_extents, ktime_ms_delta(end, start));
 	return 0;
 
 fail:
Signature · 1 line
2.4.11
author
#2 lore raw

PATCH v2 2/4 gfs2: changes to gfs2_log_XXX_bio

In reply to Abhi Das

Change gfs2_log_XXX_bio family of functions so they can be used with read operations also.

This patch also contains some clean up and coalescing of the above functions suggested by Andreas.

---
 fs/gfs2/log.c  |  4 +--
 fs/gfs2/lops.c | 86 ++++++++++++++++++++++++++--------------------------------
 fs/gfs2/lops.h |  2 +-
 3 files changed, 41 insertions(+), 51 deletions(-)
fs/gfs2/log.c +2 -2
index ee20ea42..b80fb30 100644
@@ -731,7 +731,7 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
 	lh->lh_crc = cpu_to_be32(crc);
 
 	gfs2_log_write(sdp, page, sb->s_blocksize, 0, addr);
-	gfs2_log_flush_bio(sdp, REQ_OP_WRITE, op_flags);
+	gfs2_log_flush_bio(&sdp->sd_log_bio, REQ_OP_WRITE, op_flags);
 	log_flush_wait(sdp);
 }
 
@@ -808,7 +808,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
 
 	gfs2_ordered_write(sdp);
 	lops_before_commit(sdp, tr);
-	gfs2_log_flush_bio(sdp, REQ_OP_WRITE, 0);
+	gfs2_log_flush_bio(&sdp->sd_log_bio, REQ_OP_WRITE, 0);
 
 	if (sdp->sd_log_head != sdp->sd_log_flush_head) {
 		log_flush_wait(sdp);
fs/gfs2/lops.c +38 -48

130 lines not on this page · raw message

fs/gfs2/lops.h +1 -1
index e494939..d709d99 100644
@@ -30,7 +30,7 @@ extern u64 gfs2_log_bmap(struct gfs2_sbd *sdp);
 extern void gfs2_log_write(struct gfs2_sbd *sdp, struct page *page,
 			   unsigned size, unsigned offset, u64 blkno);
 extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
-extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int op, int op_flags);
+extern void gfs2_log_flush_bio(struct bio **biop, int op, int op_flags);
 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
 
 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
Signature · 1 line
2.4.11
author
#3 lore raw

PATCH v2 3/4 gfs2: add a helper function to get_log_header that can be used elsewhere

In reply to Abhi Das

Move and re-order the error checks and hash/crc computations into another function __get_log_header() so it can be used in scenarios where buffer_heads are not being used for the log header.

---
 fs/gfs2/recovery.c | 53 ++++++++++++++++++++++++++++++++---------------------
 fs/gfs2/recovery.h |  2 ++
 2 files changed, 34 insertions(+), 21 deletions(-)
fs/gfs2/recovery.c +32 -21
index 0f501f9..1b95294 100644
@@ -120,6 +120,35 @@ void gfs2_revoke_clean(struct gfs2_jdesc *jd)
 	}
 }
 
+int __get_log_header(struct gfs2_sbd *sdp, const struct gfs2_log_header *lh,
+		     unsigned int blkno, struct gfs2_log_header_host *head)
+{
+	u32 hash, crc;
+
+	if (lh->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) ||
+	    lh->lh_header.mh_type != cpu_to_be32(GFS2_METATYPE_LH) ||
+	    (blkno && be32_to_cpu(lh->lh_blkno) != blkno))
+		return 1;
+
+	hash = crc32(~0, lh, LH_V1_SIZE - 4);
+	hash = ~crc32_le_shift(hash, 4); /* assume lh_hash is zero */
+
+	if (be32_to_cpu(lh->lh_hash) != hash)
+		return 1;
+
+	crc = crc32c(~0, (void *)lh + LH_V1_SIZE + 4,
+		     sdp->sd_sb.sb_bsize - LH_V1_SIZE - 4);
+
+	if ((lh->lh_crc != 0 && be32_to_cpu(lh->lh_crc) != crc))
+		return 1;
+
+	head->lh_sequence = be64_to_cpu(lh->lh_sequence);
+	head->lh_flags = be32_to_cpu(lh->lh_flags);
+	head->lh_tail = be32_to_cpu(lh->lh_tail);
+	head->lh_blkno = be32_to_cpu(lh->lh_blkno);
+
+	return 0;
+}
 /**
  * get_log_header - read the log header for a given segment
  * @jd: the journal
@@ -137,36 +166,18 @@ void gfs2_revoke_clean(struct gfs2_jdesc *jd)
 static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
 			  struct gfs2_log_header_host *head)
 {
-	struct gfs2_log_header *lh;
+	struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 	struct buffer_head *bh;
-	u32 hash, crc;
 	int error;
 
 	error = gfs2_replay_read_block(jd, blk, &bh);
 	if (error)
 		return error;
-	lh = (void *)bh->b_data;
-
-	hash = crc32(~0, lh, LH_V1_SIZE - 4);
-	hash = ~crc32_le_shift(hash, 4);  /* assume lh_hash is zero */
-
-	crc = crc32c(~0, (void *)lh + LH_V1_SIZE + 4,
-		     bh->b_size - LH_V1_SIZE - 4);
-
-	error = lh->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) ||
-		lh->lh_header.mh_type != cpu_to_be32(GFS2_METATYPE_LH) ||
-		be32_to_cpu(lh->lh_blkno) != blk ||
-		be32_to_cpu(lh->lh_hash) != hash ||
-		(lh->lh_crc != 0 && be32_to_cpu(lh->lh_crc) != crc);
 
+	error = __get_log_header(sdp, (const struct gfs2_log_header *)bh->b_data,
+				 blk, head);
 	brelse(bh);
 
-	if (!error) {
-		head->lh_sequence = be64_to_cpu(lh->lh_sequence);
-		head->lh_flags = be32_to_cpu(lh->lh_flags);
-		head->lh_tail = be32_to_cpu(lh->lh_tail);
-		head->lh_blkno = be32_to_cpu(lh->lh_blkno);
-	}
 	return error;
 }
 
fs/gfs2/recovery.h +2 -0
index 11fdfab..943a67c 100644
@@ -31,6 +31,8 @@ extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
 		    struct gfs2_log_header_host *head);
 extern int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd, bool wait);
 extern void gfs2_recover_func(struct work_struct *work);
+extern int __get_log_header(struct gfs2_sbd *sdp, const struct gfs2_log_header *lh,
+			    unsigned int blkno, struct gfs2_log_header_host *head);
 
 #endif /* __RECOVERY_DOT_H__ */
 
Signature · 1 line
2.4.11
author
#4 lore raw

PATCH v2 4/4 gfs2: read journal in large chunks to locate the head

In reply to Abhi Das

Use bio(s) to read in the journal sequentially in large chunks and locate the head of the journal.
This is faster in most cases when compared to the existing bisect method which operates one block at a time.

---
 fs/gfs2/incore.h     |   8 +++-
 fs/gfs2/lops.c       |  96 +++++++++++++++++++++++++++++++++++++++++-
 fs/gfs2/lops.h       |   1 +
 fs/gfs2/ops_fstype.c |   1 +
 fs/gfs2/recovery.c   | 115 +++++----------------------------------------------
 5 files changed, 114 insertions(+), 107 deletions(-)
fs/gfs2/incore.h +7 -1
index b96d39c..b24c105 100644
@@ -529,6 +529,11 @@ struct gfs2_journal_extent {
 	u64 blocks;
 };
 
+enum {
+	JDF_RECOVERY = 1,
+	JDF_JHEAD    = 2,
+};
+
 struct gfs2_jdesc {
 	struct list_head jd_list;
 	struct list_head extent_list;
@@ -536,12 +541,13 @@ struct gfs2_jdesc {
 	struct work_struct jd_work;
 	struct inode *jd_inode;
 	unsigned long jd_flags;
-#define JDF_RECOVERY 1
 	unsigned int jd_jid;
 	unsigned int jd_blocks;
 	int jd_recover_error;
 	/* Replay stuff */
 
+	struct gfs2_log_header_host jd_jhead;
+	struct bio *jd_rd_bio; /* bio used for reading this journal */
 	unsigned int jd_found_blocks;
 	unsigned int jd_found_revokes;
 	unsigned int jd_replayed_blocks;
fs/gfs2/lops.c +94 -2

120 lines not on this page · raw message

fs/gfs2/lops.h +1 -0
index d709d99..23392c5d 100644
@@ -32,6 +32,7 @@ extern void gfs2_log_write(struct gfs2_sbd *sdp, struct page *page,
 extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
 extern void gfs2_log_flush_bio(struct bio **biop, int op, int op_flags);
 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
+extern void gfs2_log_read(struct gfs2_jdesc *jd);
 
 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
 {
fs/gfs2/ops_fstype.c +1 -0
index c2469833b..dcc488b4 100644
@@ -578,6 +578,7 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
 			kfree(jd);
 			break;
 		}
+		jd->jd_rd_bio = NULL;
 
 		spin_lock(&sdp->sd_jindex_spin);
 		jd->jd_jid = sdp->sd_journals++;
fs/gfs2/recovery.c +11 -104

134 lines not on this page · raw message

Signature · 1 line
2.4.11
#5 lore raw

v2 cover Speed up journal head lookup

In reply to Abhi Das
Quoted 7 lines · Abhi Das

This is a revised version of the patchset I'd posted a few days ago. It contains fixes and some cleanup suggested by Andreas and Bob.

It is slightly different in parts from the rhel7 patchset I'd posted originally, owing to some bits already being present and the hash/crc computation code being different due to the updated log header structure.

The patches are looking good to me. I've put them on a separate branch on kernel.org for the next merge window.

Thanks,
Andreas

#6 lore raw

v2 cover Speed up journal head lookup

In reply to Abhi Das

----- Original Message -----

Quoted 29 lines

This is a revised version of the patchset I'd posted a few days ago. It contains fixes and some cleanup suggested by Andreas and Bob.

It is slightly different in parts from the rhel7 patchset I'd posted originally, owing to some bits already being present and the hash/crc computation code being different due to the updated log header structure.

Cheers!
--Abhi

Abhi Das (4):
gfs2: add timing info to map_journal_extents
gfs2: changes to gfs2_log_XXX_bio
gfs2: add a helper function to get_log_header that can be used
elsewhere
gfs2: read journal in large chunks to locate the head

 fs/gfs2/bmap.c       |   8 ++-
 fs/gfs2/incore.h     |   8 ++-
 fs/gfs2/log.c        |   4 +-
 fs/gfs2/lops.c       | 180
 +++++++++++++++++++++++++++++++++++++--------------
 fs/gfs2/lops.h       |   3 +-
 fs/gfs2/ops_fstype.c |   1 +
 fs/gfs2/recovery.c   | 168 ++++++++++++-----------------------------------
 fs/gfs2/recovery.h   |   2 +
 8 files changed, 194 insertions(+), 180 deletions(-)
Quoted 4 lines

--
2.4.11

Hi,

The patch set looks good to me. I assume you've tested it on file systems in which block size < page size, right?

Regards,

Bob Peterson

#7 lore raw

v2 cover Speed up journal head lookup

Quoted 35 lines · Bob Peterson

----- Original Message -----

Quoted 18 lines

This is a revised version of the patchset I'd posted a few days ago. It contains fixes and some cleanup suggested by Andreas and Bob.

It is slightly different in parts from the rhel7 patchset I'd posted originally, owing to some bits already being present and the hash/crc computation code being different due to the updated log header structure.

Cheers!
--Abhi

Abhi Das (4):
gfs2: add timing info to map_journal_extents
gfs2: changes to gfs2_log_XXX_bio
gfs2: add a helper function to get_log_header that can be used
elsewhere
gfs2: read journal in large chunks to locate the head

Quoted 8 lines
 fs/gfs2/bmap.c       |   8 ++-
 fs/gfs2/incore.h     |   8 ++-
 fs/gfs2/log.c        |   4 +-
 fs/gfs2/lops.c       | 180
 +++++++++++++++++++++++++++++++++++++--------------
 fs/gfs2/lops.h       |   3 +-
 fs/gfs2/ops_fstype.c |   1 +
 fs/gfs2/recovery.c   | 168

++++++++++++-----------------------------------

Quoted 7 lines
 fs/gfs2/recovery.h   |   2 +
 8 files changed, 194 insertions(+), 180 deletions(-)

--
2.4.11

Quoted 6 lines

Hi,

The patch set looks good to me. I assume you've tested it on file systems in which block size < page size, right?

Yes. But this upstream version has not been tested as much as the rhel7

one I'd posted a few weeks ago. The rhel7 patchset was tested against 2 and 4 node clusters with revolver and passed.
With changes and cleanups, this upstream version has diverged from the rhel7 one, so I'm going to backport again to rhel7 and have QE re-test it. I'll also do more single-node testing on upstream and report. I don't have an upstream cluster... Any volunteers for upstream cluster testing?

Cheer!
--Abhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20180910/fffbf4d8/attachment.htm>

#8 lore raw

v2 cover Speed up journal head lookup

In reply to Abhi Das

NACK for now. Andreas reported that xfstests fails with consistency errors with this patchset. I'm able to reproduce it also and I am trying to figure out what's going on. Hopefully I'll have revised patches soon.

Cheers!
--Abhi

Quoted 29 lines · Abhi Das

This is a revised version of the patchset I'd posted a few days ago. It contains fixes and some cleanup suggested by Andreas and Bob.

It is slightly different in parts from the rhel7 patchset I'd posted originally, owing to some bits already being present and the hash/crc computation code being different due to the updated log header structure.

Cheers!
--Abhi

Abhi Das (4):
gfs2: add timing info to map_journal_extents
gfs2: changes to gfs2_log_XXX_bio
gfs2: add a helper function to get_log_header that can be used
elsewhere
gfs2: read journal in large chunks to locate the head

 fs/gfs2/bmap.c       |   8 ++-
 fs/gfs2/incore.h     |   8 ++-
 fs/gfs2/log.c        |   4 +-
 fs/gfs2/lops.c       | 180
+++++++++++++++++++++++++++++++++++++--------------
 fs/gfs2/lops.h       |   3 +-
 fs/gfs2/ops_fstype.c |   1 +
 fs/gfs2/recovery.c   | 168 ++++++++++++-----------------------------------
 fs/gfs2/recovery.h   |   2 +
 8 files changed, 194 insertions(+), 180 deletions(-)
Quoted 4 lines

--
2.4.11

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20180910/77f11824/attachment.htm>