[Debian-ha-commits] [ocfs2-tools] 03/08: New upstream version 1.8.5
Valentin Vidic
vvidic-guest at moszumanska.debian.org
Tue Jun 20 08:20:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
vvidic-guest pushed a commit to branch master
in repository ocfs2-tools.
commit bf928cf3392df070de94b32d36c908d5adb92fb9
Author: Valentin Vidic <Valentin.Vidic at CARNet.hr>
Date: Tue Jun 20 09:28:24 2017 +0200
New upstream version 1.8.5
---
configure.in | 2 +-
debugfs.ocfs2/commands.c | 4 +-
debugfs.ocfs2/dump.c | 6 +-
debugfs.ocfs2/main.c | 2 +-
fsck.ocfs2/fsck.c | 149 ++++++++++++++++++++----------
fsck.ocfs2/journal.c | 7 +-
fsck.ocfs2/pass1.c | 8 +-
fsck.ocfs2/pass1b.c | 2 -
include/ocfs2-kernel/ocfs2_fs.h | 2 +
include/ocfs2/ocfs2.h | 2 +
include/tools-internal/scandisk.h | 2 +
libo2cb/o2cb_abi.c | 10 +-
libocfs2/alloc.c | 3 +-
libocfs2/extend_file.c | 5 +-
libocfs2/image.c | 11 +--
libocfs2/lockid.c | 4 -
libocfs2/refcount.c | 55 ++++++++++-
libocfs2/truncate.c | 11 ++-
libtools-internal/scandisk.c | 63 ++++++++++++-
mkfs.ocfs2/mkfs.c | 111 ++++++++++++++++++++--
mounted.ocfs2/mounted.c | 5 +-
o2cb_ctl/o2cb_config.c | 1 +
o2cb_ctl/o2cb_scandisk.c | 17 +++-
o2image/o2image.c | 7 +-
o2info/o2info.c | 3 +-
ocfs2_hb_ctl/ocfs2_hb_ctl.c | 16 +++-
tunefs.ocfs2/libocfs2ne.c | 2 +
tunefs.ocfs2/ocfs2ne.c | 2 +
tunefs.ocfs2/op_query.c | 26 +++---
tunefs.ocfs2/op_resize_volume.c | 6 +-
vendor/Makefile | 2 +-
vendor/common/51-ocfs2.rules | 3 +-
vendor/common/Makefile | 4 +-
vendor/common/Vendor.make | 3 +
vendor/common/o2cb.init.sh | 11 +++
vendor/common/o2cb.service | 13 +++
vendor/common/ocfs2-tools.spec-generic.in | 62 ++++++++++---
vendor/common/ocfs2.service | 14 +++
vendor/fc7/Vendor.make | 2 +
vendor/fc8/Vendor.make | 2 +
vendor/fc9/Vendor.make | 2 +
vendor/rhel4/Vendor.make | 2 +
vendor/rhel5/Vendor.make | 2 +
vendor/rhel6/Vendor.make | 2 +
vendor/rhel7/Makefile | 10 ++
vendor/rhel7/Vendor.make | 13 +++
vendor/rhel7/rpmarch.guess | 68 ++++++++++++++
vendor/rhel7/vendor.guess | 13 +++
vendor/sles10/Vendor.make | 2 +
vendor/sles9/Vendor.make | 2 +
50 files changed, 638 insertions(+), 138 deletions(-)
diff --git a/configure.in b/configure.in
index 83b8214..f89f4c2 100644
--- a/configure.in
+++ b/configure.in
@@ -9,7 +9,7 @@ AC_SUBST(PACKAGE)
# Adjust these for the software version.
MAJOR_VERSION=1
MINOR_VERSION=8
-MICRO_VERSION=4
+MICRO_VERSION=5
EXTRA_VERSION=
DIST_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 3d5518a..4e4ea7f 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -1673,7 +1673,9 @@ static void do_encode_lockres(char **args)
blkno);
return;
}
- gen = inode->i_generation;
+
+ if (inode->i_flags & OCFS2_SYSTEM_FL)
+ gen = inode->i_generation;
}
ret = ocfs2_encode_lockres(type, blkno, gen, 0, lock);
diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index da95a14..8969493 100644
--- a/debugfs.ocfs2/dump.c
+++ b/debugfs.ocfs2/dump.c
@@ -511,6 +511,7 @@ int dump_dir_entry(struct ocfs2_dir_entry *rec, uint64_t blocknr, int offset,
struct ocfs2_dinode *di;
char perms[20];
char timestr[40];
+ errcode_t ret;
rec->name[rec->name_len] = '\0';
@@ -520,7 +521,10 @@ int dump_dir_entry(struct ocfs2_dir_entry *rec, uint64_t blocknr, int offset,
rec->rec_len, rec->name_len, rec->file_type, rec->name);
} else {
memset(ls->buf, 0, ls->fs->fs_blocksize);
- ocfs2_read_inode(ls->fs, rec->inode, ls->buf);
+ ret = ocfs2_read_inode(ls->fs, rec->inode, ls->buf);
+ if (ret)
+ return ret;
+
di = (struct ocfs2_dinode *)ls->buf;
inode_perms_to_str(di->i_mode, perms, sizeof(perms));
diff --git a/debugfs.ocfs2/main.c b/debugfs.ocfs2/main.c
index 5d1e014..1402d5e 100644
--- a/debugfs.ocfs2/main.c
+++ b/debugfs.ocfs2/main.c
@@ -198,7 +198,7 @@ static void get_options(int argc, char **argv, struct dbgfs_opts *opts)
{ "noprompt", 0, 0, 'n' },
{ "decode", 0, 0, 'd' },
{ "encode", 0, 0, 'e' },
- { "superblock", 0, 0, 's' },
+ { "superblock", 1, 0, 's' },
{ "image", 0, 0, 'i' },
{ 0, 0, 0, 0}
};
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index dc5209d..e5c7cfa 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -79,6 +79,8 @@ static o2fsck_state _ost;
static int cluster_locked = 0;
static void mark_magical_clusters(o2fsck_state *ost);
+static errcode_t fsck_lock_fs(o2fsck_state *ost);
+static void fsck_unlock_fs(o2fsck_state *ost);
static void handle_signal(int sig)
{
@@ -232,6 +234,22 @@ errcode_t o2fsck_state_reinit(ocfs2_filesys *fs, o2fsck_state *ost)
return 0;
}
+static void o2fsck_state_release(o2fsck_state *ost)
+{
+ if (ost->ost_dir_inodes)
+ ocfs2_bitmap_free(&ost->ost_dir_inodes);
+ if (ost->ost_reg_inodes)
+ ocfs2_bitmap_free(&ost->ost_reg_inodes);
+ if (ost->ost_allocated_clusters)
+ ocfs2_bitmap_free(&ost->ost_allocated_clusters);
+ if (ost->ost_duplicate_clusters)
+ ocfs2_bitmap_free(&ost->ost_duplicate_clusters);
+ if (ost->ost_icount_in_inodes)
+ o2fsck_icount_free(ost->ost_icount_in_inodes);
+ if (ost->ost_icount_refs)
+ o2fsck_icount_free(ost->ost_icount_refs);
+}
+
static errcode_t check_superblock(o2fsck_state *ost)
{
struct ocfs2_dinode *di = ost->ost_fs->fs_super;
@@ -471,6 +489,7 @@ static errcode_t open_and_check(o2fsck_state *ost, char *filename,
if (ret) {
printf("fsck saw unrecoverable errors in the super block and "
"will not continue.\n");
+ ocfs2_close(ost->ost_fs);
goto out;
}
@@ -517,6 +536,8 @@ static errcode_t maybe_replay_journals(o2fsck_state *ost, char *filename,
if (!replayed)
goto out;
+ fsck_unlock_fs(ost);
+
ret = ocfs2_close(ost->ost_fs);
if (ret) {
com_err(whoami, ret, "while closing \"%s\"", filename);
@@ -524,6 +545,13 @@ static errcode_t maybe_replay_journals(o2fsck_state *ost, char *filename,
}
ret = open_and_check(ost, filename, open_flags, blkno, blksize);
+ if (ret) {
+ com_err(whoami, ret, "while opening and checking \"%s\"",
+ filename);
+ goto out;
+ }
+
+ ret = fsck_lock_fs(ost);
out:
return ret;
}
@@ -675,6 +703,67 @@ bail:
return ret;
}
+static errcode_t fsck_lock_fs(o2fsck_state *ost)
+{
+ errcode_t ret;
+
+ ret = o2cb_init();
+ if (ret) {
+ com_err(whoami, ret, "while initializing the cluster");
+ goto bail;
+ }
+
+ block_signals(SIG_BLOCK);
+ ret = ocfs2_initialize_dlm(ost->ost_fs, whoami);
+ if (ret == O2CB_ET_INVALID_STACK_NAME ||
+ ret == O2CB_ET_INVALID_CLUSTER_NAME ||
+ ret == O2CB_ET_INVALID_HEARTBEAT_MODE) {
+ block_signals(SIG_UNBLOCK);
+ ret = recover_cluster_info(ost);
+ if (ret) {
+ com_err(whoami, ret,
+ "while recovering cluster information");
+ goto bail;
+ }
+ block_signals(SIG_BLOCK);
+ ret = ocfs2_initialize_dlm(ost->ost_fs, whoami);
+ }
+ if (ret) {
+ block_signals(SIG_UNBLOCK);
+ com_err(whoami, ret, "while initializing the DLM");
+ goto bail;
+ }
+
+ ret = ocfs2_lock_down_cluster(ost->ost_fs);
+ if (ret) {
+ if (ost->ost_fs->fs_dlm_ctxt)
+ ocfs2_shutdown_dlm(ost->ost_fs, whoami);
+ block_signals(SIG_UNBLOCK);
+ com_err(whoami, ret, "while locking down the cluster");
+ goto bail;
+ }
+ cluster_locked = 1;
+ block_signals(SIG_UNBLOCK);
+
+bail:
+ return ret;
+}
+
+static void fsck_unlock_fs(o2fsck_state *ost)
+{
+ if (!ost->ost_fs)
+ return;
+
+ block_signals(SIG_BLOCK);
+ if (ost->ost_fs->fs_dlm_ctxt)
+ ocfs2_release_cluster(ost->ost_fs);
+ cluster_locked = 0;
+
+ if (ost->ost_fs->fs_dlm_ctxt)
+ ocfs2_shutdown_dlm(ost->ost_fs, whoami);
+ block_signals(SIG_UNBLOCK);
+}
+
int main(int argc, char **argv)
{
char *filename;
@@ -901,41 +990,11 @@ int main(int argc, char **argv)
if (open_flags & OCFS2_FLAG_RW && !ost->ost_skip_o2cb &&
!ocfs2_mount_local(ost->ost_fs)) {
- ret = o2cb_init();
- if (ret) {
- com_err(whoami, ret, "while initializing the cluster");
- goto close;
- }
-
- block_signals(SIG_BLOCK);
- ret = ocfs2_initialize_dlm(ost->ost_fs, whoami);
- if (ret == O2CB_ET_INVALID_STACK_NAME ||
- ret == O2CB_ET_INVALID_CLUSTER_NAME ||
- ret == O2CB_ET_INVALID_HEARTBEAT_MODE) {
- block_signals(SIG_UNBLOCK);
- ret = recover_cluster_info(ost);
- if (ret) {
- com_err(whoami, ret,
- "while recovering cluster information");
- goto close;
- }
- block_signals(SIG_BLOCK);
- ret = ocfs2_initialize_dlm(ost->ost_fs, whoami);
- }
+ ret = fsck_lock_fs(ost);
if (ret) {
- block_signals(SIG_UNBLOCK);
- com_err(whoami, ret, "while initializing the DLM");
- goto close;
- }
-
- ret = ocfs2_lock_down_cluster(ost->ost_fs);
- if (ret) {
- block_signals(SIG_UNBLOCK);
- com_err(whoami, ret, "while locking down the cluster");
+ fsck_mask |= FSCK_ERROR;
goto close;
}
- cluster_locked = 1;
- block_signals(SIG_UNBLOCK);
}
printf("Checking OCFS2 filesystem in %s:\n", filename);
@@ -958,6 +1017,7 @@ int main(int argc, char **argv)
if (ret) {
printf("fsck saw unrecoverable errors in the journal "
"files and will not continue.\n");
+ fsck_mask |= FSCK_ERROR;
goto unlock;
}
}
@@ -1085,24 +1145,19 @@ clear_dirty_flag:
}
unlock:
- block_signals(SIG_BLOCK);
- if (ost->ost_fs->fs_dlm_ctxt)
- ocfs2_release_cluster(ost->ost_fs);
- cluster_locked = 0;
- block_signals(SIG_UNBLOCK);
+ fsck_unlock_fs(ost);
close:
- block_signals(SIG_BLOCK);
- if (ost->ost_fs->fs_dlm_ctxt)
- ocfs2_shutdown_dlm(ost->ost_fs, whoami);
- block_signals(SIG_UNBLOCK);
+ if (ost->ost_fs) {
+ ret = ocfs2_close(ost->ost_fs);
+ if (ret) {
+ com_err(whoami, ret, "while closing file \"%s\"", filename);
+ /* XXX I wonder about this error.. */
+ fsck_mask |= FSCK_ERROR;
+ }
+ }
- ret = ocfs2_close(ost->ost_fs);
- if (ret) {
- com_err(whoami, ret, "while closing file \"%s\"", filename);
- /* XXX I wonder about this error.. */
- fsck_mask |= FSCK_ERROR;
- }
+ o2fsck_state_release(ost);
out:
return fsck_mask;
diff --git a/fsck.ocfs2/journal.c b/fsck.ocfs2/journal.c
index bba8499..95262d3 100644
--- a/fsck.ocfs2/journal.c
+++ b/fsck.ocfs2/journal.c
@@ -339,6 +339,7 @@ static errcode_t replay_blocks(ocfs2_filesys *fs, struct journal_info *ji,
tagp += 16;
}
+ *next_block = jwrap(ji->ji_jsb, *next_block);
out:
if (io_buf)
ocfs2_free(&io_buf);
@@ -925,10 +926,12 @@ static errcode_t check_journal_walk(o2fsck_state *ost,
ret = func(ost, ci, jc);
if (ret)
break;
- }
- if (ci)
ocfs2_free_cached_inode(fs, ci);
+ ci = NULL;
+ }
+
+ ocfs2_free_cached_inode(fs, ci);
return ret;
}
diff --git a/fsck.ocfs2/pass1.c b/fsck.ocfs2/pass1.c
index c076e28..da11d22 100644
--- a/fsck.ocfs2/pass1.c
+++ b/fsck.ocfs2/pass1.c
@@ -83,6 +83,7 @@ void o2fsck_free_inode_allocs(o2fsck_state *ost)
for (i = 0; i < OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_max_slots; i++)
ocfs2_free_cached_inode(ost->ost_fs, ost->ost_inode_allocs[i]);
+ ocfs2_free(&ost->ost_inode_allocs);
}
/* update our in memory images of the inode chain alloc bitmaps. these
@@ -146,8 +147,6 @@ static void update_inode_alloc(o2fsck_state *ost,
ost->ost_write_inode_alloc_asked = 1;
ost->ost_write_inode_alloc = !!yn;
- if (!ost->ost_write_inode_alloc)
- o2fsck_free_inode_allocs(ost);
}
break;
}
@@ -952,7 +951,7 @@ static errcode_t o2fsck_check_blocks(ocfs2_filesys *fs, o2fsck_state *ost,
ret = ocfs2_block_iterate_inode(fs, di,
OCFS2_BLOCK_FLAG_APPEND,
clear_block, &vb);
- di->i_flags &= !OCFS2_VALID_FL;
+ di->i_flags &= ~OCFS2_VALID_FL;
o2fsck_write_inode(ost, di->i_blkno, di);
/* for a directory, we also need to clear it
* from the dir_parent rb-tree. */
@@ -1447,8 +1446,6 @@ static void write_inode_alloc(o2fsck_state *ost)
com_err(whoami, ret, "while trying to write back slot "
"%d's inode allocator", i);
}
-
- o2fsck_free_inode_allocs(ost);
}
errcode_t o2fsck_pass1(o2fsck_state *ost)
@@ -1566,6 +1563,7 @@ out_free:
o2fsck_add_resource_track(&ost->ost_rt, &rt);
out:
+ o2fsck_free_inode_allocs(ost);
if (ost->ost_prog) {
tools_progress_stop(ost->ost_prog);
setlinebuf(stdout);
diff --git a/fsck.ocfs2/pass1b.c b/fsck.ocfs2/pass1b.c
index fc380ec..6edda58 100644
--- a/fsck.ocfs2/pass1b.c
+++ b/fsck.ocfs2/pass1b.c
@@ -299,7 +299,6 @@ static errcode_t dup_insert(struct dup_context *dct, uint32_t cluster,
di = dup_inode_lookup(dct, dinode->i_blkno);
if (!di) {
dup_inode_insert(dct, new_di);
- di = new_di;
new_di = NULL;
}
@@ -312,7 +311,6 @@ static errcode_t dup_insert(struct dup_context *dct, uint32_t cluster,
}
if (!dco) {
list_add_tail(&new_dco->dco_list, &dc->dc_owners);
- dco = new_dco;
new_dco = NULL;
}
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index 620c6de..a85d218 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -317,6 +317,8 @@
/* Journal limits (in bytes) */
#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
+/* Minimum Journal size shift with respect to cluster size */
+#define OCFS2_MIN_CLUSTER_TO_JOURNAL_SIZE_SHIFT 3
/*
* Default local alloc size (in megabytes)
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 1ea5cf8..f399c67 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -520,6 +520,8 @@ int ocfs2_get_refcount_rec(ocfs2_filesys *fs,
errcode_t ocfs2_create_refcount_tree(ocfs2_filesys *fs, uint64_t *refcount_loc);
errcode_t ocfs2_attach_refcount_tree(ocfs2_filesys *fs,
uint64_t ino, uint64_t refcount_loc);
+errcode_t ocfs2_detach_refcount_tree(ocfs2_filesys *fs,
+ uint64_t ino, uint64_t refcount_loc);
errcode_t ocfs2_swap_dir_entries_from_cpu(void *buf, uint64_t bytes);
errcode_t ocfs2_swap_dir_entries_to_cpu(void *buf, uint64_t bytes);
void ocfs2_swap_dir_trailer(struct ocfs2_dir_block_trailer *trailer);
diff --git a/include/tools-internal/scandisk.h b/include/tools-internal/scandisk.h
index ac69d9d..d822e29 100644
--- a/include/tools-internal/scandisk.h
+++ b/include/tools-internal/scandisk.h
@@ -72,6 +72,7 @@ struct devnode {
int md; /* 0 nothing to do with raid, 1 is raid,
* 2 is raid slave - data from /proc/mdstat */
int mapper; /* 0 nothing, 1 we believe it's a devmap dev */
+ int power; /* 0 nothing, 1 we believe it is powerpath device */
void *filter; /* your filter output.. whatever it is */
};
@@ -92,6 +93,7 @@ struct devlisthead {
* /proc/mdstat */
int mapper; /* set to 1 if we were able to run
* something against mapper */
+ int power; /* set to 1 if we detected a powerpath device */
};
typedef void (*devfilter) (struct devnode * cur, void *arg);
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index b72a266..6609aa4 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -204,6 +204,9 @@ redo:
o2cb_setup_stack(OCFS2_CLASSIC_CLUSTER_STACK);
setup_performed = 1;
goto redo;
+ } else {
+ current_stack = &classic_stack;
+ err = 0;
}
}
@@ -2615,11 +2618,12 @@ static int perform_modprobe(char *module_name)
pid_t child;
int child_status;
- char *argv[3];
+ char *argv[4];
argv[0] = MODPROBE_COMMAND;
argv[1] = module_name;
- argv[2] = NULL;
+ argv[2] = "-q";
+ argv[3] = NULL;
child = fork();
if (child == 0) {
@@ -2678,7 +2682,7 @@ redo:
else if (!strncmp(stack_name, classic_stack.s_name,
OCFS2_STACK_LABEL_LEN))
perform_modprobe(O2CB_KERNEL_MODULE);
-
+ modprobe_performed = 1;
write_single_line_file(CLUSTER_STACK_FILE, stack_name,
OCFS2_STACK_LABEL_LEN);
write_performed = 1;
diff --git a/libocfs2/alloc.c b/libocfs2/alloc.c
index 1cd21c6..258d4e5 100644
--- a/libocfs2/alloc.c
+++ b/libocfs2/alloc.c
@@ -306,7 +306,8 @@ errcode_t ocfs2_new_system_inode(ocfs2_filesys *fs, uint64_t *ino,
&gd_blkno, &suballoc_bit, ino);
if (ret)
goto out;
- }
+ } else if (ret)
+ goto out;
memset(buf, 0, fs->fs_blocksize);
di = (struct ocfs2_dinode *)buf;
diff --git a/libocfs2/extend_file.c b/libocfs2/extend_file.c
index fbb770a..1038933 100644
--- a/libocfs2/extend_file.c
+++ b/libocfs2/extend_file.c
@@ -169,7 +169,7 @@ errcode_t ocfs2_allocate_unwritten_extents(ocfs2_filesys *fs, uint64_t ino,
{
errcode_t ret = 0;
uint32_t n_clusters = 0, cpos;
- uint64_t p_blkno, v_blkno, v_end, contig_blocks, wanted_blocks;
+ uint64_t p_blkno = 0, v_blkno, v_end, contig_blocks, wanted_blocks;
ocfs2_cached_inode *ci = NULL;
if (!(fs->fs_flags & OCFS2_FLAG_RW))
@@ -198,6 +198,9 @@ errcode_t ocfs2_allocate_unwritten_extents(ocfs2_filesys *fs, uint64_t ino,
ret = ocfs2_extent_map_get_blocks(ci, v_blkno, 1,
&p_blkno, &contig_blocks,
NULL);
+ if (ret)
+ continue;
+
if (p_blkno) {
v_blkno += contig_blocks;
continue;
diff --git a/libocfs2/image.c b/libocfs2/image.c
index 41d1a53..4d4cce2 100644
--- a/libocfs2/image.c
+++ b/libocfs2/image.c
@@ -66,10 +66,6 @@ errcode_t ocfs2_image_free_bitmap(ocfs2_filesys *ofs)
struct ocfs2_image_state *ost = ofs->ost;
int i;
- /* image bitmaps are allocated only for ocfs2 image image files */
- if (!(ofs->fs_flags & OCFS2_FLAG_IMAGE_FILE))
- return 0;
-
if (!ost->ost_bmparr)
return 0;
@@ -167,7 +163,8 @@ errcode_t ocfs2_image_load_bitmap(ocfs2_filesys *ofs)
struct ocfs2_image_state *ost;
struct ocfs2_image_hdr *hdr;
uint64_t blk_off, bits_set;
- int count, i, j, fd;
+ int i, j, fd;
+ ssize_t count;
errcode_t ret;
char *blk;
@@ -222,8 +219,10 @@ errcode_t ocfs2_image_load_bitmap(ocfs2_filesys *ofs)
*/
count = pread64(fd, ost->ost_bmparr[i].arr_map,
ost->ost_bmpblksz, blk_off);
- if (count < ost->ost_bmpblksz)
+ if (count < 0) {
+ ret = OCFS2_ET_IO;
goto out;
+ }
/* add bits set in this bitmap */
for (j = 0; j < (ost->ost_bmpblksz * 8); j++)
diff --git a/libocfs2/lockid.c b/libocfs2/lockid.c
index d46e24e..ddc93b2 100644
--- a/libocfs2/lockid.c
+++ b/libocfs2/lockid.c
@@ -65,10 +65,6 @@ errcode_t ocfs2_encode_lockres(enum ocfs2_lock_type type, uint64_t blkno,
if (type >= OCFS2_NUM_LOCK_TYPES)
return OCFS2_ET_INVALID_LOCKRES;
- blkno = (type == OCFS2_LOCK_TYPE_RENAME) ? 0 : blkno;
- generation = ((type == OCFS2_LOCK_TYPE_SUPER) ||
- (type == OCFS2_LOCK_TYPE_RENAME)) ? 0 : generation;
-
if (type != OCFS2_LOCK_TYPE_DENTRY) {
snprintf(lockres, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"PRIx64"%08x",
ocfs2_lock_type_char(type), OCFS2_LOCK_ID_PAD,
diff --git a/libocfs2/refcount.c b/libocfs2/refcount.c
index 6afe032..de1a07c 100644
--- a/libocfs2/refcount.c
+++ b/libocfs2/refcount.c
@@ -2138,8 +2138,10 @@ static errcode_t create_generation(uint32_t *value)
if (randfd < 0)
return errno;
- if (read(randfd, value, readlen) != readlen)
+ if (read(randfd, value, readlen) != readlen) {
+ close(randfd);
return errno;
+ }
close(randfd);
@@ -2205,6 +2207,57 @@ out:
return ret;
}
+errcode_t ocfs2_detach_refcount_tree(ocfs2_filesys *fs,
+ uint64_t ino, uint64_t refcount_loc)
+{
+ errcode_t ret;
+ char *buf = NULL;
+ struct ocfs2_dinode *di;
+ struct ocfs2_refcount_block *rb;
+
+ ret = ocfs2_malloc_block(fs->fs_io, &buf);
+ if (ret)
+ return ret;
+
+ ret = ocfs2_read_refcount_block(fs, refcount_loc, buf);
+ if (ret)
+ goto out;
+
+ rb = (struct ocfs2_refcount_block *)buf;
+ rb->rf_count += -1;
+
+ if (!rb->rf_count) {
+ ret = ocfs2_delete_refcount_block(fs, rb->rf_blkno);
+ if (ret) {
+ com_err("refcount", ret, "remove refcount tree <%lu> failed.\n", rb->rf_blkno);
+ goto out;
+ }
+ } else {
+ ret = ocfs2_write_refcount_block(fs, refcount_loc, buf);
+ if (ret) {
+ com_err("refcount", ret, "update refcount tree <%lu> failed.\n", rb->rf_blkno);
+ goto out;
+ }
+ }
+
+ ret = ocfs2_read_inode(fs, ino, buf);
+ if (ret) {
+ com_err("refcount", ret, "read inode %lu fail, stop setting refcount tree <%lu>.\n",
+ ino, rb->rf_blkno);
+ goto out;
+ }
+
+ di = (struct ocfs2_dinode *)buf;
+
+ di->i_refcount_loc = 0;
+ di->i_dyn_features &= ~OCFS2_HAS_REFCOUNT_FL;
+
+ ret = ocfs2_write_inode(fs, ino, buf);
+out:
+ ocfs2_free(&buf);
+ return ret;
+}
+
struct xattr_value_cow_object {
struct ocfs2_xattr_value_root *xv;
uint64_t xe_blkno;
diff --git a/libocfs2/truncate.c b/libocfs2/truncate.c
index 451db28..2a14210 100644
--- a/libocfs2/truncate.c
+++ b/libocfs2/truncate.c
@@ -79,6 +79,7 @@ static int truncate_iterate(ocfs2_filesys *fs,
int func_ret = OCFS2_EXTENT_ERROR;
char *buf = NULL;
struct ocfs2_extent_list *el = NULL;
+ int cleanup_rec = 0;
if ((rec->e_cpos + ocfs2_rec_clusters(tree_depth, rec)) <=
new_size_in_clusters)
@@ -99,7 +100,7 @@ static int truncate_iterate(ocfs2_filesys *fs,
goto bail;
}
- memset(rec, 0, sizeof(struct ocfs2_extent_rec));
+ cleanup_rec = 1;
} else {
/* we're truncating into the middle of the rec */
len = rec->e_cpos +
@@ -140,7 +141,7 @@ static int truncate_iterate(ocfs2_filesys *fs,
ret = ocfs2_delete_extent_block(fs, rec->e_blkno);
if (ret)
goto bail;
- memset(rec, 0, sizeof(struct ocfs2_extent_rec));
+ cleanup_rec = 1;
}
}
}
@@ -159,6 +160,8 @@ static int truncate_iterate(ocfs2_filesys *fs,
func_ret = OCFS2_EXTENT_CHANGED;
bail:
+ if (cleanup_rec)
+ memset(rec, 0, sizeof(struct ocfs2_extent_rec));
if (buf)
ocfs2_free(&buf);
return func_ret;
@@ -399,6 +402,10 @@ truncate:
ci->ci_inode->i_size = new_i_size;
ret = ocfs2_write_cached_inode(fs, ci);
}
+
+ if (!ret && !new_i_size && ci->ci_inode->i_refcount_loc &&
+ (ci->ci_inode->i_dyn_features & OCFS2_HAS_REFCOUNT_FL))
+ ret = ocfs2_detach_refcount_tree(fs, ino, ci->ci_inode->i_refcount_loc);
out:
if (ci)
ocfs2_free_cached_inode(fs, ci);
diff --git a/libtools-internal/scandisk.c b/libtools-internal/scandisk.c
index 2f5245e..5209de2 100644
--- a/libtools-internal/scandisk.c
+++ b/libtools-internal/scandisk.c
@@ -466,6 +466,60 @@ static int scanmapper(struct devlisthead *devlisthead)
return 1;
}
+/* scanpower parses /proc/devices to identify what maj are associated
+ * with powerpath devices
+ */
+static int scanpower(struct devlisthead *devlisthead)
+{
+ struct devnode *startnode;
+ FILE *fp;
+ char line[4096];
+ char major[4];
+ char device[64];
+ int maj, start = 0;
+ int found = 0;
+
+ fp = fopen("/proc/devices", "r");
+ if (!fp)
+ return 0;
+
+ while (fgets(line, sizeof(line), fp) != NULL) {
+ memset(major, 0, 4);
+ memset(device, 0, 64);
+
+ if (strlen(line) > 4096)
+ continue;
+
+ if (!strncmp(line, "Block devices:", 13)) {
+ start = 1;
+ continue;
+ }
+
+ if (!start)
+ continue;
+
+ sscanf(line, "%s %s", major, device);
+
+ if (!strncmp(device, "power", 5)) {
+ found = 1;
+ maj = atoi(major);
+ startnode = devlisthead->devnode;
+
+ while (startnode) {
+ if (startnode->maj == maj)
+ startnode->power = 1;
+
+ startnode = startnode->next;
+ }
+
+ }
+
+ }
+
+ fclose(fp);
+ return found;
+}
+
/* scan through the list and execute the custom filter for each entry */
static void run_filter(struct devlisthead *devlisthead,
devfilter filter, void *filter_args)
@@ -709,15 +763,15 @@ static int scansysfs(struct devlisthead *devlisthead, const char *path, int leve
sysfs_is_disk(newpath);
}
- if (!stat(newpath, &sb) && !level)
+ if (!stat(newpath, &sb) && !level) {
if (S_ISDIR(sb.st_mode))
if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
return -1;
-
- if (!lstat(newpath, &sb))
+ } else if (!lstat(newpath, &sb)) {
if (S_ISDIR(sb.st_mode))
if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
return -1;
+ }
}
free(namelist[n]);
@@ -781,7 +835,10 @@ struct devlisthead *scan_for_dev(struct devlisthead *devlisthead,
/* from now on we don't alloc mem ourselves but only add info */
devlisthead->mdstat = scanmdstat(devlisthead);
+
devlisthead->mapper = scanmapper(devlisthead);
+
+ devlisthead->power = scanpower(devlisthead);
if (filter)
run_filter(devlisthead, filter, filter_args);
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index be5e421..f36d637 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -21,6 +21,7 @@
#include "mkfs.h"
static State *get_state(int argc, char **argv);
+static void free_state(State *s);
static int get_number(char *arg, uint64_t *res);
static void parse_journal_opts(char *progname, const char *opts,
uint64_t *journal_size_in_bytes,
@@ -46,6 +47,7 @@ static int alloc_from_bitmap(State *s, uint64_t num_bits, AllocBitmap *bitmap,
uint64_t *start, uint64_t *num);
static uint64_t alloc_inode(State *s, uint16_t *suballoc_bit);
static DirData *alloc_directory(State *s);
+static void free_directory(DirData *dir);
static void add_entry_to_directory(State *s, DirData *dir, char *name,
uint64_t byte_off, uint8_t type);
static uint32_t blocks_needed(State *s);
@@ -76,6 +78,7 @@ static AllocGroup * initialize_alloc_group(State *s, const char *name,
uint64_t blkno,
uint16_t chain, uint16_t cpg,
uint16_t bpc);
+static void free_alloc_group(AllocGroup *group);
static void index_system_dirs(State *s, ocfs2_filesys *fs);
static void create_lost_found_dir(State *s, ocfs2_filesys *fs);
static void format_journals(State *s, ocfs2_filesys *fs);
@@ -173,7 +176,6 @@ static int is_cluster_info_valid(State *s, char *stack_name,
"the specified cluster attribute");
return 0;
}
- return 1;
}
if (!stack_name || !strlen(stack_name)) {
@@ -580,12 +582,14 @@ main(int argc, char **argv)
/* bail if volume already mounted on cluster, etc. */
switch (ocfs2_check_volume(s)) {
case -1:
+ free_state(s);
return 1;
case 1:
if (s->prompt) {
fprintf(stdout, "Proceed (y/N): ");
if (toupper(getchar()) != 'Y') {
printf("Aborting operation.\n");
+ free_state(s);
return 1;
}
}
@@ -607,6 +611,7 @@ main(int argc, char **argv)
if (s->dry_run) {
close_device(s);
+ free_state(s);
return 0;
}
@@ -823,6 +828,16 @@ main(int argc, char **argv)
if (!s->quiet)
printf("%s successful\n\n", s->progname);
+ free_directory(root_dir);
+ free_directory(system_dir);
+ for (i = 0; i < s->initial_slots; i++)
+ free_directory(orphan_dir[i]);
+
+ for (i = 0; i < NUM_SYSTEM_INODES; i++)
+ ocfs2_free(&record[i]);
+
+ free_state(s);
+
return 0;
}
@@ -883,7 +898,7 @@ get_state(int argc, char **argv)
{ "verbose", 0, 0, 'v' },
{ "quiet", 0, 0, 'q' },
{ "version", 0, 0, 'V' },
- { "journal-options", 0, 0, 'J'},
+ { "journal-options", 1, 0, 'J'},
{ "heartbeat-device", 0, 0, 'H'},
{ "force", 0, 0, 'F'},
{ "mount", 1, 0, 'M'},
@@ -899,8 +914,6 @@ get_state(int argc, char **argv)
if (argc && *argv)
progname = basename(argv[0]);
- else
- progname = strdup("mkfs.ocfs2");
while (1) {
c = getopt_long(argc, argv, "b:C:L:N:J:M:vnqVFHxT:U:",
@@ -1227,6 +1240,28 @@ get_state(int argc, char **argv)
return s;
}
+static void
+free_state(State *s)
+{
+ int i;
+
+ ocfs2_free(&s->vol_label);
+ ocfs2_free(&s->device_name);
+ ocfs2_free(&s->cluster_stack);
+ ocfs2_free(&s->cluster_name);
+
+ if (s->global_bm) {
+ for (i = 0; i < s->nr_cluster_groups; i++)
+ free_alloc_group(s->global_bm->groups[i]);
+ ocfs2_free(&s->global_bm->groups);
+ ocfs2_free(&s->global_bm->name);
+ ocfs2_free(&s->global_bm);
+ }
+
+ free_alloc_group(s->system_group);
+ ocfs2_free(&s);
+}
+
static int
get_number(char *arg, uint64_t *res)
{
@@ -1415,10 +1450,30 @@ static unsigned int journal_size_vmstore(State *s)
return 32768;
}
+static int journal_size_valid(unsigned int j_blocks, State *s)
+{
+ return (j_blocks * s->initial_slots + 1024) <=
+ s->volume_size_in_blocks;
+}
+
+/* For operations such as mkdir that can require more than a cluster worth
+ * of journal credits, journal size should be greater than cluster size * 8.
+ * The kernel allows the maximum transaction buffer to be 1\4 th of the
+ * journal size and this is further divided by 2 for transaction
+ * reservation support. We calculate minimum journal size here
+ * accordingly and and ceil w.r.t to the cluster size.*/
+static unsigned int journal_min_size(uint32_t cluster_size)
+{
+ return (cluster_size << OCFS2_MIN_CLUSTER_TO_JOURNAL_SIZE_SHIFT)
+ + cluster_size;
+}
+
/* stolen from e2fsprogs, modified to fit ocfs2 patterns */
static uint64_t figure_journal_size(uint64_t size, State *s)
{
unsigned int j_blocks;
+ uint64_t ret;
+ unsigned int min_journal_size;
if (s->hb_dev)
return 0;
@@ -1428,19 +1483,27 @@ static uint64_t figure_journal_size(uint64_t size, State *s)
exit(1);
}
+ min_journal_size = journal_min_size(s->cluster_size);
if (size > 0) {
j_blocks = size >> s->blocksize_bits;
/* mke2fs knows about free blocks at this point, but
* we don't so lets just take a wild guess as to what
* the fs overhead we're looking at will be. */
- if ((j_blocks * s->initial_slots + 1024) >
- s->volume_size_in_blocks) {
+ if (!journal_size_valid(j_blocks, s)) {
fprintf(stderr,
"Journal size too big for filesystem.\n");
exit(1);
}
- return align_bytes_to_clusters_ceil(s, size);
+ ret = align_bytes_to_clusters_ceil(s, size);
+ /* It is better to fail mkfs than to create a non-functional
+ * filesystem.*/
+ if (ret < min_journal_size) {
+ fprintf(stderr,
+ "Journal size too small for filesystem.\n");
+ exit(1);
+ }
+ return ret;
}
switch (s->fs_type) {
@@ -1458,7 +1521,22 @@ static uint64_t figure_journal_size(uint64_t size, State *s)
break;
}
- return align_bytes_to_clusters_ceil(s, j_blocks << s->blocksize_bits);
+ ret = align_bytes_to_clusters_ceil(s, j_blocks << s->blocksize_bits);
+ /* If the default journal size is less than the minimum required
+ * size, set the default to the minimum size. Then fail if
+ * the journal size is not valid*/
+ if (ret < min_journal_size) {
+ ret = min_journal_size;
+ j_blocks = ret >> s->blocksize_bits;
+ if (!journal_size_valid(j_blocks, s)) {
+ fprintf(stderr,
+ "Volume size too small for required "
+ "configuration.\nIncrease volume size or "
+ "reduce cluster size\n");
+ exit(1);
+ }
+ }
+ return ret;
}
static uint32_t cluster_size_default(State *s)
@@ -1841,6 +1919,16 @@ initialize_alloc_group(State *s, const char *name,
return group;
}
+static void
+free_alloc_group(AllocGroup *group)
+{
+ if (group) {
+ ocfs2_free(&group->name);
+ ocfs2_free(&group->gd);
+ ocfs2_free(&group);
+ }
+}
+
static AllocBitmap *
initialize_bitmap(State *s, uint32_t bits, uint32_t unit_bits,
const char *name, SystemFileDiskRecord *bm_record)
@@ -2129,6 +2217,13 @@ alloc_directory(State *s)
}
static void
+free_directory(DirData *dir)
+{
+ ocfs2_free(&dir->buf);
+ ocfs2_free(&dir);
+}
+
+static void
add_entry_to_directory(State *s, DirData *dir, char *name, uint64_t byte_off,
uint8_t type)
{
diff --git a/mounted.ocfs2/mounted.c b/mounted.ocfs2/mounted.c
index c40f5f5..a1b8172 100644
--- a/mounted.ocfs2/mounted.c
+++ b/mounted.ocfs2/mounted.c
@@ -366,14 +366,15 @@ static errcode_t build_partition_list(struct list_head *dev_list, char *device)
}
/* skip devices smaller than 1M */
- ret = ocfs2_get_device_size(dev->dev_name, 4096, &numblocks);
- if (ret < 0) {
+
+ if (ocfs2_get_device_size(dev->dev_name, 4096, &numblocks)) {
verbosef(VL_DEBUG, "Unable to get size of %s\n",
dev->dev_name);
ocfs2_free(&dev);
continue;
}
+
if (numblocks <= (1024 * 1024 / 4096)) {
verbosef(VL_DEBUG, "Skipping small device %s\n",
dev->dev_name);
diff --git a/o2cb_ctl/o2cb_config.c b/o2cb_ctl/o2cb_config.c
index 17749f8..2bb1094 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -549,6 +549,7 @@ gint o2cb_config_store(O2CBConfig *config, const gchar *filename)
g_free(text);
out:
+ j_config_free(cf);
return rc;
} /* o2cb_config_store() */
diff --git a/o2cb_ctl/o2cb_scandisk.c b/o2cb_ctl/o2cb_scandisk.c
index 6cd3635..3cc2b7f 100644
--- a/o2cb_ctl/o2cb_scandisk.c
+++ b/o2cb_ctl/o2cb_scandisk.c
@@ -57,7 +57,7 @@ static int fill_desc(char *device, struct o2cb_region_desc *reg,
return ret;
}
-static void get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs)
+static int get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs)
{
struct o2cb_device *od;
struct list_head *pos, *pos1;
@@ -71,7 +71,7 @@ static void get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs
}
if (!numhbdevs)
- return;
+ return 0;
list_for_each(pos, &ctxt->sc_devlist) {
hb = list_entry(pos, struct hb_devices, hb_list);
@@ -97,6 +97,8 @@ static void get_device_uuids(struct scan_context *ctxt, struct list_head *hbdevs
if (!numhbdevs)
break;
}
+
+ return numhbdevs;
}
static void free_scan_context(struct scan_context *ctxt)
@@ -124,12 +126,18 @@ static void add_to_list(struct list_head *device_list, struct devnode *node)
while (path) {
if (node->mapper)
add = !strncmp(path->path, "/dev/mapper/", 12);
+ else if (node->power)
+ add = !strncmp(path->path, "/dev/emcpower", 13);
else {
add = !strncmp(path->path, "/dev/sd", 7);
if (!add)
add = !strncmp(path->path, "/dev/loop", 9);
if (!add)
add = !strncmp(path->path, "/dev/xvd", 8);
+ if (!add)
+ add = !strncmp(path->path, "/dev/vd", 7);
+ if (!add)
+ add = !strncmp(path->path, "/dev/rbd", 8);
}
if (add) {
hb = malloc(sizeof(struct hb_devices));
@@ -194,9 +202,10 @@ void o2cb_scandisk(struct list_head *hbdevs)
dev = scan_for_dev(NULL, 5, filter_devices, ctxt);
if (!dev)
goto bail;
- } while (ctxt->sc_rescan);
- get_device_uuids(ctxt, hbdevs);
+ if (!get_device_uuids(ctxt, hbdevs))
+ break;
+ } while (ctxt->sc_rescan);
bail:
free_scan_context(ctxt);
diff --git a/o2image/o2image.c b/o2image/o2image.c
index 465e7fe..ee62acf 100644
--- a/o2image/o2image.c
+++ b/o2image/o2image.c
@@ -329,8 +329,7 @@ out:
return ret;
}
-static errcode_t o2image_initialize(ocfs2_filesys *ofs, int raw_flag,
- int install_flag)
+static errcode_t o2image_initialize(ocfs2_filesys *ofs, int raw_flag)
{
uint64_t blocks[OCFS2_MAX_BACKUP_SUPERBLOCKS];
struct ocfs2_super_block *super;
@@ -674,9 +673,11 @@ static int prompt_image_creation(ocfs2_filesys *ofs, int rawflg, char *filename)
img_size/1024, free_spc/1024);
if (toupper(getchar()) != 'Y') {
fprintf(stdout, "Aborting image creation.\n");
+ ocfs2_free(&filepath);
return 0;
}
+ ocfs2_free(&filepath);
return 1;
}
@@ -770,7 +771,7 @@ int main(int argc, char **argv)
goto out;
}
- ret = o2image_initialize(ofs, raw_flag, install_flag);
+ ret = o2image_initialize(ofs, raw_flag);
if (ret) {
com_err(program_name, ret, "during o2image initialize");
goto out;
diff --git a/o2info/o2info.c b/o2info/o2info.c
index e64564a..aa4103e 100644
--- a/o2info/o2info.c
+++ b/o2info/o2info.c
@@ -348,8 +348,7 @@ static errcode_t o2info_append_task(struct o2info_operation *o2p)
task->o2p_task = o2p;
list_add_tail(&task->o2p_list, &o2info_op_task_list);
o2info_op_task_count++;
- } else
- ocfs2_free(&task);
+ }
return err;
}
diff --git a/ocfs2_hb_ctl/ocfs2_hb_ctl.c b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
index e4daa92..270fb6b 100644
--- a/ocfs2_hb_ctl/ocfs2_hb_ctl.c
+++ b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
@@ -171,13 +171,16 @@ out:
return err;
}
-static errcode_t get_uuid(char *dev, char *uuid)
+static errcode_t get_uuid(char *dev, char **uuid)
{
errcode_t ret;
ret = get_desc(dev);
- if (!ret)
- strcpy(uuid, region_desc->r_name);
+ if (!ret) {
+ *uuid = strdup(region_desc->r_name);
+ if (!*uuid)
+ ret = OCFS2_ET_NO_MEMORY;
+ }
return ret;
}
@@ -543,7 +546,7 @@ int main(int argc, char **argv)
struct hb_ctl_options hbo = {
.action = HB_ACTION_UNKNOWN,
};
- char hbuuid[33];
+ char *hbuuid = NULL;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
@@ -577,7 +580,7 @@ int main(int argc, char **argv)
}
if (!hbo.uuid_str) {
- err = get_uuid(hbo.dev_str, hbuuid);
+ err = get_uuid(hbo.dev_str, &hbuuid);
if (err) {
com_err(progname, err, "while reading uuid");
ret = -EINVAL;
@@ -631,6 +634,9 @@ int main(int argc, char **argv)
block_signals(SIG_UNBLOCK);
bail:
+ ocfs2_free(&hbo.dev_str);
+ ocfs2_free(&hbo.service);
+ ocfs2_free(&hbo.uuid_str);
free_desc();
return ret ? 1 : 0;
}
diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
index 1f4796b..240c1d9 100644
--- a/tunefs.ocfs2/libocfs2ne.c
+++ b/tunefs.ocfs2/libocfs2ne.c
@@ -1794,6 +1794,8 @@ static errcode_t tunefs_journal_check(ocfs2_filesys *fs)
jsb->s_feature_ro_compat;
state->ts_journal_features.opt_incompat |=
jsb->s_feature_incompat;
+ ocfs2_free_cached_inode(fs, ci);
+ ci = NULL;
}
/*
diff --git a/tunefs.ocfs2/ocfs2ne.c b/tunefs.ocfs2/ocfs2ne.c
index d2f06e4..368d316 100644
--- a/tunefs.ocfs2/ocfs2ne.c
+++ b/tunefs.ocfs2/ocfs2ne.c
@@ -1002,6 +1002,8 @@ static errcode_t parse_options(int argc, char *argv[], char **device)
}
out:
+ ocfs2_free(&optstring);
+ ocfs2_free(&long_options);
return err;
}
diff --git a/tunefs.ocfs2/op_query.c b/tunefs.ocfs2/op_query.c
index dc24cfd..295c185 100644
--- a/tunefs.ocfs2/op_query.c
+++ b/tunefs.ocfs2/op_query.c
@@ -324,19 +324,19 @@ static int query_run(struct tunefs_operation *op, ocfs2_filesys *fs,
return 1;
}
- register_printf_specifier('B', handle_blocksize, handle_arginfo);
- register_printf_specifier('T', handle_clustersize, handle_arginfo);
- register_printf_specifier('N', handle_numslots, handle_arginfo);
- register_printf_specifier('R', handle_rootdir, handle_arginfo);
- register_printf_specifier('Y', handle_sysdir, handle_arginfo);
- register_printf_specifier('P', handle_clustergroup, handle_arginfo);
-
- register_printf_specifier('V', handle_label, handle_arginfo);
- register_printf_specifier('U', handle_uuid, handle_arginfo);
-
- register_printf_specifier('M', handle_compat, handle_arginfo);
- register_printf_specifier('H', handle_incompat, handle_arginfo);
- register_printf_specifier('O', handle_ro_compat, handle_arginfo);
+ register_printf_function('B', handle_blocksize, handle_arginfo);
+ register_printf_function('T', handle_clustersize, handle_arginfo);
+ register_printf_function('N', handle_numslots, handle_arginfo);
+ register_printf_function('R', handle_rootdir, handle_arginfo);
+ register_printf_function('Y', handle_sysdir, handle_arginfo);
+ register_printf_function('P', handle_clustergroup, handle_arginfo);
+
+ register_printf_function('V', handle_label, handle_arginfo);
+ register_printf_function('U', handle_uuid, handle_arginfo);
+
+ register_printf_function('M', handle_compat, handle_arginfo);
+ register_printf_function('H', handle_incompat, handle_arginfo);
+ register_printf_function('O', handle_ro_compat, handle_arginfo);
query_fs = fs;
fprintf(stdout, fmt);
diff --git a/tunefs.ocfs2/op_resize_volume.c b/tunefs.ocfs2/op_resize_volume.c
index 076bda0..79f5fd0 100644
--- a/tunefs.ocfs2/op_resize_volume.c
+++ b/tunefs.ocfs2/op_resize_volume.c
@@ -62,8 +62,8 @@ struct resize_specs {
static errcode_t online_resize_lock(ocfs2_filesys *fs)
{
- return tunefs_dlm_lock(fs, lock_name, O2DLM_LEVEL_EXMODE,
- O2DLM_TRYLOCK);
+ return tunefs_dlm_lock(fs, lock_name, O2DLM_TRYLOCK,
+ O2DLM_LEVEL_EXMODE);
}
static errcode_t online_resize_unlock(ocfs2_filesys *fs)
@@ -543,7 +543,7 @@ static errcode_t check_new_size(ocfs2_filesys *fs, uint64_t new_size,
"Clusters (%"PRIu64" is greater than "
"maximum possible clusters %"PRIu32"\n",
device_clusters, UINT32_MAX);
- try_blocks = UINT32_MAX << b_to_c_bits;
+ try_blocks = (uint64_t)UINT32_MAX << b_to_c_bits;
errorf("Clusters %"PRIu64" is greater than max allowed"
" %"PRIu32".\nIf you want to resize to %"PRIu64
" blocks please specify %"PRIu64" as "
diff --git a/vendor/Makefile b/vendor/Makefile
index 8819586..58ac84d 100644
--- a/vendor/Makefile
+++ b/vendor/Makefile
@@ -2,6 +2,6 @@ TOPDIR = ..
include $(TOPDIR)/Preamble.make
-SUBDIRS = common rhel6 rhel5 sles10 rhel4 sles9 fc7 fc8 fc9
+SUBDIRS = common rhel7 rhel6 rhel5 sles10 rhel4 sles9 fc7 fc8 fc9
include $(TOPDIR)/Postamble.make
diff --git a/vendor/common/51-ocfs2.rules b/vendor/common/51-ocfs2.rules
index e348e25..381e87b 100644
--- a/vendor/common/51-ocfs2.rules
+++ b/vendor/common/51-ocfs2.rules
@@ -1,2 +1 @@
-KERNEL=="ocfs2_control", NAME="misc/ocfs2_control", MODE="0660"
-
+KERNEL=="ocfs2_control", SYMLINK+="misc/ocfs2_control", MODE="0660"
diff --git a/vendor/common/Makefile b/vendor/common/Makefile
index 864a71e..3c8902c 100644
--- a/vendor/common/Makefile
+++ b/vendor/common/Makefile
@@ -25,6 +25,8 @@ DIST_FILES = \
ocfs2-tools.spec-generic.in \
51-ocfs2.rules \
Vendor.make \
- o2cb.sysconfig.5.in
+ o2cb.sysconfig.5.in \
+ o2cb.service \
+ ocfs2.service
include $(TOPDIR)/Postamble.make
diff --git a/vendor/common/Vendor.make b/vendor/common/Vendor.make
index e92884e..1dcd42e 100644
--- a/vendor/common/Vendor.make
+++ b/vendor/common/Vendor.make
@@ -20,6 +20,9 @@ $(TOPDIR)/ocfs2-tools-$(DIST_VERSION)-$(PKG_VERSION).$(VENDOR_EXTENSION).src.rpm
-e 's,@@PYVERSION@@,'$(PYVERSION)',g' \
-e 's,@@COMPILE_PY@@,'$(COMPILE_PY)',g' \
-e 's,@@CHKCONFIG_DEP@@,'$(CHKCONFIG_DEP)',g' \
+ -e 's,@@SYSTEMD_ENABLED@@,'$(SYSTEMD_ENABLED)',g' \
+ -e 's:@@INSTALL_DEP_PKG@@:'$(INSTALL_DEP_PKG)':g' \
+ -e 's:@@BUILD_DEP_PKG@@:'$(BUILD_DEP_PKG)':g' \
< "$(TOPDIR)/vendor/common/ocfs2-tools.spec-generic" \
> "$(TOPDIR)/vendor/common/ocfs2-tools.spec"
$(RPMBUILD) -bs --define "_sourcedir $(RPM_TOPDIR)" --define "_srcrpmdir $(RPM_TOPDIR)" "$(TOPDIR)/vendor/common/ocfs2-tools.spec"
diff --git a/vendor/common/o2cb.init.sh b/vendor/common/o2cb.init.sh
index dedb408..5e85906 100755
--- a/vendor/common/o2cb.init.sh
+++ b/vendor/common/o2cb.init.sh
@@ -18,8 +18,18 @@
# Force LC_ALL=C
export LC_ALL=C
+if [ -f /etc/redhat-release ]
+then
+. /etc/init.d/functions
+
+start_daemon () {
+ daemon $*
+}
+else
# Let's try to use the LSB functions
. /lib/lsb/init-functions
+fi
+
if [ $? != 0 ]
then
echo "Unable to load LSB init functions" >&2
@@ -610,6 +620,7 @@ mount_filesystem()
mount -t ${FSNAME} ${FSNAME} ${MOUNTPOINT}
if [ $? != 0 ]
then
+ check_filesystem "$FSNAME" "$MOUNTPOINT" && return 2
echo "Unable to mount ${FSNAME} filesystem" >&2
return 1
fi
diff --git a/vendor/common/o2cb.service b/vendor/common/o2cb.service
new file mode 100644
index 0000000..09d0354
--- /dev/null
+++ b/vendor/common/o2cb.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Load o2cb Modules
+Requires=network.service
+After=network.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/sbin/o2cb.init enable
+ExecStop=/sbin/o2cb.init disable
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/common/ocfs2-tools.spec-generic.in b/vendor/common/ocfs2-tools.spec-generic.in
index 4fabc8c..194520d 100644
--- a/vendor/common/ocfs2-tools.spec-generic.in
+++ b/vendor/common/ocfs2-tools.spec-generic.in
@@ -17,6 +17,7 @@
%define build_ocfs2console 0
%define compile_py 0
+%define systemd_enabled @@SYSTEMD_ENABLED@@
%if %{build_ocfs2console}
%define compile_py @@COMPILE_PY@@
@@ -34,10 +35,13 @@ Distribution: Oracle
Vendor: Oracle
Packager: nobody <nobody at oracle.com>
Exclusiveos: Linux
-Requires: bash, which, coreutils, net-tools, modutils, e2fsprogs, @@CHKCONFIG_DEP@@, glib2 >= 2.2.3, util-linux >= 2.12j, redhat-lsb
-BuildRequires: e2fsprogs-devel, glib2-devel >= 2.2.3, @@PYGTK_NAME@@ >= 1.99.16, python-devel >= @@PYVERSION@@, util-linux >= 2.12j
+Requires: bash, which, coreutils, net-tools, e2fsprogs, @@CHKCONFIG_DEP@@, glib2 >= 2.2.3, util-linux >= 2.12j, @@INSTALL_DEP_PKG@@
+BuildRequires: e2fsprogs-devel, glib2-devel >= 2.2.3, @@PYGTK_NAME@@ >= 1.99.16, python-devel >= @@PYVERSION@@, util-linux >= 2.12j, @@BUILD_DEP_PKG@@
BuildRoot: %{_tmppath}/ocfs2-tools-%{PACKAGE_VERSION}-%{PACKAGE_RELEASE}-root
+%if !%{build_ocfs2console}
+Obsoletes: ocfs2console
+%endif
%description
Tools to manage Oracle Cluster Filesystem 2 volumes.
@@ -80,9 +84,18 @@ make
%install
-mkdir -p $RPM_BUILD_ROOT/etc/init.d
-cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/etc/init.d/o2cb
-cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/etc/init.d/ocfs2
+%if %{systemd_enabled}
+ mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
+ cp -f vendor/common/o2cb.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
+ cp -f vendor/common/ocfs2.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
+ mkdir -p $RPM_BUILD_ROOT/sbin
+ cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/sbin
+ cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/sbin
+%else
+ mkdir -p $RPM_BUILD_ROOT/etc/init.d
+ cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/etc/init.d/o2cb
+ cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/etc/init.d/ocfs2
+%endif
if [ -f /etc/redhat-release ]
then
# Red Hat chkconfig is completely and utterly broken
@@ -104,14 +117,27 @@ rm -rf "$RPM_BUILD_ROOT"
%post
-/sbin/chkconfig --add o2cb >/dev/null
-/sbin/chkconfig --add ocfs2 >/dev/null
+%if !%{systemd_enabled}
+ /sbin/chkconfig --add o2cb >/dev/null
+ /sbin/chkconfig --add ocfs2 >/dev/null
+%else
+ # clean up start/kill entry in /etc/rc*.d/ when upgrade.
+ if [ -f /etc/init.d/o2cb ]; then
+ /sbin/chkconfig --del o2cb >/dev/null
+ fi
+
+ if [ -f /etc/init.d/ocfs2 ]; then
+ /sbin/chkconfig --del ocfs2 >/dev/null
+ fi
+%endif
%preun
-if [ $1 = 0 ]; then # execute this only if we are NOT doing an upgrade
- /sbin/chkconfig --del ocfs2 >/dev/null
- /sbin/chkconfig --del o2cb >/dev/null
-fi
+%if !%{systemd_enabled}
+ if [ $1 = 0 ]; then # execute this only if we are NOT doing an upgrade
+ /sbin/chkconfig --del ocfs2 >/dev/null
+ /sbin/chkconfig --del o2cb >/dev/null
+ fi
+%endif
%files
%defattr(-,root,root)
@@ -127,10 +153,17 @@ fi
/sbin/o2image
/sbin/o2cluster
/sbin/ocfs2_hb_ctl
-/usr/bin/o2info
-/usr/sbin/o2hbmonitor
+%if %{systemd_enabled}
+/sbin/o2cb.init
+/sbin/ocfs2.init
+/usr/lib/systemd/system/o2cb.service
+/usr/lib/systemd/system/ocfs2.service
+%else
/etc/init.d/o2cb
/etc/init.d/ocfs2
+%endif
+/usr/bin/o2info
+/usr/sbin/o2hbmonitor
%config(noreplace) /etc/sysconfig/o2cb
/usr/share/man/man8/debugfs.ocfs2.8.gz
/usr/share/man/man8/fsck.ocfs2.8.gz
@@ -172,6 +205,9 @@ fi
%changelog
+* Thu Jun 18 2015 Junxiao Bi <junxiao.bi at oracle.com>
+- Add systemd support
+
* Thu Jan 27 2005 Manish Singh <manish.singh at oracle.com>
- Add ocfs2console
diff --git a/vendor/common/ocfs2.service b/vendor/common/ocfs2.service
new file mode 100644
index 0000000..768f806
--- /dev/null
+++ b/vendor/common/ocfs2.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Load ocfs2 Modules
+Requires=o2cb.service
+After=o2cb.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/sbin/ocfs2.init start
+ExecStop=/sbin/ocfs2.init stop
+ExecReload=/sbin/ocfs2.init restart
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/fc7/Vendor.make b/vendor/fc7/Vendor.make
index 025de08..8167603 100644
--- a/vendor/fc7/Vendor.make
+++ b/vendor/fc7/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/fc7/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = fc7
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "redhat-lsb\,\ modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/fc8/Vendor.make b/vendor/fc8/Vendor.make
index 6a78602..48b97b9 100644
--- a/vendor/fc8/Vendor.make
+++ b/vendor/fc8/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/fc8/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = fc8
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "redhat-lsb\,\ modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/fc9/Vendor.make b/vendor/fc9/Vendor.make
index db9fde1..676b0a5 100644
--- a/vendor/fc9/Vendor.make
+++ b/vendor/fc9/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/fc9/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = fc9
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "redhat-lsb\,\ modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel4/Vendor.make b/vendor/rhel4/Vendor.make
index 2245f44..8babca1 100644
--- a/vendor/rhel4/Vendor.make
+++ b/vendor/rhel4/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel4/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el4
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "redhat-lsb\,\ modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel5/Vendor.make b/vendor/rhel5/Vendor.make
index fb5b591..f72ddf1 100644
--- a/vendor/rhel5/Vendor.make
+++ b/vendor/rhel5/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel5/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el5
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel6/Vendor.make b/vendor/rhel6/Vendor.make
index 8f4a470..e02e172 100644
--- a/vendor/rhel6/Vendor.make
+++ b/vendor/rhel6/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel6/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el6
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel7/Makefile b/vendor/rhel7/Makefile
new file mode 100644
index 0000000..7afe47c
--- /dev/null
+++ b/vendor/rhel7/Makefile
@@ -0,0 +1,10 @@
+TOPDIR = ../..
+
+include $(TOPDIR)/Preamble.make
+
+DIST_FILES = \
+ rpmarch.guess \
+ Vendor.make \
+ vendor.guess
+
+include $(TOPDIR)/Postamble.make
diff --git a/vendor/rhel7/Vendor.make b/vendor/rhel7/Vendor.make
new file mode 100644
index 0000000..271f252
--- /dev/null
+++ b/vendor/rhel7/Vendor.make
@@ -0,0 +1,13 @@
+#
+# RHEL 7
+#
+
+TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel7/rpmarch.guess tools $(TOPDIR))
+VENDOR_EXTENSION = el7
+SYSTEMD_ENABLED = 1
+INSTALL_DEP_PKG = "kmod"
+BUILD_DEP_PKG = "libuuid-devel\,\ ncurses-devel\,\ readline-devel"
+
+include $(TOPDIR)/vendor/common/Vendor.make
+
+packages: rpm
diff --git a/vendor/rhel7/rpmarch.guess b/vendor/rhel7/rpmarch.guess
new file mode 100755
index 0000000..8519589
--- /dev/null
+++ b/vendor/rhel7/rpmarch.guess
@@ -0,0 +1,68 @@
+#! /bin/sh
+
+mode="$1"
+srcdir="$2"
+
+host_cpu=
+
+
+QUERYFILE=/etc/redhat-release
+
+if test -n "$QUERYFILE"; then
+ host_cpu="`rpm -qf $QUERYFILE --queryformat \"%{ARCH}\"`"
+fi
+
+if test -z "$host_cpu" -o "$host_cpu" = "noarch" ; then
+ host_alias=`$srcdir/config.guess`
+ host=`$srcdir/config.sub $host_alias`
+ host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+fi
+
+case "$host_cpu" in
+ x86_64|ia64|s390x)
+ TOOLSARCH="$host_cpu"
+ ;;
+ i386|i486|i586|i686|i786|k6|k7)
+ TOOLSARCH="i386"
+ ;;
+ ppc|ppc64|ppciseries|ppcpseries|ppc64iseries|ppc64pseries|powerpc|powerpc64)
+ TOOLSARCH="ppc"
+ ;;
+ *)
+ echo "rpmarch.guess: Warning: unknown RPM CPU architecture: $host_cpu" >&2
+ TOOLSARCH=""
+ ;;
+esac
+
+# Only a few of these need to be overwritten from RPM's default
+case "$host_cpu" in
+ i386|i586)
+ MODULEARCH="i686"
+ ;;
+ ppc|ppc64|ppciseries|ppcpseries|ppc64iseries|ppc64pseries|powerpc|powerpc64)
+ MODULEARCH="ppc64"
+ ;;
+ *)
+ MODULEARCH=""
+ ;;
+esac
+
+case "$mode" in
+ module)
+ if [ -n "$MODULEARCH" ] ; then
+ echo "--target $MODULEARCH"
+ fi
+ ;;
+ tools)
+ if [ -n "$TOOLSARCH" ] ; then
+ echo "--target $TOOLSARCH"
+ fi
+ ;;
+ *)
+ echo "rpmarch.guess: Invalid mode: $mode" >&2
+ echo "error"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/vendor/rhel7/vendor.guess b/vendor/rhel7/vendor.guess
new file mode 100755
index 0000000..c3a8b12
--- /dev/null
+++ b/vendor/rhel7/vendor.guess
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ ! -f /etc/redhat-release ]
+then
+ exit 1
+fi
+
+case "`rpm -qf /etc/redhat-release --qf '%{VERSION}' 2>/dev/null`" in
+ 7*) ;;
+ *) exit 1;;
+esac
+
+exit 0
diff --git a/vendor/sles10/Vendor.make b/vendor/sles10/Vendor.make
index 85969ea..57112ef 100644
--- a/vendor/sles10/Vendor.make
+++ b/vendor/sles10/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/sles10/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = SLE10
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "redhat-lsb\,\ modutils"
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/sles9/Vendor.make b/vendor/sles9/Vendor.make
index 8cb0482..6b0927c 100644
--- a/vendor/sles9/Vendor.make
+++ b/vendor/sles9/Vendor.make
@@ -4,6 +4,8 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/sles9/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = SLE9
+SYSTEMD_ENABLED = 0
+INSTALL_DEP_PKG = "redhat-lsb\,\ modutils"
include $(TOPDIR)/vendor/common/Vendor.make
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-ha/ocfs2-tools.git
More information about the Debian-HA-Commits
mailing list