]> sourceware.org Git - lvm2.git/commitdiff
Remove lockingfailed().
authorPetr Rockai <prokai@redhat.com>
Wed, 15 Jul 2009 05:49:47 +0000 (05:49 +0000)
committerPetr Rockai <prokai@redhat.com>
Wed, 15 Jul 2009 05:49:47 +0000 (05:49 +0000)
  We provide a lock type that behaves like no_locking, but is not
  clustered. Moreover, it also forbids any write locks. This magically (and
  consistently) prevents use of clustered VGs, or changing local VGs with
  --ignorelockingfailure. As a bonus, we can remove the special hacks in a few
  places. Of course, people looking for trouble can always set their locking_type
  to 0 to override.

lib/locking/locking.c
lib/locking/locking_types.h
lib/locking/no_locking.c
lib/metadata/metadata.c
lib/misc/lvm-globals.c
tools/lvchange.c
tools/vgchange.c

index 032f8ba138f27fdd217ee28e83a245b81d2c55f9..32d54b7079be6065e5519885a9e2d136bf263077 100644 (file)
@@ -215,8 +215,6 @@ static void _update_vg_lock_count(const char *resource, uint32_t flags)
  */
 int init_locking(int type, struct cmd_context *cmd)
 {
-       init_lockingfailed(0);
-
        if (type < 0)
                type = find_config_tree_int(cmd, "global/locking_type", 1);
                
@@ -279,9 +277,7 @@ int init_locking(int type, struct cmd_context *cmd)
 
        /* FIXME Ensure only read ops are permitted */
        log_verbose("Locking disabled - only read operations permitted.");
-
-       init_no_locking(&_locking, cmd);
-       init_lockingfailed(1);
+       init_readonly_locking(&_locking, cmd);
 
        return 1;
 }
index 65b39f52e6001ab37f49b399bca56ff04f896998..7fa0acdd468260f3c42d3e806ceef65b5e800c63 100644 (file)
@@ -40,6 +40,8 @@ struct locking_type {
  */
 int init_no_locking(struct locking_type *locking, struct cmd_context *cmd);
 
+int init_boottime_locking(struct locking_type *locking, struct cmd_context *cmd);
+
 int init_file_locking(struct locking_type *locking, struct cmd_context *cmd);
 
 int init_external_locking(struct locking_type *locking, struct cmd_context *cmd);
index 5eebafa99b56e0f8310a6a3bcc5582fd459021ec..0182973c9fb12eb3f1077bb70faf92cd56c4b729 100644 (file)
@@ -66,6 +66,17 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
        return 1;
 }
 
+static int _readonly_lock_resource(struct cmd_context *cmd,
+                                  const char *resource,
+                                  uint32_t flags)
+{
+       if (flags & LCK_TYPE_MASK == LCK_WRITE) {
+               log_error("Write locks are prohibited with --ignorelockingfailure.");
+               return 0;
+       }
+       return _no_lock_resource(cmd, resource, flags);
+}
+
 int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
 {
        locking->lock_resource = _no_lock_resource;
@@ -75,3 +86,13 @@ int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attr
 
        return 1;
 }
+
+int init_readonly_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
+{
+       locking->lock_resource = _readonly_lock_resource;
+       locking->reset_locking = _no_reset_locking;
+       locking->fin_locking = _no_fin_locking;
+       locking->flags = 0;
+
+       return 1;
+}
index 60366430887349e1e06d48e9884312c23b3ca9c8..c8166ad84d85818999862e8d36b81b6d61ecdcf1 100644 (file)
@@ -2772,8 +2772,7 @@ static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
        uint32_t failure = 0;
 
        if ((status & CLUSTERED) &&
-           (vg_is_clustered(vg)) && !locking_is_clustered() &&
-           !lockingfailed()) {
+           (vg_is_clustered(vg)) && !locking_is_clustered()) {
                log_error("Skipping clustered volume group %s", vg->name);
                /* Return because other flags are considered undefined. */
                return FAILED_CLUSTERED;
@@ -2922,8 +2921,7 @@ static vg_t *_vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
                goto_bad;
        }
 
-       if (vg_is_clustered(vg) && !locking_is_clustered() &&
-           !lockingfailed()) {
+       if (vg_is_clustered(vg) && !locking_is_clustered()) {
                log_error("Skipping clustered volume group %s", vg->name);
                failure |= FAILED_CLUSTERED;
                goto_bad;
index 870b2d7c528f52d8f1876f1fd777ef992fd68178..a409e684d213c1255aee2d82f68cce9d4fcd3020 100644 (file)
@@ -31,7 +31,6 @@ static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
 static int _debug_level = 0;
 static int _log_cmd_name = 0;
 static int _ignorelockingfailure = 0;
-static int _lockingfailed = 0;
 static int _security_level = SECURITY_LEVEL;
 static char _cmd_name[30] = "";
 static int _mirror_in_sync = 0;
@@ -77,11 +76,6 @@ void init_ignorelockingfailure(int level)
        _ignorelockingfailure = level;
 }
 
-void init_lockingfailed(int level)
-{
-       _lockingfailed = level;
-}
-
 void init_security_level(int level)
 {
        _security_level = level;
@@ -161,11 +155,6 @@ int trust_cache()
        return _trust_cache;
 }
 
-int lockingfailed()
-{
-       return _lockingfailed;
-}
-
 int ignorelockingfailure()
 {
        return _ignorelockingfailure;
index 2639328978076ba68e962b3dcc5d0a9efc6905b5..27a50d956522681d2c63bc73b04ba4e9b3fb1bdb 100644 (file)
@@ -119,12 +119,6 @@ static int lvchange_availability(struct cmd_context *cmd,
                if (!deactivate_lv(cmd, lv))
                        return_0;
        } else {
-               if (lockingfailed() && (vg_is_clustered(lv->vg))) {
-                       log_verbose("Locking failed: ignoring clustered "
-                                   "logical volume %s", lv->name);
-                       return 0;
-               }
-
                if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
                        log_verbose("Activating logical volume \"%s\" "
                                    "exclusively", lv->name);
index d8017142fb17ef590394a2f56e75df00432a6bc7..19c3eb7ef3bd7c858d74c9a1ec995c80d4d0cb59 100644 (file)
@@ -144,14 +144,8 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
                return ECMD_FAILED;
        }
 
-       if (activate && lockingfailed() && (vg_is_clustered(vg))) {
-               log_error("Locking inactive: ignoring clustered "
-                         "volume group %s", vg->name);
-               return ECMD_FAILED;
-       }
-
        /* FIXME Move into library where clvmd can use it */
-       if (activate && !lockingfailed())
+       if (activate)
                check_current_backup(vg);
 
        if (activate && (active = lvs_in_vg_activated(vg))) {
This page took 0.04863 seconds and 5 git commands to generate.