From mboxrd@z Thu Jan 1 00:00:00 1970 From: rpeterso@sourceware.org Date: 14 Jul 2006 19:25:09 -0000 Subject: [Cluster-devel] cluster/gfs/libgfs libgfs.h super.c Message-ID: <20060714192509.8166.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: rpeterso at sourceware.org 2006-07-14 19:25:08 Modified files: gfs/libgfs : libgfs.h super.c Log message: Split read_sb into read_sb and compute_constants like libgfs2. That enables programs that do not read the superblock (like mkfs) to get the constants they need. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/libgfs.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/super.c.diff?cvsroot=cluster&r1=1.1&r2=1.2 --- cluster/gfs/libgfs/libgfs.h 2006/07/10 23:28:11 1.2 +++ cluster/gfs/libgfs/libgfs.h 2006/07/14 19:25:08 1.3 @@ -386,6 +386,7 @@ int write_sb(int disk_fd, struct gfs_sbd *sdp); int set_block_ranges(int disk_fd, struct gfs_sbd *sdp); int read_super_block(int disk_fd, struct gfs_sbd *sdp); +int compute_constants(struct gfs_sbd *sdp); /* ------------------------------------------------------------------------- */ /* formerly rgrp.h: */ --- cluster/gfs/libgfs/super.c 2006/05/15 18:56:07 1.1 +++ cluster/gfs/libgfs/super.c 2006/07/14 19:25:08 1.2 @@ -73,40 +73,19 @@ return error; } - /* - * read_sb: read the super block from disk - * sdp: in-core super block - * - * This function reads in the super block from disk and - * initializes various constants maintained in the super - * block + * compute_constants: compute constants for the superblock * - * Returns: 0 on success, -1 on failure. + * assumes: + * sb_bsize_shift is set either from the ondisk superblock or otherwise. + * sb_bsize is set either from the ondisk superblock or otherwise. */ -int read_sb(int disk_fd, struct gfs_sbd *sdp) +int compute_constants(struct gfs_sbd *sdp) { - osi_buf_t *bh; - uint64 space = 0; unsigned int x; - int error; - error = get_and_read_buf(disk_fd, 512, /* assume 512 block size at first */ - GFS_SB_ADDR >> sdp->sd_fsb2bb_shift, &bh, 0); - if (error){ - log_crit("Unable to read superblock\n"); - goto out; - } - - gfs_sb_in(&sdp->sd_sb, BH_DATA(bh)); - - relse_buf(bh); - - error = check_sb(sdp, &sdp->sd_sb); - if (error) - goto out; + uint64 space = 0; + int error = 0; -/* FIXME: Need to verify all this */ - /* FIXME: What's this 9? */ sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9; sdp->sd_diptrs = (sdp->sd_sb.sb_bsize-sizeof(struct gfs_dinode)) / @@ -115,7 +94,6 @@ (sdp->sd_sb.sb_bsize-sizeof(struct gfs_indirect)) / sizeof(uint64); sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs_meta_header); - /* FIXME: Why is this /2 */ sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2; sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64); sdp->sd_heightsize[0] = sdp->sd_sb.sb_bsize - @@ -133,7 +111,7 @@ if(sdp->sd_max_height > GFS_MAX_META_HEIGHT){ log_err("Bad max metadata height.\n"); error = -1; - goto out; + return error; } sdp->sd_jheightsize[0] = sdp->sd_sb.sb_bsize - @@ -151,6 +129,39 @@ log_err("Bad max jheight.\n"); error = -1; } + return error; +} + +/* + * read_sb: read the super block from disk + * sdp: in-core super block + * + * This function reads in the super block from disk and + * initializes various constants maintained in the super + * block + * + * Returns: 0 on success, -1 on failure. + */ +int read_sb(int disk_fd, struct gfs_sbd *sdp) +{ + osi_buf_t *bh; + int error; + error = get_and_read_buf(disk_fd, 512, /* assume 512 block size at first */ + GFS_SB_ADDR >> sdp->sd_fsb2bb_shift, &bh, 0); + if (error){ + log_crit("Unable to read superblock\n"); + goto out; + } + + gfs_sb_in(&sdp->sd_sb, BH_DATA(bh)); + + relse_buf(bh); + + error = check_sb(sdp, &sdp->sd_sb); + if (error) + goto out; + + compute_constants(sdp); out: