Skip to contentSkip to conversation

conga/ricci modules/storage/LV.cpp modules/sto ...

Cluster-devel [email protected] 1 participant 1 message Jun 28, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2006-06-28 20:09:08

Modified files:
ricci/modules/storage: LV.cpp LVM.cpp LVM.h PV.cpp VG.cpp
ricci/docs : storage_api.html
Added files:
ricci/modules/storage: ClvmdError.h

Log message:
storage module: clvm support

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ClvmdError.h.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LV.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LVM.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LVM.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/PV.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/VG.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/storage_api.html.diff?cvsroot=cluster&r1=1.2&r2=1.3

/cvs/cluster/conga/ricci/modules/storage/ClvmdError.h,v --> standard output revision 1.1

- renamed from ricci/modules/storage/ClvmdError.h +41 -0
@@ -0,0 +1,41 @@
+/*
+  Copyright Red Hat, Inc. 2006
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  MA 02139, USA.
+*/
+/*
+ * Author: Stanko Kupcevic <[email protected]>
+ */
+
+
+#ifndef ClvmdError_h
+#define ClvmdError_h
+
+#include "Except.h"
+
+
+class ClvmdError : public Except
+{
+ public:
+  ClvmdError()
+    : Except(4, std::string("clvmd required, but unable to start. Start cluster infrastructure.")) {}
+  virtual ~ClvmdError()
+    {}
+  
+};
+
+
+#endif  // ClvmdError_h
ricci/modules/storage/LV.cpp +18 -0
@@ -29,6 +29,7 @@
 #include "utils.h"
 #include "ContentFactory.h"
 #include "ContentNone.h"
+#include "ClvmdError.h"
 
 
 using namespace std;
@@ -42,6 +43,13 @@
   
   string vgname = bd_temp.props.get("vgname").get_string();
   
+  
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (!LVM::clustered_available() &&
+      bd_temp.props.get("clustered").get_bool())
+    throw ClvmdError();
+  
+  
   string lvname = bd_temp.props.get("lvname").get_string();
   long long size = bd_temp.props.get("size").get_int();
   
