GFS2: Introduce new gfs2_log_header_v2
PATCH 1/1 GFS2: Introduce new gfs2_log_header_v2
In reply to a message not in the archiveHi,
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.
--- fs/gfs2/log.c | 22 ++++++++++++++++++++-- include/uapi/linux/gfs2_ondisk.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)
fs/gfs2/log.c +20 -2
@@ -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);
include/uapi/linux/gfs2_ondisk.h +19 -0
@@ -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 */
PATCH 1/1 GFS2: Introduce new gfs2_log_header_v2
Hi,
Quoted 68 lines · Bob Peterson
Hi,
This patch adds a new structure called
gfs2_log_header_v2which 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 <[email protected]>--- fs/gfs2/log.c | 22 ++++++++++++++++++++-- include/uapi/linux/gfs2_ondisk.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)fs/gfs2/log.c +20
-2@@ -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);include/uapi/linux/gfs2_ondisk.h +0
-0
include/uapi/linux/gfs2_ondisk.h struct gfs2_log_header { · line 412
Quoted 7 lines
include/uapi/linux/gfs2_ondisk.h +4
-0@@ -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 */
Where has setting the CRC gone?? That appears to be missing from this patch.
include/uapi/linux/gfs2_ondisk.h struct gfs2_log_header { · line 425
Quoted 13 lines
include/uapi/linux/gfs2_ondisk.h +13
-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;
Why is there padding here? There is nothing following it.
Quoted 6 lines
include/uapi/linux/gfs2_ondisk.h +2
-0+}; +/* * Log type descriptor */
PATCH 1/1 GFS2: Introduce new gfs2_log_header_v2
Hi,
----- Original Message -----
| On 01/12/17 19:34, Bob Peterson wrote: | > 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.
(snip)
| Where has setting the CRC gone?? That appears to be missing from this patch.
Well, I'm not convinced we really need another crc in this first patch. The original part of the log header already has a crc32 field. The new fields are all just for debugging until we get to the patches that take advantage of the local statfs and quota fields (rather than separate inodes), in which case keeping a crc may be a good idea to ensure their integrity. But if (or when) we do that, we should also add code to check its integrity during recovery. Setting the crc just seemed out of the scope of this patch, but I guess it's not that big of a deal; I have no problem adding it back in on the assumption that we'll eventually get to that point.
(snip)
| > + __be32 lh_pad;
| Why is there padding here? There is nothing following it.
Yeah, I fully expected to expand the structure with some more fields. So I was going to use it, but didn't quite get there. So it was kind of just a reminder to myself: I wanted to preempt potential compiler-padding during future expansion.
Bob
PATCH 1/1 GFS2: Introduce new gfs2_log_header_v2
Hi,
Quoted 16 lines · Bob Peterson
Hi,
----- Original Message -----
| On 01/12/17 19:34, Bob Peterson wrote: | > 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.(snip)
| Where has setting the CRC gone?? That appears to be missing from this patch.
Quoted 10 lines
Well, I'm not convinced we really need another crc in this first patch. The original part of the log header already has a crc32 field. The new fields are all just for debugging until we get to the patches that take advantage of the local statfs and quota fields (rather than separate inodes), in which case keeping a crc may be a good idea to ensure their integrity. But if (or when) we do that, we should also add code to check its integrity during recovery. Setting the crc just seemed out of the scope of this patch, but I guess it's not that big of a deal; I have no problem adding it back in on the assumption that we'll eventually get to that point.
We can't just leave those fields not set. lh_addr and lh_crc both need setting, otherwise how is fsck supposed to detect these blocks? The whole reason that it has taken so long to get this in, was down to the performance testing to ensure that the checksum doesn't make a big difference here. I assume that this is the case?
Quoted 11 lines
(snip)
| > +__be32lh_pad;
| Why is there padding here? There is nothing following it.Yeah, I fully expected to expand the structure with some more fields. So I was going to use it, but didn't quite get there. So it was kind of just a reminder to myself: I wanted to preempt potential compiler-padding during future expansion.
Bob
Thats ok, we can expand it without any issue since there is nothing that follows this structure. We don't need any padding for that.
We do need to make sure that we write the new header from recovery too. We also could perhaps find a way of writing out the actual location of the journal extent into which we are writing, i.e. physical block start & length. That would be very handy for fsck, but would have to be added at the time we write the header, as per lh_addr. In that case we'd have to get gfs2_log_bmap() to return the extent info, not just the block for the header,
Steve.
PATCH v2 1/1 GFS2: Introduce new gfs2_log_header_v2
In reply to Bob PetersonHere is a version 2 replacement for this patch, with improvements.
---
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.
--- fs/gfs2/log.c | 26 +++++++++++++++++++++--- fs/gfs2/lops.c | 43 +++++++++++++++++++++++++++++++++++++--- fs/gfs2/lops.h | 1 + include/uapi/linux/gfs2_ondisk.h | 18 +++++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-)
fs/gfs2/log.c +23 -3
@@ -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);
@@ -688,7 +706,9 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags) } sdp->sd_log_idle = (tail == sdp->sd_log_flush_head); -gfs2_log_write_page (sdp, page); + +/* Sets both the header address & overall checksum */ +gfs2_log_write_hdr (sdp, page);gfs2_log_flush_bio (sdp,REQ_OP_WRITE , op_flags);log_flush_wait (sdp);
fs/gfs2/lops.c +40 -3
79 lines not on this page · raw message
fs/gfs2/lops.h +1 -0
@@ -27,6 +27,7 @@ extern const struct gfs2_log_operations gfs2_databuf_lops;extern const struct gfs2_log_operations *gfs2_log_ops[];extern void gfs2_log_write_page (struct gfs2_sbd *sdp,struct page *page); +extern void gfs2_log_write_hdr (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_pin (struct gfs2_sbd *sdp,struct buffer_head *bh);
include/uapi/linux/gfs2_ondisk.h +18 -0
@@ -406,6 +406,24 @@ 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_flushers;/* what processes competed for log_flush */ +}; +/* * Log type descriptor */
PATCH v2 1/1 GFS2: Introduce new gfs2_log_header_v2
Quoted 10 lines · Bob Peterson
Here is a version 2 replacement for this patch, with improvements.
---
This patch adds a new structure calledgfs2_log_header_v2which 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.
Quoted 7 lines
Signed-off-by Bob Peterson <[email protected]>--- fs/gfs2/log.c | 26 +++++++++++++++++++++--- fs/gfs2/lops.c | 43 +++++++++++++++++++++++++++++++++++++--- fs/gfs2/lops.h | 1 + include/uapi/linux/gfs2_ondisk.h | 18 +++++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-)
recovery.c has:
gfs2_log_header_in()get_log_header()clean_journal()
which deal with log headers - do they need to be updated?
<snip>
Quoted 20 lines
fs/gfs2/lops.c +7
-0@@ -18,6 +18,7 @@#include <linux/fs.h> #include <linux/list_sort.h> +#include "dir.h" #include "gfs2.h" #include "incore.h" #include "inode.h" @@ -306,6 +307,25 @@ static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno)return gfs2_log_alloc_bio (sdp, blkno); } +/** +* gfs2_set_log_csum - Set a whole-block checksum for a page +* @sb: The superblock +* @page: The page to write +* @blkno: The device block number we want to write to +*
fs/gfs2/lops.c static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno) · line 325
Quoted 10 lines
fs/gfs2/lops.c +10
-0+* Set the location of the block to be written and then checksum the block +* before writing it. +*/ +static void gfs2_set_log_csum (struct super_block *sb,struct page *page, +u64 blkno) +{ +struct gfs2_log_header_v2 *lh =page_address (page); +u32 hash; + + lh->lh_addr =cpu_to_be64 (blkno);
Does lh->lh_crc need to be zeroed at this point?
fs/gfs2/lops.c static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno) · line 328
Quoted 3 lines
fs/gfs2/lops.c +3
-0+ hash =gfs2_disk_hash (page_address (page), sb->s_blocksize); + lh->lh_crc =cpu_to_be32 (hash); +}
Cheers,
Andy