gfs2-utils: RHEL7 - gfs2-utils: Tidy up Makefile.am files
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=d039a5dc...
Commit: d039a5dccc1e21c60bd705e282ef81c753e947d0
Parent: 1021c18e8d3053f1a232661d0d2108665bf1afc0
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sun Mar 29 07:41:14 2015 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:52:44 2015 +0100
gfs2-utils: Tidy up Makefile.am files
Reorganise the Makefile.am files for ease of maintenance.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
Makefile.am | 37 +++++++++++++++-----
doc/Makefile.am | 17 +++++----
gfs2/Makefile.am | 14 ++++++--
gfs2/convert/Makefile.am | 13 ++++---
gfs2/edit/Makefile.am | 34 +++++++++++++-----
gfs2/fsck/Makefile.am | 44 ++++++++++++++++++-------
gfs2/include/Makefile.am | 8 +++-
gfs2/libgfs2/Makefile.am | 83 +++++++++++++++++++++++++++++++--------------
gfs2/man/Makefile.am | 23 +++++++------
gfs2/mkfs/Makefile.am | 19 ++++++++--
gfs2/scripts/Makefile.am | 6 ++-
gfs2/tune/Makefile.am | 17 +++++----
tests/Makefile.am | 21 +++++++++--
13 files changed, 231 insertions(+), 105 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 963c060..1c4f8ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,18 +1,35 @@
-EXTRA_DIST = autogen.sh README.build
+EXTRA_DIST = autogen.sh README.build
-AUTOMAKE_OPTIONS = foreign
+AUTOMAKE_OPTIONS = foreign
-MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure depcomp \
- config.guess config.sub missing install-sh \
- autoheader automake autoconf libtool libtoolize \
- ltmain.sh compile make/clusterautoconfig.h.in \
- make/clusterautoconfig.h.in~
+MAINTAINERCLEANFILES = \
+ Makefile.in \
+ aclocal.m4 \
+ configure \
+ depcomp \
+ config.guess \
+ config.sub \
+ missing \
+ install-sh \
+ autoheader \
+ automake \
+ autoconf \
+ libtool \
+ libtoolize \
+ ltmain.sh \
+ compile \
+ make/clusterautoconfig.h.in \
+ make/clusterautoconfig.h.in~
-noinst_HEADERS = make/copyright.cf
+noinst_HEADERS = make/copyright.cf
-ACLOCAL_AMFLAGS = -I m4
+ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = po gfs2 doc tests
+SUBDIRS = \
+ po \
+ gfs2 \
+ doc \
+ tests
maintainer-clean-local:
rm -rf m4
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 32987b2..cf671d5 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,9 +1,10 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-dist_doc_DATA = gfs2.txt \
- journaling.txt \
- COPYING.applications \
- COPYING.libraries \
- COPYRIGHT \
- README.contributing \
- README.licence
+dist_doc_DATA = \
+ gfs2.txt \
+ journaling.txt \
+ COPYING.applications \
+ COPYING.libraries \
+ COPYRIGHT \
+ README.contributing \
+ README.licence
diff --git a/gfs2/Makefile.am b/gfs2/Makefile.am
index 645119f..028e840 100644
--- a/gfs2/Makefile.am
+++ b/gfs2/Makefile.am
@@ -1,4 +1,12 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-SUBDIRS = libgfs2 convert edit fsck mkfs man \
- tune include scripts #init.d
+SUBDIRS = \
+ include \
+ libgfs2 \
+ convert \
+ edit \
+ fsck \
+ mkfs \
+ man \
+ tune \
+ scripts
diff --git a/gfs2/convert/Makefile.am b/gfs2/convert/Makefile.am
index eb3c330..30924d7 100644
--- a/gfs2/convert/Makefile.am
+++ b/gfs2/convert/Makefile.am
@@ -1,9 +1,10 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-sbin_PROGRAMS = gfs2_convert
+sbin_PROGRAMS = gfs2_convert
-gfs2_convert_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DHELPER_PROGRAM \
- -I$(top_srcdir)/gfs2/include \
- -I$(top_srcdir)/gfs2/libgfs2
+gfs2_convert_CPPFLAGS = \
+ -D_FILE_OFFSET_BITS=64 \
+ -I$(top_srcdir)/gfs2/include \
+ -I$(top_srcdir)/gfs2/libgfs2
-gfs2_convert_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
+gfs2_convert_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/edit/Makefile.am b/gfs2/edit/Makefile.am
index 8b977ae..5d2942e 100644
--- a/gfs2/edit/Makefile.am
+++ b/gfs2/edit/Makefile.am
@@ -1,17 +1,31 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-sbin_PROGRAMS = gfs2_edit
+sbin_PROGRAMS = gfs2_edit
-noinst_HEADERS = gfs2hex.h hexedit.h extended.h journal.h
+noinst_HEADERS = \
+ gfs2hex.h \
+ hexedit.h \
+ extended.h \
+ journal.h
-gfs2_edit_SOURCES = gfs2hex.c hexedit.c savemeta.c extended.c journal.c
+gfs2_edit_SOURCES = \
+ gfs2hex.c \
+ hexedit.c \
+ savemeta.c \
+ extended.c \
+ journal.c
-gfs2_edit_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DHELPER_PROGRAM \
- -I$(top_srcdir)/gfs2/include \
- -I$(top_srcdir)/gfs2/libgfs2
+gfs2_edit_CPPFLAGS = \
+ -D_FILE_OFFSET_BITS=64 \
+ -I$(top_srcdir)/gfs2/include \
+ -I$(top_srcdir)/gfs2/libgfs2
-gfs2_edit_CFLAGS = $(ncurses_CFLAGS) $(zlib_CFLAGS)
+gfs2_edit_CFLAGS = \
+ $(ncurses_CFLAGS) \
+ $(zlib_CFLAGS)
-gfs2_edit_LDFLAGS = $(ncurses_LIBS) $(zlib_LIBS)
+gfs2_edit_LDFLAGS = \
+ $(ncurses_LIBS) \
+ $(zlib_LIBS)
-gfs2_edit_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
+gfs2_edit_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/fsck/Makefile.am b/gfs2/fsck/Makefile.am
index b34833b..fb93110 100644
--- a/gfs2/fsck/Makefile.am
+++ b/gfs2/fsck/Makefile.am
@@ -1,17 +1,37 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-sbin_PROGRAMS = fsck.gfs2
+sbin_PROGRAMS = fsck.gfs2
-noinst_HEADERS = fsck.h fs_recovery.h \
- inode_hash.h link.h lost_n_found.h metawalk.h util.h
+noinst_HEADERS = \
+ fsck.h \
+ fs_recovery.h \
+ inode_hash.h \
+ link.h \
+ lost_n_found.h \
+ metawalk.h \
+ util.h
-fsck_gfs2_SOURCES = fs_recovery.c initialize.c \
- inode_hash.c link.c lost_n_found.c main.c metawalk.c \
- pass1b.c pass1.c pass1c.c pass2.c pass3.c pass4.c \
- pass5.c rgrepair.c util.c
+fsck_gfs2_SOURCES = \
+ fs_recovery.c \
+ initialize.c \
+ inode_hash.c \
+ link.c \
+ lost_n_found.c \
+ main.c \
+ metawalk.c \
+ pass1b.c \
+ pass1.c \
+ pass1c.c \
+ pass2.c \
+ pass3.c \
+ pass4.c \
+ pass5.c \
+ rgrepair.c \
+ util.c
-fsck_gfs2_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DHELPER_PROGRAM \
- -I$(top_srcdir)/gfs2/include \
- -I$(top_srcdir)/gfs2/libgfs2
+fsck_gfs2_CPPFLAGS = \
+ -D_FILE_OFFSET_BITS=64 \
+ -I$(top_srcdir)/gfs2/include \
+ -I$(top_srcdir)/gfs2/libgfs2
-fsck_gfs2_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
+fsck_gfs2_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/include/Makefile.am b/gfs2/include/Makefile.am
index c755181..fca6f6a 100644
--- a/gfs2/include/Makefile.am
+++ b/gfs2/include/Makefile.am
@@ -1,3 +1,7 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-noinst_HEADERS = osi_list.h osi_tree.h linux_endian.h logging.h
+noinst_HEADERS = \
+ osi_list.h \
+ osi_tree.h \
+ linux_endian.h \
+ logging.h
diff --git a/gfs2/libgfs2/Makefile.am b/gfs2/libgfs2/Makefile.am
index 1ce8c13..2b7aa16 100644
--- a/gfs2/libgfs2/Makefile.am
+++ b/gfs2/libgfs2/Makefile.am
@@ -1,29 +1,60 @@
-MAINTAINERCLEANFILES = Makefile.in
-
-CLEANFILES = parser.h parser.c lexer.c lexer.h
-BUILT_SOURCES = parser.h lexer.h
-AM_LFLAGS = --header-file=lexer.h
-AM_YFLAGS = -d
-
-noinst_HEADERS = libgfs2.h lang.h config.h rgrp.h
-
-noinst_LTLIBRARIES = libgfs2.la
-
-noinst_PROGRAMS = gfs2l
-
-libgfs2_la_SOURCES = block_list.c fs_bits.c gfs1.c misc.c rgrp.c super.c \
- buf.c fs_geometry.c gfs2_disk_hash.c ondisk.c config.c \
- device_geometry.c fs_ops.c recovery.c \
- structures.c meta.c lang.c parser.y lexer.l
-
-libgfs2_la_CPPFLAGS = -D_FILE_OFFSET_BITS=64 \
- -D_LARGEFILE64_SOURCE \
- -D_GNU_SOURCE \
- -I$(top_srcdir)/gfs2/include
-
-gfs2l_SOURCES = gfs2l.c
-gfs2l_CPPFLAGS = -I$(top_srcdir)/gfs2/include -D_FILE_OFFSET_BITS=64
-gfs2l_LDADD = libgfs2.la
+MAINTAINERCLEANFILES = Makefile.in
+
+CLEANFILES = \
+ parser.h \
+ parser.c \
+ lexer.c \
+ lexer.h
+
+BUILT_SOURCES = \
+ parser.h \
+ lexer.h
+
+AM_LFLAGS = --header-file=lexer.h
+AM_YFLAGS = -d
+
+noinst_HEADERS = \
+ libgfs2.h \
+ lang.h \
+ config.h \
+ rgrp.h
+
+noinst_LTLIBRARIES = libgfs2.la
+
+noinst_PROGRAMS = gfs2l
+
+libgfs2_la_SOURCES = \
+ block_list.c \
+ fs_bits.c \
+ gfs1.c \
+ misc.c \
+ rgrp.c \
+ super.c \
+ buf.c \
+ fs_geometry.c \
+ gfs2_disk_hash.c \
+ ondisk.c \
+ config.c \
+ device_geometry.c \
+ fs_ops.c \
+ recovery.c \
+ structures.c \
+ meta.c \
+ lang.c \
+ parser.y \
+ lexer.l
+
+libgfs2_la_CPPFLAGS = \
+ -D_FILE_OFFSET_BITS=64 \
+ -D_LARGEFILE64_SOURCE \
+ -D_GNU_SOURCE \
+ -I$(top_srcdir)/gfs2/include
+
+gfs2l_SOURCES = gfs2l.c
+gfs2l_LDADD = libgfs2.la
+gfs2l_CPPFLAGS = \
+ -I$(top_srcdir)/gfs2/include \
+ -D_FILE_OFFSET_BITS=64
# Autotools can't handle header files output by flex so we have to generate it manually
lexer.h: lexer.l
diff --git a/gfs2/man/Makefile.am b/gfs2/man/Makefile.am
index 82eab9a..d73f1ed 100644
--- a/gfs2/man/Makefile.am
+++ b/gfs2/man/Makefile.am
@@ -1,12 +1,13 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-dist_man_MANS = fsck.gfs2.8 \
- gfs2.5 \
- gfs2_convert.8 \
- gfs2_edit.8 \
- gfs2_grow.8 \
- gfs2_jadd.8 \
- mkfs.gfs2.8 \
- tunegfs2.8 \
- gfs2_lockcapture.8 \
- gfs2_trace.8
+dist_man_MANS = \
+ fsck.gfs2.8 \
+ gfs2.5 \
+ gfs2_convert.8 \
+ gfs2_edit.8 \
+ gfs2_grow.8 \
+ gfs2_jadd.8 \
+ mkfs.gfs2.8 \
+ tunegfs2.8 \
+ gfs2_lockcapture.8 \
+ gfs2_trace.8
diff --git a/gfs2/mkfs/Makefile.am b/gfs2/mkfs/Makefile.am
index 475f1a8..6c49d3b 100644
--- a/gfs2/mkfs/Makefile.am
+++ b/gfs2/mkfs/Makefile.am
@@ -7,9 +7,14 @@ COMMON_CPPFLAGS = \
-I$(top_srcdir)/gfs2/include \
-I$(top_srcdir)/gfs2/libgfs2
-sbin_PROGRAMS = mkfs.gfs2 gfs2_jadd gfs2_grow
+sbin_PROGRAMS = \
+ mkfs.gfs2 \
+ gfs2_jadd \
+ gfs2_grow
-noinst_HEADERS = gfs2_mkfs.h metafs.h
+noinst_HEADERS = \
+ gfs2_mkfs.h \
+ metafs.h
mkfs_gfs2_SOURCES = main_mkfs.c
mkfs_gfs2_CPPFLAGS = $(COMMON_CPPFLAGS)
@@ -17,13 +22,19 @@ mkfs_gfs2_CFLAGS = $(blkid_CFLAGS)
mkfs_gfs2_LDFLAGS = $(blkid_LIBS)
mkfs_gfs2_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
-gfs2_grow_SOURCES = main_grow.c metafs.c
+gfs2_grow_SOURCES = \
+ main_grow.c \
+ metafs.c
+
gfs2_grow_CPPFLAGS = $(COMMON_CPPFLAGS)
gfs2_grow_CFLAGS = $(blkid_CFLAGS)
gfs2_grow_LDFLAGS = $(blkid_LIBS)
gfs2_grow_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
-gfs2_jadd_SOURCES = main_jadd.c metafs.c
+gfs2_jadd_SOURCES = \
+ main_jadd.c \
+ metafs.c
+
gfs2_jadd_CPPFLAGS = $(COMMON_CPPFLAGS)
gfs2_jadd_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/scripts/Makefile.am b/gfs2/scripts/Makefile.am
index 1c98f95..62fb2fe 100644
--- a/gfs2/scripts/Makefile.am
+++ b/gfs2/scripts/Makefile.am
@@ -1,3 +1,5 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-dist_sbin_SCRIPTS = gfs2_lockcapture gfs2_trace
+dist_sbin_SCRIPTS = \
+ gfs2_lockcapture \
+ gfs2_trace
diff --git a/gfs2/tune/Makefile.am b/gfs2/tune/Makefile.am
index 41371bc..c060183 100644
--- a/gfs2/tune/Makefile.am
+++ b/gfs2/tune/Makefile.am
@@ -1,11 +1,14 @@
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
-sbin_PROGRAMS = tunegfs2
+sbin_PROGRAMS = tunegfs2
-noinst_HEADERS = tunegfs2.h
+noinst_HEADERS = tunegfs2.h
-tunegfs2_SOURCES = main.c super.c
+tunegfs2_SOURCES = \
+ main.c \
+ super.c
-tunegfs2_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DHELPER_PROGRAM \
- -I$(top_srcdir)/gfs2/include \
- -I$(top_srcdir)/group/include
+tunegfs2_CPPFLAGS = \
+ -D_FILE_OFFSET_BITS=64 \
+ -I$(top_srcdir)/gfs2/include \
+ -I$(top_srcdir)/group/include
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3abb640..5a37319 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,14 @@
-EXTRA_DIST = $(TESTSUITE_AT) package.m4 $(TESTSUITE) atlocal atconfig
-DISTCLEANFILES = atlocal atconfig
+EXTRA_DIST = \
+ $(TESTSUITE_AT) \
+ $(TESTSUITE) \
+ package.m4 \
+ atlocal \
+ atconfig
+
+DISTCLEANFILES = \
+ atlocal \
+ atconfig
+
CLEANFILES = testvol
if HAVE_CHECK
@@ -22,12 +31,16 @@ UNIT_CPPFLAGS = \
check_PROGRAMS = $(UNIT_TESTS)
-check_meta_SOURCES = $(UNIT_SOURCES) check_meta.c
+check_meta_SOURCES = \
+ $(UNIT_SOURCES) \
+ check_meta.c
check_meta_CFLAGS = $(UNIT_CFLAGS)
check_meta_LDADD = $(UNIT_LDADD)
check_meta_CPPFLAGS = $(UNIT_CPPFLAGS)
-check_rgrp_SOURCES = $(UNIT_SOURCES) check_rgrp.c
+check_rgrp_SOURCES = \
+ $(UNIT_SOURCES) \
+ check_rgrp.c
check_rgrp_CFLAGS = $(UNIT_CFLAGS)
check_rgrp_LDADD = $(UNIT_LDADD)
check_rgrp_CPPFLAGS = $(UNIT_CPPFLAGS)
9 years, 1 month
gfs2-utils: RHEL7 - libgfs2: Remove some unused data structures
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=1021c18e...
Commit: 1021c18e8d3053f1a232661d0d2108665bf1afc0
Parent: 873b4503359aaea1270144e5a21a8c22b11175ad
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jan 15 19:09:26 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:52:44 2015 +0100
libgfs2: Remove some unused data structures
struct per_node and some fields of struct master_dir are not being used
at all, remove them.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 21 +--------------------
1 files changed, 1 insertions(+), 20 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 374d774..f1f81d3 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -236,39 +236,20 @@ struct gfs2_inode {
struct rgrp_tree *i_rgd; /* The rgrp this inode is in */
};
-/* FIXME not sure that i want to keep a record of the inodes or the
- * contents of them, or both ... if I need to write back to them, it
- * would be easier to hold the inode as well */
-struct per_node
-{
- struct gfs2_inode *inum;
- struct gfs2_inum_range inum_range;
- struct gfs2_inode *statfs;
- struct gfs2_statfs_change statfs_change;
- struct gfs2_inode *unlinked;
- struct gfs2_inode *quota;
- struct gfs2_quota_change quota_change;
-};
-
struct master_dir
{
struct gfs2_inode *inum;
uint64_t next_inum;
struct gfs2_inode *statfs;
- struct gfs2_statfs_change statfs_change;
-
- struct gfs2_rindex rindex;
struct gfs2_inode *qinode;
- struct gfs2_quota quotas;
struct gfs2_inode *jiinode;
struct gfs2_inode *riinode;
struct gfs2_inode *rooti;
struct gfs2_inode *pinode;
-
+
struct gfs2_inode **journal; /* Array of journals */
uint32_t journals; /* Journal count */
- struct per_node *pn; /* Array of per_node entries */
};
struct gfs2_sbd {
9 years, 1 month
gfs2-utils: RHEL7 - fsck.gfs2: Fetch directory inodes early in pass2()
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=873b4503...
Commit: 873b4503359aaea1270144e5a21a8c22b11175ad
Parent: 6b2eb6636469cf637937a1c8b7fe1a5ca698f048
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Mar 4 08:35:19 2015 -0600
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
fsck.gfs2: Fetch directory inodes early in pass2()
pass2() reads directory inodes twice: once indirectly through
check_dir() and again shortly afterwards to perform other checks on the
inode. To remove the duplicate reads, this patch moves the inode loading
outside of check_dir() and keeps it around for the further checks. In
order to avoid adding a fsck_inode_put() at each return point, and to
remove some levels of nesting, the directory checking has been moved
into a new pass2_check_dir() function which accepts the inode as an
argument. pass2() now fetches the inode, calls pass2_check_dir() and
then puts the inode. The patch also adds failure checking for the
fsck_load_inode() calls.
Resolves: rhbz#1154726
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/metawalk.c | 17 ++--
gfs2/fsck/metawalk.h | 2 +-
gfs2/fsck/pass2.c | 243 ++++++++++++++++++++++++++------------------------
3 files changed, 136 insertions(+), 126 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b679459..f05fb51 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1697,14 +1697,11 @@ int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return error;
}
-int check_dir(struct gfs2_sbd *sdp, uint64_t block, struct metawalk_fxns *pass)
+int check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
- struct gfs2_inode *ip;
int error = 0;
struct alloc_state as;
- ip = fsck_load_inode(sdp, block);
-
astate_save(ip, &as);
if (ip->i_di.di_flags & GFS2_DIF_EXHASH)
@@ -1718,7 +1715,6 @@ int check_dir(struct gfs2_sbd *sdp, uint64_t block, struct metawalk_fxns *pass)
if (astate_changed(ip, &as))
reprocess_inode(ip, _("Current"));
- fsck_inode_put(&ip); /* does a brelse */
return error;
}
@@ -1750,6 +1746,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
uint64_t dentryblock)
{
struct metawalk_fxns remove_dentry_fxns = {0};
+ struct gfs2_inode *ip;
uint8_t q;
int error;
@@ -1769,10 +1766,16 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
log_info( _("Parent block is not an inode...ignoring\n"));
return 1;
}
+
+ ip = fsck_load_inode(sdp, dir);
+ if (ip == NULL) {
+ stack;
+ return -1;
+ }
/* Need to run check_dir with a private var of dentryblock,
* and fxns that remove that dentry if found */
- error = check_dir(sdp, dir, &remove_dentry_fxns);
-
+ error = check_dir(sdp, ip, &remove_dentry_fxns);
+ fsck_inode_put(&ip);
return error;
}
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 057e698..779360e 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -12,7 +12,7 @@ extern int check_inode_eattr(struct gfs2_inode *ip,
struct metawalk_fxns *pass);
extern int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass);
extern int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass);
-extern int check_dir(struct gfs2_sbd *sdp, uint64_t block,
+extern int check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip,
struct metawalk_fxns *pass);
extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
struct metawalk_fxns *pass);
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 1d32335..b31fbd4 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1712,7 +1712,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
if (astate_changed(sysinode, &as))
reprocess_inode(sysinode, _("System inode"));
}
- error = check_dir(sysinode->i_sbd, iblock, &pass2_fxns);
+ error = check_dir(sysinode->i_sbd, sysinode, &pass2_fxns);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
if (error < 0) {
@@ -1807,6 +1807,116 @@ static inline int is_system_dir(struct gfs2_sbd *sdp, uint64_t block)
return FALSE;
}
+static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
+{
+ uint64_t dirblk = ip->i_di.di_num.no_addr;
+ struct dir_status ds = {0};
+ struct alloc_state as;
+ int error;
+
+ pass2_fxns.private = &ds;
+ if (ds.q == GFS2_BLKST_UNLINKED) {
+ /* First check that the directory's metatree is valid */
+ astate_save(ip, &as);
+ error = check_metatree(ip, &pass2_fxns);
+ if (error < 0) {
+ stack;
+ return error;
+ }
+ if (astate_changed(ip, &as))
+ reprocess_inode(ip, "current");
+ }
+ error = check_dir(sdp, ip, &pass2_fxns);
+ if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+ return FSCK_OK;
+ if (error < 0) {
+ stack;
+ return FSCK_ERROR;
+ }
+ if (error > 0) {
+ struct dir_info *di;
+
+ di = dirtree_find(dirblk);
+ if (!di) {
+ stack;
+ return FSCK_ERROR;
+ }
+ if (query(_("Remove directory entry for bad inode "
+ "%llu (0x%llx) in %llu (0x%llx)? (y/n)"),
+ (unsigned long long)dirblk,
+ (unsigned long long)dirblk,
+ (unsigned long long)di->treewalk_parent,
+ (unsigned long long)di->treewalk_parent)) {
+ error = remove_dentry_from_dir(sdp, di->treewalk_parent, dirblk);
+ if (error < 0) {
+ stack;
+ return FSCK_ERROR;
+ }
+ if (error > 0) {
+ log_warn(_("Unable to find dentry for %llu (0x%llx) "
+ "in %llu (0x%llx)\n"),
+ (unsigned long long)dirblk,
+ (unsigned long long)dirblk,
+ (unsigned long long)di->treewalk_parent,
+ (unsigned long long)di->treewalk_parent);
+ }
+ log_warn(_("Directory entry removed\n"));
+ } else
+ log_err(_("Directory entry to invalid inode remains.\n"));
+
+ log_debug(_("Directory block %lld (0x%llx) is now marked as 'invalid'\n"),
+ (unsigned long long)dirblk, (unsigned long long)dirblk);
+ /* Can't use fsck_blockmap_set here because we don't
+ have an inode in memory. */
+ gfs2_blockmap_set(bl, dirblk, GFS2_BLKST_FREE);
+ check_n_fix_bitmap(sdp, dirblk, 0, GFS2_BLKST_FREE);
+ }
+
+ if (!ds.dotdir) {
+ log_err(_("No '.' entry found for directory inode at block %llu (0x%llx)\n"),
+ (unsigned long long)dirblk, (unsigned long long)dirblk);
+
+ if (query( _("Is it okay to add '.' entry? (y/n) "))) {
+ astate_save(ip, &as);
+ error = dir_add(ip, ".", 1, &(ip->i_di.di_num),
+ (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
+ if (error) {
+ log_err(_("Error adding directory %s: %s\n"), "'.'",
+ strerror(errno));
+ return -errno;
+ }
+ if (astate_changed(ip, &as)) {
+ char dirname[80];
+
+ sprintf(dirname, _("Directory at %lld (0x%llx)"),
+ (unsigned long long)dirblk,
+ (unsigned long long)dirblk);
+ reprocess_inode(ip, dirname);
+ }
+ /* directory links to itself via '.' */
+ incr_link_count(ip->i_di.di_num, ip, _("\". (itself)\""));
+ ds.entry_count++;
+ log_err(_("The directory was fixed.\n"));
+ } else {
+ log_err(_("The directory was not fixed.\n"));
+ }
+ }
+
+ if (!fsck_abort && ip->i_di.di_entries != ds.entry_count) {
+ log_err(_("Entries is %d - should be %d for inode block %llu (0x%llx)\n"),
+ ip->i_di.di_entries, ds.entry_count,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
+ if (query(_("Fix the entry count? (y/n) "))) {
+ ip->i_di.di_entries = ds.entry_count;
+ bmodified(ip->i_bh);
+ } else {
+ log_err(_("The entry count was not fixed.\n"));
+ }
+ }
+ return FSCK_OK;
+}
+
/* What i need to do in this pass is check that the dentries aren't
* pointing to invalid blocks...and verify the contents of each
* directory. and start filling in the directory info structure*/
@@ -1821,12 +1931,7 @@ static inline int is_system_dir(struct gfs2_sbd *sdp, uint64_t block)
int pass2(struct gfs2_sbd *sdp)
{
uint64_t dirblk;
- struct alloc_state as;
uint8_t q;
- struct dir_status ds = {0};
- struct gfs2_inode *ip;
- int error = 0;
- struct dir_info *dt;
/* Check all the system directory inodes. */
if (!sdp->gfs1 &&
@@ -1859,6 +1964,10 @@ int pass2(struct gfs2_sbd *sdp)
log_info( _("Checking directory inodes.\n"));
/* Grab each directory inode, and run checks on it */
for (dirblk = 0; dirblk < last_fs_block; dirblk++) {
+ struct gfs2_inode *ip;
+ struct dir_info *dt;
+ int error;
+
warm_fuzzy_stuff(dirblk);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
@@ -1868,7 +1977,6 @@ int pass2(struct gfs2_sbd *sdp)
continue;
q = block_type(dirblk);
-
if (q != GFS2_BLKST_DINODE)
continue;
@@ -1884,125 +1992,24 @@ int pass2(struct gfs2_sbd *sdp)
continue;
}
- log_debug( _("Checking directory inode at block %llu (0x%llx)\n"),
+ log_debug(_("Checking directory inode at block %llu (0x%llx)\n"),
(unsigned long long)dirblk, (unsigned long long)dirblk);
- memset(&ds, 0, sizeof(ds));
- pass2_fxns.private = (void *) &ds;
- if (ds.q == GFS2_BLKST_UNLINKED) {
- /* First check that the directory's metatree
- * is valid */
- ip = fsck_load_inode(sdp, dirblk);
- astate_save(ip, &as);
- error = check_metatree(ip, &pass2_fxns);
- if (error < 0) {
- stack;
- fsck_inode_put(&ip);
- return error;
- }
- if (astate_changed(ip, &as))
- reprocess_inode(ip, "current");
- fsck_inode_put(&ip);
- }
- error = check_dir(sdp, dirblk, &pass2_fxns);
- if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
- return FSCK_OK;
- if (error < 0) {
+ ip = fsck_load_inode(sdp, dirblk);
+ if (ip == NULL) {
stack;
return FSCK_ERROR;
}
- if (error > 0) {
- struct dir_info *di;
+ error = pass2_check_dir(sdp, ip);
+ fsck_inode_put(&ip);
- di = dirtree_find(dirblk);
- if (!di) {
- stack;
- return FSCK_ERROR;
- }
- if (query( _("Remove directory entry for bad"
- " inode %llu (0x%llx) in %llu"
- " (0x%llx)? (y/n)"),
- (unsigned long long)dirblk,
- (unsigned long long)dirblk,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent)) {
- error = remove_dentry_from_dir(sdp, di->treewalk_parent,
- dirblk);
- if (error < 0) {
- stack;
- return FSCK_ERROR;
- }
- if (error > 0) {
- log_warn( _("Unable to find dentry for %llu"
- " (0x%llx) in %llu"
- " (0x%llx)\n"),
- (unsigned long long)dirblk,
- (unsigned long long)dirblk,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent);
- }
- log_warn( _("Directory entry removed\n"));
- } else
- log_err( _("Directory entry to invalid inode remains.\n"));
- log_debug( _("Directory block %lld (0x%llx) "
- "is now marked as 'invalid'\n"),
- (unsigned long long)dirblk,
- (unsigned long long)dirblk);
- /* Can't use fsck_blockmap_set here because we don't
- have an inode in memory. */
- gfs2_blockmap_set(bl, dirblk, GFS2_BLKST_FREE);
- check_n_fix_bitmap(sdp, dirblk, 0, GFS2_BLKST_FREE);
- }
- ip = fsck_load_inode(sdp, dirblk);
- if (!ds.dotdir) {
- log_err(_("No '.' entry found for directory inode at "
- "block %llu (0x%llx)\n"),
- (unsigned long long)dirblk,
- (unsigned long long)dirblk);
-
- if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- astate_save(ip, &as);
- error = dir_add(ip, ".", 1, &(ip->i_di.di_num),
- (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
- if (error) {
- log_err(_("Error adding directory %s: %s\n"), "'.'",
- strerror(errno));
- fsck_inode_put(&ip);
- return -errno;
- }
- if (astate_changed(ip, &as)) {
- char dirname[80];
-
- sprintf(dirname, _("Directory at %lld "
- "(0x%llx)"),
- (unsigned long long)dirblk,
- (unsigned long long)dirblk);
- reprocess_inode(ip, dirname);
- }
- /* directory links to itself via '.' */
- incr_link_count(ip->i_di.di_num, ip,
- _("\". (itself)\""));
- ds.entry_count++;
- log_err( _("The directory was fixed.\n"));
- } else {
- log_err( _("The directory was not fixed.\n"));
- }
- }
+ if (skip_this_pass || fsck_abort)
+ return FSCK_OK;
- if (!fsck_abort && ip->i_di.di_entries != ds.entry_count) {
- log_err( _("Entries is %d - should be %d for inode "
- "block %llu (0x%llx)\n"),
- ip->i_di.di_entries, ds.entry_count,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- if (query( _("Fix the entry count? (y/n) "))) {
- ip->i_di.di_entries = ds.entry_count;
- bmodified(ip->i_bh);
- } else {
- log_err( _("The entry count was not fixed.\n"));
- }
+ if (error != FSCK_OK) {
+ stack;
+ return error;
}
- fsck_inode_put(&ip); /* does a gfs2_dinode_out, brelse */
}
return FSCK_OK;
}
9 years, 1 month
gfs2-utils: RHEL7 - gfs2_edit savemeta: Don't read rgrps twice
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=6b2eb663...
Commit: 6b2eb6636469cf637937a1c8b7fe1a5ca698f048
Parent: 8960e299cf520a1c41613bc66f3a91c3d52997e9
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 25 17:01:33 2015 -0600
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
gfs2_edit savemeta: Don't read rgrps twice
By the time savemeta() is called the rindex has already been read into
memory, and before savemeta() processes each resource group it calls
gfs2_rgrp_read() to read in the rgrp header. It frees the rgrp once it's
done with it.
Strangely, before processing the resource groups, savemeta() reads the
superblock a second time and calls ri_update() which reads the rindex
again, as well as reading in every rgrp header to be kept in memory for
the duration. This caused high memory usage and a noticeable performance
reduction when saving metadata of large file systems.
To solve these problems, this patch removes the code which re-reads the
superblock, rindex and the rgrps. The code which reads the rindex has
been reorganised for clarity and the sbd.fssize field is now set
properly at that point.
With this patch, using a large fs, I'm seeing improvements similar to:
Before: 43:36.12elapsed 10822268maxresident k
After: 28:44.67elapsed 226980maxresident k
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 15 +++++++++++-
gfs2/edit/savemeta.c | 58 ++++++-------------------------------------------
tests/edit.at | 4 +-
3 files changed, 22 insertions(+), 55 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index dd4b625..4df1b9f 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -966,8 +966,6 @@ static int block_has_extended_info(void)
/* ------------------------------------------------------------------------ */
static void read_superblock(int fd)
{
- int count, sane;
-
sbd1 = (struct gfs_sb *)&sbd.sd_sb;
ioctl(fd, BLKFLSBUF, 0);
memset(&sbd, 0, sizeof(struct gfs2_sbd));
@@ -1033,9 +1031,20 @@ static void read_superblock(int fd)
gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
}
}
+}
+
+static int read_rindex(void)
+{
+ struct gfs2_rindex *ri;
+ int count, sane;
+
sbd.fssize = sbd.device.length;
if (sbd.md.riinode) /* If we found the rindex */
rindex_read(&sbd, 0, &count, &sane);
+
+ ri = &((struct rgrp_tree *)osi_last(&sbd.rgtree))->ri;
+ sbd.fssize = ri->ri_data0 + ri->ri_data;
+ return 0;
}
/* ------------------------------------------------------------------------ */
@@ -2539,6 +2548,8 @@ int main(int argc, char *argv[])
max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
read_superblock(fd);
+ if (read_rindex())
+ exit(-1);
max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
if (sbd.gfs1)
edit_row[GFS2_MODE]++;
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 5d30d28..b68b0ff 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -721,75 +721,32 @@ static int check_header(struct savemeta_header *smh)
void savemeta(char *out_fn, int saveoption, int gziplevel)
{
- int rgcount;
uint64_t jindex_block;
struct gfs2_buffer_head *lbh;
struct metafd mfd;
- int sane;
- struct osi_node *n, *next = NULL;
+ struct osi_node *n;
int err = 0;
sbd.md.journals = 1;
mfd = savemetaopen(out_fn, gziplevel);
- lseek(sbd.device_fd, 0, SEEK_SET);
blks_saved = 0;
- if (!sbd.gfs1)
- sbd.bsize = GFS2_DEFAULT_BSIZE;
- if (lgfs2_get_dev_info(sbd.device_fd, &sbd.dinfo)) {
- perror(device);
- exit(-1);
- }
- fix_device_geometry(&sbd);
- sbd.rgtree.osi_node = NULL;
- if (!sbd.gfs1)
- sbd.sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
- if (compute_constants(&sbd)) {
- fprintf(stderr, "Bad constants (1)\n");
- exit(-1);
- }
- if (read_sb(&sbd) < 0) {
- fprintf(stderr, "Unable to read superblock.\n");
- exit(-1);
- }
if (sbd.gfs1)
sbd.bsize = sbd.sd_sb.sb_bsize;
- printf("There are %llu blocks of %u bytes in the destination "
- "device.\n", (unsigned long long)sbd.fssize, sbd.bsize);
- if (sbd.gfs1) {
- sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
- if (sbd.md.riinode == NULL) {
- fprintf(stderr, "Unable to read rindex: %s.\n", strerror(errno));
- exit(-1);
- }
+ printf("There are %llu blocks of %u bytes in the filesystem.\n",
+ (unsigned long long)sbd.fssize, sbd.bsize);
+ if (sbd.gfs1)
jindex_block = sbd1->sb_jindex_di.no_addr;
- } else {
- sbd.master_dir = lgfs2_inode_read(&sbd,
- sbd.sd_sb.sb_master_dir.no_addr);
- if (sbd.master_dir == NULL) {
- fprintf(stderr, "Unable to read master: %s.\n", strerror(errno));
- exit(-1);
- }
-
- gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
+ else
jindex_block = masterblock("jindex");
- }
lbh = bread(&sbd, jindex_block);
gfs2_dinode_in(&di, lbh);
if (!sbd.gfs1)
do_dinode_extended(&di, lbh);
brelse(lbh);
- printf("Reading resource groups...");
- fflush(stdout);
- if (sbd.gfs1)
- gfs1_ri_update(&sbd, 0, &rgcount, 0);
- else
- ri_update(&sbd, 0, &rgcount, &sane);
- printf("Done. File system size: %s\n\n", anthropomorphize(sbd.fssize * sbd.bsize));
- fflush(stdout);
-
+ printf("Filesystem size: %s\n", anthropomorphize(sbd.fssize * sbd.bsize));
get_journal_inode_blocks();
/* Write the savemeta file header */
@@ -818,10 +775,9 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
}
}
/* Walk through the resource groups saving everything within */
- for (n = osi_first(&sbd.rgtree); n; n = next) {
+ for (n = osi_first(&sbd.rgtree); n; n = osi_next(n)) {
struct rgrp_tree *rgd;
- next = osi_next(n);
rgd = (struct rgrp_tree *)n;
if (gfs2_rgrp_read(&sbd, rgd))
continue;
diff --git a/tests/edit.at b/tests/edit.at
index e3f02e6..3bd4163 100644
--- a/tests/edit.at
+++ b/tests/edit.at
@@ -6,8 +6,8 @@ AT_KEYWORDS(gfs2_edit edit)
GFS_TGT_REGEN
AT_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT $(($(gfs_max_blocks 4096)/2))], 0, [ignore], [ignore])
AT_CHECK([gfs2_edit savemeta $GFS_TGT test.meta > savemeta.log], 0, [ignore], [ignore])
-AT_CHECK([head -2 savemeta.log], 0, [There are 2621440 blocks of 4096 bytes in the destination device.
-Reading resource groups...Done. File system size: 4.1023GB
+AT_CHECK([head -2 savemeta.log], 0, [There are 1310718 blocks of 4096 bytes in the filesystem.
+Filesystem size: 4.1023GB
], [ignore])
GFS_TGT_REGEN
AT_CHECK([gfs2_edit restoremeta test.meta $GFS_TGT], 0, [ignore], [ignore])
9 years, 1 month
gfs2-utils: RHEL7 - fsck.gfs2: Fix coverity error in pass4.c
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=8960e299...
Commit: 8960e299cf520a1c41613bc66f3a91c3d52997e9
Parent: 554ab685599e08d0543d218d529dbb0925040b95
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Feb 26 09:49:07 2015 -0600
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
fsck.gfs2: Fix coverity error in pass4.c
This simple patch checks for lf_dip (the lost+found inode) being NULL,
and if it is, returns at the end of function scan_inode_list. This is
fixing a false positive spotted by coverity, but it makes the code a
bit more intuitive.
---
gfs2/fsck/pass4.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index f307782..850a2fe 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -177,7 +177,9 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
(unsigned long long)ii->di_num.no_addr, ii->di_nlink);
} /* osi_list_foreach(tmp, list) */
- if (lf_dip && astate_changed(lf_dip, &lf_as))
+ if (lf_dip == NULL)
+ return 0;
+ if (astate_changed(lf_dip, &lf_as))
reprocess_inode(lf_dip, "lost+found");
if (lf_addition) {
9 years, 1 month
gfs2-utils: RHEL7 - gfs2_grow/jadd: Use a matching context mount option in mount_gfs2_meta
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=554ab685...
Commit: 554ab685599e08d0543d218d529dbb0925040b95
Parent: 439b337f0ce36cf960b2331e6fa7f000120a3f01
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Feb 23 17:36:12 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
gfs2_grow/jadd: Use a matching context mount option in mount_gfs2_meta
On a system with SELinux enabled, if a gfs2 file system is mounted with
a context= option, the tools gfs2_grow and gfs2_jadd will fail with
"Invalid argument". This is due to SELinux failing the mount due to an
mismatched context ("SELinux: mount invalid. Same superblock, different
security settings").
In order to work around this, parse the context option of the mntent
relating to the gfs2 mount point and use it in mount_gfs2_meta().
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_grow.c | 1 +
gfs2/mkfs/main_jadd.c | 2 +-
gfs2/mkfs/metafs.c | 23 ++++++++++++++++++++++-
gfs2/mkfs/metafs.h | 2 ++
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index c3ae4b7..6ba14b0 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -396,6 +396,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
fix_device_geometry(sdp);
+ mfs.context = copy_context_opt(mnt);
if (mount_gfs2_meta(&mfs, mnt->mnt_dir, (print_level > MSG_NOTICE))) {
perror(_("Failed to mount GFS2 meta file system"));
exit(EXIT_FAILURE);
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index d83ec2b..9190d44 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -520,7 +520,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
gather_info(sdp, &opts);
-
+ mfs.context = copy_context_opt(mnt);
if (mount_gfs2_meta(&mfs, mnt->mnt_dir, opts.debug)) {
perror("GFS2 metafs");
exit(EXIT_FAILURE);
diff --git a/gfs2/mkfs/metafs.c b/gfs2/mkfs/metafs.c
index 12b1cdb..112ce2d 100644
--- a/gfs2/mkfs/metafs.c
+++ b/gfs2/mkfs/metafs.c
@@ -9,6 +9,7 @@
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
+#include <mntent.h>
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
@@ -70,7 +71,7 @@ int mount_gfs2_meta(struct metafs *mfs, const char *path, int debug)
setsigs(sighandler);
- ret = mount(path, mfs->path, "gfs2meta", 0, NULL);
+ ret = mount(path, mfs->path, "gfs2meta", 0, mfs->context);
if (ret)
goto err_rmdir;
@@ -115,4 +116,24 @@ void cleanup_metafs(struct metafs *mfs)
free(mfs->path);
mfs->path = NULL;
+ free(mfs->context);
+ mfs->context = NULL;
+}
+
+/**
+ * Returns a duplicate of the 'context' mount option, or NULL if not found.
+ */
+char *copy_context_opt(struct mntent *mnt)
+{
+ char *ctx, *end;
+
+ ctx = hasmntopt(mnt, "context");
+ if (ctx == NULL)
+ return NULL;
+
+ end = strchr(ctx, ',');
+ if (end == NULL)
+ return NULL;
+
+ return strndup(ctx, end - ctx);
}
diff --git a/gfs2/mkfs/metafs.h b/gfs2/mkfs/metafs.h
index a765634..1372977 100644
--- a/gfs2/mkfs/metafs.h
+++ b/gfs2/mkfs/metafs.h
@@ -6,9 +6,11 @@ extern int metafs_interrupted;
struct metafs {
int fd;
char *path;
+ char *context; /* 'context=' mount option */
};
extern int mount_gfs2_meta(struct metafs *mfs, const char *path, int debug);
extern void cleanup_metafs(struct metafs *mfs);
+extern char *copy_context_opt(struct mntent *mnt);
#endif /* METAFS_H */
9 years, 1 month
gfs2-utils: RHEL7 - gfs2-utils: Move metafs handling into gfs2/mkfs/
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=439b337f...
Commit: 439b337f0ce36cf960b2331e6fa7f000120a3f01
Parent: cb2f650eb5d27dfc628c99ea2a7f1446322ef88a
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Feb 23 17:18:48 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
gfs2-utils: Move metafs handling into gfs2/mkfs/
gfs2_grow and gfs2_jadd are the two remaining mounters of the metafs so
move the high-level metafs mounting bits from libgfs2/misc.c into the
mkfs directory and give them a suitable interface.
This allows the metafs-related fields to be removed from struct gfs2_sbd
and the metafs_interrupted flag and the signal handling functions
exported by libgfs2 to be pushed down into the applications.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 7 ---
gfs2/libgfs2/misc.c | 111 ---------------------------------------------
gfs2/mkfs/Makefile.am | 6 +-
gfs2/mkfs/main_grow.c | 10 +++--
gfs2/mkfs/main_jadd.c | 40 +++++++++-------
gfs2/mkfs/metafs.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++
gfs2/mkfs/metafs.h | 14 ++++++
7 files changed, 163 insertions(+), 143 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 4d1e540..374d774 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -324,8 +324,6 @@ struct gfs2_sbd {
struct gfs2_inode *master_dir;
struct master_dir md;
- int metafs_fd;
- char *metafs_path; /* where metafs is mounted */
struct special_blocks eattr_blocks;
uint64_t rg_one_length;
@@ -665,17 +663,12 @@ extern void gfs_rgrp_in(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
extern void gfs_rgrp_out(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
/* misc.c */
-
-extern int metafs_interrupted;
-
extern int compute_heightsize(unsigned bsize, uint64_t *heightsize,
uint32_t *maxheight, uint32_t bsize1, int diptrs, int inptrs);
extern int compute_constants(struct gfs2_sbd *sdp);
extern int lgfs2_open_mnt(const char *path, int dirflags, int *dirfd, int devflags, int *devfd, struct mntent **mnt);
extern int lgfs2_open_mnt_dev(const char *path, int flags, struct mntent **mnt);
extern int lgfs2_open_mnt_dir(const char *path, int flags, struct mntent **mnt);
-extern int mount_gfs2_meta(struct gfs2_sbd *sdp, const char *path);
-extern void cleanup_metafs(struct gfs2_sbd *sdp);
/* recovery.c */
extern void gfs2_replay_incr_blk(struct gfs2_inode *ip, unsigned int *blk);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index c72af55..cb2a231 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -1,32 +1,17 @@
#include "clusterautoconfig.h"
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <time.h>
-#include <errno.h>
-#include <sys/mount.h>
-#include <linux/types.h>
-#include <sys/file.h>
-#include <dirent.h>
-#include <sys/sysmacros.h>
-#include <mntent.h>
-#include <signal.h>
#include "libgfs2.h"
-#include "config.h"
#define PAGE_SIZE (4096)
#define DIV_RU(x, y) (((x) + (y) - 1) / (y))
-int metafs_interrupted = 0;
-
int compute_heightsize(unsigned bsize, uint64_t *heightsize,
uint32_t *maxheight, uint32_t bsize1, int diptrs, int inptrs)
{
@@ -197,99 +182,3 @@ int lgfs2_open_mnt_dir(const char *path, int flags, struct mntent **mnt)
close(devfd);
return dirfd;
}
-
-static int lock_for_admin(struct gfs2_sbd *sdp)
-{
- int error;
-
- if (cfg_debug)
- printf("\nTrying to get admin lock...\n");
-
- sdp->metafs_fd = open(sdp->metafs_path, O_RDONLY | O_NOFOLLOW);
- if (sdp->metafs_fd < 0)
- return -1;
-
- error = flock(sdp->metafs_fd, LOCK_EX);
- if (error) {
- close(sdp->metafs_fd);
- return -1;
- }
- if (cfg_debug)
- printf("Got it.\n");
- return 0;
-}
-
-static void sighandler(int error)
-{
- metafs_interrupted = 1;
-}
-
-static void setsigs(void (*handler)(int))
-{
- struct sigaction sa = { .sa_handler = handler };
-
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGILL, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGABRT, &sa, NULL);
- sigaction(SIGCONT, &sa, NULL);
- sigaction(SIGUSR1, &sa, NULL);
- sigaction(SIGUSR2, &sa, NULL);
-}
-
-int mount_gfs2_meta(struct gfs2_sbd *sdp, const char *path)
-{
- int ret;
-
- sdp->metafs_path = strdup("/tmp/.gfs2meta.XXXXXX");
- if (sdp->metafs_path == NULL)
- return -1;
-
- if(!mkdtemp(sdp->metafs_path))
- goto err_free;
-
- setsigs(sighandler);
-
- ret = mount(path, sdp->metafs_path, "gfs2meta", 0, NULL);
- if (ret)
- goto err_rmdir;
-
- if (lock_for_admin(sdp))
- goto err_umount;
-
- return 0;
-
-err_umount:
- if (umount(sdp->metafs_path))
- fprintf(stderr, "Could not unmount %s: %s\n", sdp->metafs_path, strerror(errno));
- setsigs(SIG_DFL);
-err_rmdir:
- rmdir(sdp->metafs_path);
-err_free:
- free(sdp->metafs_path);
- sdp->metafs_path = NULL;
- return -1;
-}
-
-void cleanup_metafs(struct gfs2_sbd *sdp)
-{
- int ret;
-
- if (sdp->metafs_fd <= 0)
- return;
-
- fsync(sdp->metafs_fd);
- close(sdp->metafs_fd);
- ret = umount(sdp->metafs_path);
- if (ret)
- fprintf(stderr, "Couldn't unmount %s : %s\n",
- sdp->metafs_path, strerror(errno));
- else
- rmdir(sdp->metafs_path);
-
- setsigs(SIG_DFL);
- metafs_interrupted = 0;
- free(sdp->metafs_path);
- sdp->metafs_path = NULL;
-}
diff --git a/gfs2/mkfs/Makefile.am b/gfs2/mkfs/Makefile.am
index 822b41e..475f1a8 100644
--- a/gfs2/mkfs/Makefile.am
+++ b/gfs2/mkfs/Makefile.am
@@ -9,7 +9,7 @@ COMMON_CPPFLAGS = \
sbin_PROGRAMS = mkfs.gfs2 gfs2_jadd gfs2_grow
-noinst_HEADERS = gfs2_mkfs.h
+noinst_HEADERS = gfs2_mkfs.h metafs.h
mkfs_gfs2_SOURCES = main_mkfs.c
mkfs_gfs2_CPPFLAGS = $(COMMON_CPPFLAGS)
@@ -17,13 +17,13 @@ mkfs_gfs2_CFLAGS = $(blkid_CFLAGS)
mkfs_gfs2_LDFLAGS = $(blkid_LIBS)
mkfs_gfs2_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
-gfs2_grow_SOURCES = main_grow.c
+gfs2_grow_SOURCES = main_grow.c metafs.c
gfs2_grow_CPPFLAGS = $(COMMON_CPPFLAGS)
gfs2_grow_CFLAGS = $(blkid_CFLAGS)
gfs2_grow_LDFLAGS = $(blkid_LIBS)
gfs2_grow_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
-gfs2_jadd_SOURCES = main_jadd.c
+gfs2_jadd_SOURCES = main_jadd.c metafs.c
gfs2_jadd_CPPFLAGS = $(COMMON_CPPFLAGS)
gfs2_jadd_LDADD = $(top_builddir)/gfs2/libgfs2/libgfs2.la
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 3ab8e72..c3ae4b7 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -27,6 +27,7 @@
#include <logging.h>
#include "libgfs2.h"
#include "gfs2_mkfs.h"
+#include "metafs.h"
#define BUF_SIZE 4096
#define MB (1024 * 1024)
@@ -359,6 +360,7 @@ int main(int argc, char *argv[])
decode_arguments(argc, argv, sdp);
for(; (argc - optind) > 0; optind++) {
+ struct metafs mfs = {0};
struct mntent *mnt;
unsigned rgcount;
unsigned old_rg_count;
@@ -394,13 +396,13 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
fix_device_geometry(sdp);
- if (mount_gfs2_meta(sdp, mnt->mnt_dir)) {
+ if (mount_gfs2_meta(&mfs, mnt->mnt_dir, (print_level > MSG_NOTICE))) {
perror(_("Failed to mount GFS2 meta file system"));
exit(EXIT_FAILURE);
}
- rindex_fd = open_rindex(sdp->metafs_path, (test ? O_RDONLY : O_RDWR));
+ rindex_fd = open_rindex(mfs.path, (test ? O_RDONLY : O_RDWR));
if (rindex_fd < 0) {
- cleanup_metafs(sdp);
+ cleanup_metafs(&mfs);
exit(EXIT_FAILURE);
}
/* Get master dinode */
@@ -456,7 +458,7 @@ int main(int argc, char *argv[])
out:
lgfs2_rgrps_free(&rgs);
close(rindex_fd);
- cleanup_metafs(sdp);
+ cleanup_metafs(&mfs);
close(sdp->device_fd);
if (metafs_interrupted)
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index fea474a..d83ec2b 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -24,6 +24,7 @@
#include <linux/types.h>
#include "libgfs2.h"
#include "gfs2_mkfs.h"
+#include "metafs.h"
#define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0)))
@@ -38,25 +39,26 @@ struct jadd_opts {
unsigned debug:1;
};
-static void
-make_jdata(int fd, const char *value)
+#define JA_FL_SET 0
+#define JA_FL_CLEAR 1
+static void set_flags(int fd, int op, uint32_t flags)
{
int err;
- uint32_t val;
+ uint32_t val;
err = ioctl(fd, FS_IOC_GETFLAGS, &val);
- if (err){
+ if (err) {
perror("GETFLAGS");
exit(EXIT_FAILURE);
}
- if (strcmp(value, "set") == 0)
- val |= FS_JOURNAL_DATA_FL;
- if (strcmp(value, "clear") == 0)
- val &= ~FS_JOURNAL_DATA_FL;
- err = ioctl(fd, FS_IOC_SETFLAGS, &val);
+ if (op == JA_FL_SET)
+ val |= flags;
+ else if (op == JA_FL_CLEAR)
+ val &= ~flags;
- if (err){
+ err = ioctl(fd, FS_IOC_SETFLAGS, &val);
+ if (err) {
perror("SETFLAGS");
exit(EXIT_FAILURE);
}
@@ -272,7 +274,8 @@ static void add_ir(struct jadd_opts *opts)
{
struct gfs2_inum_range ir;
- make_jdata(fd, "set");
+
+ set_flags(fd, JA_FL_SET, FS_JOURNAL_DATA_FL);
memset(&ir, 0, sizeof(struct gfs2_inum_range));
if (write(fd, (void*)&ir, sizeof(struct gfs2_inum_range)) !=
sizeof(struct gfs2_inum_range)) {
@@ -301,7 +304,7 @@ static void add_sc(struct jadd_opts *opts)
{
struct gfs2_statfs_change sc;
- make_jdata(fd, "set");
+ set_flags(fd, JA_FL_SET, FS_JOURNAL_DATA_FL);
memset(&sc, 0, sizeof(struct gfs2_statfs_change));
if (write(fd, (void*)&sc, sizeof(struct gfs2_statfs_change)) !=
@@ -338,7 +341,7 @@ static void add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts)
struct gfs2_buffer_head dummy_bh;
dummy_bh.b_data = buf;
- make_jdata(fd, "clear");
+ set_flags(fd, JA_FL_CLEAR, FS_JOURNAL_DATA_FL);
memset(buf, 0, sdp->bsize);
for (x=0; x<blocks; x++) {
@@ -433,7 +436,7 @@ static void add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
struct gfs2_log_header lh;
uint64_t seq = RANDOM(blocks);
- make_jdata(fd, "clear");
+ set_flags(fd, JA_FL_CLEAR, FS_JOURNAL_DATA_FL);
memset(buf, 0, sdp->bsize);
for (x=0; x<blocks; x++) {
if (write(fd, buf, sdp->bsize) != sdp->bsize) {
@@ -491,6 +494,7 @@ int main(int argc, char *argv[])
{
struct jadd_opts opts = {0};
struct gfs2_sbd sbd, *sdp = &sbd;
+ struct metafs mfs = {0};
struct mntent *mnt;
unsigned int total;
@@ -517,12 +521,12 @@ int main(int argc, char *argv[])
}
gather_info(sdp, &opts);
- if (mount_gfs2_meta(sdp, mnt->mnt_dir)) {
+ if (mount_gfs2_meta(&mfs, mnt->mnt_dir, opts.debug)) {
perror("GFS2 metafs");
exit(EXIT_FAILURE);
}
- if (build_paths(sdp->metafs_path, &opts)) {
+ if (build_paths(mfs.path, &opts)) {
perror(_("Failed to build paths"));
exit(EXIT_FAILURE);
}
@@ -538,7 +542,7 @@ int main(int argc, char *argv[])
opts.journals < total;
opts.journals++) {
if (metafs_interrupted) {
- cleanup_metafs(&sbd);
+ cleanup_metafs(&mfs);
exit(130);
}
add_ir(&opts);
@@ -551,7 +555,7 @@ int main(int argc, char *argv[])
free(opts.per_node);
free(opts.jindex);
close(sdp->path_fd);
- cleanup_metafs(sdp);
+ cleanup_metafs(&mfs);
sync();
print_results(&opts);
diff --git a/gfs2/mkfs/metafs.c b/gfs2/mkfs/metafs.c
new file mode 100644
index 0000000..12b1cdb
--- /dev/null
+++ b/gfs2/mkfs/metafs.c
@@ -0,0 +1,118 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include <libintl.h>
+#include <locale.h>
+#define _(String) gettext(String)
+
+#include "metafs.h"
+
+int metafs_interrupted;
+
+static int lock_for_admin(struct metafs *mfs, int debug)
+{
+ int error;
+
+ if (debug)
+ printf(_("Trying to get admin lock..."));
+
+ mfs->fd = open(mfs->path, O_RDONLY | O_NOFOLLOW);
+ if (mfs->fd < 0)
+ return -1;
+
+ error = flock(mfs->fd, LOCK_EX);
+ if (error) {
+ close(mfs->fd);
+ return -1;
+ }
+ if (debug)
+ printf(_("locked.\n"));
+ return 0;
+}
+
+static void sighandler(int error)
+{
+ metafs_interrupted = 1;
+}
+
+static void setsigs(void (*handler)(int))
+{
+ struct sigaction sa = { .sa_handler = handler };
+
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGILL, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGABRT, &sa, NULL);
+ sigaction(SIGCONT, &sa, NULL);
+ sigaction(SIGUSR1, &sa, NULL);
+ sigaction(SIGUSR2, &sa, NULL);
+}
+
+int mount_gfs2_meta(struct metafs *mfs, const char *path, int debug)
+{
+ int ret;
+
+ mfs->path = strdup("/tmp/.gfs2meta.XXXXXX");
+ if (mfs->path == NULL)
+ return -1;
+
+ if(!mkdtemp(mfs->path))
+ goto err_free;
+
+ setsigs(sighandler);
+
+ ret = mount(path, mfs->path, "gfs2meta", 0, NULL);
+ if (ret)
+ goto err_rmdir;
+
+ if (lock_for_admin(mfs, debug))
+ goto err_umount;
+
+ return 0;
+
+err_umount:
+ if (umount(mfs->path))
+ /* Translators: the first %s here is a path, the second is an error message */
+ fprintf(stderr, _("Could not unmount %s: %s\n"),
+ mfs->path, strerror(errno));
+ setsigs(SIG_DFL);
+err_rmdir:
+ rmdir(mfs->path);
+err_free:
+ free(mfs->path);
+ mfs->path = NULL;
+ return -1;
+}
+
+void cleanup_metafs(struct metafs *mfs)
+{
+ int ret;
+
+ if (mfs->fd <= 0)
+ return;
+
+ fsync(mfs->fd);
+ close(mfs->fd);
+ ret = umount(mfs->path);
+ if (ret)
+ /* Translators: the first %s here is a path, the second is an error message */
+ fprintf(stderr, "Could not unmount %s : %s\n",
+ mfs->path, strerror(errno));
+ else
+ rmdir(mfs->path);
+
+ setsigs(SIG_DFL);
+ metafs_interrupted = 0;
+
+ free(mfs->path);
+ mfs->path = NULL;
+}
diff --git a/gfs2/mkfs/metafs.h b/gfs2/mkfs/metafs.h
new file mode 100644
index 0000000..a765634
--- /dev/null
+++ b/gfs2/mkfs/metafs.h
@@ -0,0 +1,14 @@
+#ifndef METAFS_H
+#define METAFS_H
+
+extern int metafs_interrupted;
+
+struct metafs {
+ int fd;
+ char *path;
+};
+
+extern int mount_gfs2_meta(struct metafs *mfs, const char *path, int debug);
+extern void cleanup_metafs(struct metafs *mfs);
+
+#endif /* METAFS_H */
9 years, 1 month
gfs2-utils: RHEL7 - libgfs2: Remove some obsolete function declarations
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=cb2f650e...
Commit: cb2f650eb5d27dfc628c99ea2a7f1446322ef88a
Parent: 156b36b3637abfbc03f46b9fc7da5d5c23d031ec
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Feb 16 17:08:10 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
libgfs2: Remove some obsolete function declarations
These functions no longer exist or never existed so there's no need to
declare them in libgfs2.h
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 2907e8c..4d1e540 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -674,11 +674,8 @@ extern int compute_constants(struct gfs2_sbd *sdp);
extern int lgfs2_open_mnt(const char *path, int dirflags, int *dirfd, int devflags, int *devfd, struct mntent **mnt);
extern int lgfs2_open_mnt_dev(const char *path, int flags, struct mntent **mnt);
extern int lgfs2_open_mnt_dir(const char *path, int flags, struct mntent **mnt);
-extern int find_gfs2_meta(struct gfs2_sbd *sdp);
-extern int dir_exists(const char *dir);
extern int mount_gfs2_meta(struct gfs2_sbd *sdp, const char *path);
extern void cleanup_metafs(struct gfs2_sbd *sdp);
-extern int is_fsname(char *name);
/* recovery.c */
extern void gfs2_replay_incr_blk(struct gfs2_inode *ip, unsigned int *blk);
9 years, 1 month
gfs2-utils: RHEL7 - libgfs2: Use the correct parent for rgrp tree insertion
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=156b36b3...
Commit: 156b36b3637abfbc03f46b9fc7da5d5c23d031ec
Parent: 03a7bea1ace2ab3b8bd753662b6b848027a6e9b8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 19 23:55:53 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
libgfs2: Use the correct parent for rgrp tree insertion
lgfs2_rgrps_append() was using the parent of the last rgrp instead of
the last rgrp itself as the intended parent when inserting new rgrps
into the tree. This left the tree unbalanced in such a way as to make
lookups of the last node in the tree effectively a linear list search.
This was done for each rgrp insertion so, although it didn't cause a
noticeable slow-down for smaller file sytems, tests on 250TB volumes
requiring over a million resource groups would become CPU bound and
could take hours to complete.
This patch fixes lgfs2_rgrps_append() to use the correct parent node for
rgrp tree insertions, giving a significant performance improvement when
creating file systems on large volumes.
Resolves: rhbz#1194446
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/rgrp.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index ed8e01d..cf4385a 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -539,9 +539,9 @@ struct osi_node *lgfs2_rgrps_root(lgfs2_rgrps_t rgs)
lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
{
lgfs2_rgrp_t rg;
- lgfs2_rgrp_t lastrg = (lgfs2_rgrp_t)osi_last(&rgs->root);
struct osi_node **link = &rgs->root.osi_node;
- struct osi_node *parent = NULL;
+ struct osi_node *parent = osi_last(&rgs->root);
+ lgfs2_rgrp_t lastrg = (lgfs2_rgrp_t)parent;
errno = EINVAL;
if (entry == NULL)
@@ -550,7 +550,6 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
if (lastrg != NULL) { /* Tree is not empty */
if (entry->ri_addr <= lastrg->ri.ri_addr)
return NULL; /* Appending with a lower address doesn't make sense */
- parent = osi_parent(&lastrg->node);
link = &lastrg->node.osi_right;
}
9 years, 1 month
gfs2-utils: RHEL7 - fsck.gfs2: Fix memory leaks in pass1_process_rgrp
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=03a7bea1...
Commit: 03a7bea1ace2ab3b8bd753662b6b848027a6e9b8
Parent: d496c725c7566620a587b8d10afe607f0e7e7454
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Feb 20 13:26:08 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Apr 1 16:51:35 2015 +0100
fsck.gfs2: Fix memory leaks in pass1_process_rgrp
Spotted by coverity: "Variable ibuf going out of scope leaks the storage
it points to"
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/pass1.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index b516a21..69c88f4 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1625,7 +1625,10 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
unsigned k, n, i;
uint64_t *ibuf = malloc(sdp->bsize * GFS2_NBBY * sizeof(uint64_t));
- int ret;
+ int ret = 0;
+
+ if (ibuf == NULL)
+ return FSCK_ERROR;
for (k = 0; k < rgd->ri.ri_length; k++) {
n = lgfs2_bm_scan(rgd, k, ibuf, GFS2_BLKST_DINODE);
@@ -1633,11 +1636,11 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
if (n) {
ret = pass1_process_bitmap(sdp, rgd, ibuf, n);
if (ret)
- return ret;
+ goto out;
}
if (fsck_abort)
- return 0;
+ goto out;
/*
For GFS1, we have to count the "free meta" blocks in the
resource group and mark them specially so we can count them
@@ -1650,12 +1653,13 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
for (i = 0; i < n; i++) {
gfs2_blockmap_set(bl, ibuf[i], GFS2_BLKST_UNLINKED);
if (fsck_abort)
- return 0;
+ goto out;
}
}
+out:
free(ibuf);
- return 0;
+ return ret;
}
/**
9 years, 1 month