]> sourceware.org Git - lvm2.git/commitdiff
Use new status code from fsadm check
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 1 Nov 2010 14:17:35 +0000 (14:17 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 1 Nov 2010 14:17:35 +0000 (14:17 +0000)
Patch updates exec_cmd() and adds 3rd parameter with pointer for
status value, so caller might examine returned status code.
If the passed pointer is NULL, behavior is unmodified.

Patch allows to confinue with lvresize if the failure from fsadm check is
caused by mounted filesystem as many of filesystem resize tools do support
online filesystem resize. (originally user had to use flag '-n' to bypass
this filesystem check)

WHATS_NEW
lib/activate/activate.c
lib/misc/lvm-exec.c
lib/misc/lvm-exec.h
tools/lvresize.c

index 3902e57b7763d8edeb56eac01a24efea2837615f..bc0972f97826f2945f012fca6aa19e6457e9a938 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.76 - 
 ===================================
+  Fix handling of online filesystem resize (using new fsadm return code).
   Add DIAGNOSTICS section to fsadm man page.
   Modify fsadm to return different status code for check of mounted filesystem.
   Update VG metadata only once in vgchange when making multiple changes.
index 40c0fdea5a4686db82896e93d25e2bc910453101..474b70b3793bd4ce408c7245e136fd12d1e2c788 100644 (file)
@@ -425,7 +425,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
        argv[1] = module;
        argv[2] = NULL;
 
-       ret = exec_cmd(cmd, argv);
+       ret = exec_cmd(cmd, argv, NULL);
 #endif
        return ret;
 }
index d332aaa106bdc34bf7ae20c9be4950b03a87046e..5cad79eb2996d8c51e717a279bf13230b12f667d 100644 (file)
@@ -46,7 +46,7 @@ static char *_verbose_args(const char *const argv[], char *buf, size_t sz)
 /*
  * Execute and wait for external command
  */
-int exec_cmd(struct cmd_context *cmd, const char *const argv[])
+int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus)
 {
        pid_t pid;
        int status;
@@ -71,6 +71,9 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[])
                _exit(errno);
        }
 
+       if (rstatus)
+               *rstatus = -1;
+
        /* Parent */
        if (wait4(pid, &status, 0, NULL) != pid) {
                log_error("wait4 child process %u failed: %s", pid,
@@ -84,9 +87,16 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[])
        }
 
        if (WEXITSTATUS(status)) {
-               log_error("%s failed: %u", argv[0], WEXITSTATUS(status));
+               if (rstatus) {
+                       *rstatus = WEXITSTATUS(status);
+                       log_verbose("%s failed: %u", argv[0], *rstatus);
+               } else
+                       log_error("%s failed: %u", argv[0], WEXITSTATUS(status));
                return 0;
        }
 
+       if (rstatus)
+               *rstatus = 0;
+
        return 1;
 }
index 6afc3a7725a74620142eb399cf485a0d16845ed4..6d984f846743f3af75f6bb0d7c816c2368214972 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
- * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -19,6 +19,6 @@
 #include "lib.h"
 
 struct cmd_context;
-int exec_cmd(struct cmd_context *cmd, const char *const argv[]);
+int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus);
 
 #endif
index 018dfc2e69f9ced1603e8f98d8f476c46e929c41..ca707f401172121f0e8b39c38b7fd7a046ad3732 100644 (file)
@@ -129,6 +129,7 @@ static int _request_confirmation(struct cmd_context *cmd,
 enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
 #define FSADM_CMD "fsadm"
 #define FSADM_CMD_MAX_ARGS 6
+#define FSADM_CHECK_FAILS_FOR_MOUNTED 3 /* shell exist status code */
 
 /*
  * FSADM_CMD --dry-run --verbose --force check lv_path
@@ -137,7 +138,8 @@ enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
 static int _fsadm_cmd(struct cmd_context *cmd,
                      const struct volume_group *vg,
                      const struct lvresize_params *lp,
-                     enum fsadm_cmd_e fcmd)
+                     enum fsadm_cmd_e fcmd,
+                     int *status)
 {
        char lv_path[PATH_MAX];
        char size_buf[SIZE_BUF];
@@ -177,7 +179,7 @@ static int _fsadm_cmd(struct cmd_context *cmd,
 
        argv[i] = NULL;
 
-       return exec_cmd(cmd, argv);
+       return exec_cmd(cmd, argv, status);
 }
 
 static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
@@ -321,6 +323,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
        struct lv_segment *seg, *uninitialized_var(mirr_seg);
        uint32_t seg_extents;
        uint32_t sz, str;
+       int status;
        struct dm_list *pvh = NULL;
        int use_policy = arg_count(cmd, use_policies_ARG);
 
@@ -637,13 +640,16 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
 
        if (lp->resizefs) {
                if (!lp->nofsck &&
-                   !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK)) {
-                       stack;
-                       return ECMD_FAILED;
+                   !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK, &status)) {
+                       if (status != FSADM_CHECK_FAILS_FOR_MOUNTED) {
+                               stack;
+                               return ECMD_FAILED;
+                       }
+                        /* some filesystems supports online resize */
                }
 
                if ((lp->resize == LV_REDUCE) &&
-                   !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
+                   !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL)) {
                        stack;
                        return ECMD_FAILED;
                }
@@ -711,7 +717,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
        log_print("Logical volume %s successfully resized", lp->lv_name);
 
        if (lp->resizefs && (lp->resize == LV_EXTEND) &&
-           !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE)) {
+           !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL)) {
                stack;
                return ECMD_FAILED;
        }
This page took 0.05104 seconds and 5 git commands to generate.