fence-agents: master - fence_vmware_soap: fix short/long option parsing traceback
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=f1ee9c...
Commit: f1ee9c18423a1c65ccab4650601bd0146f200ef3
Parent: ed6ed4c4f8e5142457a2fabb4385d7d75209196d
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Feb 27 08:27:19 2014 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Thu Feb 27 08:27:19 2014 +0100
fence_vmware_soap: fix short/long option parsing traceback
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
fence/agents/vmware_soap/fence_vmware_soap.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index c73a1d6..bbac1c5 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -16,7 +16,7 @@ BUILD_DATE="April, 2011"
#END_VERSION_GENERATION
def soap_login(options):
- if options["-o"] in ["off", "reboot"]:
+ if options["--action"] in ["off", "reboot"]:
time.sleep(int(options["--delay"]))
if options.has_key("--ssl"):
10 years, 1 month
fence-agents: master - fencing: accept only options used in fence-agent
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=ed6ed4...
Commit: ed6ed4c4f8e5142457a2fabb4385d7d75209196d
Parent: dc7509aa2e1b67bbce9bebe58c027e85944f8b96
Author: Ondrej Mular <omular(a)redhat.com>
AuthorDate: Fri Feb 21 07:03:23 2014 -0500
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Feb 26 15:39:31 2014 +0100
fencing: accept only options used in fence-agent
In transformation from short options to long options, was used list of all options. That caused collision of options if there was 2 options with same short name, but only one was used in fence-agent.
---
fence/agents/lib/fencing.py.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index b8aa98f..2006f0d 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -572,7 +572,7 @@ def process_input(avail_opt):
opt["--" + all_opt[x]["longopt"]] = dict(old_opt)[o]
else:
for x in all_opt.keys():
- if all_opt[x].has_key("getopt") and all_opt[x].has_key("longopt") and \
+ if x in avail_opt and all_opt[x].has_key("getopt") and all_opt[x].has_key("longopt") and \
("-" + all_opt[x]["getopt"] == o or "-" + all_opt[x]["getopt"].rstrip(":") == o):
opt["--" + all_opt[x]["longopt"]] = dict(old_opt)[o]
opt[o] = dict(old_opt)[o]
10 years, 1 month
fence-agents: master - fencing: correct default values in manual pages for symlinks
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=dc7509...
Commit: dc7509aa2e1b67bbce9bebe58c027e85944f8b96
Parent: c360d3eecf6f9976d3371090034d08d03000f0e1
Author: Ondrej Mular <omular(a)redhat.com>
AuthorDate: Thu Jan 30 03:33:37 2014 -0500
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Feb 26 15:31:32 2014 +0100
fencing: correct default values in manual pages for symlinks
---
make/fenceman.mk | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make/fenceman.mk b/make/fenceman.mk
index d4f0377..163fe88 100644
--- a/make/fenceman.mk
+++ b/make/fenceman.mk
@@ -1,7 +1,7 @@
%.8: $(TARGET) $(top_srcdir)/fence/agents/lib/fence2man.xsl
set -e && \
PYTHONPATH=$(abs_srcdir)/../lib:$(abs_builddir)/../lib \
- python $^ -o metadata > .$@.tmp && \
+ python $(@:%.8=%) -o metadata > .$@.tmp && \
xmllint --noout --relaxng $(abs_srcdir)/../lib/metadata.rng .$@.tmp && \
xsltproc $(top_srcdir)/fence/agents/lib/fence2man.xsl .$@.tmp > $@
10 years, 1 month
fence-agents: master - vmware_soap: drop warning from python suds when error occours
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=c360d3...
Commit: c360d3eecf6f9976d3371090034d08d03000f0e1
Parent: 6bb1f3363e3856c1d95e21b25d380ca651eeeb1b
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Wed Feb 26 09:34:35 2014 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Feb 26 09:34:35 2014 +0100
vmware_soap: drop warning from python suds when error occours
prepatch:
fence_vmware_soap -z -l test -p wrongpasswd -a blabla -n vm1 -o reboot -v
No handlers could be found for logger "suds.client"
Failed: The user does not have the correct privileges to do the requested action.
postpatch:
fence_vmware_soap -z -l test -p wrongpassed -a blabla -n vm1 -o reboot -v
Failed: The user does not have the correct privileges to do the requested action.
Based on https://fedorahosted.org/suds/wiki/Documentation
logging must be configured and filter for CRITICAL since the harmless
error is at INFO level.
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
fence/agents/vmware_soap/fence_vmware_soap.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index 400e81f..c73a1d6 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -2,6 +2,7 @@
import sys, exceptions, time
import shutil, tempfile, suds
+import logging
sys.path.append("@FENCEAGENTSLIBDIR@")
from suds.client import Client
@@ -199,6 +200,9 @@ Alternatively you can always use UUID to access virtual machine."
docs["vendorurl"] = "http://www.vmware.com"
show_docs(options, docs)
+ logging.basicConfig(level=logging.INFO)
+ logging.getLogger('suds.client').setLevel(logging.CRITICAL)
+
##
## Operate the fencing device
####
10 years, 1 month
fence-agents: master - Allow ssl connections to fallback to SSL3.0 negotiation
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=6bb1f3...
Commit: 6bb1f3363e3856c1d95e21b25d380ca651eeeb1b
Parent: ff12e705744a4f5a525c7a64cd22ca358a43daaa
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Feb 20 12:03:08 2014 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Thu Feb 20 12:03:08 2014 +0100
Allow ssl connections to fallback to SSL3.0 negotiation
The preferred/default method is TLS1.x, but some old devices
just can't deal with it.
Add support for "notls" option that will force negotiation
to use SSL3.0. Wherever possible you are adviced to upgrade
your device firwmare.
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
fence/agents/cisco_ucs/fence_cisco_ucs.py | 2 +-
fence/agents/ilo/fence_ilo.py | 2 +-
fence/agents/lib/fencing.py.py | 14 +++++++++++++-
fence/agents/rhevm/fence_rhevm.py | 2 +-
fence/agents/vmware_soap/fence_vmware_soap.py | 2 +-
5 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index f70a835..71782cb 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -107,7 +107,7 @@ def define_new_opts():
"order" : 1 }
def main():
- device_opt = [ "ipaddr", "login", "passwd", "ssl", "port", "web", "suborg" ]
+ device_opt = [ "ipaddr", "login", "passwd", "ssl", "notls", "port", "web", "suborg" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index ab6e342..444f94b 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -63,7 +63,7 @@ def define_new_opts():
"order" : 1 }
def main():
- device_opt = [ "ipaddr", "login", "passwd", "ssl", "ribcl" ]
+ device_opt = [ "ipaddr", "login", "passwd", "ssl", "notls", "ribcl" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 798f855..b8aa98f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -170,6 +170,14 @@ all_opt = {
"required" : "0",
"shortdesc" : "SSL connection",
"order" : 1 },
+ "notls" : {
+ "getopt" : "t",
+ "longopt" : "notls",
+ "help" : "-t, --notls Disable TLS negotiation and force SSL3.0.\n" +
+ " This should only be used for devices that do not support TLS1.0 and up.",
+ "required" : "0",
+ "shortdesc" : "Disable TLS negotiation",
+ "order" : 1 },
"port" : {
"getopt" : "n:",
"longopt" : "plug",
@@ -960,7 +968,11 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(userna
re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
if options.has_key("--ssl"):
- command = '%s --insecure --crlf -p %s %s' % (SSL_PATH, options["--ipport"], options["--ip"])
+ gnutls_opts=""
+ if options.has_key("--notls"):
+ gnutls_opts = "--priority \"NORMAL:-VERS-TLS1.2:-VERS-TLS1.1:-VERS-TLS1.0:+VERS-SSL3.0\""
+
+ command = '%s %s --insecure --crlf -p %s %s' % (SSL_PATH, gnutls_opts, options["--ipport"], options["--ip"])
try:
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index d7fc326..ff3d19f 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -101,7 +101,7 @@ def send_command(opt, command, method = "GET"):
return result
def main():
- device_opt = [ "ipaddr", "login", "passwd", "ssl", "web", "port" ]
+ device_opt = [ "ipaddr", "login", "passwd", "ssl", "notls", "web", "port" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index 776273e..400e81f 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -177,7 +177,7 @@ def remove_tmp_dir(tmp_dir):
shutil.rmtree(tmp_dir)
def main():
- device_opt = [ "ipaddr", "login", "passwd", "web", "ssl", "port" ]
+ device_opt = [ "ipaddr", "login", "passwd", "web", "ssl", "notls", "port" ]
atexit.register(atexit_handler)
10 years, 1 month
gfs2-utils: RHEL7 - libgfs2: Add support for new leaf hint fields
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=e7b57dae...
Commit: e7b57dae8cfd096514b970d200e1e97648b495a6
Parent: 75a68102d55a1c361725ed01864c98fee6f77199
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 6 16:19:02 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Feb 17 19:44:44 2014 +0000
libgfs2: Add support for new leaf hint fields
Kernel commit 01bcb0de introduces new gfs2_leaf fields. This patch adds
support for those fields to libgfs2, conditional upon them being
discovered in the configure stage. Includes meta.c changes by Steve
Whitehouse.
Resolves: rhbz#1063842
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 10 ++++------
gfs2/edit/extended.c | 20 ++++++++++++++++----
gfs2/edit/gfs2hex.c | 9 ++-------
gfs2/edit/hexedit.c | 14 ++++++++++++++
gfs2/edit/hexedit.h | 5 +----
gfs2/fsck/metawalk.c | 2 +-
gfs2/libgfs2/fs_ops.c | 11 +++++++++--
gfs2/libgfs2/meta.c | 8 ++++++++
gfs2/libgfs2/ondisk.c | 26 +++++++++++++++++++++++---
9 files changed, 78 insertions(+), 27 deletions(-)
diff --git a/configure.ac b/configure.ac
index 628d85e..80310be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,12 +116,10 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h mnt
AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h linux/netlink.h linux/fs.h],,
[AC_MSG_ERROR([Unable to find all required kernel headers.])])
-AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
- [AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
- [AC_MSG_ERROR([Unable to find gfs2 uuid support in your headers.
-Please update your kernel headers to a more recent version])],
- [#include <linux/gfs2_ondisk.h>])],
- [AC_MSG_ERROR([Unable to find required kernel headers.])])
+AC_CHECK_HEADER([linux/gfs2_ondisk.h], [], [AC_MSG_ERROR([Unable to find linux/gfs2_ondisk.h])])
+AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [], [], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],[Leaf block hints])],
+ [], [[#include <linux/gfs2_ondisk.h>]])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 27c32a9..328e35c 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -296,8 +296,18 @@ static void print_inode_type(__be16 de_type)
}
}
+#ifdef GFS2_HAS_LEAF_HINTS
+#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
+ "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
+#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
+#else
+#define LEAF_HINT_FMTS
+#define LEAF_HINT_FIELDS(lp)
+#endif
+
static int display_leaf(struct iinfo *ind)
{
+ struct gfs2_leaf *leaf = &ind->ii[0].lf;
int start_line, total_dirents = start_row[dmode];
int d;
@@ -305,11 +315,13 @@ static int display_leaf(struct iinfo *ind)
if (gfs2_struct_type == GFS2_METATYPE_SB)
print_gfs2("The superblock has 2 directories");
else
- print_gfs2("Directory block: lf_depth:%d, lf_entries:%d,"
+ print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, "
+ LEAF_HINT_FMTS
"fmt:%d next=0x%llx (%d dirents).",
- ind->ii[0].lf_depth, ind->ii[0].lf_entries,
- ind->ii[0].lf_dirent_format,
- ind->ii[0].lf_next,
+ leaf->lf_depth, leaf->lf_entries,
+ LEAF_HINT_FIELDS(leaf)
+ leaf->lf_dirent_format,
+ leaf->lf_next,
ind->ii[0].dirents);
start_line = line;
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index cc0ceb6..cda4dbe 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -341,17 +341,12 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
{
int x, i;
struct gfs2_dirent de;
- struct gfs2_leaf leaf;
struct gfs2_buffer_head tbh; /* kludge */
x = 0;
memset(indir, 0, sizeof(*indir));
tbh.b_data = dlebuf;
- gfs2_leaf_in(&leaf, &tbh);
- indir->ii[0].lf_depth = leaf.lf_depth;
- indir->ii[0].lf_entries = leaf.lf_entries;
- indir->ii[0].lf_dirent_format = leaf.lf_dirent_format;
- indir->ii[0].lf_next = leaf.lf_next;
+ gfs2_leaf_in(&indir->ii[0].lf, &tbh);
/* Directory Entries: */
for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
i += de.de_rec_len) {
@@ -372,7 +367,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
if (de.de_rec_len <= sizeof(struct gfs2_dirent))
break;
}
- return leaf.lf_next;
+ return indir->ii[0].lf.lf_next;
}
static void do_eattr_extended(struct gfs2_buffer_head *ebh)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 0708445..1738652 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -219,7 +219,15 @@ static int gfs2_leaf_printval(struct gfs2_leaf *lf, const char *strfield)
checkprint(strfield, lf, lf_entries);
checkprint(strfield, lf, lf_dirent_format);
checkprint(strfield, lf, lf_next);
+#ifdef GFS2_HAS_LEAF_HINTS
+ checkprint(strfield, lf, lf_inode);
+ checkprint(strfield, lf, lf_dist);
+ checkprint(strfield, lf, lf_nsec);
+ checkprint(strfield, lf, lf_sec);
+ checkprints(strfield, lf, lf_reserved2);
+#else
checkprints(strfield, lf, lf_reserved);
+#endif
return -1;
}
@@ -231,6 +239,12 @@ static int gfs2_leaf_assignval(struct gfs2_leaf *lf, const char *strfield,
checkassign(strfield, lf, lf_entries, value);
checkassign(strfield, lf, lf_dirent_format, value);
checkassign(strfield, lf, lf_next, value);
+#ifdef GFS2_HAS_LEAF_HINTS
+ checkassign(strfield, lf, lf_inode, value);
+ checkassign(strfield, lf, lf_dist, value);
+ checkassign(strfield, lf, lf_nsec, value);
+ checkassign(strfield, lf, lf_sec, value);
+#endif
return -1;
}
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 706909c..ebe3855 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -78,10 +78,7 @@ struct indirect_info {
int height;
uint64_t block;
uint32_t dirents;
- uint16_t lf_depth;
- uint16_t lf_entries;
- uint32_t lf_dirent_format;
- uint64_t lf_next;
+ struct gfs2_leaf lf;
struct metapath mp;
struct gfs2_dirents dirent[64];
};
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b8cef87..59fbde8 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -657,7 +657,6 @@ static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
int error = 0;
- struct gfs2_leaf leaf;
unsigned hsize = (1 << ip->i_di.di_depth);
uint64_t leaf_no, leaf_next;
uint64_t first_ok_leaf, orig_di_blocks;
@@ -767,6 +766,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
chained_leaf = 0;
do {
+ struct gfs2_leaf leaf;
if (fsck_abort) {
free(tbl);
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 4a84687..1790421 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1024,6 +1024,9 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
oleaf->lf_depth = cpu_to_be16(oleaf->lf_depth);
nleaf->lf_depth = oleaf->lf_depth;
+#ifdef GFS2_HAS_LEAF_HINTS
+ nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
dip->i_di.di_blocks++;
bmodified(dip->i_bh);
@@ -1206,7 +1209,9 @@ restart:
nleaf = (struct gfs2_leaf *)nbh->b_data;
nleaf->lf_depth = leaf->lf_depth;
nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+ nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
err = dirent_alloc(dip, nbh, len, &dent);
if (err)
return err;
@@ -1256,7 +1261,9 @@ static void dir_make_exhash(struct gfs2_inode *dip)
leaf = (struct gfs2_leaf *)bh->b_data;
leaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+ leaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
buffer_copy_tail(sdp, bh, sizeof(struct gfs2_leaf),
dip->i_bh, sizeof(struct gfs2_dinode));
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 94be823..4305393 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -317,7 +317,15 @@ F(lf_depth)
F(lf_entries)
F(lf_dirent_format)
F(lf_next)
+#ifdef GFS2_HAS_LEAF_HINTS
+FP(lf_inode, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
+F(lf_dist)
+F(lf_nsec, .flags = LGFS2_MFF_NSECS)
+F(lf_sec, .flags = LGFS2_MFF_SECS)
+RF(lf_reserved2)
+#else
RF(lf_reserved)
+#endif
};
#undef STRUCT
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 43618bc..dcc537e 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -433,8 +433,15 @@ void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
CPIN_16(lf, str, lf_entries);
CPIN_32(lf, str, lf_dirent_format);
CPIN_64(lf, str, lf_next);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+ CPIN_64(lf, str, lf_inode);
+ CPIN_32(lf, str, lf_dist);
+ CPIN_32(lf, str, lf_nsec);
+ CPIN_64(lf, str, lf_sec);
+ CPIN_08(lf, str, lf_reserved2, 40);
+#else
CPIN_08(lf, str, lf_reserved, 32);
+#endif
}
void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
@@ -446,8 +453,15 @@ void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
CPOUT_16(lf, str, lf_entries);
CPOUT_32(lf, str, lf_dirent_format);
CPOUT_64(lf, str, lf_next);
-
- CPOUT_08(lf, str, lf_reserved, 32);
+#ifdef GFS2_HAS_LEAF_HINTS
+ CPOUT_64(lf, str, lf_inode);
+ CPOUT_32(lf, str, lf_dist);
+ CPOUT_32(lf, str, lf_nsec);
+ CPOUT_64(lf, str, lf_sec);
+ CPOUT_08(lf, str, lf_reserved2, 40);
+#else
+ CPOUT_08(lf, str, lf_reserved, 64);
+#endif
bmodified(bh);
}
@@ -458,6 +472,12 @@ void gfs2_leaf_print(struct gfs2_leaf *lf)
pv(lf, lf_entries, "%u", "0x%x");
pv(lf, lf_dirent_format, "%u", "0x%x");
pv(lf, lf_next, "%llu", "0x%llx");
+#ifdef GFS2_HAS_LEAF_HINTS
+ pv(lf, lf_inode, "%llu", "0x%llx");
+ pv(lf, lf_dist, "%u", "0x%x");
+ pv(lf, lf_nsec, "%u", "0x%x");
+ pv(lf, lf_sec, "%llu", "0x%llx");
+#endif
}
void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf)
10 years, 1 month
gfs2-utils: RHEL7 - gfs2-utils: Ensure sb_uuid uses are guarded
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=75a68102...
Commit: 75a68102d55a1c361725ed01864c98fee6f77199
Parent: 37cf0257bf6298df38ca74ee8577bac5a40e6598
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 6 13:16:18 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Feb 17 19:43:59 2014 +0000
gfs2-utils: Ensure sb_uuid uses are guarded
Guard uses of sb_uuid with #ifdef GFS2_HAS_UUID
Tweak print_results() in mkfs.gfs2 to accept the gfs2_sb which we
conditionally print the uuid from, instead of the gfs2_sbd.
Resolves: rhbz#1063842
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 5 ++++-
gfs2/mkfs/main_mkfs.c | 27 ++++++++++++++-------------
gfs2/tune/super.c | 5 +++--
3 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 36f6600..0708445 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -104,10 +104,12 @@ static int gfs2_sb_printval(struct gfs2_sb *lsb, const char *strfield)
checkprints(strfield, lsb, sb_locktable);
checkprint(strfield, lsb, __pad3.no_addr);
checkprint(strfield, lsb, __pad4.no_addr);
+#ifdef GFS2_HAS_UUID
if (strcmp(strfield, "sb_uuid") == 0) {
printf("%s\n", str_uuid(lsb->sb_uuid));
return 0;
}
+#endif
return -1;
}
@@ -135,8 +137,9 @@ static int gfs2_sb_assigns(struct gfs2_sb *lsb, const char *strfield,
{
checkassigns(strfield, lsb, sb_lockproto, val);
checkassigns(strfield, lsb, sb_locktable, val);
+#ifdef GFS2_HAS_UUID
checkassigns(strfield, lsb, sb_uuid, val);
-
+#endif
return -1;
}
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 8bd396a..32da585 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -555,24 +555,25 @@ static void opts_check(struct mkfs_opts *opts)
}
}
-static void print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
- struct mkfs_opts *opts, unsigned char uuid[16])
+static void print_results(struct gfs2_sb *sb, struct mkfs_dev *dev, struct mkfs_opts *opts,
+ uint64_t rgrps, uint64_t fssize)
{
printf("%-27s%s\n", _("Device:"), opts->device);
- printf("%-27s%u\n", _("Block size:"), sdp->bsize);
- printf("%-27s%.2f %s (%llu %s)\n", _("Device size:"),
+ printf("%-27s%u\n", _("Block size:"), sb->sb_bsize);
+ printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Device size:"),
/* Translators: "GB" here means "gigabytes" */
- real_device_size / ((float)(1 << 30)), _("GB"),
- (unsigned long long)real_device_size / sdp->bsize, _("blocks"));
- printf("%-27s%.2f %s (%llu %s)\n", _("Filesystem size:"),
- sdp->fssize / ((float)(1 << 30)) * sdp->bsize, _("GB"),
- (unsigned long long)sdp->fssize, _("blocks"));
- printf("%-27s%u\n", _("Journals:"), sdp->md.journals);
- printf("%-27s%llu\n", _("Resource groups:"), (unsigned long long)sdp->rgrps);
+ (dev->size / ((float)(1 << 30))), _("GB"),
+ (dev->size / sb->sb_bsize), _("blocks"));
+ printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Filesystem size:"),
+ (fssize / ((float)(1 << 30)) * sb->sb_bsize), _("GB"), fssize, _("blocks"));
+ printf("%-27s%u\n", _("Journals:"), opts->journals);
+ printf("%-27s%"PRIu64"\n", _("Resource groups:"), rgrps);
printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
+#ifdef GFS2_HAS_UUID
/* Translators: "UUID" = universally unique identifier. */
- printf("%-27s%s\n", _("UUID:"), str_uuid(uuid));
+ printf("%-27s%s\n", _("UUID:"), str_uuid(sb->sb_uuid));
+#endif
}
static void warn_of_destruction(const char *path)
@@ -909,5 +910,5 @@ void main_mkfs(int argc, char *argv[])
}
if (!opts.quiet)
- print_results(&sbd, dev.size, &opts, sb.sb_uuid);
+ print_results(&sb, &dev, &opts, sbd.rgrps, sbd.fssize);
}
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index cc34990..cbd0026 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -124,8 +124,9 @@ static int is_gfs2(const struct tunegfs2 *tfs)
int print_super(const struct tunegfs2 *tfs)
{
printf(_("File system volume name: %s\n"), tfs->sb->sb_locktable);
- if (is_gfs2(tfs))
- printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+#ifdef GFS2_HAS_UUID
+ printf(_("File system UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+#endif
printf( _("File system magic number: 0x%X\n"), be32_to_cpu(tfs->sb->sb_header.mh_magic));
printf(_("Block size: %d\n"), be32_to_cpu(tfs->sb->sb_bsize));
printf(_("Block shift: %d\n"), be32_to_cpu(tfs->sb->sb_bsize_shift));
10 years, 1 month
gfs2-utils: RHEL7 - libgfs2: Superblock building and writing improvements
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=37cf0257...
Commit: 37cf0257bf6298df38ca74ee8577bac5a40e6598
Parent: 9a070d60d70937da51f1430c6626327c971dec33
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 6 04:25:27 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Feb 17 19:41:54 2014 +0000
libgfs2: Superblock building and writing improvements
build_sb was creating the sb, setting its fields from an sdp and then
writing it, and also zeroing the gap before the sb on the device in a
block-by-block way using buffer_heads.
This patch splits the build_sb function into lgfs2_sb_init and
lgfs2_sb_write which operate on gfs2_sb structures instead of gfs2_sbds.
lgfs2_sb_write now uses pwritev to zero the initial blocks and write the
sb to an fd.
get_random_bytes has been moved into structures.c and made static as
only lgfs2_sb_init now uses it.
Resolves: rhbz#1063842
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 3 +-
gfs2/edit/hexedit.c | 3 +-
gfs2/fsck/initialize.c | 14 +++--
gfs2/libgfs2/libgfs2.h | 8 ++--
gfs2/libgfs2/misc.c | 45 ----------------
gfs2/libgfs2/ondisk.c | 9 ++--
gfs2/libgfs2/structures.c | 120 ++++++++++++++++++++++++++++++++-----------
gfs2/libgfs2/super.c | 12 ----
gfs2/mkfs/main_mkfs.c | 32 ++++++++----
9 files changed, 132 insertions(+), 114 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 719ba9c..ce056a7 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2374,7 +2374,8 @@ int main(int argc, char **argv)
bh = bread(&sb2, sb2.sb_addr);
sb2.sd_sb.sb_fs_format = GFS2_FORMAT_FS;
sb2.sd_sb.sb_multihost_format = GFS2_FORMAT_MULTI;
- gfs2_sb_out(&sb2.sd_sb, bh);
+ gfs2_sb_out(&sb2.sd_sb, bh->b_data);
+ bmodified(bh);
brelse(bh);
error = fsync(sb2.device_fd);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index f0d9789..36f6600 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2132,7 +2132,8 @@ static void process_field(const char *field, const char *nstr)
gfs2_sb_assigns(&lsb, field, nstr);
else
gfs2_sb_assignval(&lsb, field, newval);
- gfs2_sb_out(&lsb, rbh);
+ gfs2_sb_out(&lsb, rbh->b_data);
+ bmodified(rbh);
if (!termlines)
gfs2_sb_printval(&lsb, field);
} else {
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 5758607..0f33aa6 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -60,7 +60,7 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
}
}
- if (write_sb(sdp)) {
+ if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) {
stack;
return -1;
}
@@ -1130,7 +1130,6 @@ static int sb_repair(struct gfs2_sbd *sdp)
{
uint64_t half;
uint32_t known_bsize = 0;
- unsigned char uuid[16];
int error = 0;
memset(&fix_md, 0, sizeof(fix_md));
@@ -1205,9 +1204,8 @@ static int sb_repair(struct gfs2_sbd *sdp)
}
}
/* Step 3 - Rebuild the lock protocol and file system table name */
- strcpy(sdp->lockproto, GFS2_DEFAULT_LOCKPROTO);
- strcpy(sdp->locktable, "unknown");
if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
+ struct gfs2_sb sb;
log_info(_("Found system master directory at: 0x%llx\n"),
sdp->sd_sb.sb_master_dir.no_addr);
sdp->master_dir = lgfs2_inode_read(sdp,
@@ -1226,8 +1224,12 @@ static int sb_repair(struct gfs2_sbd *sdp)
log_crit(_("Error reading root inode: %s\n"), strerror(errno));
return -1;
}
- get_random_bytes(uuid, sizeof(uuid));
- build_sb(sdp, uuid);
+ lgfs2_sb_init(&sb, sdp->bsize);
+ strcpy(sb.sb_lockproto, GFS2_DEFAULT_LOCKPROTO);
+ strcpy(sb.sb_locktable, "unknown");
+ sb.sb_master_dir = sdp->master_dir->i_di.di_num;
+ sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
+ lgfs2_sb_write(&sb, sdp->device_fd, sdp->bsize);
inode_put(&sdp->md.rooti);
inode_put(&sdp->master_dir);
sb_fixed = 1;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e785017..6710e72 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -724,7 +724,6 @@ extern int mount_gfs2_meta(struct gfs2_sbd *sdp);
extern void cleanup_metafs(struct gfs2_sbd *sdp);
extern int set_sysfs(const char *fsname, const char *filename, const char *val);
extern int is_fsname(char *name);
-extern void get_random_bytes(void *buf, int nbytes);
/* recovery.c */
extern void gfs2_replay_incr_blk(struct gfs2_inode *ip, unsigned int *blk);
@@ -758,7 +757,8 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
/* structures.c */
extern int build_master(struct gfs2_sbd *sdp);
-extern void build_sb(struct gfs2_sbd *sdp, const unsigned char *uuid);
+extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize);
+extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize);
extern int build_journal(struct gfs2_sbd *sdp, int j,
struct gfs2_inode *jindex);
extern int build_jindex(struct gfs2_sbd *sdp);
@@ -794,14 +794,14 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
/* Translation functions */
extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
-extern void gfs2_inum_out(struct gfs2_inum *no, char *buf);
+extern void gfs2_inum_out(const struct gfs2_inum *no, char *buf);
extern void gfs2_meta_header_in(struct gfs2_meta_header *mh,
struct gfs2_buffer_head *bh);
extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
extern void gfs2_meta_header_out_bh(const struct gfs2_meta_header *mh,
struct gfs2_buffer_head *bh);
extern void gfs2_sb_in(struct gfs2_sb *sb, struct gfs2_buffer_head *bh);
-extern void gfs2_sb_out(struct gfs2_sb *sb, struct gfs2_buffer_head *bh);
+extern void gfs2_sb_out(const struct gfs2_sb *sb, char *buf);
extern void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf);
extern void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf);
extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index c4ed722..d707687 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -17,7 +17,6 @@
#include <dirent.h>
#include <sys/sysmacros.h>
#include <mntent.h>
-#include <sys/time.h>
#include <signal.h>
#include "libgfs2.h"
@@ -304,47 +303,3 @@ int set_sysfs(const char *fsname, const char *filename, const char *val)
close(fd);
return 0;
}
-
-/*
- * get_random_bytes - Generate a series of random bytes using /dev/urandom.
- *
- * Modified from original code in gen_uuid.c in e2fsprogs/lib
- */
-void get_random_bytes(void *buf, int nbytes)
-{
- int i, n = nbytes, fd;
- int lose_counter = 0;
- unsigned char *cp = (unsigned char *) buf;
- struct timeval tv;
-
- gettimeofday(&tv, 0);
- fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
- srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
- /* Crank the random number generator a few times */
- gettimeofday(&tv, 0);
- for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--)
- rand();
- if (fd >= 0) {
- while (n > 0) {
- i = read(fd, cp, n);
- if (i <= 0) {
- if (lose_counter++ > 16)
- break;
- continue;
- }
- n -= i;
- cp += i;
- lose_counter = 0;
- }
- close(fd);
- }
-
- /*
- * We do this all the time, but this is the only source of
- * randomness if /dev/random/urandom is out to lunch.
- */
- for (cp = buf, i = 0; i < nbytes; i++)
- *cp++ ^= (rand() >> 7) & 0xFF;
-
- return;
-}
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 4baacc7..43618bc 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -48,7 +48,7 @@ void gfs2_inum_in(struct gfs2_inum *no, char *buf)
CPIN_64(no, str, no_addr);
}
-void gfs2_inum_out(struct gfs2_inum *no, char *buf)
+void gfs2_inum_out(const struct gfs2_inum *no, char *buf)
{
struct gfs2_inum *str = (struct gfs2_inum *)buf;
@@ -124,11 +124,11 @@ void gfs2_sb_in(struct gfs2_sb *sb, struct gfs2_buffer_head *bh)
#endif
}
-void gfs2_sb_out(struct gfs2_sb *sb, struct gfs2_buffer_head *bh)
+void gfs2_sb_out(const struct gfs2_sb *sb, char *buf)
{
- struct gfs2_sb *str = (struct gfs2_sb *)bh->b_data;
+ struct gfs2_sb *str = (struct gfs2_sb *)buf;
- gfs2_meta_header_out_bh(&sb->sb_header, bh);
+ gfs2_meta_header_out(&sb->sb_header, buf);
CPOUT_32(sb, str, sb_fs_format);
CPOUT_32(sb, str, sb_multihost_format);
@@ -144,7 +144,6 @@ void gfs2_sb_out(struct gfs2_sb *sb, struct gfs2_buffer_head *bh)
#ifdef GFS2_HAS_UUID
memcpy(str->sb_uuid, sb->sb_uuid, 16);
#endif
- bmodified(bh);
}
const char *str_uuid(const unsigned char *uuid)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index e888f1e..2c1939a 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <errno.h>
#include <linux/types.h>
+#include <sys/time.h>
#include "libgfs2.h"
@@ -41,43 +42,102 @@ int build_master(struct gfs2_sbd *sdp)
return 0;
}
-void build_sb(struct gfs2_sbd *sdp, const unsigned char *uuid)
+#ifdef GFS2_HAS_UUID
+/**
+ * Generate a series of random bytes using /dev/urandom.
+ * Modified from original code in gen_uuid.c in e2fsprogs/lib
+ */
+static void get_random_bytes(void *buf, int nbytes)
{
- unsigned int x;
- struct gfs2_buffer_head *bh;
- struct gfs2_sb sb;
-
- /* Zero out the beginning of the device up to the superblock */
- for (x = 0; x < sdp->sb_addr; x++) {
- bh = bget(sdp, x);
- memset(bh->b_data, 0, sdp->bsize);
- bmodified(bh);
- brelse(bh);
+ int i, n = nbytes, fd;
+ int lose_counter = 0;
+ unsigned char *cp = (unsigned char *) buf;
+ struct timeval tv;
+
+ gettimeofday(&tv, 0);
+ fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
+ srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
+ /* Crank the random number generator a few times */
+ gettimeofday(&tv, 0);
+ for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--)
+ rand();
+ if (fd >= 0) {
+ while (n > 0) {
+ i = read(fd, cp, n);
+ if (i <= 0) {
+ if (lose_counter++ > 16)
+ break;
+ continue;
+ }
+ n -= i;
+ cp += i;
+ lose_counter = 0;
+ }
+ close(fd);
}
- memset(&sb, 0, sizeof(struct gfs2_sb));
- sb.sb_header.mh_magic = GFS2_MAGIC;
- sb.sb_header.mh_type = GFS2_METATYPE_SB;
- sb.sb_header.mh_format = GFS2_FORMAT_SB;
- sb.sb_fs_format = GFS2_FORMAT_FS;
- sb.sb_multihost_format = GFS2_FORMAT_MULTI;
- sb.sb_bsize = sdp->bsize;
- sb.sb_bsize_shift = ffs(sdp->bsize) - 1;
- sb.sb_master_dir = sdp->master_dir->i_di.di_num;
- sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
- strcpy(sb.sb_lockproto, sdp->lockproto);
- strcpy(sb.sb_locktable, sdp->locktable);
+ /*
+ * We do this all the time, but this is the only source of
+ * randomness if /dev/random/urandom is out to lunch.
+ */
+ for (cp = buf, i = 0; i < nbytes; i++)
+ *cp++ ^= (rand() >> 7) & 0xFF;
+
+ return;
+}
+#endif
+
+/**
+ * Initialise a gfs2_sb structure with sensible defaults.
+ */
+void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize)
+{
+ memset(sb, 0, sizeof(struct gfs2_sb));
+ sb->sb_header.mh_magic = GFS2_MAGIC;
+ sb->sb_header.mh_type = GFS2_METATYPE_SB;
+ sb->sb_header.mh_format = GFS2_FORMAT_SB;
+ sb->sb_fs_format = GFS2_FORMAT_FS;
+ sb->sb_multihost_format = GFS2_FORMAT_MULTI;
+ sb->sb_bsize = bsize;
+ sb->sb_bsize_shift = ffs(bsize) - 1;
#ifdef GFS2_HAS_UUID
- memcpy(sb.sb_uuid, uuid, sizeof(sb.sb_uuid));
+ get_random_bytes(&sb->sb_uuid, sizeof(sb->sb_uuid));
#endif
- bh = bget(sdp, sdp->sb_addr);
- gfs2_sb_out(&sb, bh);
- brelse(bh);
+}
- if (sdp->debug) {
- printf("\nSuper Block:\n");
- gfs2_sb_print(&sb);
+int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
+{
+ int i, err = -1;
+ struct iovec *iov;
+ const size_t sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / bsize;
+ const size_t len = sb_addr + 1;
+
+ /* We only need 2 blocks: one for zeroing and a second for the superblock */
+ char *buf = calloc(2, bsize);
+ if (buf == NULL)
+ return -1;
+
+ iov = malloc(len * sizeof(*iov));
+ if (iov == NULL)
+ goto out_buf;
+
+ for (i = 0; i < len; i++) {
+ iov[i].iov_base = buf;
+ iov[i].iov_len = bsize;
}
+
+ gfs2_sb_out(sb, buf + bsize);
+ iov[sb_addr].iov_base = buf + bsize;
+
+ if (pwritev(fd, iov, len, 0) < (len * bsize))
+ goto out_iov;
+
+ err = 0;
+out_iov:
+ free(iov);
+out_buf:
+ free(buf);
+ return err;
}
int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index d074236..b956366 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -309,15 +309,3 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet)
return __ri_update(sdp, fd, rgcount, &sane, quiet);
}
-
-int write_sb(struct gfs2_sbd *sbp)
-{
- struct gfs2_buffer_head *bh;
-
- bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);
- gfs2_sb_out(&sbp->sd_sb, bh);
- brelse(bh);
- fsync(sbp->device_fd); /* make sure the change gets to disk ASAP */
- return 0;
-}
-
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 0d84064..8bd396a 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -569,8 +569,8 @@ static void print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
(unsigned long long)sdp->fssize, _("blocks"));
printf("%-27s%u\n", _("Journals:"), sdp->md.journals);
printf("%-27s%llu\n", _("Resource groups:"), (unsigned long long)sdp->rgrps);
- printf("%-27s\"%s\"\n", _("Locking protocol:"), sdp->lockproto);
- printf("%-27s\"%s\"\n", _("Lock table:"), sdp->locktable);
+ printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
+ printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
/* Translators: "UUID" = universally unique identifier. */
printf("%-27s%s\n", _("UUID:"), str_uuid(uuid));
}
@@ -701,8 +701,6 @@ static void sbd_init(struct gfs2_sbd *sdp, struct mkfs_opts *opts, struct mkfs_d
/* TODO: Check if the fssize is too small, somehow */
sdp->device.length = opts->fssize;
}
- strcpy(sdp->lockproto, opts->lockproto);
- strcpy(sdp->locktable, opts->locktable);
}
static int probe_contents(struct mkfs_dev *dev)
@@ -791,11 +789,11 @@ static void open_dev(const char *path, struct mkfs_dev *dev)
void main_mkfs(int argc, char *argv[])
{
struct gfs2_sbd sbd;
+ struct gfs2_sb sb;
struct mkfs_opts opts;
struct mkfs_dev dev;
lgfs2_rgrps_t rgs;
int error;
- unsigned char uuid[16];
unsigned bsize;
opts_init(&opts);
@@ -810,15 +808,16 @@ void main_mkfs(int argc, char *argv[])
}
sbd_init(&sbd, &opts, &dev, bsize);
+ lgfs2_sb_init(&sb, bsize);
if (opts.debug) {
printf(_("File system options:\n"));
printf(" bsize = %u\n", sbd.bsize);
printf(" qcsize = %u\n", sbd.qcsize);
printf(" jsize = %u\n", sbd.jsize);
printf(" journals = %u\n", sbd.md.journals);
- printf(" proto = %s\n", sbd.lockproto);
+ printf(" proto = %s\n", opts.lockproto);
+ printf(" table = %s\n", opts.locktable);
printf(" rgsize = %u\n", sbd.rgsize);
- printf(" table = %s\n", sbd.locktable);
printf(" fssize = %"PRIu64"\n", opts.fssize);
printf(" sunit = %lu\n", opts.sunit);
printf(" swidth = %lu\n", opts.swidth);
@@ -838,8 +837,13 @@ void main_mkfs(int argc, char *argv[])
exit(1);
}
sbd.rgtree.osi_node = lgfs2_rgrps_root(rgs); // Temporary
+
build_root(&sbd);
+ sb.sb_root_dir = sbd.md.rooti->i_di.di_num;
+
build_master(&sbd);
+ sb.sb_master_dir = sbd.master_dir->i_di.di_num;
+
error = build_jindex(&sbd);
if (error) {
fprintf(stderr, _("Error building '%s': %s\n"), "jindex", strerror(errno));
@@ -872,8 +876,9 @@ void main_mkfs(int argc, char *argv[])
fprintf(stderr, _("Error building '%s': %s\n"), "quota", strerror(errno));
exit(EXIT_FAILURE);
}
- get_random_bytes(uuid, sizeof(uuid));
- build_sb(&sbd, uuid);
+
+ strcpy(sb.sb_lockproto, opts.lockproto);
+ strcpy(sb.sb_locktable, opts.locktable);
do_init_inum(&sbd);
do_init_statfs(&sbd);
@@ -884,6 +889,13 @@ void main_mkfs(int argc, char *argv[])
inode_put(&sbd.md.statfs);
gfs2_rgrp_free(&sbd.rgtree);
+
+ error = lgfs2_sb_write(&sb, dev.fd, sbd.bsize);
+ if (error) {
+ perror(_("Failed to write superblock\n"));
+ exit(EXIT_FAILURE);
+ }
+
error = fsync(dev.fd);
if (error){
perror(opts.device);
@@ -897,5 +909,5 @@ void main_mkfs(int argc, char *argv[])
}
if (!opts.quiet)
- print_results(&sbd, dev.size, &opts, uuid);
+ print_results(&sbd, dev.size, &opts, sb.sb_uuid);
}
10 years, 1 month
gfs2-utils: master - mkfs.gfs2: Remove a dead structure
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=638f3cd5...
Commit: 638f3cd5b541dc5952651d696e26cd8a8abd27c1
Parent: b675ddeb26172a96277e21f6d2663f4d1ddb9a0a
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Sun Feb 16 20:07:05 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sun Feb 16 20:07:05 2014 +0000
mkfs.gfs2: Remove a dead structure
struct mkfs_rgs has not been used since the new rgrp functions were
added to libgfs2. Remove it.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 19 -------------------
1 files changed, 0 insertions(+), 19 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 32da585..e58de68 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -151,25 +151,6 @@ struct mkfs_dev {
unsigned int got_topol:1;
};
-/**
- * A representation of the state of resource group calculation. Allows mkfs to create
- * resource groups at any point instead of creating them all in one batch.
- */
-struct mkfs_rgs {
- struct osi_root *root;
- uint64_t nextaddr;
- unsigned bsize;
- unsigned long align;
- unsigned long align_off;
- unsigned long curr_offset;
- uint64_t maxrgsz;
- uint64_t minrgsz;
- uint64_t devlen;
- uint64_t rgsize;
- uint64_t count;
- uint64_t blks_total;
-};
-
static void opts_init(struct mkfs_opts *opts)
{
memset(opts, 0, sizeof(*opts));
10 years, 1 month
gfs2-utils: master - libgfs2: Add support for new leaf hint fields
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=b675ddeb...
Commit: b675ddeb26172a96277e21f6d2663f4d1ddb9a0a
Parent: d39954ec68c21c3e4295f5fca6bad578e262b170
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 6 16:19:02 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Sun Feb 16 19:56:26 2014 +0000
libgfs2: Add support for new leaf hint fields
Kernel commit 01bcb0de introduces new gfs2_leaf fields. This patch adds
support for those fields to libgfs2, conditional upon them being
discovered in the configure stage. Includes meta.c changes by Steve
Whitehouse.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 10 ++++------
gfs2/edit/extended.c | 20 ++++++++++++++++----
gfs2/edit/gfs2hex.c | 9 ++-------
gfs2/edit/hexedit.c | 14 ++++++++++++++
gfs2/edit/hexedit.h | 5 +----
gfs2/fsck/metawalk.c | 2 +-
gfs2/libgfs2/fs_ops.c | 11 +++++++++--
gfs2/libgfs2/meta.c | 8 ++++++++
gfs2/libgfs2/ondisk.c | 26 +++++++++++++++++++++++---
9 files changed, 78 insertions(+), 27 deletions(-)
diff --git a/configure.ac b/configure.ac
index 628d85e..80310be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,12 +116,10 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h mnt
AC_CHECK_HEADERS([linux/dlmconstants.h linux/limits.h linux/types.h linux/netlink.h linux/fs.h],,
[AC_MSG_ERROR([Unable to find all required kernel headers.])])
-AC_CHECK_HEADERS([linux/gfs2_ondisk.h],
- [AC_CHECK_MEMBERS([struct gfs2_sb.sb_uuid],,
- [AC_MSG_ERROR([Unable to find gfs2 uuid support in your headers.
-Please update your kernel headers to a more recent version])],
- [#include <linux/gfs2_ondisk.h>])],
- [AC_MSG_ERROR([Unable to find required kernel headers.])])
+AC_CHECK_HEADER([linux/gfs2_ondisk.h], [], [AC_MSG_ERROR([Unable to find linux/gfs2_ondisk.h])])
+AC_CHECK_MEMBER([struct gfs2_sb.sb_uuid], [], [], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],[Leaf block hints])],
+ [], [[#include <linux/gfs2_ondisk.h>]])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index ac1e5d7..793ef6b 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -296,8 +296,18 @@ static void print_inode_type(__be16 de_type)
}
}
+#ifdef GFS2_HAS_LEAF_HINTS
+#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
+ "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
+#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
+#else
+#define LEAF_HINT_FMTS
+#define LEAF_HINT_FIELDS(lp)
+#endif
+
static int display_leaf(struct iinfo *ind)
{
+ struct gfs2_leaf *leaf = &ind->ii[0].lf;
int start_line, total_dirents = start_row[dmode];
int d;
@@ -305,11 +315,13 @@ static int display_leaf(struct iinfo *ind)
if (gfs2_struct_type == GFS2_METATYPE_SB)
print_gfs2("The superblock has 2 directories");
else
- print_gfs2("Directory block: lf_depth:%d, lf_entries:%d,"
+ print_gfs2("Directory block: lf_depth:%d, lf_entries:%d, "
+ LEAF_HINT_FMTS
"fmt:%d next=0x%llx (%d dirents).",
- ind->ii[0].lf_depth, ind->ii[0].lf_entries,
- ind->ii[0].lf_dirent_format,
- ind->ii[0].lf_next,
+ leaf->lf_depth, leaf->lf_entries,
+ LEAF_HINT_FIELDS(leaf)
+ leaf->lf_dirent_format,
+ leaf->lf_next,
ind->ii[0].dirents);
start_line = line;
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 8544bbd..979aee0 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -322,17 +322,12 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
{
int x, i;
struct gfs2_dirent de;
- struct gfs2_leaf leaf;
struct gfs2_buffer_head tbh; /* kludge */
x = 0;
memset(indir, 0, sizeof(*indir));
tbh.b_data = dlebuf;
- gfs2_leaf_in(&leaf, &tbh);
- indir->ii[0].lf_depth = leaf.lf_depth;
- indir->ii[0].lf_entries = leaf.lf_entries;
- indir->ii[0].lf_dirent_format = leaf.lf_dirent_format;
- indir->ii[0].lf_next = leaf.lf_next;
+ gfs2_leaf_in(&indir->ii[0].lf, &tbh);
/* Directory Entries: */
for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
i += de.de_rec_len) {
@@ -353,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
if (de.de_rec_len <= sizeof(struct gfs2_dirent))
break;
}
- return leaf.lf_next;
+ return indir->ii[0].lf.lf_next;
}
static void do_eattr_extended(struct gfs2_buffer_head *ebh)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 1ed4755..cf57ec8 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -219,7 +219,15 @@ static int gfs2_leaf_printval(struct gfs2_leaf *lf, const char *strfield)
checkprint(strfield, lf, lf_entries);
checkprint(strfield, lf, lf_dirent_format);
checkprint(strfield, lf, lf_next);
+#ifdef GFS2_HAS_LEAF_HINTS
+ checkprint(strfield, lf, lf_inode);
+ checkprint(strfield, lf, lf_dist);
+ checkprint(strfield, lf, lf_nsec);
+ checkprint(strfield, lf, lf_sec);
+ checkprints(strfield, lf, lf_reserved2);
+#else
checkprints(strfield, lf, lf_reserved);
+#endif
return -1;
}
@@ -231,6 +239,12 @@ static int gfs2_leaf_assignval(struct gfs2_leaf *lf, const char *strfield,
checkassign(strfield, lf, lf_entries, value);
checkassign(strfield, lf, lf_dirent_format, value);
checkassign(strfield, lf, lf_next, value);
+#ifdef GFS2_HAS_LEAF_HINTS
+ checkassign(strfield, lf, lf_inode, value);
+ checkassign(strfield, lf, lf_dist, value);
+ checkassign(strfield, lf, lf_nsec, value);
+ checkassign(strfield, lf, lf_sec, value);
+#endif
return -1;
}
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 21cf70a..7615242 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -79,10 +79,7 @@ struct indirect_info {
int height;
uint64_t block;
uint32_t dirents;
- uint16_t lf_depth;
- uint16_t lf_entries;
- uint32_t lf_dirent_format;
- uint64_t lf_next;
+ struct gfs2_leaf lf;
struct metapath mp;
struct gfs2_dirents dirent[64];
};
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b9b4154..15cba56 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -657,7 +657,6 @@ static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
int error = 0;
- struct gfs2_leaf leaf;
unsigned hsize = (1 << ip->i_di.di_depth);
uint64_t leaf_no, leaf_next;
uint64_t first_ok_leaf, orig_di_blocks;
@@ -767,6 +766,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
chained_leaf = 0;
do {
+ struct gfs2_leaf leaf;
if (fsck_abort) {
free(tbl);
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e00bd1f..f59f014 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -941,6 +941,9 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
oleaf->lf_depth = cpu_to_be16(oleaf->lf_depth);
nleaf->lf_depth = oleaf->lf_depth;
+#ifdef GFS2_HAS_LEAF_HINTS
+ nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
dip->i_di.di_blocks++;
bmodified(dip->i_bh);
@@ -1124,7 +1127,9 @@ restart:
nleaf = (struct gfs2_leaf *)nbh->b_data;
nleaf->lf_depth = leaf->lf_depth;
nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+ nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
err = dirent_alloc(dip, nbh, len, &dent);
if (err)
return err;
@@ -1175,7 +1180,9 @@ static void dir_make_exhash(struct gfs2_inode *dip)
leaf = (struct gfs2_leaf *)bh->b_data;
leaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+ leaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+#endif
buffer_copy_tail(sdp, bh, sizeof(struct gfs2_leaf),
dip->i_bh, sizeof(struct gfs2_dinode));
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 94be823..4305393 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -317,7 +317,15 @@ F(lf_depth)
F(lf_entries)
F(lf_dirent_format)
F(lf_next)
+#ifdef GFS2_HAS_LEAF_HINTS
+FP(lf_inode, .points_to = (1 << LGFS2_MT_GFS2_DINODE))
+F(lf_dist)
+F(lf_nsec, .flags = LGFS2_MFF_NSECS)
+F(lf_sec, .flags = LGFS2_MFF_SECS)
+RF(lf_reserved2)
+#else
RF(lf_reserved)
+#endif
};
#undef STRUCT
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 43618bc..dcc537e 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -433,8 +433,15 @@ void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
CPIN_16(lf, str, lf_entries);
CPIN_32(lf, str, lf_dirent_format);
CPIN_64(lf, str, lf_next);
-
+#ifdef GFS2_HAS_LEAF_HINTS
+ CPIN_64(lf, str, lf_inode);
+ CPIN_32(lf, str, lf_dist);
+ CPIN_32(lf, str, lf_nsec);
+ CPIN_64(lf, str, lf_sec);
+ CPIN_08(lf, str, lf_reserved2, 40);
+#else
CPIN_08(lf, str, lf_reserved, 32);
+#endif
}
void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
@@ -446,8 +453,15 @@ void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
CPOUT_16(lf, str, lf_entries);
CPOUT_32(lf, str, lf_dirent_format);
CPOUT_64(lf, str, lf_next);
-
- CPOUT_08(lf, str, lf_reserved, 32);
+#ifdef GFS2_HAS_LEAF_HINTS
+ CPOUT_64(lf, str, lf_inode);
+ CPOUT_32(lf, str, lf_dist);
+ CPOUT_32(lf, str, lf_nsec);
+ CPOUT_64(lf, str, lf_sec);
+ CPOUT_08(lf, str, lf_reserved2, 40);
+#else
+ CPOUT_08(lf, str, lf_reserved, 64);
+#endif
bmodified(bh);
}
@@ -458,6 +472,12 @@ void gfs2_leaf_print(struct gfs2_leaf *lf)
pv(lf, lf_entries, "%u", "0x%x");
pv(lf, lf_dirent_format, "%u", "0x%x");
pv(lf, lf_next, "%llu", "0x%llx");
+#ifdef GFS2_HAS_LEAF_HINTS
+ pv(lf, lf_inode, "%llu", "0x%llx");
+ pv(lf, lf_dist, "%u", "0x%x");
+ pv(lf, lf_nsec, "%u", "0x%x");
+ pv(lf, lf_sec, "%llu", "0x%llx");
+#endif
}
void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf)
10 years, 1 month