fence-agents: master - fence_wti: Add support for firmware v1.40 (on MPC device)
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=53fe38...
Commit: 53fe387f00278e769e00ec10b28e2cb6ff52c8b1
Parent: b6a75b41f9180f3cf4d2d2632873f4c5920ce260
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Jan 29 15:29:21 2014 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Jan 29 15:29:21 2014 +0100
fence_wti: Add support for firmware v1.40 (on MPC device)
Previously, named groups were tested only on firmware v1.43 (on NPS device).
---
fence/agents/wti/fence_wti.py | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 34967e1..c9c5237 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -96,12 +96,13 @@ def get_plug_group_status(conn, options):
if (line.find("|") >= 0 and line.lstrip().startswith("GROUP NAME") == False):
plug_line = [x.strip().lower() for x in line.split("|")]
if ["list", "monitor"].count(options["--action"]) == 0 and options["--plug"].lower() == plug_line[name_index]:
- line_index += 1
plug_status = []
while line_index < len(lines) and line_index >= 0:
plug_line = [x.strip().lower() for x in lines[line_index].split("|")]
- if len(plug_line[plug_index]) > 0 and len(plug_line[name_index]) == 0:
- plug_status.append(plug_line[status_index])
+ if len(plug_line) >= max(name_index, status_index) and len(plug_line[plug_index]) > 0 and (len(plug_line[name_index]) == 0 or options["--plug"].lower() == plug_line[name_index]):
+ ## Firmware 1.43 does not have a valid value of plug on first line as only name is defined on that line
+ if not "---" in plug_line[status_index]:
+ plug_status.append(plug_line[status_index])
line_index += 1
else:
line_index = -1
10 years, 2 months
gfs2-utils: master - libgfs2: Remove exit call from build_rgrps
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=0e703881...
Commit: 0e7038812bb5d12cbe32504f8bba94decf9e75b9
Parent: 4300064eccf5568e2d69e156af7d92bf9cac8368
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Jan 27 14:11:40 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Jan 27 14:11:40 2014 +0000
libgfs2: Remove exit call from build_rgrps
Change build_rgrps to return an error value instead of void and push the
exit call down into fsck.gfs2 and gfs2_grow.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 5 ++++-
gfs2/libgfs2/fs_geometry.c | 10 ++++------
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/mkfs/main_grow.c | 5 ++++-
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 1ebdc70..2c1d613 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -654,7 +654,10 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
/* Compute the default resource group layout as mkfs would have done */
compute_rgrp_layout(sdp, &sdp->rgcalc, TRUE);
debug_print_rgrps(sdp, &sdp->rgcalc);
- build_rgrps(sdp, FALSE); /* FALSE = calc but don't write to disk. */
+ if (build_rgrps(sdp, FALSE)) { /* FALSE = calc but don't write to disk. */
+ fprintf(stderr, _("Failed to build resource groups\n"));
+ exit(-1);
+ }
log_debug( _("fs_total_size = 0x%llx blocks.\n"),
(unsigned long long)sdp->device.length);
log_warn( _("L3: number of rgs in the index = %d.\n"), *num_rgs);
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 932a2e6..4bdb64a 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -171,7 +171,7 @@ uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks, u
* If fd > 0, write the data to the given file handle.
* Otherwise, use gfs2 buffering in buf.c.
*/
-void build_rgrps(struct gfs2_sbd *sdp, int do_write)
+int build_rgrps(struct gfs2_sbd *sdp, int do_write)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rl;
@@ -207,11 +207,8 @@ void build_rgrps(struct gfs2_sbd *sdp, int do_write)
rl->rg.rg_header.mh_format = GFS2_FORMAT_RG;
rl->rg.rg_free = rgblocks;
- if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rl)) {
- fprintf(stderr, "%s: Unable to build resource groups "
- "with these characteristics.\n", __FUNCTION__);
- exit(-1);
- }
+ if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rl))
+ return -1;
if (do_write) {
for (x = 0; x < bitblocks; x++) {
@@ -231,4 +228,5 @@ void build_rgrps(struct gfs2_sbd *sdp, int do_write)
sdp->blks_total += rgblocks;
sdp->fssize = ri->ri_data0 + ri->ri_data;
}
+ return 0;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 71adb30..cc65003 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -431,7 +431,7 @@ extern uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev,
int rgsize_specified);
extern void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
int rgsize_specified);
-extern void build_rgrps(struct gfs2_sbd *sdp, int write);
+extern int build_rgrps(struct gfs2_sbd *sdp, int write);
/* fs_ops.c */
#define IS_LEAF (1)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 541b0f2..718bb30 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -181,7 +181,10 @@ static void initialize_new_portion(struct gfs2_sbd *sdp, int *old_rg_count)
discard_blocks(sdp->device_fd, rl->start * sdp->bsize,
(sdp->device.length - rl->start) * sdp->bsize);
/* Build the remaining resource groups */
- build_rgrps(sdp, !test);
+ if (build_rgrps(sdp, !test)) {
+ fprintf(stderr, _("Failed to build resource groups\n"));
+ exit(-1);
+ }
inode_put(&sdp->md.riinode);
inode_put(&sdp->master_dir);
10 years, 2 months
gfs2-utils: master - gfs2-utils: Clean up unused functions
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=4300064e...
Commit: 4300064eccf5568e2d69e156af7d92bf9cac8368
Parent: efd06c888ff3bbf1a7076b3283bf1f0bfa51be1c
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Jan 27 12:27:50 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Jan 27 12:27:50 2014 +0000
gfs2-utils: Clean up unused functions
Remove unused functions, some of which call exit() from libgfs2.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/Makefile.am | 4 +-
gfs2/fsck/eattr.c | 63 ------------------------------------------------
gfs2/fsck/eattr.h | 18 -------------
gfs2/fsck/pass2.c | 1 -
gfs2/libgfs2/fs_ops.c | 18 -------------
gfs2/libgfs2/gfs1.c | 14 ----------
gfs2/libgfs2/libgfs2.h | 4 ---
gfs2/libgfs2/misc.c | 28 ---------------------
8 files changed, 2 insertions(+), 148 deletions(-)
diff --git a/gfs2/fsck/Makefile.am b/gfs2/fsck/Makefile.am
index b92c745..92d56f3 100644
--- a/gfs2/fsck/Makefile.am
+++ b/gfs2/fsck/Makefile.am
@@ -10,10 +10,10 @@ sbindir := $(shell rpl=0; test '$(exec_prefix):$(sbindir)' = /usr:/usr/sbin \
sbin_PROGRAMS = fsck.gfs2
-noinst_HEADERS = eattr.h fsck.h fs_recovery.h \
+noinst_HEADERS = fsck.h fs_recovery.h \
inode_hash.h link.h lost_n_found.h metawalk.h util.h
-fsck_gfs2_SOURCES = eattr.c fs_recovery.c initialize.c \
+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
diff --git a/gfs2/fsck/eattr.c b/gfs2/fsck/eattr.c
deleted file mode 100644
index 3f95d93..0000000
--- a/gfs2/fsck/eattr.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdint.h>
-#include <string.h>
-#include <libintl.h>
-#define _(String) gettext(String)
-
-#include "libgfs2.h"
-#include "fsck.h"
-#include "metawalk.h"
-#include "eattr.h"
-
-int clear_eattr_entry (struct gfs2_inode *ip,
- struct gfs2_buffer_head *leaf_bh,
- struct gfs2_ea_header *ea_hdr,
- struct gfs2_ea_header *ea_hdr_prev,
- void *private)
-{
- struct gfs2_sbd *sdp = ip->i_sbd;
-
- if (!ea_hdr->ea_name_len){
- /* Skip this entry for now */
- return 1;
- }
-
- if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
- ((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
- /* Skip invalid entry */
- return 1;
- }
-
- if (ea_hdr->ea_num_ptrs){
- uint32_t avail_size;
- int max_ptrs;
-
- avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
- max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len)+avail_size-1)/avail_size;
-
- if (max_ptrs > ea_hdr->ea_num_ptrs) {
- return 1;
- } else {
- log_debug( _(" Pointers Required: %d\n"
- " Pointers Reported: %d\n"),
- max_ptrs, ea_hdr->ea_num_ptrs);
- }
-
-
- }
- return 0;
-}
-
-int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
- struct gfs2_buffer_head *leaf_bh,
- struct gfs2_ea_header *ea_hdr,
- struct gfs2_ea_header *ea_hdr_prev, void *private)
-{
- uint64_t block = be64_to_cpu(*ea_data_ptr);
-
- return delete_eattr_leaf(ip, block, 0, &leaf_bh, private);
-}
-
-
-
diff --git a/gfs2/fsck/eattr.h b/gfs2/fsck/eattr.h
deleted file mode 100644
index f4264b0..0000000
--- a/gfs2/fsck/eattr.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _EATTR_H
-#define _EATTR_H
-
-int clear_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
- struct gfs2_buffer_head **bh, void *private);
-int clear_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
- struct gfs2_buffer_head **bh, void *private);
-int clear_eattr_entry (struct gfs2_inode *ip,
- struct gfs2_buffer_head *leaf_bh,
- struct gfs2_ea_header *ea_hdr,
- struct gfs2_ea_header *ea_hdr_prev,
- void *private);
-int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
- struct gfs2_buffer_head *leaf_bh,
- struct gfs2_ea_header *ea_hdr,
- struct gfs2_ea_header *ea_hdr_prev, void *private);
-
-#endif /* _EATTR_H */
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 26f7d48..d3b56fc 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -12,7 +12,6 @@
#include "libgfs2.h"
#include "fsck.h"
#include "util.h"
-#include "eattr.h"
#include "metawalk.h"
#include "link.h"
#include "lost_n_found.h"
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 7a6f57a..e00bd1f 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -835,24 +835,6 @@ void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
*leaf_out = be64_to_cpu(leaf_no);
}
-void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
-{
- uint64_t leaf_no;
- int count;
-
- if (dip->i_sbd->gfs1) {
- gfs_put_leaf_nr(dip, inx, leaf_out);
- return;
- }
- leaf_no = cpu_to_be64(leaf_out);
- count = gfs2_writei(dip, (char *)&leaf_no, inx * sizeof(uint64_t),
- sizeof(uint64_t));
- if (count != sizeof(uint64_t)) {
- fprintf(stderr, "gfs2_put_leaf_nr: Bad internal write.\n");
- exit(1);
- }
-}
-
void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
struct gfs2_buffer_head *obh)
{
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 8c8ca91..c00d7be 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -389,17 +389,3 @@ void gfs_rgrp_out(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh)
memcpy(str->rg_reserved, rgrp->rg_reserved, 64);
bmodified(rbh);
}
-
-void gfs_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
-{
- uint64_t leaf_no;
- int count;
-
- leaf_no = cpu_to_be64(leaf_out);
- count = gfs1_writei(dip, (char *)&leaf_no, inx * sizeof(uint64_t),
- sizeof(uint64_t));
- if (count != sizeof(uint64_t)) {
- fprintf(stderr, "gfs_put_leaf_nr: Bad internal write.\n");
- exit(1);
- }
-}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 084ef41..71adb30 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -481,7 +481,6 @@ extern void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
uint64_t *dblock, uint32_t *extlen, int prealloc);
extern void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t index,
uint64_t *leaf_out);
-extern void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out);
extern void dir_split_leaf(struct gfs2_inode *dip, uint32_t start,
uint64_t leaf_no, struct gfs2_buffer_head *obh);
extern void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block);
@@ -670,8 +669,6 @@ extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp,
extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
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);
-extern void gfs_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx,
- uint64_t leaf_out);
/* gfs2_log.c */
@@ -721,7 +718,6 @@ 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);
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);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 8ee8324..d34b8a5 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -23,7 +23,6 @@
#include "libgfs2.h"
#define PAGE_SIZE (4096)
-#define SYS_BASE "/sys/fs/gfs2" /* FIXME: Look in /proc/mounts to find this */
#define DIV_RU(x, y) (((x) + (y) - 1) / (y))
int metafs_interrupted = 0;
@@ -278,33 +277,6 @@ void cleanup_metafs(struct gfs2_sbd *sdp)
metafs_interrupted = 0;
}
-int set_sysfs(const char *fsname, const char *filename, const char *val)
-{
- char path[PATH_MAX];
- int fd, rv, len;
-
- len = strlen(val) + 1;
- if (len > PAGE_SIZE) {
- errno = EINVAL;
- return -1;
- }
-
- memset(path, 0, PATH_MAX);
- snprintf(path, PATH_MAX - 1, "%s/%s/%s", SYS_BASE, fsname, filename);
-
- fd = open(path, O_WRONLY);
- if (fd < 0)
- return -1;
-
- rv = write(fd, val, len);
- if (rv != len) {
- close(fd);
- return -1;
- }
- close(fd);
- return 0;
-}
-
/*
* get_random_bytes - Generate a series of random bytes using /dev/urandom.
*
10 years, 2 months
gfs2-utils: master - libgfs2: Refactor block allocation functions
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=efd06c88...
Commit: efd06c888ff3bbf1a7076b3283bf1f0bfa51be1c
Parent: f1fe60d8d2fca0eb10d5cec6ecf8dacac3cb262e
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 22 21:33:51 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Jan 27 11:46:58 2014 +0000
libgfs2: Refactor block allocation functions
Split the part of blk_alloc_in_rg which finds a free block out into a
separate find_free_block function. This will allow callers to have more
control over where blocks are allocated in future.
Also combine the old blk_alloc_i and lgfs2_dinode_alloc and meta_alloc
functions into a single block_alloc function which now acts as a backing
function for lgfs2_dinode_alloc and meta_alloc, which is renamed
lgfs2_meta_alloc. An exit() call from blk_alloc_i has been pushed down
into its callers and replaced with error returns where possible.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/metawalk.c | 7 ++-
gfs2/libgfs2/fs_ops.c | 119 +++++++++++++++++++++++------------------------
gfs2/libgfs2/gfs1.c | 6 ++-
gfs2/libgfs2/libgfs2.h | 2 +-
4 files changed, 70 insertions(+), 64 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b8cef87..b9b4154 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1912,7 +1912,12 @@ int write_new_leaf(struct gfs2_inode *dip, int start_lindex, int num_copies,
}
/* allocate and write out a new leaf block */
- *bn = meta_alloc(dip);
+ if (lgfs2_meta_alloc(dip, bn)) {
+ log_err( _("Error: allocation failed while fixing directory leaf "
+ "pointers.\n"));
+ free(padbuf);
+ return -1;
+ }
fsck_blockmap_set(dip, *bn, _("directory leaf"), gfs2_leaf_blk);
log_err(_("A new directory leaf was allocated at block %lld "
"(0x%llx) to fill the %d (0x%x) pointer gap %s the existing "
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 1d6fb4a..7a6f57a 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -112,24 +112,16 @@ void inode_put(struct gfs2_inode **ip_in)
*ip_in = NULL; /* make sure the memory isn't accessed again */
}
-static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tree *rgd, uint64_t *blkno)
+static uint64_t find_free_block(struct rgrp_tree *rgd)
{
- unsigned int release = 0;
- unsigned int bm;
- int error = -1;
+ unsigned bm;
+ uint64_t blkno = 0;
if (rgd == NULL || rgd->rg.rg_free == 0) {
errno = ENOSPC;
- return -1;
- }
-
- if (rgd->bh[0] == NULL) {
- if (gfs2_rgrp_read(sdp, rgd))
- return -1;
- release = 1;
+ return 0;
}
- *blkno = 0;
for (bm = 0; bm < rgd->ri.ri_length; bm++) {
unsigned long blk = 0;
struct gfs2_bitmap *bits = &rgd->bits[bm];
@@ -137,17 +129,20 @@ static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tre
blk = gfs2_bitfit((unsigned char *)rgd->bh[bm]->b_data + bits->bi_offset,
bits->bi_len, blk, GFS2_BLKST_FREE);
if (blk != BFITNOENT) {
- *blkno = blk + (bits->bi_start * GFS2_NBBY) + rgd->ri.ri_data0;
+ blkno = blk + (bits->bi_start * GFS2_NBBY) + rgd->ri.ri_data0;
break;
}
}
+ return blkno;
+}
- if (*blkno == 0)
- goto out;
+static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tree *rgd, uint64_t blkno)
+{
+ if (blkno == 0)
+ return -1;
- error = gfs2_set_bitmap(sdp, *blkno, state);
- if (error)
- goto out;
+ if (gfs2_set_bitmap(sdp, blkno, state))
+ return -1;
if (state == GFS2_BLKST_DINODE)
rgd->rg.rg_dinodes++;
@@ -159,50 +154,22 @@ static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tre
gfs2_rgrp_out_bh(&rgd->rg, rgd->bh[0]);
sdp->blks_alloced++;
-out:
- if (release)
- gfs2_rgrp_relse(rgd);
- return error;
-}
-
-/**
- * Do not use this function, it's only here until we can kill it.
- * Use blk_alloc_in_rg directly instead.
- */
-static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
-{
- int ret;
- uint64_t blkno = 0;
- struct osi_node *n = NULL;
- for (n = osi_first(&sdp->rgtree); n; n = osi_next(n)) {
- if (((struct rgrp_tree *)n)->rg.rg_free)
- break;
- }
- ret = blk_alloc_in_rg(sdp, type, (struct rgrp_tree *)n, &blkno);
- if (ret != 0) /* Do what the old blk_alloc_i did */
- exit(1);
- return blkno;
-}
-
-uint64_t meta_alloc(struct gfs2_inode *ip)
-{
- uint64_t x;
- x = blk_alloc_i(ip->i_sbd, GFS2_BLKST_USED);
- ip->i_di.di_goal_meta = x;
- bmodified(ip->i_bh);
- return x;
+ return 0;
}
/**
- * Allocate a dinode block in a bitmap. In order to plan ahead we look for a
- * resource group with blksreq free blocks but only allocate the one dinode block.
+ * Allocate a block in a bitmap. In order to plan ahead we look for a
+ * resource group with blksreq free blocks but only allocate the one block.
* Returns 0 on success with the allocated block number in *blkno or non-zero otherwise.
*/
-int lgfs2_dinode_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, uint64_t *blkno)
+static int block_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, int state, uint64_t *blkno)
{
int ret;
+ int release = 0;
struct rgrp_tree *rgt = NULL;
struct osi_node *n = NULL;
+ uint64_t bn = 0;
+
for (n = osi_first(&sdp->rgtree); n; n = osi_next(n)) {
rgt = (struct rgrp_tree *)n;
if (rgt->rg.rg_free >= blksreq)
@@ -211,10 +178,35 @@ int lgfs2_dinode_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, uint64_t *b
if (rgt == NULL)
return -1;
- ret = blk_alloc_in_rg(sdp, GFS2_BLKST_DINODE, rgt, blkno);
+ if (rgt->bh[0] == NULL) {
+ if (gfs2_rgrp_read(sdp, rgt))
+ return -1;
+ release = 1;
+ }
+
+ bn = find_free_block(rgt);
+ ret = blk_alloc_in_rg(sdp, state, rgt, bn);
+ if (release)
+ gfs2_rgrp_relse(rgt);
+ *blkno = bn;
+ return ret;
+}
+
+int lgfs2_dinode_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, uint64_t *blkno)
+{
+ int ret = block_alloc(sdp, blksreq, GFS2_BLKST_DINODE, blkno);
if (ret == 0)
sdp->dinodes_alloced++;
+ return ret;
+}
+int lgfs2_meta_alloc(struct gfs2_inode *ip, uint64_t *blkno)
+{
+ int ret = block_alloc(ip->i_sbd, 1, GFS2_BLKST_USED, blkno);
+ if (ret == 0) {
+ ip->i_di.di_goal_meta = *blkno;
+ bmodified(ip->i_bh);
+ }
return ret;
}
@@ -245,10 +237,11 @@ void unstuff_dinode(struct gfs2_inode *ip)
int isdir = S_ISDIR(ip->i_di.di_mode) || is_gfs_dir(&ip->i_di);
if (ip->i_di.di_size) {
+ if (lgfs2_meta_alloc(ip, &block))
+ exit(1);
if (isdir) {
struct gfs2_meta_header mh;
- block = meta_alloc(ip);
bh = bget(sdp, block);
mh.mh_magic = GFS2_MAGIC;
mh.mh_type = GFS2_METATYPE_JD;
@@ -261,7 +254,6 @@ void unstuff_dinode(struct gfs2_inode *ip)
brelse(bh);
} else {
- block = meta_alloc(ip);
bh = bget(sdp, block);
buffer_copy_tail(sdp, bh, 0,
@@ -325,7 +317,8 @@ void build_height(struct gfs2_inode *ip, int height)
if (new_block) {
struct gfs2_meta_header mh;
- block = meta_alloc(ip);
+ if (lgfs2_meta_alloc(ip, &block))
+ exit(1);
bh = bget(sdp, block);
mh.mh_magic = GFS2_MAGIC;
mh.mh_type = GFS2_METATYPE_IN;
@@ -377,7 +370,8 @@ void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (!create)
return;
- *block = meta_alloc(ip);
+ if (lgfs2_meta_alloc(ip, block))
+ return;
*ptr = cpu_to_be64(*block);
bmodified(bh);
ip->i_di.di_blocks++;
@@ -871,7 +865,8 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
int x, moved = FALSE;
int count;
- bn = meta_alloc(dip);
+ if (lgfs2_meta_alloc(dip, &bn))
+ exit(1);
nbh = bget(dip->i_sbd, bn);
{
struct gfs2_meta_header mh;
@@ -1134,7 +1129,8 @@ restart:
} else {
struct gfs2_meta_header mh;
- bn = meta_alloc(dip);
+ if (lgfs2_meta_alloc(dip, &bn))
+ exit(1);
nbh = bget(dip->i_sbd, bn);
mh.mh_magic = GFS2_MAGIC;
mh.mh_type = GFS2_METATYPE_LF;
@@ -1183,7 +1179,8 @@ static void dir_make_exhash(struct gfs2_inode *dip)
uint32_t x;
uint64_t *lp, bn;
- bn = meta_alloc(dip);
+ if (lgfs2_meta_alloc(dip, &bn))
+ exit(1);
bh = bget(sdp, bn);
{
struct gfs2_meta_header mh;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 00e18e6..8c8ca91 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -57,7 +57,11 @@ void gfs1_lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (!create)
return;
- *block = meta_alloc(ip);
+ if (lgfs2_meta_alloc(ip, block)) {
+ *block = 0;
+ return;
+ }
+
*ptr = cpu_to_be64(*block);
bmodified(bh);
ip->i_di.di_blocks++;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 07cb221..084ef41 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -448,7 +448,7 @@ extern struct gfs2_inode *is_system_inode(struct gfs2_sbd *sdp,
uint64_t block);
extern void inode_put(struct gfs2_inode **ip);
extern uint64_t data_alloc(struct gfs2_inode *ip);
-extern uint64_t meta_alloc(struct gfs2_inode *ip);
+extern int lgfs2_meta_alloc(struct gfs2_inode *ip, uint64_t *blkno);
extern int lgfs2_dinode_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, uint64_t *blkno);
extern int gfs2_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
unsigned int size);
10 years, 2 months
gfs2-utils: master - mkfs.gfs2 tests: Enable debug output
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=f1fe60d8...
Commit: f1fe60d8d2fca0eb10d5cec6ecf8dacac3cb262e
Parent: df42f67e822a19d4158735d2254be64131830da8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 22 18:46:53 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Jan 27 11:46:14 2014 +0000
mkfs.gfs2 tests: Enable debug output
Enable debug output of mkfs.gfs2 tests and define the base options as a
shell variable to make them easier to maintain.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
tests/atlocal.in | 1 +
tests/mkfs.at | 46 +++++++++++++++++++++++-----------------------
2 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 660c87a..b021b13 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -1,5 +1,6 @@
GFS_TGT="$abs_builddir/testvol"
GFS_TGT_SZ=10
+GFS_MKFS="mkfs.gfs2 -O -D"
gfs_max_blocks()
{
diff --git a/tests/mkfs.at b/tests/mkfs.at
index a3973af..2616109 100644
--- a/tests/mkfs.at
+++ b/tests/mkfs.at
@@ -2,70 +2,70 @@ AT_TESTED([mkfs.gfs2])
AT_BANNER([mkfs.gfs2 tests])
AT_SETUP([Locking protocol validation])
-AT_CHECK([mkfs.gfs2 -O -p badprotocol $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p badprotocol $GFS_TGT], 255, [ignore], [ignore])
AT_CLEANUP
AT_SETUP([Resource group size validation])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -r 31 $GFS_TGT], 255, [ignore], [ignore])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -r 2049 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 31 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -r 2049 $GFS_TGT], 255, [ignore], [ignore])
AT_CLEANUP
AT_SETUP([Journal size validation])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -J 7 $GFS_TGT], 255, [ignore], [ignore])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -J 1025 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -J 7 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -J 1025 $GFS_TGT], 255, [ignore], [ignore])
AT_CLEANUP
AT_SETUP([Block count validation])
GFS_TGT_REGEN
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -b 512 $GFS_TGT $(($(gfs_max_blocks 512)+1))], 255, [ignore], [ignore])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -b 4096 $GFS_TGT $(($(gfs_max_blocks 4096)+1))], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -b 512 $GFS_TGT $(($(gfs_max_blocks 512)+1))], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -b 4096 $GFS_TGT $(($(gfs_max_blocks 4096)+1))], 255, [ignore], [ignore])
AT_CLEANUP
AT_SETUP([Quota change file size validation])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -c 0 $GFS_TGT], 255, [ignore], [ignore])
-AT_CHECK([mkfs.gfs2 -O -p lock_nolock -c 65 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -c 0 $GFS_TGT], 255, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -c 65 $GFS_TGT], 255, [ignore], [ignore])
AT_CLEANUP
AT_SETUP([Locking protocols])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_dlm -t foo:bar $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_dlm -t foo:bar $GFS_TGT])
AT_CLEANUP
AT_SETUP([Valid block sizes 512-4096])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -b 512 $GFS_TGT])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -b 1024 $GFS_TGT])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -b 2048 $GFS_TGT])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -b 4096 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 512 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 1024 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 2048 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 4096 $GFS_TGT])
AT_CLEANUP
AT_SETUP([Max. blocks, min. block size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -b 512 $GFS_TGT $(gfs_max_blocks 512)])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 512 $GFS_TGT $(gfs_max_blocks 512)])
AT_CLEANUP
AT_SETUP([Max. blocks, max. block size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -b 4096 $GFS_TGT $(util_max_blocks 4096)])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -b 4096 $GFS_TGT $(util_max_blocks 4096)])
AT_CLEANUP
AT_SETUP([Max. resource group size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -r 2048 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -r 2048 $GFS_TGT])
AT_CLEANUP
AT_SETUP([Min. resource group size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -r 32 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -r 32 $GFS_TGT])
AT_CLEANUP
AT_SETUP([Max. journal size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -J 1024 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -J 1024 $GFS_TGT])
AT_CLEANUP
AT_SETUP([Min. journal size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -J 8 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -J 8 $GFS_TGT])
AT_CLEANUP
AT_SETUP([Max. quota change file size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -c 64 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -c 64 $GFS_TGT])
AT_CLEANUP
AT_SETUP([Min. quota change file size])
-GFS_FSCK_CHECK([mkfs.gfs2 -O -p lock_nolock -c 1 $GFS_TGT])
+GFS_FSCK_CHECK([$GFS_MKFS -p lock_nolock -c 1 $GFS_TGT])
AT_CLEANUP
10 years, 2 months
gfs2-utils: master - libgfs2: Improve and simplify blk_alloc_in_rg
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=df42f67e...
Commit: df42f67e822a19d4158735d2254be64131830da8
Parent: 51c39f1d31996b3e3f6536369dea8dba17af6782
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 22 18:04:08 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Jan 27 11:46:14 2014 +0000
libgfs2: Improve and simplify blk_alloc_in_rg
This function included naive implementations of gfs2_setbit and
gfs2_bitfit so these have been replaced with calls to those functions.
The 'type' parameter has been replaced with 'state' and the type
defines removed in favour of the GFS2_BLKST_* values. As these were the
same for both meta and data block allocations, data_alloc() has been
removed and its callers updated to use meta_alloc().
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 117 ++++++++++++++----------------------------------
gfs2/libgfs2/gfs1.c | 7 +---
2 files changed, 35 insertions(+), 89 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 03b1c41..1d6fb4a 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -14,10 +14,6 @@
#include <linux/types.h>
#include "libgfs2.h"
-#define DATA (1)
-#define META (2)
-#define DINODE (3)
-
static __inline__ uint64_t *metapointer(struct gfs2_buffer_head *bh,
unsigned int height,
struct metapath *mp)
@@ -116,88 +112,57 @@ void inode_put(struct gfs2_inode **ip_in)
*ip_in = NULL; /* make sure the memory isn't accessed again */
}
-static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned int type, struct rgrp_tree *rl, uint64_t *blkno)
+static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tree *rgd, uint64_t *blkno)
{
- struct gfs2_rindex *ri;
- struct gfs2_rgrp *rg;
- unsigned int block, bn = 0, x = 0, y = 0;
- unsigned int state;
unsigned int release = 0;
- struct gfs2_buffer_head *bh;
+ unsigned int bm;
+ int error = -1;
- if (rl == NULL || rl->rg.rg_free == 0) {
+ if (rgd == NULL || rgd->rg.rg_free == 0) {
errno = ENOSPC;
return -1;
}
- if (rl->bh[0] == NULL) {
- if (gfs2_rgrp_read(sdp, rl) != 0)
+ if (rgd->bh[0] == NULL) {
+ if (gfs2_rgrp_read(sdp, rgd))
return -1;
release = 1;
}
- ri = &rl->ri;
- rg = &rl->rg;
- for (block = 0; block < ri->ri_length; block++) {
- bh = rl->bh[block];
- x = (block) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_rgrp);
-
- for (; x < sdp->bsize; x++)
- for (y = 0; y < GFS2_NBBY; y++) {
- state = (bh->b_data[x] >> (GFS2_BIT_SIZE * y)) & 0x03;
- if (state == GFS2_BLKST_FREE)
- goto found;
- bn++;
- }
- }
+ *blkno = 0;
+ for (bm = 0; bm < rgd->ri.ri_length; bm++) {
+ unsigned long blk = 0;
+ struct gfs2_bitmap *bits = &rgd->bits[bm];
- fprintf(stderr, "allocation is broken (1): %"PRIu64" %u\n",
- (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
- goto out_err;
-
-found:
- if (bn >= ri->ri_bitbytes * GFS2_NBBY) {
- fprintf(stderr, "allocation is broken (2): bn: %u %u rgrp: %"PRIu64
- " (0x%" PRIx64 ") Free:%u\n",
- bn, ri->ri_bitbytes * GFS2_NBBY, (uint64_t)rl->ri.ri_addr,
- (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
- goto out_err;
+ blk = gfs2_bitfit((unsigned char *)rgd->bh[bm]->b_data + bits->bi_offset,
+ bits->bi_len, blk, GFS2_BLKST_FREE);
+ if (blk != BFITNOENT) {
+ *blkno = blk + (bits->bi_start * GFS2_NBBY) + rgd->ri.ri_data0;
+ break;
+ }
}
- switch (type) {
- case DATA:
- case META:
- state = GFS2_BLKST_USED;
- break;
- case DINODE:
- state = GFS2_BLKST_DINODE;
- rg->rg_dinodes++;
- break;
- default:
- fprintf(stderr, "bad state\n");
- goto out_err;
- }
+ if (*blkno == 0)
+ goto out;
- bh->b_data[x] &= ~(0x03 << (GFS2_BIT_SIZE * y));
- bh->b_data[x] |= state << (GFS2_BIT_SIZE * y);
- rg->rg_free--;
+ error = gfs2_set_bitmap(sdp, *blkno, state);
+ if (error)
+ goto out;
- bmodified(bh);
+ if (state == GFS2_BLKST_DINODE)
+ rgd->rg.rg_dinodes++;
+
+ rgd->rg.rg_free--;
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)rg, rl->bh[0]);
+ gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bh[0]);
else
- gfs2_rgrp_out_bh(rg, rl->bh[0]);
+ gfs2_rgrp_out_bh(&rgd->rg, rgd->bh[0]);
sdp->blks_alloced++;
- *blkno = ri->ri_data0 + bn;
- if (release)
- gfs2_rgrp_relse(rl);
- return 0;
-out_err:
+out:
if (release)
- gfs2_rgrp_relse(rl);
- return -1;
-
+ gfs2_rgrp_relse(rgd);
+ return error;
}
/**
@@ -219,19 +184,10 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
return blkno;
}
-uint64_t data_alloc(struct gfs2_inode *ip)
-{
- uint64_t x;
- x = blk_alloc_i(ip->i_sbd, DATA);
- ip->i_di.di_goal_data = x;
- bmodified(ip->i_bh);
- return x;
-}
-
uint64_t meta_alloc(struct gfs2_inode *ip)
{
uint64_t x;
- x = blk_alloc_i(ip->i_sbd, META);
+ x = blk_alloc_i(ip->i_sbd, GFS2_BLKST_USED);
ip->i_di.di_goal_meta = x;
bmodified(ip->i_bh);
return x;
@@ -255,7 +211,7 @@ int lgfs2_dinode_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, uint64_t *b
if (rgt == NULL)
return -1;
- ret = blk_alloc_in_rg(sdp, DINODE, rgt, blkno);
+ ret = blk_alloc_in_rg(sdp, GFS2_BLKST_DINODE, rgt, blkno);
if (ret == 0)
sdp->dinodes_alloced++;
@@ -305,7 +261,7 @@ void unstuff_dinode(struct gfs2_inode *ip)
brelse(bh);
} else {
- block = data_alloc(ip);
+ block = meta_alloc(ip);
bh = bget(sdp, block);
buffer_copy_tail(sdp, bh, 0,
@@ -421,12 +377,7 @@ void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (!create)
return;
- if (height == ip->i_di.di_height - 1&&
- !(S_ISDIR(ip->i_di.di_mode)))
- *block = data_alloc(ip);
- else
- *block = meta_alloc(ip);
-
+ *block = meta_alloc(ip);
*ptr = cpu_to_be64(*block);
bmodified(bh);
ip->i_di.di_blocks++;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 619542c..00e18e6 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -57,12 +57,7 @@ void gfs1_lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (!create)
return;
- if (height == ip->i_di.di_height - 1&&
- !(S_ISDIR(ip->i_di.di_mode)))
- *block = data_alloc(ip);
- else
- *block = meta_alloc(ip);
-
+ *block = meta_alloc(ip);
*ptr = cpu_to_be64(*block);
bmodified(bh);
ip->i_di.di_blocks++;
10 years, 2 months
gfs2-utils: master - libgfs2: Rework find_metapath
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=51c39f1d...
Commit: 51c39f1d31996b3e3f6536369dea8dba17af6782
Parent: b3c699223e3c87d03d04cc1089934268a41e5426
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 22 02:42:43 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Jan 22 10:51:25 2014 +0000
libgfs2: Rework find_metapath
Rework find_metapath to receive a pointer to a metapath structure
instead of allocating memory and exiting on allocation failure. Also
simplify some other aspects of the function and update its callers.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 41 +++++++++++++++--------------------------
gfs2/libgfs2/gfs1.c | 17 +++++++----------
gfs2/libgfs2/libgfs2.h | 2 +-
3 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 4a84687..03b1c41 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -393,24 +393,16 @@ void build_height(struct gfs2_inode *ip, int height)
}
}
-struct metapath *find_metapath(struct gfs2_inode *ip, uint64_t block)
+void find_metapath(struct gfs2_inode *ip, uint64_t block, struct metapath *mp)
{
- struct gfs2_sbd *sdp = ip->i_sbd;
- struct metapath *mp;
- uint64_t b = block;
- unsigned int i;
+ const uint32_t inptrs = ip->i_sbd->sd_inptrs;
+ unsigned int i = ip->i_di.di_height;
- mp = calloc(1, sizeof(struct metapath));
- if (mp == NULL) {
- fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
- exit(-1);
- }
- for (i = ip->i_di.di_height; i--;) {
- mp->mp_list[i] = b % sdp->sd_inptrs;
- b /= sdp->sd_inptrs;
+ memset(mp, 0, sizeof(struct metapath));
+ while (i--) {
+ mp->mp_list[i] = block % inptrs;
+ block /= inptrs;
}
-
- return mp;
}
void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
@@ -448,7 +440,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
{
struct gfs2_sbd *sdp = ip->i_sbd;
struct gfs2_buffer_head *bh;
- struct metapath *mp;
+ struct metapath mp;
int create = *new;
unsigned int bsize;
unsigned int height;
@@ -479,17 +471,17 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
build_height(ip, height);
}
- mp = find_metapath(ip, lblock);
+ find_metapath(ip, lblock, &mp);
end_of_metadata = ip->i_di.di_height - 1;
bh = ip->i_bh;
for (x = 0; x < end_of_metadata; x++) {
- lookup_block(ip, bh, x, mp, create, new, dblock);
+ lookup_block(ip, bh, x, &mp, create, new, dblock);
if (bh != ip->i_bh)
brelse(bh);
if (!*dblock)
- goto out;
+ return;
if (*new) {
struct gfs2_meta_header mh;
@@ -507,7 +499,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
}
if (!prealloc)
- lookup_block(ip, bh, end_of_metadata, mp, create, new, dblock);
+ lookup_block(ip, bh, end_of_metadata, &mp, create, new, dblock);
if (extlen && *dblock) {
*extlen = 1;
@@ -519,8 +511,8 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
nptrs = (end_of_metadata) ? sdp->sd_inptrs : sdp->sd_diptrs;
- while (++mp->mp_list[end_of_metadata] < nptrs) {
- lookup_block(ip, bh, end_of_metadata, mp, FALSE, &tmp_new,
+ while (++mp.mp_list[end_of_metadata] < nptrs) {
+ lookup_block(ip, bh, end_of_metadata, &mp, FALSE, &tmp_new,
&tmp_dblock);
if (*dblock + *extlen != tmp_dblock)
@@ -533,9 +525,6 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
if (bh != ip->i_bh)
brelse(bh);
-
- out:
- free(mp);
}
static void
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 89fb898..619542c 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -76,7 +76,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
{
struct gfs2_sbd *sdp = ip->i_sbd;
struct gfs2_buffer_head *bh;
- struct metapath *mp;
+ struct metapath mp;
int create = *new;
unsigned int bsize;
unsigned int height;
@@ -107,17 +107,17 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
build_height(ip, height);
}
- mp = find_metapath(ip, lblock);
+ find_metapath(ip, lblock, &mp);
end_of_metadata = ip->i_di.di_height - 1;
bh = ip->i_bh;
for (x = 0; x < end_of_metadata; x++) {
- gfs1_lookup_block(ip, bh, x, mp, create, new, dblock);
+ gfs1_lookup_block(ip, bh, x, &mp, create, new, dblock);
if (bh != ip->i_bh)
brelse(bh);
if (!*dblock)
- goto out;
+ return;
if (*new) {
struct gfs2_meta_header mh;
@@ -136,7 +136,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
}
if (!prealloc)
- gfs1_lookup_block(ip, bh, end_of_metadata, mp, create, new,
+ gfs1_lookup_block(ip, bh, end_of_metadata, &mp, create, new,
dblock);
if (extlen && *dblock) {
@@ -149,8 +149,8 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
nptrs = (end_of_metadata) ? sdp->sd_inptrs : sdp->sd_diptrs;
- while (++mp->mp_list[end_of_metadata] < nptrs) {
- gfs1_lookup_block(ip, bh, end_of_metadata, mp,
+ while (++mp.mp_list[end_of_metadata] < nptrs) {
+ gfs1_lookup_block(ip, bh, end_of_metadata, &mp,
FALSE, &tmp_new,
&tmp_dblock);
@@ -164,9 +164,6 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
if (bh != ip->i_bh)
brelse(bh);
-
- out:
- free(mp);
}
int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 42f9d44..07cb221 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -437,7 +437,7 @@ extern void build_rgrps(struct gfs2_sbd *sdp, int write);
#define IS_LEAF (1)
#define IS_DINODE (2)
-extern struct metapath *find_metapath(struct gfs2_inode *ip, uint64_t block);
+extern void find_metapath(struct gfs2_inode *ip, uint64_t block, struct metapath *mp);
extern void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
unsigned int height, struct metapath *mp,
int create, int *new, uint64_t *block);
10 years, 2 months
gfs2-utils: master - libgfs2: Remove sdp and j arguments from write_journal
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=b3c69922...
Commit: b3c699223e3c87d03d04cc1089934268a41e5426
Parent: eae45ea572cac6dfb746741feb8ceee92fd520df
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 14 15:41:53 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Tue Jan 14 15:44:54 2014 +0000
libgfs2: Remove sdp and j arguments from write_journal
write_journal accepts an sdp argument which it only used to look up the
current journal (using j as the index) and the bsize. Replace these
arguments with the journal inode itself and the block size.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 2 +-
gfs2/fsck/fs_recovery.c | 2 +-
gfs2/libgfs2/libgfs2.h | 3 +--
gfs2/libgfs2/structures.c | 21 +++++++--------------
4 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index e9dd0da..8ab3981 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2006,7 +2006,7 @@ static int conv_build_jindex(struct gfs2_sbd *sdp)
sprintf(name, "journal%u", j);
sdp->md.journal[j] = createi(sdp->md.jiinode, name, S_IFREG |
0600, GFS2_DIF_SYSTEM);
- write_journal(sdp, j,
+ write_journal(sdp->md.journal[j], sdp->bsize,
sdp->jsize << 20 >> sdp->sd_sb.sb_bsize_shift);
inode_put(&sdp->md.journal[j]);
printf(_("done.\n"));
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 41d575a..54a8c5f 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -552,7 +552,7 @@ out:
log_info( _("jid=%u: Failed\n"), j);
reinit:
if (query( _("Do you want to clear the journal instead? (y/n)")))
- error = write_journal(sdp, j,
+ error = write_journal(sdp->md.journal[j], sdp->bsize,
sdp->md.journal[j]->i_di.di_size /
sdp->sd_sb.sb_bsize);
else
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3119f39..42f9d44 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -496,8 +496,7 @@ extern int gfs2_dirent_next(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
extern void build_height(struct gfs2_inode *ip, int height);
extern void unstuff_dinode(struct gfs2_inode *ip);
extern unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size);
-extern int write_journal(struct gfs2_sbd *sdp, unsigned int j,
- unsigned int blocks);
+extern int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned blocks);
/* gfs1.c - GFS1 backward compatibility structures and functions */
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index e888f1e..030974b 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -80,7 +80,7 @@ void build_sb(struct gfs2_sbd *sdp, const unsigned char *uuid)
}
}
-int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
+int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
{
struct gfs2_log_header lh;
unsigned int x;
@@ -90,9 +90,8 @@ int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
/* Build the height up so our journal blocks will be contiguous and */
/* not broken up by indirect block pages. */
- height = calc_tree_height(sdp->md.journal[j],
- (blocks + 1) * sdp->bsize);
- build_height(sdp->md.journal[j], height);
+ height = calc_tree_height(jnl, (blocks + 1) * bsize);
+ build_height(jnl, height);
memset(&lh, 0, sizeof(struct gfs2_log_header));
lh.lh_header.mh_magic = GFS2_MAGIC;
@@ -101,20 +100,18 @@ int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
for (x = 0; x < blocks; x++) {
- struct gfs2_buffer_head *bh = get_file_buf(sdp->md.journal[j],
- x, TRUE);
+ struct gfs2_buffer_head *bh = get_file_buf(jnl, x, TRUE);
if (!bh)
return -1;
bmodified(bh);
brelse(bh);
}
for (x = 0; x < blocks; x++) {
- struct gfs2_buffer_head *bh = get_file_buf(sdp->md.journal[j],
- x, FALSE);
+ struct gfs2_buffer_head *bh = get_file_buf(jnl, x, FALSE);
if (!bh)
return -1;
- memset(bh->b_data, 0, sdp->bsize);
+ memset(bh->b_data, 0, bsize);
lh.lh_sequence = seq;
lh.lh_blkno = x;
gfs2_log_header_out(&lh, bh);
@@ -128,10 +125,6 @@ int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
seq = 0;
}
- if (sdp->debug) {
- printf("\nJournal %u:\n", j);
- gfs2_dinode_print(&sdp->md.journal[j]->i_di);
- }
return 0;
}
@@ -146,7 +139,7 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)
if (sdp->md.journal[j] == NULL) {
return errno;
}
- ret = write_journal(sdp, j,
+ ret = write_journal(sdp->md.journal[j], sdp->bsize,
sdp->jsize << 20 >> sdp->sd_sb.sb_bsize_shift);
return ret;
}
10 years, 2 months
gfs2-utils: master - libgfs2: Remove sdp argument from compute_heightsize
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=eae45ea5...
Commit: eae45ea572cac6dfb746741feb8ceee92fd520df
Parent: 63db4e964739673d36c430cc5c78b02d93419f8a
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 14 15:30:31 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Tue Jan 14 15:30:31 2014 +0000
libgfs2: Remove sdp argument from compute_heightsize
compute_heightsize only uses the bsize member of sdp so just accept a
bsize argument instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 8 ++++----
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/libgfs2/misc.c | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 719ba9c..e9dd0da 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1611,13 +1611,13 @@ static int init(struct gfs2_sbd *sbp)
sizeof(uint64_t);
sbp->sd_jbsize = sbp->bsize - sizeof(struct gfs2_meta_header);
brelse(bh);
- if (compute_heightsize(sbp, sbp->sd_heightsize, &sbp->sd_max_height,
+ if (compute_heightsize(sbp->bsize, sbp->sd_heightsize, &sbp->sd_max_height,
sbp->bsize, sbp->sd_diptrs, sbp->sd_inptrs)) {
log_crit(_("Error: Bad constants (1)\n"));
exit(-1);
}
- if (compute_heightsize(sbp, sbp->sd_jheightsize, &sbp->sd_max_jheight,
+ if (compute_heightsize(sbp->bsize, sbp->sd_jheightsize, &sbp->sd_max_jheight,
sbp->sd_jbsize, sbp->sd_diptrs, sbp->sd_inptrs)) {
log_crit(_("Error: Bad constants (1)\n"));
exit(-1);
@@ -1628,13 +1628,13 @@ static int init(struct gfs2_sbd *sbp)
gfs2_inptrs = (sbp->bsize - sizeof(struct gfs2_meta_header)) /
sizeof(uint64_t); /* How many ptrs can we fit on a block? */
memset(gfs2_heightsize, 0, sizeof(gfs2_heightsize));
- if (compute_heightsize(sbp, gfs2_heightsize, &gfs2_max_height,
+ if (compute_heightsize(sbp->bsize, gfs2_heightsize, &gfs2_max_height,
sbp->bsize, sbp->sd_diptrs, gfs2_inptrs)) {
log_crit(_("Error: Bad constants (1)\n"));
exit(-1);
}
memset(gfs2_jheightsize, 0, sizeof(gfs2_jheightsize));
- if (compute_heightsize(sbp, gfs2_jheightsize, &gfs2_max_jheight,
+ if (compute_heightsize(sbp->bsize, gfs2_jheightsize, &gfs2_max_jheight,
sbp->sd_jbsize, sbp->sd_diptrs, gfs2_inptrs)) {
log_crit(_("Error: Bad constants (1)\n"));
exit(-1);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e785017..3119f39 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -712,7 +712,7 @@ extern void decrease_verbosity(void);
extern int metafs_interrupted;
-extern int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
+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);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index c4ed722..8ee8324 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -28,10 +28,10 @@
int metafs_interrupted = 0;
-int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
+int compute_heightsize(unsigned bsize, uint64_t *heightsize,
uint32_t *maxheight, uint32_t bsize1, int diptrs, int inptrs)
{
- heightsize[0] = sdp->bsize - sizeof(struct gfs2_dinode);
+ heightsize[0] = bsize - sizeof(struct gfs2_dinode);
heightsize[1] = bsize1 * diptrs;
for (*maxheight = 2;; (*maxheight)++) {
uint64_t space, d;
@@ -91,11 +91,11 @@ int compute_constants(struct gfs2_sbd *sdp)
sdp->sd_max_dirres = hash_blocks + ind_blocks + leaf_blocks;
- if (compute_heightsize(sdp, sdp->sd_heightsize, &sdp->sd_max_height,
+ if (compute_heightsize(sdp->bsize, sdp->sd_heightsize, &sdp->sd_max_height,
sdp->bsize, sdp->sd_diptrs, sdp->sd_inptrs)) {
return -1;
}
- if (compute_heightsize(sdp, sdp->sd_jheightsize, &sdp->sd_max_jheight,
+ if (compute_heightsize(sdp->bsize, sdp->sd_jheightsize, &sdp->sd_max_jheight,
sdp->sd_jbsize, sdp->sd_diptrs, sdp->sd_inptrs)) {
return -1;
}
10 years, 2 months
fence-agents: master - fencing: Do not output duplicities in metadata
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b6a75b...
Commit: b6a75b41f9180f3cf4d2d2632873f4c5920ce260
Parent: 849d0dba262c2111446fb5a03040b22146c35726
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Jan 27 13:49:16 2014 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Jan 27 13:49:16 2014 +0100
fencing: Do not output duplicities in metadata
With DEPENDENCY_OPT it becomes possible that items in device_opt can occur multiple times easily as they
are added automatically (e.g. 'password' imports also 'password_script'). This lead to a situation when
eveyrything works but XML metadata contains this item multiple times and metadata can not be used properly
by cluster stack.
---
fence/agents/lib/fencing.py.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 889bb04..fd21c69 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -440,7 +440,8 @@ def usage(avail_opt):
print " " + value["help"]
def metadata(avail_opt, options, docs):
- sorted_list = [ (key, all_opt[key]) for key in avail_opt ]
+ # avail_opt has to be unique, if there are duplicities then they should be removed
+ sorted_list = [ (key, all_opt[key]) for key in list(set(avail_opt)) ]
sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"]))
print "<?xml version=\"1.0\" ?>"
10 years, 2 months