@@ -158,6 +166,11 @@
 counting_auto_ptr<BD> 
 LV::apply(const BDParsed& bd_parsed)
 {
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (_props.get("clustered").get_bool() &&
+      !LVM::clustered_available())
+    throw ClvmdError();
+  
   // snapshots neither resize nor replace content, see LV()
   
   if (_props.get("snapshot").get_bool()) {
@@ -217,6 +230,11 @@
 void 
 LV::remove()
 {
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (_props.get("clustered").get_bool() &&
+      !LVM::clustered_available())
+    throw ClvmdError();
+  
   content->remove();
   LVM::lvremove(path());
 }
ricci/modules/storage/LVM.cpp +156 -61

316 lines not on this page · raw message

ricci/modules/storage/LVM.h +9 -2
@@ -50,14 +50,17 @@
   static void pvcreate(const std::string& path);
   static void pvremove(const std::string& path);
   
-  static void vgcreate(const std::string& vgname,
-		       long long extent_size,
+  static void vgcreate(const std::string& vgname, 
+		       long long extent_size, 
+		       bool clustered, 
 		       const std::list<std::string>& pv_paths);
   static void vgremove(const std::string& vgname);
   static void vgextend(const std::string& vgname,
 		       const std::list<std::string>& pv_paths);
   static void vgreduce(const std::string& vgname,
 		       const std::string& pv_path);
+  static void vgchange(const std::string& vgname,
+		       bool clustered);
   
   static void lvcreate(const std::string& vgname,
 		       const std::string& lvname,
@@ -70,6 +73,10 @@
   static void lvreduce(const std::string& path, long long new_size);
   static void lvextend(const std::string& path, long long new_size);
   
+  static void check_locking();
+  static bool clustered_available();
+  static bool vg_clustered(const std::string& vgname);
+  
 };
 
 
ricci/modules/storage/PV.cpp +23 -0
@@ -25,6 +25,7 @@
 #include "LVM.h"
 #include "MapperFactory.h"
 #include "utils.h"
+#include "ClvmdError.h"
 
 
 using namespace std;
@@ -91,6 +92,13 @@
   
   string vgname = _props.get("vgname").get_string();
   
+  
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (!LVM::clustered_available() &&
+      LVM::vg_clustered(vgname))
+    throw ClvmdError();
+  
+  
   if (vg->sources.size() == 1) {
     if (vgname.size())
       LVM::vgremove(vgname);
@@ -111,6 +119,14 @@
   string vgname_old(_props.get("vgname").get_string());
   string vgname_new(new_props.get("vgname").get_string());
   
+  
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (!LVM::clustered_available() &&
+      (LVM::vg_clustered(vgname_old) || 
+       LVM::vg_clustered(vgname_new)))
+    throw ClvmdError();
+  
+  
   counting_auto_ptr<Mapper> vg_old = 
     MapperFactory::get_mapper(_mapper_type,
 			      _mapper_id);
@@ -135,6 +151,13 @@
 {
   string vgname(templ->_props.get("vgname").get_string());
   
+  
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (!LVM::clustered_available() &&
+      LVM::vg_clustered(vgname))
+    throw ClvmdError();
+  
+  
   LVM::pvcreate(path);
   try {
     if (vgname.size())
ricci/modules/storage/VG.cpp +31 -3
@@ -28,6 +28,7 @@
 #include "defines.h"
 #include "utils.h"
 #include "MidAir.h"
+#include "ClvmdError.h"
 
 #include "Time.h"
 
@@ -41,6 +42,8 @@
 list<string> 
 get_VG_ids()
 {
+  LVM::check_locking();
+  
   list<string> vgids;
   
   vector<string> args;
@@ -148,6 +151,7 @@
     
     new_lv->props.set(Variable("vgname", _vgname));
     new_lv->props.set(Variable("snapshot", false));
+    new_lv->props.set(Variable("clustered", _props.get("clustered").get_bool()));
     new_targets.push_back(new_lv);
     
     // snapshots
@@ -183,14 +187,25 @@
 
 
 void 
-VG::apply(const MapperParsed&)
+VG::apply(const MapperParsed& mp)
 {
-  // nothing to do, for now
+  string vgname(mp.props.get("vgname").get_string());
+  
+  // clustered
+  bool clustered_old = _props.get("clustered").get_bool();
+  bool clustered_new = mp.props.get("clustered").get_bool();
+  if (clustered_old != clustered_new)
+    LVM::vgchange(vgname, clustered_new);
 }
 
 void 
 VG::__add_sources(const list<counting_auto_ptr<BD> >& bds)
 {
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (_props.get("clustered").get_bool() &&
+      !LVM::clustered_available())
+    throw ClvmdError();
+  
   string vgname;
   try {
     vgname = _props.get("vgname").get_string();
@@ -231,6 +246,11 @@
 void 
 VG::__remove()
 {
+  // if VG is marked as clustered, but cluster locking is not available, throw
+  if (_props.get("clustered").get_bool() &&
+      !LVM::clustered_available())
+    throw ClvmdError();
+  
   string vgname = _props.get("vgname").get_string();
   LVM::vgremove(vgname);
   for (list<counting_auto_ptr<BD> >::const_iterator iter = sources.begin();
@@ -251,6 +271,11 @@
   
   string vgname = temp.props.get("vgname").get_string();
   long long extent_size = temp.props.get("extent_size").get_int();
+  bool clustered = temp.props.get("clustered").get_bool();
+  
+  if (clustered &&
+      !LVM::clustered_available())
+    throw ClvmdError();
   
   try {
     utils::clear_cache();
@@ -267,7 +292,7 @@
     }
     
     // create VG
-    LVM::vgcreate(vgname, extent_size, pv_paths);
+    LVM::vgcreate(vgname, extent_size, clustered, pv_paths);
   } catch ( ... ) {
     for (list<counting_auto_ptr<BD> >::const_iterator iter = temp.sources.begin();
 	 iter != temp.sources.end();
@@ -319,6 +344,9 @@
 		     4 * 1024 * 1024 /* 4 MB */,
 		     ext_sizes));
   
+  // clustered
+  props.set(Variable("clustered", false, true));
+  
   // new sources
   VG unused(VG_PREFIX);
   for (list<counting_auto_ptr<BD> >::iterator iter = unused.sources.begin();
ricci/docs/storage_api.html +8 -1
@@ -5,7 +5,7 @@
 	<TITLE>Storage Module</TITLE>
 	<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.2  (Linux)">
 	<META NAME="CREATED" CONTENT="20060410;13011800">
-	<META NAME="CHANGED" CONTENT="20060413;13424800">
+	<META NAME="CHANGED" CONTENT="20060626;19014000">
 </HEAD>
 <BODY LANG="en-US" DIR="LTR">
 <P>Storage module manages all aspects of storage. Supports partition
@@ -66,6 +66,13 @@
 	<LI><P>3 ??? umount error<BR>It will happen in the case of umount
 	failure. 
 	</P>
+	<LI><P>4 ??? clvmd not running<BR>Clustered Volume Groups need clvmd
+	daemon running, and yet clvmd is not running. <BR>Storage module
+	will try to start it. On failure, this error will be raised. <BR>User
+	should either start clvmd, or mark VG non-clustered. <BR>In order to
+	start clvmd: <BR>1. lvm2-cluster needs to be installed<BR>2. cluster
+	infrastructure needs to be started<BR>3. clvmd should be started
+	(service clvmd start)</P>
 </UL>
 <P><BR><BR>
 </P>