[Cluster-devel] [PATCH 1/2] libgfs2: Move valid_block into fsck.gfs2

Andrew Price anprice at redhat.com
Thu Oct 25 21:38:03 UTC 2012


valid_block() is only used by fsck.gfs2 as none of the other utils
require the same level of paranoia so we can move it into fsck.h and
make it static inline.

In my (small) tests the speedup effect is barely noticeable but it
should make a difference for larger file systems, particularly those
with very large directories.

Also fsck/fs_bits.h is no longer used so this patch removes it.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/fsck/Makefile.am  |  2 +-
 gfs2/fsck/fs_bits.h    | 17 -----------------
 gfs2/fsck/fsck.h       |  6 ++++++
 gfs2/fsck/util.c       |  1 -
 gfs2/libgfs2/fs_bits.c | 17 -----------------
 gfs2/libgfs2/libgfs2.h |  1 -
 6 files changed, 7 insertions(+), 37 deletions(-)
 delete mode 100644 gfs2/fsck/fs_bits.h

diff --git a/gfs2/fsck/Makefile.am b/gfs2/fsck/Makefile.am
index 261f6b1..b92c745 100644
--- a/gfs2/fsck/Makefile.am
+++ b/gfs2/fsck/Makefile.am
@@ -10,7 +10,7 @@ sbindir := $(shell rpl=0; test '$(exec_prefix):$(sbindir)' = /usr:/usr/sbin \
 
 sbin_PROGRAMS		= fsck.gfs2
 
-noinst_HEADERS		= eattr.h fs_bits.h fsck.h fs_recovery.h \
+noinst_HEADERS		= eattr.h fsck.h fs_recovery.h \
 			  inode_hash.h link.h lost_n_found.h metawalk.h util.h
 
 fsck_gfs2_SOURCES	= eattr.c fs_recovery.c initialize.c \
diff --git a/gfs2/fsck/fs_bits.h b/gfs2/fsck/fs_bits.h
deleted file mode 100644
index d4f262e..0000000
--- a/gfs2/fsck/fs_bits.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __FS_BITS_H__
-#define __FS_BITS_H__
-
-#include "libgfs2.h"
-#include "fsck.h"
-
-#define BFITNOENT (0xFFFFFFFF)
-
-struct fs_bitmap
-{
-	uint32_t   bi_offset;	/* The offset in the buffer of the first byte */
-	uint32_t   bi_start;    /* The position of the first byte in this block */
-	uint32_t   bi_len;      /* The number of bytes in this block */
-};
-typedef struct fs_bitmap fs_bitmap_t;
-
-#endif /* __FS_BITS_H__ */
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 70fc3d7..dd49280 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -148,4 +148,10 @@ extern int dups_found_first; /* How many duplicates have we found the original
 				reference for? */
 extern struct gfs_sb *sbd1;
 
+static inline int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
+{
+	return !((blkno > sdp->fssize) || (blkno <= sdp->sb_addr) ||
+	         (gfs2_get_bitmap(sdp, blkno, NULL) < 0));
+}
+
 #endif /* _FSCK_H */
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 6c80ae8..eff7382 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -13,7 +13,6 @@
 #define _(String) gettext(String)
 
 #include "libgfs2.h"
-#include "fs_bits.h"
 #include "metawalk.h"
 #include "util.h"
 
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index 5eeb920..fdc3bb3 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -113,23 +113,6 @@ int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno)
 }
 
 /*
- * valid_block - check if blkno is valid and not part of our rgrps or bitmaps
- * @sdp: super block
- * @blkno: block number
- *
- * Returns: 1 if ok, 0 if out of bounds
- */
-int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
-{
-	if((blkno > sdp->fssize) || (blkno <= sdp->sb_addr))
-		return 0;
-	/* Check if the block is one of our rgrp or bitmap blocks */
-	if (gfs2_get_bitmap(sdp, blkno, NULL) < 0)
-		return 0;
-	return 1;
-}
-
-/*
  * gfs2_set_bitmap
  * @sdp: super block
  * @blkno: block number relative to file system
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3045337..bf65922 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -408,7 +408,6 @@ extern uint32_t gfs2_blkalloc_internal(struct rgrp_tree *rgd, uint32_t goal,
 extern int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno);
 
 /* functions with blk #'s that are file system relative */
-extern int valid_block(struct gfs2_sbd *sdp, uint64_t blkno);
 extern int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno,
 			   struct rgrp_tree *rgd);
 extern int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state);
-- 
1.7.11.7




More information about the Cluster-devel mailing list