gfs2-utils: New list implementation
cover gfs2-utils: New list implementation
This patch set updates the list implementation to the one currently in Linux. See the comments in the new gfs2/include/list.h for details.
Andrew Price (5):
Update list implementation
gfs2_convert: Use the new list.h
fsck.gfs2: Use the new list.h
libgfs2: Use the new list.h
Remove osi_list.h
gfs2/convert/gfs2_convert.c | 80 ++-- gfs2/edit/savemeta.c | 25 +- gfs2/fsck/fs_recovery.c | 29 +- gfs2/fsck/fsck.h | 7 +- gfs2/fsck/inode_hash.c | 1 - gfs2/fsck/main.c | 1 - gfs2/fsck/metawalk.c | 38 +- gfs2/fsck/pass1.c | 2 +- gfs2/fsck/pass1b.c | 36 +- gfs2/fsck/pass3.c | 1 - gfs2/fsck/pass4.c | 4 +- gfs2/fsck/rgrepair.c | 3 +- gfs2/fsck/util.c | 66 ++- gfs2/fsck/util.h | 2 +- gfs2/include/Makefile.am | 2 +- gfs2/include/list.h | 902 ++++++++++++++++++++++++++++++++++++ gfs2/include/osi_list.h | 84 ---- gfs2/libgfs2/block_list.c | 17 +- gfs2/libgfs2/buf.c | 4 +- gfs2/libgfs2/fs_ops.c | 13 +- gfs2/libgfs2/gfs1.c | 1 - gfs2/libgfs2/lang.h | 1 + gfs2/libgfs2/libgfs2.h | 6 +- gfs2/libgfs2/super.c | 1 - gfs2/mkfs/gfs2_mkfs.h | 1 - 25 files changed, 1063 insertions(+), 264 deletions(-) create mode 100644 gfs2/include/list.h delete mode 100644 gfs2/include/osi_list.h
Signature · 1 line
2.21.0
PATCH 1/5 Update list implementation
gfs2-utils has been carrying an ancient, macro-based list implementation that makes problems difficult to debug. Bring in a new implementation from the kernel source.
--- gfs2/include/Makefile.am | 1 + gfs2/include/list.h | 902 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 903 insertions(+) create mode 100644 gfs2/include/list.h
gfs2/include/Makefile.am +1 -0
@@ -2,6 +2,7 @@ MAINTAINERCLEANFILES = Makefile.in noinst_HEADERS = \ osi_list.h \ + list.h \ osi_tree.h \ linux_endian.h \ logging.h
gfs2/include/list.h new file +902 -0
902 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 2/5 gfs2_convert: Use the new list.h
In reply to Andrew Price--- gfs2/convert/gfs2_convert.c | 80 ++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-)
gfs2/convert/gfs2_convert.c +40 -40
@@ -31,7 +31,7 @@#include <linux/types.h> #include <linux/gfs2_ondisk.h> #include <logging.h> -#include "osi_list.h" +#include <list.h> #include "copyright.cf" #include "libgfs2.h"
@@ -71,18 +71,18 @@#define DIV_RU (x, y) (((x) + (y) - 1) / (y))struct inode_dir_block { -osi_list_t list; +struct list_head list;uint64_t di_addr;uint64_t di_paddr;/* Parent dir inode addr */ };struct inode_block { -osi_list_t list; +struct list_head list;uint64_t di_addr; };struct blocklist { -osi_list_t list; +struct list_head list;uint64_t block;struct metapath mp;int height;
@@ -510,7 +510,7 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str {struct blocklist *blk, *newblk;struct gfs2_buffer_head *bh, *dibh = ip->i_bh; -osi_list_t *tmp; +struct list_head *tmp;uint64_t *ptr1, block;int h, ptrnum;int bufsize = sbp->bsize -sizeof (struct gfs_indirect );
@@ -537,11 +537,11 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str/* Zero out the pointers so we can fill them in later. */ memset (dibh->b_data +sizeof (struct gfs_dinode ),0 , sbp->bsize -sizeof (struct gfs_dinode )); -osi_list_add_prev (&blk->list, &blocks->list); +list_add_tail (&blk->list, &blocks->list);/* Now run the metadata chain and build lists of all metadata blocks */ - osi_list_foreach(tmp, &blocks->list) { - blk = osi_list_entry(tmp, struct blocklist, list); +list_for_each (tmp, &blocks->list) { + blk = list_entry(tmp, struct blocklist, list);if (blk->height >= ip->i_di.di_height -1 )continue ;
@@ -572,7 +572,7 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str newblk->mp.mp_list[h] = blk->mp.mp_list[h]; newblk->mp.mp_list[h] = ptrnum;/* Queue it to be processed later on in the loop. */ -osi_list_add_prev (&newblk->list, &blocks->list); +list_add_tail (&newblk->list, &blocks->list);/* read the new metadata block's pointers */ bh =bread (sbp, block);memcpy (newblk->ptrbuf, bh->b_data +sizeof (struct gfs_indirect ), bufsize);
@@ -704,7 +704,7 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip) {uint64_t dinode_size;uint32_t gfs2_hgt, di_height; -osi_list_t *tmp=NULL , *x; +struct list_head *tmp=NULL , *x;struct blocklist blocks, *blk;int error =0 ;
@@ -722,7 +722,7 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)return 0 ;/* nothing to do */ } -osi_list_init (&blocks.list); +INIT_LIST_HEAD (&blocks.list); error =get_inode_metablocks (sbp, ip, &blocks);if (error)
@@ -740,13 +740,13 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)/* Now run through the block list a second time. If the block is a data block, rewrite the data to the gfs2 offset. */ - osi_list_foreach_safe(tmp, &blocks.list, x) { +list_for_each_safe (tmp, x, &blocks.list) { - blk = osi_list_entry(tmp, struct blocklist, list); + blk = list_entry(tmp, struct blocklist, list);/* If it's not metadata that holds data block pointers (i.e. metadata pointing to other metadata) */ if (blk->height != di_height -1 ) { -osi_list_del (tmp); +list_del (tmp);free (blk->ptrbuf);free (blk);continue ;
@@ -760,7 +760,7 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)if (error) goto out; -osi_list_del (tmp); +list_del (tmp);free (blk->ptrbuf);free (blk); }
@@ -773,9 +773,9 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)return error; out: -while (!osi_list_empty (&blocks.list)) { - blk = osi_list_entry(tmp, struct blocklist, list); -osi_list_del (&blocks.list); +while (!list_empty (&blocks.list)) { + blk = list_entry(tmp, struct blocklist, list); +list_del (&blocks.list);free (blk->ptrbuf);free (blk); }
@@ -811,8 +811,8 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s }memset (fix,0 ,sizeof (struct inode_dir_block )); fix->di_addr = ip->i_di.di_num.no_addr; -osi_list_add_prev ((osi_list_t *)&fix->list, - (osi_list_t *)&cdpns_to_fix); +list_add_tail ((struct list_head *)&fix->list, + (struct list_head *)&cdpns_to_fix); }return 0 ;
@@ -893,8 +893,8 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh) }memset (fixdir,0 ,sizeof (struct inode_block )); fixdir->di_addr = inode->i_di.di_num.no_addr; -osi_list_add_prev ((osi_list_t *)&fixdir->list, - (osi_list_t *)&dirs_to_fix); +list_add_tail ((struct list_head *)&fixdir->list, + (struct list_head *)&dirs_to_fix);break ;case GFS_FILE_REG :/* regular file */ inode->i_di.di_mode |=S_IFREG ;
@@ -1025,7 +1025,7 @@ static int next_rg_metatype(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,/* */ /* Returns: 0 on success, -1 on failure */ /* ------------------------------------------------------------------------- */ -static int inode_renumber (struct gfs2_sbd *sbp,uint64_t root_inode_addr,osi_list_t *cdpn_to_fix) +static int inode_renumber (struct gfs2_sbd *sbp,uint64_t root_inode_addr,struct list_head *cdpn_to_fix) {struct rgrp_tree *rgd;struct osi_node *n, *next =NULL ;
@@ -1237,10 +1237,10 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,* a cdpn symlink's parent. If so add it to the list element */ if (dent->de_type ==cpu_to_be16 (DT_LNK )) { -osi_list_t *tmp; +struct list_head *tmp;struct inode_dir_block *fix; - osi_list_foreach(tmp, &cdpns_to_fix.list) { - fix = osi_list_entry(tmp, struct inode_dir_block, list); +list_for_each (tmp, &cdpns_to_fix.list) { + fix = list_entry(tmp, struct inode_dir_block, list);if (fix->di_addr == inum.no_addr) fix->di_paddr = dip->i_di.di_num.no_addr; }
@@ -1349,9 +1349,9 @@ static int process_directory(struct gfs2_sbd *sbp, uint64_t dirblock, uint64_t d/* fix_directory_info - sync new inode numbers with directory info */ /* Returns: 0 on success, -1 on failure */ /* ------------------------------------------------------------------------- */ -static int fix_directory_info (struct gfs2_sbd *sbp,osi_list_t *dir_to_fix) +static int fix_directory_info (struct gfs2_sbd *sbp,struct list_head *dir_to_fix) { -osi_list_t *tmp, *fix; +struct list_head *tmp, *fix;struct inode_block *dir_iblk;uint64_t dirblock;uint32_t gfs1_inptrs = sbp->sd_inptrs;
@@ -1369,7 +1369,7 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)/* for every directory in the list */ for (fix = dir_to_fix->next; fix != dir_to_fix; fix = fix->next) {if (tmp) { -osi_list_del (tmp); +list_del (tmp);free (tmp); } tmp = fix;/* remember the addr to free next time */
@@ -1384,7 +1384,7 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix) }/* Free the last entry in memory: */ if (tmp) { -osi_list_del (tmp); +list_del (tmp);free (tmp); } sbp->sd_inptrs = gfs1_inptrs;
@@ -1395,21 +1395,21 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)/* fix_cdpn_symlinks - convert cdpn symlinks to empty directories */ /* Returns: 0 on success, -1 on failure */ /* ------------------------------------------------------------------------- */ -static int fix_cdpn_symlinks (struct gfs2_sbd *sbp,osi_list_t *cdpn_to_fix) +static int fix_cdpn_symlinks (struct gfs2_sbd *sbp,struct list_head *cdpn_to_fix) { -osi_list_t *tmp, *x; +struct list_head *tmp, *x;int error =0 ; cdpns_fixed =0 ; - osi_list_foreach_safe(tmp, cdpn_to_fix, x) { +list_for_each_safe (tmp, x, cdpn_to_fix) {struct gfs2_inum fix, dir;struct inode_dir_block *l_fix;struct gfs2_buffer_head *bh =NULL ;struct gfs2_inode *fix_inode;uint64_t eablk; - l_fix = osi_list_entry(tmp, struct inode_dir_block, list); -osi_list_del (tmp); + l_fix = list_entry(tmp, struct inode_dir_block, list); +list_del (tmp);/* convert symlink to empty dir */ error =fetch_inum (sbp, l_fix->di_addr, &fix, &eablk);
@@ -1565,8 +1565,8 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts) sbp->sd_sb.sb_header.mh_type =GFS2_METATYPE_SB ; sbp->sd_sb.sb_header.mh_format =GFS2_FORMAT_SB ; -osi_list_init ((osi_list_t *)&dirs_to_fix); -osi_list_init ((osi_list_t *)&cdpns_to_fix); +INIT_LIST_HEAD ((struct list_head *)&dirs_to_fix); +INIT_LIST_HEAD ((struct list_head *)&cdpns_to_fix);/* ---------------------------------------------- */ /* Initialize lists and read in the superblock. */ /* ---------------------------------------------- */
@@ -2210,7 +2210,7 @@ int main(int argc, char **argv)if (!error) {/* Add a string notifying inode converstion start? */ error =inode_renumber (&sb2, sb2.sd_sb.sb_root_dir.no_addr, - (osi_list_t *)&cdpns_to_fix); + (struct list_head *)&cdpns_to_fix);if (error)log_crit (_ ("\n%s: Error renumbering inodes.\n" ), opts.device);fsync (sb2.device_fd);/* write the buffers to disk */
@@ -2219,7 +2219,7 @@ int main(int argc, char **argv)/* Fix the directories to match the new numbers. */ /* ---------------------------------------------- */ if (!error) { - error =fix_directory_info (&sb2, (osi_list_t *)&dirs_to_fix); + error =fix_directory_info (&sb2, (struct list_head *)&dirs_to_fix);log_notice (_ ("\r%llu directories, %llu dirents fixed." ), (unsigned long long )dirs_fixed, (unsigned long long )dirents_fixed);
@@ -2231,7 +2231,7 @@ int main(int argc, char **argv)/* Convert cdpn symlinks to empty dirs */ /* ---------------------------------------------- */ if (!error) { - error =fix_cdpn_symlinks (&sb2, (osi_list_t *)&cdpns_to_fix); + error =fix_cdpn_symlinks (&sb2, (struct list_head *)&cdpns_to_fix);log_notice (_ ("\r%llu cdpn symlinks moved to empty directories." ), (unsigned long long )cdpns_fixed);fflush (stdout);
Signature · 1 line
2.21.0
PATCH 3/5 fsck.gfs2: Use the new list.h
In reply to Andrew Price--- gfs2/fsck/fs_recovery.c | 29 +++++++++--------- gfs2/fsck/fsck.h | 7 +++-- gfs2/fsck/inode_hash.c | 1 - gfs2/fsck/main.c | 1 - gfs2/fsck/metawalk.c | 4 +-- gfs2/fsck/pass1b.c | 34 ++++++++++----------- gfs2/fsck/pass3.c | 1 - gfs2/fsck/rgrepair.c | 1 - gfs2/fsck/util.c | 66 +++++++++++++++++++---------------------- 9 files changed, 69 insertions(+), 75 deletions(-)
gfs2/fsck/fs_recovery.c +15 -14
@@ -10,6 +10,7 @@#define _ (String) gettext(String)#include <logging.h> +#include <list.h> #include "fsck.h" #include "fs_recovery.h" #include "libgfs2.h"
@@ -22,23 +23,23 @@unsigned int sd_found_jblocks =0 , sd_replayed_jblocks =0 ;unsigned int sd_found_metablocks =0 , sd_replayed_metablocks =0 ;unsigned int sd_found_revokes =0 ; -osi_list_t sd_revoke_list; +struct list_head sd_revoke_list;unsigned int sd_replay_tail;struct gfs2_revoke_replay { -osi_list_t rr_list; +struct list_head rr_list;uint64_t rr_blkno;unsigned int rr_where; };int gfs2_revoke_add (struct gfs2_sbd *sdp,uint64_t blkno,unsigned int where) { -osi_list_t *tmp, *head = &sd_revoke_list; +struct list_head *tmp, *head = &sd_revoke_list;struct gfs2_revoke_replay *rr;int found =0 ; - osi_list_foreach(tmp, head) { - rr = osi_list_entry(tmp, struct gfs2_revoke_replay, rr_list); +list_for_each (tmp, head) { + rr = list_entry(tmp, struct gfs2_revoke_replay, rr_list);if (rr->rr_blkno == blkno) { found =1 ;break ;
@@ -56,19 +57,19 @@ int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where) rr->rr_blkno = blkno; rr->rr_where = where; -osi_list_add (&rr->rr_list, head); +list_add (&rr->rr_list, head);return 1 ; }int gfs2_revoke_check (struct gfs2_sbd *sdp,uint64_t blkno,unsigned int where) { -osi_list_t *tmp; +struct list_head *tmp;struct gfs2_revoke_replay *rr;int wrap, a, b;int found =0 ; - osi_list_foreach(tmp, &sd_revoke_list) { - rr = osi_list_entry(tmp, struct gfs2_revoke_replay, rr_list); +list_for_each (tmp, &sd_revoke_list) { + rr = list_entry(tmp, struct gfs2_revoke_replay, rr_list);if (rr->rr_blkno == blkno) { found =1 ;break ;
@@ -86,12 +87,12 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where)void gfs2_revoke_clean (struct gfs2_sbd *sdp) { -osi_list_t *head = &sd_revoke_list; +struct list_head *head = &sd_revoke_list;struct gfs2_revoke_replay *rr; -while (!osi_list_empty (head)) { - rr = osi_list_entry(head->next, struct gfs2_revoke_replay, rr_list); -osi_list_del (&rr->rr_list); +while (!list_empty (head)) { + rr = list_entry(head->next, struct gfs2_revoke_replay, rr_list); +list_del (&rr->rr_list);free (rr); } }
@@ -502,7 +503,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen, *was_clean =0 ;log_info (_ ("jid=%u: Looking at journal...\n" ), j); -osi_list_init (&sd_revoke_list); +INIT_LIST_HEAD (&sd_revoke_list); error =gfs2_find_jhead (ip, &head);if (!error) { error =check_journal_seq_no (ip,0 );
gfs2/fsck/fsck.h +4 -3
@@ -1,6 +1,7 @@#ifndef _FSCK_H#define _FSCK_H +#include <list.h> #include "libgfs2.h" #include "osi_tree.h"
@@ -69,8 +70,8 @@ struct duptree {int dup_flags;int refs;uint64_t block; -osi_list_t ref_inode_list;/* list of inodes referencing a dup block */ -osi_list_t ref_invinode_list;/* list of invalid inodes referencing */ +struct list_head ref_inode_list;/* list of inodes referencing a dup block */ +struct list_head ref_invinode_list;/* list of invalid inodes referencing */ };enum dup_ref_type {
@@ -84,7 +85,7 @@ enum dup_ref_type { };struct inode_with_dups { -osi_list_t list; +struct list_head list;uint64_t block_no;int dup_count;int reftypecount[ref_types];
gfs2/fsck/inode_hash.c +0 -1
@@ -7,7 +7,6 @@#include <logging.h> #include "libgfs2.h" -#include "osi_list.h" #include "inode_hash.h" #include "fsck.h" #define _ (String) gettext(String)
gfs2/fsck/main.c +0 -1
@@ -21,7 +21,6 @@#include "libgfs2.h" #include "fsck.h" #include "link.h" -#include "osi_list.h" #include "metawalk.h" #include "util.h"
gfs2/fsck/metawalk.c +2 -2
@@ -1585,7 +1585,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)free_metalist (ip, &metalist[0 ]);return 0 ; } - bh = osi_list_entry(tmp, struct gfs2_buffer_head, b_altlist); + bh = list_entry(tmp, struct gfs2_buffer_head, b_altlist); head_size =hdr_size (bh, height);if (!head_size)continue ;
@@ -1625,7 +1625,7 @@ undo_metalist:for (i =0 ; pass->undo_check_meta && i < height; i++) {while (!osi_list_empty (&metalist[i])) { list = &metalist[i]; - bh =osi_list_entry (list->next, + bh =list_entry (list->next, struct gfs2_buffer_head, b_altlist); log_err(_("Undoing metadata work for block %llu "
gfs2/fsck/pass1b.c +17 -17
@@ -9,10 +9,10 @@#define _ (String) gettext(String)#include <logging.h> +#include <list.h> #include "libgfs2.h" #include "link.h" #include "fsck.h" -#include "osi_list.h" #include "util.h" #include "metawalk.h" #include "inode_hash.h"
@@ -45,12 +45,12 @@ static int clone_data(struct gfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct gfs2_buffer_head *bh, uint64_t *ptr); -static void log_inode_reference (struct duptree *dt,osi_list_t *tmp,int inval) +static void log_inode_reference (struct duptree *dt,struct list_head *tmp,int inval) {char reftypestring[32 ];struct inode_with_dups *id; - id = osi_list_entry(tmp, struct inode_with_dups, list); + id = list_entry(tmp, struct inode_with_dups, list);if (id->dup_count ==1 )sprintf (reftypestring,"as %s" , reftypes[get_ref_type (id)]);else
@@ -145,7 +145,7 @@ static void clone_data_block(struct gfs2_sbd *sdp, struct duptree *dt,*/ static void revise_dup_handler (uint64_t dup_blk,struct dup_handler *dh) { -osi_list_t *tmp; +struct list_head *tmp;struct duptree *dt;struct inode_with_dups *id;
@@ -159,13 +159,13 @@ static void revise_dup_handler(uint64_t dup_blk, struct dup_handler *dh) dh->dt = dt;/* Count the duplicate references, both valid and invalid */ - osi_list_foreach(tmp, &dt->ref_invinode_list) { - id = osi_list_entry(tmp, struct inode_with_dups, list); +list_for_each (tmp, &dt->ref_invinode_list) { + id = list_entry(tmp, struct inode_with_dups, list); dh->ref_inode_count++; dh->ref_count += id->dup_count; } - osi_list_foreach(tmp, &dt->ref_inode_list) { - id = osi_list_entry(tmp, struct inode_with_dups, list); +list_for_each (tmp, &dt->ref_inode_list) { + id = list_entry(tmp, struct inode_with_dups, list); dh->ref_inode_count++; dh->ref_count += id->dup_count; }
@@ -185,13 +185,13 @@ static void revise_dup_handler(uint64_t dup_blk, struct dup_handler *dh)* _but_ this type. Try to save references as this type. */ static void resolve_dup_references (struct gfs2_sbd *sdp,struct duptree *dt, -osi_list_t *ref_list, +struct list_head *ref_list,struct dup_handler *dh,int inval,int acceptable_ref) {struct gfs2_inode *ip;struct inode_with_dups *id; -osi_list_t *tmp, *x; +struct list_head *tmp, *x;struct metawalk_fxns pass1b_fxns_delete = { .private =NULL , .check_metalist = delete_metadata,
@@ -208,11 +208,11 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,int found_good_ref =0 ;int q; - osi_list_foreach_safe(tmp, ref_list, x) { +list_for_each_safe (tmp, x, ref_list) {if (skip_this_pass || fsck_abort)return ; - id = osi_list_entry(tmp, struct inode_with_dups, list); + id = list_entry(tmp, struct inode_with_dups, list); dh->dt = dt;if (dh->ref_inode_count ==1 )/* down to the last reference */
@@ -553,7 +553,7 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt, {struct gfs2_inode *ip;struct inode_with_dups *id; -osi_list_t *tmp; +struct list_head *tmp;int q; log_notice( _("Block %llu (0x%llx) has only one remaining "
@@ -566,7 +566,7 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,from invalid to data or metadata. Start at the first one in the list, not the structure's place holder. */ tmp = dt->ref_inode_list.next; - id = osi_list_entry(tmp, struct inode_with_dups, list); + id = list_entry(tmp, struct inode_with_dups, list); log_debug( _("----------------------------------------------\n" "Step 4. Set block type based on the remaining " "reference in inode %lld (0x%llx).\n"),
@@ -648,7 +648,7 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,*/ static int handle_dup_blk (struct gfs2_sbd *sdp,struct duptree *dt) { -osi_list_t *tmp; +struct list_head *tmp;struct dup_handler dh = {0 };struct gfs2_buffer_head *bh;uint32_t cmagic, ctype;
@@ -665,9 +665,9 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt) (unsigned long long )dt->block, dh.ref_inode_count, dh.ref_count); - osi_list_foreach(tmp, &dt->ref_invinode_list) +list_for_each (tmp, &dt->ref_invinode_list)log_inode_reference (dt, tmp,1 ); - osi_list_foreach(tmp, &dt->ref_inode_list) +list_for_each (tmp, &dt->ref_inode_list)log_inode_reference (dt, tmp,0 );/* Figure out the block type to see if we can eliminate references
gfs2/fsck/pass3.c +0 -1
@@ -10,7 +10,6 @@#include <logging.h> #include "libgfs2.h" -#include "osi_list.h" #include "fsck.h" #include "lost_n_found.h" #include "link.h"
gfs2/fsck/rgrepair.c +0 -1
@@ -12,7 +12,6 @@#include <logging.h> #include "libgfs2.h" -#include "osi_list.h" #include "fsck.h" #include "fs_recovery.h"
gfs2/fsck/util.c +31 -35
155 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH 4/5 libgfs2: Use the new list.h
In reply to Andrew PriceRequires updates in the utils where they use osi_list_t exposed through libgfs2 interfaces.
The new list.h's pointer poisoning found a double-release in savemeta which is fixed.
--- gfs2/edit/savemeta.c | 25 ++++++++++--------------- gfs2/fsck/metawalk.c | 38 +++++++++++++++++--------------------- gfs2/fsck/pass1.c | 2 +- gfs2/fsck/pass1b.c | 2 +- gfs2/fsck/pass4.c | 4 ++-- gfs2/fsck/rgrepair.c | 2 +- gfs2/fsck/util.h | 2 +- gfs2/libgfs2/block_list.c | 17 ++++++++--------- gfs2/libgfs2/buf.c | 4 ++-- gfs2/libgfs2/fs_ops.c | 13 ++++++------- gfs2/libgfs2/gfs1.c | 1 - gfs2/libgfs2/lang.h | 1 + gfs2/libgfs2/libgfs2.h | 6 +++--- gfs2/libgfs2/super.c | 1 - gfs2/mkfs/gfs2_mkfs.h | 1 - 15 files changed, 53 insertions(+), 66 deletions(-)
gfs2/edit/savemeta.c +10 -15
@@ -22,7 +22,6 @@#include <time.h> #include <logging.h> -#include "osi_list.h" #include "gfs2hex.h" #include "hexedit.h" #include "libgfs2.h"
@@ -516,7 +515,7 @@ static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh, u/* * save_indirect_blocks - save all indirect blocks for the given buffer */ -static void save_indirect_blocks (struct metafd *mfd,osi_list_t *cur_list, +static void save_indirect_blocks (struct metafd *mfd,struct list_head *cur_list,struct gfs2_buffer_head *mybh,uint64_t owner,int height,int hgt) {uint64_t old_block =0 , indir_block;
@@ -545,7 +544,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,if (height != hgt &&/* If not at max height and */ (!gfs2_check_range (&sbd, indir_block))) { nbh =bread (&sbd, indir_block); -osi_list_add_prev (&nbh->b_altlist, cur_list); +list_add_tail (&nbh->b_list, cur_list);/* The buffer_head needs to be queued ahead, so don't release it! brelse(nbh);*/
@@ -601,13 +600,13 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk) {uint32_t height;struct gfs2_inode *inode; -osi_list_t metalist[GFS2_MAX_META_HEIGHT ]; -osi_list_t *prev_list, *cur_list, *tmp; +struct list_head metalist[GFS2_MAX_META_HEIGHT ]; +struct list_head *prev_list, *cur_list, *tmp;struct gfs2_buffer_head *metabh, *mybh;int i;for (i =0 ; i <GFS2_MAX_META_HEIGHT ; i++) -osi_list_init (&metalist[i]); +INIT_LIST_HEAD (&metalist[i]); metabh =bread (&sbd, iblk);if (sbd.gfs1) { inode =lgfs2_gfs_inode_get (&sbd, metabh);
@@ -631,14 +630,13 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk)else if (height && !(inode->i_di.di_flags &GFS2_DIF_SYSTEM ) && !block_is_systemfile (iblk) && !S_ISDIR (inode->i_di.di_mode)) height--; -osi_list_add (&metabh->b_altlist, &metalist[0 ]); +list_add (&metabh->b_list, &metalist[0 ]);for (i =1 ; i <= height; i++){ prev_list = &metalist[i -1 ]; cur_list = &metalist[i];for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next){ - mybh = osi_list_entry(tmp, struct gfs2_buffer_head, - b_altlist); + mybh = list_entry(tmp, struct gfs2_buffer_head, b_list);warm_fuzzy_stuff (iblk, FALSE);save_indirect_blocks (mfd, cur_list, mybh, iblk, height, i);
@@ -647,12 +645,10 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk)/* free metalists */ for (i =0 ; i <GFS2_MAX_META_HEIGHT ; i++) { cur_list = &metalist[i]; -while (!osi_list_empty (cur_list)) { - mybh =osi_list_entry (cur_list->next, - struct gfs2_buffer_head, - b_altlist); +while (!list_empty (cur_list)) { + mybh = list_entry(cur_list->next, struct gfs2_buffer_head, b_list);if (mybh == inode->i_bh) -osi_list_del (&mybh->b_altlist); +list_del (&mybh->b_list);else brelse (mybh); }
@@ -703,7 +699,6 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk)brelse (lbh); }inode_put (&inode); -brelse (metabh); }static void get_journal_inode_blocks (void )
gfs2/fsck/metawalk.c +17 -21
@@ -1137,20 +1137,19 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)/** * free_metalist - free all metadata on a multi-level metadata list */ -static void free_metalist (struct gfs2_inode *ip,osi_list_t *mlp) +static void free_metalist (struct gfs2_inode *ip,struct list_head *mlp) {int i;struct gfs2_buffer_head *nbh;for (i =0 ; i <GFS2_MAX_META_HEIGHT ; i++) { -osi_list_t *list; +struct list_head *list; list = &mlp[i]; -while (!osi_list_empty (list)) { - nbh =osi_list_entry (list->next, - struct gfs2_buffer_head, b_altlist); +while (!list_empty (list)) { + nbh = list_entry(list->next, struct gfs2_buffer_head, b_list);if (nbh == ip->i_bh) -osi_list_del_init (&nbh->b_altlist); +list_del_init (&nbh->b_list);else brelse (nbh); }
@@ -1221,18 +1220,18 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,* @ip: * @mlp: */ -static int build_and_check_metalist (struct gfs2_inode *ip,osi_list_t *mlp, +static int build_and_check_metalist (struct gfs2_inode *ip,struct list_head *mlp,struct metawalk_fxns *pass) {uint32_t height = ip->i_di.di_height;struct gfs2_buffer_head *bh, *nbh, *metabh = ip->i_bh; -osi_list_t *prev_list, *cur_list, *tmp; +struct list_head *prev_list, *cur_list, *tmp;int h, head_size, iblk_type;uint64_t *ptr, block, *undoptr;int error, was_duplicate, is_valid;int maxptrs; -osi_list_add (&metabh->b_altlist, &mlp[0 ]); +list_add (&metabh->b_list, &mlp[0 ]);/* Directories are special. Their 'data' is the hash table, which is basically an indirect block list. Their height is not important
@@ -1269,8 +1268,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp, cur_list = &mlp[h];for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next){ - bh = osi_list_entry(tmp, struct gfs2_buffer_head, - b_altlist); + bh = list_entry(tmp, struct gfs2_buffer_head, b_list);if (gfs2_check_meta (bh->b_data, iblk_type)) {if (pass->invalid_meta_is_fatal)return meta_error;
@@ -1355,7 +1353,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp, }if (!nbh) nbh =bread (ip->i_sbd, block); -osi_list_add_prev (&nbh->b_altlist, cur_list); +list_add_tail (&nbh->b_list, cur_list); }/* for all data on the indirect block */ }/* for blocks at that height */ }/* for height */
@@ -1537,8 +1535,8 @@ static int hdr_size(struct gfs2_buffer_head *bh, int height)*/ int check_metatree (struct gfs2_inode *ip,struct metawalk_fxns *pass) { -osi_list_t metalist[GFS2_MAX_META_HEIGHT ]; -osi_list_t *list, *tmp; +struct list_head metalist[GFS2_MAX_META_HEIGHT ]; +struct list_head *list, *tmp;struct gfs2_buffer_head *bh;uint32_t height = ip->i_di.di_height;int i, head_size;
@@ -1552,7 +1550,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)return 0 ;for (i =0 ; i <GFS2_MAX_META_HEIGHT ; i++) -osi_list_init (&metalist[i]); +INIT_LIST_HEAD (&metalist[i]);/* create and check the metadata list for each height */ error =build_and_check_metalist (ip, &metalist[0 ], pass);
@@ -1585,7 +1583,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)free_metalist (ip, &metalist[0 ]);return 0 ; } - bh = list_entry(tmp, struct gfs2_buffer_head, b_altlist); + bh = list_entry(tmp, struct gfs2_buffer_head, b_list); head_size =hdr_size (bh, height);if (!head_size)continue ;
@@ -1623,11 +1621,9 @@ undo_metalist:return error; }for (i =0 ; pass->undo_check_meta && i < height; i++) { -while (!osi_list_empty (&metalist[i])) { +while (!list_empty (&metalist[i])) { list = &metalist[i]; - bh =list_entry (list->next, - struct gfs2_buffer_head, - b_altlist); + bh = list_entry(list->next, struct gfs2_buffer_head, b_list); log_err(_("Undoing metadata work for block %llu " "(0x%llx)\n"), (unsigned long long)bh->b_blocknr,
@@ -1661,7 +1657,7 @@ undo_metalist: } }if (bh == ip->i_bh) -osi_list_del (&bh->b_altlist); +list_del (&bh->b_list);else brelse (bh); }
gfs2/fsck/pass1.c +1 -1
@@ -2167,7 +2167,7 @@ int pass1(struct gfs2_sbd *sdp)gfs2_bmap_destroy (sdp, bl);return FSCK_ERROR ; } -osi_list_init (&gfs1_rindex_blks.list); +INIT_LIST_HEAD (&gfs1_rindex_blks.list);/* FIXME: In the gfs fsck, we had to mark things like the * journals and indices and such as 'other_meta' - in gfs2,
gfs2/fsck/pass1b.c +1 -1
@@ -758,7 +758,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)/* If there's still a last remaining reference, and it's a valid reference, use it to determine the correct block type for our blockmap and bitmap. */ -if (dh.ref_inode_count ==1 && !osi_list_empty (&dt->ref_inode_list)) { +if (dh.ref_inode_count ==1 && !list_empty (&dt->ref_inode_list)) {resolve_last_reference (sdp, dt, acceptable_ref); }else {/* They may have answered no and not fixed all references. */
gfs2/fsck/pass4.c +2 -2
@@ -205,7 +205,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp)log_debug (_ ("block %llu (0x%llx) has link count %d\n" ), (unsigned long long )ii->di_num.no_addr, (unsigned long long )ii->di_num.no_addr, ii->di_nlink); - }/* osi_list_foreach(tmp, list) */ + }return adjust_lf_links (lf_addition); }
@@ -238,7 +238,7 @@ static int scan_dir_list(struct gfs2_sbd *sdp)log_debug (_ ("block %llu (0x%llx) has link count %d\n" ), (unsigned long long )di->dinode.no_addr, (unsigned long long )di->dinode.no_addr, di->di_nlink); - }/* osi_list_foreach(tmp, list) */ + }return adjust_lf_links (lf_addition); }
gfs2/fsck/rgrepair.c +1 -1
@@ -56,7 +56,7 @@ static void find_journaled_rgs(struct gfs2_sbd *sdp)struct gfs2_buffer_head *bh;int false_count; -osi_list_init (&false_rgrps.list); +INIT_LIST_HEAD (&false_rgrps.list);for (j =0 ; j < sdp->md.journals; j++) { ip = sdp->md.journal[j]; log_debug(_("Checking for rgrps in journal%d which starts "
gfs2/fsck/util.h +1 -1
@@ -12,7 +12,7 @@#define INODE_VALID 1#define INODE_INVALID 0 -struct di_info *search_list (osi_list_t *list,uint64_t addr); +struct di_info *search_list (struct list_head *list,uint64_t addr);void big_file_comfort (struct gfs2_inode *ip,uint64_t blks_checked);void warm_fuzzy_stuff (uint64_t block); int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
gfs2/libgfs2/block_list.c +8 -9
@@ -14,22 +14,21 @@ void gfs2_special_free(struct special_blocks *blist) {struct special_blocks *f; -while (!osi_list_empty (&blist->list)) { - f = osi_list_entry(blist->list.next, struct special_blocks, - list); -osi_list_del (&f->list); +while (!list_empty (&blist->list)) { + f = list_entry(blist->list.next, struct special_blocks, list); +list_del (&f->list);free (f); } }struct special_blocks *blockfind (struct special_blocks *blist,uint64_t num) { -osi_list_t *head = &blist->list; -osi_list_t *tmp; +struct list_head *head = &blist->list; +struct list_head *tmp;struct special_blocks *b;for (tmp = head->next; tmp != head; tmp = tmp->next) { - b = osi_list_entry(tmp, struct special_blocks, list); + b = list_entry(tmp, struct special_blocks, list);if (b->block == num)return b; }
@@ -44,7 +43,7 @@ void gfs2_special_add(struct special_blocks *blocklist, uint64_t block)if (b) {memset (b,0 ,sizeof (*b)); b->block = block; -osi_list_add_prev (&b->list, &blocklist->list); +list_add_tail (&b->list, &blocklist->list); } }
@@ -61,7 +60,7 @@ void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block) b =blockfind (blocklist, block);if (b) { -osi_list_del (&b->list); +list_del (&b->list);free (b); } }
gfs2/libgfs2/buf.c +2 -2
@@ -112,8 +112,8 @@ int brelse(struct gfs2_buffer_head *bh)if (bh->b_modified) error =bwrite (bh); bh->b_blocknr =-1 ; -if (bh->b_altlist.next && !osi_list_empty (&bh->b_altlist)) -osi_list_del (&bh->b_altlist); +if (bh->b_list.next && !list_empty (&bh->b_list)) +list_del (&bh->b_list);free (bh);return error; }
gfs2/libgfs2/fs_ops.c +6 -7
@@ -1948,11 +1948,11 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)uint64_t *ptr, block;struct rgrp_tree *rgd;uint32_t height; -osi_list_t metalist[GFS2_MAX_META_HEIGHT ]; -osi_list_t *cur_list, *next_list, *tmp; +struct list_head metalist[GFS2_MAX_META_HEIGHT ]; +struct list_head *cur_list, *next_list, *tmp;for (h =0 ; h <GFS2_MAX_META_HEIGHT ; h++) -osi_list_init (&metalist[h]); +INIT_LIST_HEAD (&metalist[h]); bh =bread (sdp, diblock);if (bh ==NULL )
@@ -1961,7 +1961,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)if (ip ==NULL )return -1 ; height = ip->i_di.di_height; -osi_list_add (&bh->b_altlist, &metalist[0 ]); +list_add (&bh->b_list, &metalist[0 ]);for (h =0 ; h < height; h++){ cur_list = &metalist[h];
@@ -1970,8 +1970,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock) sizeof(struct gfs2_dinode));for (tmp = cur_list->next; tmp != cur_list; tmp = tmp->next){ - bh = osi_list_entry(tmp, struct gfs2_buffer_head, - b_altlist); + bh = list_entry(tmp, struct gfs2_buffer_head, b_list);for (ptr = (uint64_t *)(bh->b_data + head_size); (char *)ptr < (bh->b_data + sdp->bsize); ptr++) {
@@ -1984,7 +1983,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)continue ;/* don't queue it up */ /* Read the next metadata block in the chain */ nbh =bread (sdp, block); -osi_list_add (&nbh->b_altlist, next_list); +list_add (&nbh->b_list, next_list);brelse (nbh); } }
gfs2/libgfs2/gfs1.c +0 -1
@@ -13,7 +13,6 @@#include <linux/types.h> #include <linux/gfs2_ondisk.h> -#include "osi_list.h" #include "libgfs2.h" /* GFS1 compatibility functions - so that programs like gfs2_convert
gfs2/libgfs2/lang.h +1 -0
@@ -1,6 +1,7 @@#ifndef LANG_H #define LANG_H #include <stdint.h> +#undef LIST_HEAD#include "libgfs2.h" struct lgfs2_lang_state {
gfs2/libgfs2/libgfs2.h +3 -3
@@ -15,7 +15,7 @@#include <mntent.h> #include <linux/gfs2_ondisk.h> -#include "osi_list.h" +#include <list.h> #include "osi_tree.h" __BEGIN_DECLS
@@ -217,7 +217,7 @@ extern lgfs2_rgrp_t lgfs2_rgrp_prev(lgfs2_rgrp_t rg);extern struct osi_node *lgfs2_rgrps_root (lgfs2_rgrps_t rgs) __attribute__((deprecated));struct gfs2_buffer_head { -osi_list_t b_altlist;/* alternate list */ +struct list_head b_list;uint64_t b_blocknr;union {char *b_data;
@@ -228,7 +228,7 @@ struct gfs2_buffer_head { };struct special_blocks { -osi_list_t list; +struct list_head list;uint64_t block; };
gfs2/libgfs2/super.c +0 -1
@@ -10,7 +10,6 @@#include <fcntl.h> #include "libgfs2.h" -#include "osi_list.h" /** * check_sb - Check superblock
gfs2/mkfs/gfs2_mkfs.h +0 -1
@@ -3,7 +3,6 @@#include <stdarg.h> #include <linux/gfs2_ondisk.h> -#include "osi_list.h" #include "copyright.cf" /* die() used to be in libgfs2.h */
Signature · 1 line
2.21.0
PATCH 5/5 Remove osi_list.h
In reply to Andrew PriceNo longer required.
--- gfs2/include/Makefile.am | 1 - gfs2/include/osi_list.h | 84 ---------------------------------------- 2 files changed, 85 deletions(-) delete mode 100644 gfs2/include/osi_list.h
gfs2/include/Makefile.am +0 -1
@@ -1,7 +1,6 @@ MAINTAINERCLEANFILES = Makefile.in noinst_HEADERS = \ - osi_list.h \ list.h \ osi_tree.h \ linux_endian.h \
gfs2/include/osi_list.h deleted +0 -84
84 lines not on this page · raw message
Signature · 1 line
2.21.0