From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 5/6] libgfs2: Clean up sb read/check functions
Date: Wed, 30 Nov 2011 15:04:41 +0000 [thread overview]
Message-ID: <1322665482-28435-6-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1322665482-28435-1-git-send-email-swhiteho@redhat.com>
There is no need to specify in advance whether we want to accept
gfs1 format super blocks or not. We can simply return that info
and let the caller decide if gfs1 format is acceptable or not.
We can also remove the message regarding the magic number of the
superblock, since the caller prints out a message anyway if
the check fails.
That removes some more of the log_ messages from libgfs2 as a
result.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
gfs2/edit/savemeta.c | 4 ++--
gfs2/fsck/initialize.c | 4 ++--
gfs2/libgfs2/libgfs2.h | 4 ++--
gfs2/libgfs2/super.c | 23 ++++++-----------------
gfs2/mkfs/main_grow.c | 6 ++++--
5 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 31af23d..9d790fe 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -670,7 +670,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
fprintf(stderr, "Bad constants (1)\n");
exit(-1);
}
- ret = read_sb(&sbd, 1);
+ ret = read_sb(&sbd);
if (ret < 0) {
slow = TRUE;
sbd.gfs1 = 0;
@@ -911,7 +911,7 @@ static int restore_data(int fd, gzFile *gzin_fd, int printblocksonly,
memcpy(&bufsb, savedata->buf, sizeof(bufsb));
gfs2_sb_in(&sbd.sd_sb, &dummy_bh);
sbd1 = (struct gfs_sb *)&sbd.sd_sb;
- ret = check_sb(&sbd.sd_sb, 1);
+ ret = check_sb(&sbd.sd_sb);
if (ret < 0) {
fprintf(stderr,"Error: Invalid superblock data.\n");
return -1;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index ba0df41..132d65a 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1227,12 +1227,12 @@ static int fill_super_block(struct gfs2_sbd *sdp)
log_crit(_("Bad constants (1)\n"));
exit(FSCK_ERROR);
}
- ret = read_sb(sdp, 1);
+ ret = read_sb(sdp);
if (ret < 0) {
if (sb_repair(sdp) != 0)
return -1; /* unrepairable, so exit */
/* Now that we've tried to repair it, re-read it. */
- ret = read_sb(sdp, 1);
+ ret = read_sb(sdp);
if (ret < 0)
return -1;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 04169bf..b24e555 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -722,8 +722,8 @@ extern int gfs2_next_rg_freemeta(struct rgrp_tree *rgd, uint64_t *block,
int first);
/* super.c */
-extern int check_sb(struct gfs2_sb *sb, int allow_gfs);
-extern int read_sb(struct gfs2_sbd *sdp, int allow_gfs);
+extern int check_sb(struct gfs2_sb *sb);
+extern int read_sb(struct gfs2_sbd *sdp);
extern int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane);
extern int ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int *sane);
extern int write_sb(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 2f544ab..c9a9ad3 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -13,7 +13,6 @@
/**
* check_sb - Check superblock
- * @sdp: the filesystem
* @sb: The superblock
*
* Checks the version code of the FS is one that we understand how to
@@ -22,25 +21,17 @@
*
* Returns: -1 on failure, 1 if this is gfs (gfs1), 2 if this is gfs2
*/
-int check_sb(struct gfs2_sb *sb, int allow_gfs)
+int check_sb(struct gfs2_sb *sb)
{
if (sb->sb_header.mh_magic != GFS2_MAGIC ||
sb->sb_header.mh_type != GFS2_METATYPE_SB) {
- log_crit("Either the super block is corrupted, or this "
- "is not a GFS2 filesystem\n");
- log_crit("Header magic: %X Header Type: %X\n",
- sb->sb_header.mh_magic,
- sb->sb_header.mh_type);
- return -EINVAL;
+ errno = -EIO;
+ return -1;
}
if (sb->sb_fs_format == GFS_FORMAT_FS &&
sb->sb_header.mh_format == GFS_FORMAT_SB &&
sb->sb_multihost_format == GFS_FORMAT_MULTI) {
- if (allow_gfs)
- return 1;
-
- log_crit("Old gfs1 file system detected.\n");
- return -EINVAL;
+ return 1;
}
return 2;
}
@@ -54,12 +45,10 @@ int check_sb(struct gfs2_sb *sb, int allow_gfs)
* initializes various constants maintained in the super
* block
*
- * allow_gfs - passed in as 1 if we're allowed to accept gfs1 file systems
- *
* Returns: 0 on success, -1 on failure
* sdp->gfs1 will be set if this is gfs (gfs1)
*/
-int read_sb(struct gfs2_sbd *sdp, int allow_gfs)
+int read_sb(struct gfs2_sbd *sdp)
{
struct gfs2_buffer_head *bh;
uint64_t space = 0;
@@ -70,7 +59,7 @@ int read_sb(struct gfs2_sbd *sdp, int allow_gfs)
gfs2_sb_in(&sdp->sd_sb, bh);
brelse(bh);
- ret = check_sb(&sdp->sd_sb, allow_gfs);
+ ret = check_sb(&sdp->sd_sb);
if (ret < 0)
return ret;
if (ret == 1)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 1dc911a..5ed5a2d 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -358,9 +358,11 @@ main_grow(int argc, char *argv[])
perror(_("Bad constants (1)"));
exit(EXIT_FAILURE);
}
- if (read_sb(sdp, 0) < 0)
+ if (read_sb(sdp) < 0)
die( _("gfs: Error reading superblock.\n"));
-
+ if (sdp->gfs1) {
+ die( _("cannot grow gfs1 filesystem\n"));
+ }
if (fix_device_geometry(sdp)) {
fprintf(stderr, _("Device is too small (%llu bytes)\n"),
(unsigned long long)sdp->device.length << GFS2_BASIC_BLOCK_SHIFT);
--
1.7.4.4
next prev parent reply other threads:[~2011-11-30 15:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-30 15:04 [Cluster-devel] libgfs2 cleanups Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 1/6] libgfs2: Move generic_interrupt() into utils Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 2/6] libgfs2: Move gfs2_getch " Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 3/6] libgfs2: Prepare to remove log_xxx() macros from library Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 4/6] libgfs2: Move some debug messages out into mkfs/fsck Steven Whitehouse
2011-11-30 15:04 ` Steven Whitehouse [this message]
2011-11-30 15:04 ` [Cluster-devel] [PATCH 6/6] libgfs2: Remove some more log_xxx calls Steven Whitehouse
2011-11-30 15:55 ` [Cluster-devel] libgfs2 cleanups Bob Peterson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322665482-28435-6-git-send-email-swhiteho@redhat.com \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).