Fix sign issues in stafs and quota code, plus clean up
Hi,
This patch fixes some sign issues which were accidentally introduced into the quota & statfs code during the endianess annotation process. Also included is a general clean up which moves all of the _host structures out of gfs2_ondisk.h (where they should not have been to start with) and into the places where they are actually used (often only one place). Also those _host structures which are not required any more are removed entirely (which is the eventual plan for all of them).
The conversion routines from ondisk.c are also moved into the places where they are actually used, which for almost every one, was just one single place, so all those are now static functions. This also cleans up the end of gfs2_ondisk.h which no longer needs the #ifdef __KERNEL__.
The net result is a reduction of about 100 lines of code, many functions now marked static plus the bug fixes as mentioned above. For good measure I ran the code through sparse after making these changes to check that there are no warnings generated.
This fixes Red Hat bz #239686
Steve.
-------------------------------------------------------------------------
fs/gfs2/Makefile +1 -1
@@ -1,7 +1,7 @@ obj-$(CONFIG_GFS2_FS) += gfs2.o gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ glops.o inode.o lm.o log.o lops.o locking.o main.o meta_io.o \ - mount.o ondisk.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ + mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ ops_fstype.o ops_inode.o ops_super.o ops_vm.o quota.o \ recovery.o rgrp.o super.o sys.o trans.o util.o
fs/gfs2/acl.c +0 -0
fs/gfs2/bmap.c +2 -2
@@ -718,7 +718,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,for (x =0 ; x < rlist.rl_rgrps; x++) {struct gfs2_rgrpd *rgd; rgd = rlist.rl_ghs[x].gh_gl->gl_object; - rg_blocks += rgd->rd_ri.ri_length; + rg_blocks += rgd->rd_length; } error =gfs2_glock_nq_m (rlist.rl_rgrps, rlist.rl_ghs);
@@ -824,7 +824,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size) goto out_gunlock_q; error =gfs2_trans_begin (sdp, - sdp->sd_max_height + al->al_rgd->rd_ri.ri_length + + sdp->sd_max_height + al->al_rgd->rd_length +RES_JDATA +RES_DINODE +RES_STATFS +RES_QUOTA ,0 );if (error) goto out_ipres;
fs/gfs2/daemon.c +0 -0
fs/gfs2/dir.c +1 -1
@@ -1897,7 +1897,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,for (x =0 ; x < rlist.rl_rgrps; x++) {struct gfs2_rgrpd *rgd; rgd = rlist.rl_ghs[x].gh_gl->gl_object; - rg_blocks += rgd->rd_ri.ri_length; + rg_blocks += rgd->rd_length; } error =gfs2_glock_nq_m (rlist.rl_rgrps, rlist.rl_ghs);
fs/gfs2/eaops.c +0 -0
fs/gfs2/eattr.c +3 -3
@@ -254,7 +254,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,if (error)return error; - error =gfs2_trans_begin (sdp, rgd->rd_ri.ri_length +RES_DINODE + + error =gfs2_trans_begin (sdp, rgd->rd_length +RES_DINODE +RES_EATTR +RES_STATFS +RES_QUOTA , blks);if (error) goto out_gunlock;
@@ -700,7 +700,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, goto out_gunlock_q; error =gfs2_trans_begin (GFS2_SB (&ip->i_inode), - blks + al->al_rgd->rd_ri.ri_length + + blks + al->al_rgd->rd_length +RES_DINODE +RES_STATFS +RES_QUOTA ,0 );if (error) goto out_ipres;
@@ -1352,7 +1352,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)for (x =0 ; x < rlist.rl_rgrps; x++) {struct gfs2_rgrpd *rgd; rgd = rlist.rl_ghs[x].gh_gl->gl_object; - rg_blocks += rgd->rd_ri.ri_length; + rg_blocks += rgd->rd_length; } error =gfs2_glock_nq_m (rlist.rl_rgrps, rlist.rl_ghs);
fs/gfs2/glock.c +0 -0
fs/gfs2/glops.c +0 -0
fs/gfs2/incore.h +62 -1
98 lines not on this page · raw message
fs/gfs2/inode.c +82 -1
104 lines not on this page · raw message
fs/gfs2/inode.h +10 -0
@@ -38,6 +38,14 @@ static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr,return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino; } +static inline void gfs2_inum_out (const struct gfs2_inode *ip, +struct gfs2_dirent *dent) +{ + dent->de_inum.no_formal_ino =cpu_to_be64 (ip->i_no_formal_ino); + dent->de_inum.no_addr =cpu_to_be64 (ip->i_no_addr); +} + +void gfs2_inode_attr_in (struct gfs2_inode *ip);struct inode *gfs2_inode_lookup (struct super_block *sb,u64 no_addr,unsigned type);struct inode *gfs2_ilookup (struct super_block *sb,u64 no_addr);
@@ -59,6 +67,8 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);int gfs2_glock_nq_atime (struct gfs2_holder *gh);int gfs2_setattr_simple (struct gfs2_inode *ip,struct iattr *attr);struct inode *gfs2_lookup_simple (struct inode *dip,const char *name); +void gfs2_dinode_out (const struct gfs2_inode *ip,void *buf); +void gfs2_dinode_print (const struct gfs2_inode *ip);#endif /* __INODE_DOT_H__ */
fs/gfs2/lm.c +0 -0
fs/gfs2/locking.c +0 -0
fs/gfs2/log.c +0 -0
fs/gfs2/lops.c +0 -0
fs/gfs2/main.c +0 -0
fs/gfs2/meta_io.c +0 -0
fs/gfs2/mount.c +0 -0
fs/gfs2/ondisk.c deleted +0 -246
246 lines not on this page · raw message
fs/gfs2/ops_address.c +0 -0
fs/gfs2/ops_dentry.c +0 -0
fs/gfs2/ops_export.c +9 -1
@@ -22,10 +22,18 @@#include "glops.h" #include "inode.h" #include "ops_dentry.h" -#include "ops_export.h" +#include "ops_fstype.h" #include "rgrp.h" #include "util.h" +#define GFS2_SMALL_FH_SIZE 4 +#define GFS2_LARGE_FH_SIZE 10 + +struct gfs2_fh_obj { +struct gfs2_inum_host this; +u32 imode; +}; + static struct dentry *gfs2_decode_fh(struct super_block *sb, __u32 *p, int fh_len,
fs/gfs2/ops_export.h deleted +0 -22
@@ -1,22 +0,0 @@ -/* -* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. -* -* This copyrighted material is made available to anyone wishing to use, -* modify, copy, or redistribute it subject to the terms and conditions -* of the GNU General Public License version 2. -*/ - -#ifndef __OPS_EXPORT_DOT_H__ -#define __OPS_EXPORT_DOT_H__ - -#define GFS2_SMALL_FH_SIZE 4 -#define GFS2_LARGE_FH_SIZE 10 - -extern struct export_operations gfs2_export_ops; -struct gfs2_fh_obj { -struct gfs2_inum_host this; -__u32 imode; -}; - -#endif /* __OPS_EXPORT_DOT_H__ */
fs/gfs2/ops_file.c +0 -0
fs/gfs2/ops_fstype.c +3 -10
@@ -27,7 +27,6 @@#include "inode.h" #include "lm.h" #include "mount.h" -#include "ops_export.h" #include "ops_fstype.h" #include "ops_super.h" #include "recovery.h"
@@ -116,7 +115,6 @@ static void init_vfs(struct super_block *sb, unsigned noatime)static int init_names (struct gfs2_sbd *sdp,int silent) { -struct page *page;char *proto, *table;int error =0 ;
@@ -126,14 +124,9 @@ static int init_names(struct gfs2_sbd *sdp, int silent)/* Try to autodetect */ if (!proto[0 ] || !table[0 ]) { -struct gfs2_sb *sb; - page =gfs2_read_super (sdp->sd_vfs,GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); -if (!page) -return -ENOBUFS ; - sb =kmap (page); -gfs2_sb_in (&sdp->sd_sb, sb); -kunmap (page); -__free_page (page); + error =gfs2_read_super (sdp,GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); +if (error) +return error; error =gfs2_check_sb (sdp, &sdp->sd_sb, silent);if (error)
fs/gfs2/ops_fstype.h +1 -0
@@ -14,5 +14,6 @@extern struct file_system_type gfs2_fs_type;extern struct file_system_type gfs2meta_fs_type; +extern struct export_operations gfs2_export_ops;#endif /* __OPS_FSTYPE_DOT_H__ */
fs/gfs2/ops_inode.c +2 -2
@@ -206,7 +206,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, goto out_gunlock_q; error =gfs2_trans_begin (sdp, sdp->sd_max_dirres + - al->al_rgd->rd_ri.ri_length + + al->al_rgd->rd_length +2 *RES_DINODE +RES_STATFS +RES_QUOTA ,0 );if (error)
@@ -711,7 +711,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, goto out_gunlock_q; error =gfs2_trans_begin (sdp, sdp->sd_max_dirres + - al->al_rgd->rd_ri.ri_length + + al->al_rgd->rd_length +4 *RES_DINODE +4 *RES_LEAF +RES_STATFS +RES_QUOTA +4 ,0 );if (error)
fs/gfs2/ops_super.c +0 -0
fs/gfs2/ops_vm.c +1 -1
@@ -66,7 +66,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)if (error) goto out_gunlock_q; - error =gfs2_trans_begin (sdp, al->al_rgd->rd_ri.ri_length + + error =gfs2_trans_begin (sdp, al->al_rgd->rd_length + ind_blocks +RES_DINODE +RES_STATFS +RES_QUOTA ,0 );if (error)
fs/gfs2/quota.c +41 -1
66 lines not on this page · raw message
fs/gfs2/recovery.c +18 -4
@@ -116,6 +116,22 @@ void gfs2_revoke_clean(struct gfs2_sbd *sdp) } } +static int gfs2_log_header_in (struct gfs2_log_header_host *lh,const void *buf) +{ +const struct gfs2_log_header *str = buf; + +if (str->lh_header.mh_magic !=cpu_to_be32 (GFS2_MAGIC ) || + str->lh_header.mh_type !=cpu_to_be32 (GFS2_METATYPE_LH )) +return 1 ; + + lh->lh_sequence =be64_to_cpu (str->lh_sequence); + lh->lh_flags =be32_to_cpu (str->lh_flags); + lh->lh_tail =be32_to_cpu (str->lh_tail); + lh->lh_blkno =be32_to_cpu (str->lh_blkno); + lh->lh_hash =be32_to_cpu (str->lh_hash); +return 0 ; +} +/** * get_log_header - read the log header for a given segment * @jd: the journal
@@ -147,12 +163,10 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, sizeof(u32)); hash =crc32_le (hash, (unsigned char const *)¬hing,sizeof (nothing)); hash ^= (u32 )~0 ; -gfs2_log_header_in (&lh, bh->b_data); + error =gfs2_log_header_in (&lh, bh->b_data);brelse (bh); -if (lh.lh_header.mh_magic !=GFS2_MAGIC || - lh.lh_header.mh_type !=GFS2_METATYPE_LH || - lh.lh_blkno != blk || lh.lh_hash != hash) +if (error || lh.lh_blkno != blk || lh.lh_hash != hash)return 1 ; *head = lh;
fs/gfs2/rgrp.c +22 -12
@@ -204,7 +204,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) {struct gfs2_sbd *sdp = rgd->rd_sbd;struct gfs2_bitmap *bi =NULL ; -u32 length = rgd->rd_ri.ri_length; +u32 length = rgd->rd_length;u32 count[4 ], tmp;int buf, x;
@@ -227,7 +227,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd)return ; } - tmp = rgd->rd_ri.ri_data - + tmp = rgd->rd_data - rgd->rd_rg.rg_free - rgd->rd_rg.rg_dinodes;if (count[1 ] + count[2 ] != tmp) {
@@ -253,10 +253,10 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) } -static inline int rgrp_contains_block (struct gfs2_rindex_host *ri,u64 block) +static inline int rgrp_contains_block (struct gfs2_rgrpd *rgd,u64 block) { -u64 first = ri->ri_data0; -u64 last = first + ri->ri_data; +u64 first = rgd->rd_data0; +u64 last = first + rgd->rd_data;return first <= block && block < last; }
@@ -275,7 +275,7 @@ struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk)spin_lock (&sdp->sd_rindex_spin);list_for_each_entry (rgd, &sdp->sd_rindex_mru_list, rd_list_mru) { -if (rgrp_contains_block (&rgd->rd_ri, blk)) { +if (rgrp_contains_block (rgd, blk)) {list_move (&rgd->rd_list_mru, &sdp->sd_rindex_mru_list);spin_unlock (&sdp->sd_rindex_spin);return rgd;
@@ -354,6 +354,15 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)mutex_unlock (&sdp->sd_rindex_mutex); } +static void gfs2_rindex_print (const struct gfs2_rgrpd *rgd) +{ +printk (KERN_INFO " ri_addr = %llu\n" , (unsigned long long )rgd->rd_addr); +printk (KERN_INFO " ri_length = %u\n" , rgd->rd_length); +printk (KERN_INFO " ri_data0 = %llu\n" , (unsigned long long )rgd->rd_data0); +printk (KERN_INFO " ri_data = %u\n" , rgd->rd_data); +printk (KERN_INFO " ri_bitbytes = %u\n" , rgd->rd_bitbytes); +} +/** * gfs2_compute_bitstructs - Compute the bitmap sizes * @rgd: The resource group descriptor
@@ -367,7 +376,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) {struct gfs2_sbd *sdp = rgd->rd_sbd;struct gfs2_bitmap *bi; -u32 length = rgd->rd_ri.ri_length;/* # blocks in hdr & bitmap */ +u32 length = rgd->rd_length;/* # blocks in hdr & bitmap */ u32 bytes_left, bytes;int x;
@@ -378,7 +387,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)if (!rgd->rd_bits)return -ENOMEM ; - bytes_left = rgd->rd_ri.ri_bitbytes; + bytes_left = rgd->rd_bitbytes;for (x =0 ; x < length; x++) { bi = rgd->rd_bits + x;
@@ -399,14 +408,14 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) }else if (x +1 == length) { bytes = bytes_left; bi->bi_offset =sizeof (struct gfs2_meta_header ); - bi->bi_start = rgd->rd_ri.ri_bitbytes - bytes_left; + bi->bi_start = rgd->rd_bitbytes - bytes_left; bi->bi_len = bytes;/* other blocks */ }else { bytes = sdp->sd_sb.sb_bsize -sizeof (struct gfs2_meta_header ); bi->bi_offset =sizeof (struct gfs2_meta_header ); - bi->bi_start = rgd->rd_ri.ri_bitbytes - bytes_left; + bi->bi_start = rgd->rd_bitbytes - bytes_left; bi->bi_len = bytes; }
@@ -418,9 +427,9 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)return -EIO ; } bi = rgd->rd_bits + (length -1 ); -if ((bi->bi_start + bi->bi_len) *GFS2_NBBY != rgd->rd_ri.ri_data) { +if ((bi->bi_start + bi->bi_len) *GFS2_NBBY != rgd->rd_data) {if (gfs2_consist_rgrpd (rgd)) { -gfs2_rindex_print (&rgd->rd_ri); +gfs2_rindex_print (rgd);fs_err (sdp,"start=%u len=%u offset=%u\n" , bi->bi_start, bi->bi_len, bi->bi_offset); }
@@ -431,6 +440,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) }/** +