[Cluster-devel] [GFS2 PATCH] GFS2: Introduce new gfs2_log_header_v2

Bob Peterson rpeterso at redhat.com
Fri Dec 1 19:34:12 UTC 2017


Hi,

This patch adds a new structure called gfs2_log_header_v2 which is
used to store expanded fields into previously unused areas of the
log headers. Some of these are used for debug purposes so we can
backtrack when problems occur. Others are reserved for future
expansion.

This is based on a prototype patch from Steve Whitehouse.

Signed-off-by: Bob Peterson <rpeterso at redhat.com>
---
 fs/gfs2/log.c                    | 22 ++++++++++++++++++++--
 include/uapi/linux/gfs2_ondisk.h | 19 +++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index f72c44231406..311e22ec6716 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -656,15 +656,20 @@ void gfs2_write_revokes(struct gfs2_sbd *sdp)
 
 static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
 {
+	struct gfs2_log_header_v2 *lh2;
 	struct gfs2_log_header *lh;
 	unsigned int tail;
 	u32 hash;
 	int op_flags = REQ_PREFLUSH | REQ_FUA | REQ_META | REQ_SYNC;
 	struct page *page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
 	enum gfs2_freeze_state state = atomic_read(&sdp->sd_freeze_state);
-	lh = page_address(page);
-	clear_page(lh);
+	struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
+	struct timespec64 tv;
 
+	lh2 = page_address(page);
+	clear_page(lh2);
+
+	lh = &lh2->lhv1;
 	gfs2_assert_withdraw(sdp, (state != SFS_FROZEN));
 
 	tail = current_tail(sdp);
@@ -681,6 +686,19 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
 	hash = gfs2_disk_hash(page_address(page), sizeof(struct gfs2_log_header));
 	lh->lh_hash = cpu_to_be32(hash);
 
+	tv = current_kernel_time64();
+	lh2->lh_nsec = cpu_to_be32(tv.tv_nsec);
+	lh2->lh_sec = cpu_to_be64(tv.tv_sec);
+	lh2->lh_jinode = cpu_to_be64(GFS2_I(sdp->sd_jdesc->jd_inode)->i_no_addr);
+	lh2->lh_statfs_addr = cpu_to_be64(GFS2_I(sdp->sd_sc_inode)->i_no_addr);
+	lh2->lh_quota_addr = cpu_to_be64(GFS2_I(sdp->sd_qc_inode)->i_no_addr);
+
+	spin_lock(&sdp->sd_statfs_spin);
+	lh2->lh_local_total = cpu_to_be64(l_sc->sc_total);
+	lh2->lh_local_free = cpu_to_be64(l_sc->sc_free);
+	lh2->lh_local_dinodes = cpu_to_be64(l_sc->sc_dinodes);
+	spin_unlock(&sdp->sd_statfs_spin);
+
 	if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) {
 		gfs2_ordered_wait(sdp);
 		log_flush_wait(sdp);
diff --git a/include/uapi/linux/gfs2_ondisk.h b/include/uapi/linux/gfs2_ondisk.h
index 5156bad77b47..ebc7339ffb63 100644
--- a/include/uapi/linux/gfs2_ondisk.h
+++ b/include/uapi/linux/gfs2_ondisk.h
@@ -406,6 +406,25 @@ struct gfs2_log_header {
 	__be32 lh_hash;
 };
 
+struct gfs2_log_header_v2 {
+	struct gfs2_log_header lhv1;
+
+	__be32 lh_crc;		/* crc32 of whole block with this field 0 */
+	__be32 lh_nsec;		/* Nano second time stamp */
+	__be64 lh_sec;		/* Second based time stamp */
+	__be64 lh_addr;		/* Block number of this log header (absolute) */
+	__be64 lh_jinode;	/* Journal inode number */
+	__be64 lh_statfs_addr;	/* Local statfs inode number */
+	__be64 lh_quota_addr;	/* Local quota change inode number */
+
+	/* Statfs local changes (i.e. diff from global statfs) */
+	__be64 lh_local_total;
+	__be64 lh_local_free;
+	__be64 lh_local_dinodes;
+	__be32 lh_log_flusher;
+	__be32 lh_pad;
+};
+
 /*
  * Log type descriptor
  */




More information about the Cluster-devel mailing list