]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: deliberate crash on ENOSPC or EIO
authorSage Weil <sage@newdream.net>
Mon, 18 Oct 2010 20:28:07 +0000 (13:28 -0700)
committerSage Weil <sage@newdream.net>
Mon, 18 Oct 2010 20:28:07 +0000 (13:28 -0700)
Neither of these are handled, so crash when we hit them.  This ensures we
don't blindly continue on with a partially applied transaction and corrupt
our store any further.

Signed-off-by: Sage Weil <sage@newdream.net>
src/os/FileStore.cc

index c519b5f5446d1277ad7a9c001ad2ae8c65688ea5..1ab1b941a14d20f9d6705ad003edd5123927f30e 100644 (file)
@@ -1131,12 +1131,13 @@ unsigned FileStore::_do_transaction(Transaction& t)
 
   while (t.have_op()) {
     int op = t.get_op();
+    int r = 0;
     switch (op) {
     case Transaction::OP_TOUCH:
       {
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
-       _touch(cid, oid);
+       r = _touch(cid, oid);
       }
       break;
       
@@ -1148,7 +1149,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        uint64_t len = t.get_length();
        bufferlist bl;
        t.get_bl(bl);
-       _write(cid, oid, off, len, bl);
+       r = _write(cid, oid, off, len, bl);
       }
       break;
       
@@ -1158,7 +1159,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        sobject_t oid = t.get_oid();
        uint64_t off = t.get_length();
        uint64_t len = t.get_length();
-       _zero(cid, oid, off, len);
+       r = _zero(cid, oid, off, len);
       }
       break;
       
@@ -1177,7 +1178,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
        uint64_t off = t.get_length();
-       _truncate(cid, oid, off);
+       r = _truncate(cid, oid, off);
       }
       break;
       
@@ -1185,7 +1186,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
       {
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
-       _remove(cid, oid);
+       r = _remove(cid, oid);
       }
       break;
       
@@ -1196,7 +1197,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        string name = t.get_attrname();
        bufferlist bl;
        t.get_bl(bl);
-       _setattr(cid, oid, name.c_str(), bl.c_str(), bl.length());
+       r = _setattr(cid, oid, name.c_str(), bl.c_str(), bl.length());
       }
       break;
       
@@ -1206,7 +1207,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        sobject_t oid = t.get_oid();
        map<string, bufferptr> aset;
        t.get_attrset(aset);
-       _setattrs(cid, oid, aset);
+       r = _setattrs(cid, oid, aset);
       }
       break;
 
@@ -1215,7 +1216,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
        string name = t.get_attrname();
-       _rmattr(cid, oid, name.c_str());
+       r = _rmattr(cid, oid, name.c_str());
       }
       break;
 
@@ -1223,7 +1224,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
       {
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
-       _rmattrs(cid, oid);
+       r = _rmattrs(cid, oid);
       }
       break;
       
@@ -1232,7 +1233,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
        sobject_t noid = t.get_oid();
-       _clone(cid, oid, noid);
+       r = _clone(cid, oid, noid);
       }
       break;
 
@@ -1243,21 +1244,21 @@ unsigned FileStore::_do_transaction(Transaction& t)
        sobject_t noid = t.get_oid();
        uint64_t off = t.get_length();
        uint64_t len = t.get_length();
-       _clone_range(cid, oid, noid, off, len);
+       r = _clone_range(cid, oid, noid, off, len);
       }
       break;
 
     case Transaction::OP_MKCOLL:
       {
        coll_t cid = t.get_cid();
-       _create_collection(cid);
+       r = _create_collection(cid);
       }
       break;
 
     case Transaction::OP_RMCOLL:
       {
        coll_t cid = t.get_cid();
-       _destroy_collection(cid);
+       r = _destroy_collection(cid);
       }
       break;
 
@@ -1266,7 +1267,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        coll_t ocid = t.get_cid();
        coll_t ncid = t.get_cid();
        sobject_t oid = t.get_oid();
-       _collection_add(ocid, ncid, oid);
+       r = _collection_add(ocid, ncid, oid);
       }
       break;
 
@@ -1274,7 +1275,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        {
        coll_t cid = t.get_cid();
        sobject_t oid = t.get_oid();
-       _collection_remove(cid, oid);
+       r = _collection_remove(cid, oid);
        }
       break;
 
@@ -1284,7 +1285,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
        string name = t.get_attrname();
        bufferlist bl;
        t.get_bl(bl);
-       _collection_setattr(cid, name.c_str(), bl.c_str(), bl.length());
+       r = _collection_setattr(cid, name.c_str(), bl.c_str(), bl.length());
       }
       break;
 
@@ -1292,7 +1293,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
       {
        coll_t cid = t.get_cid();
        string name = t.get_attrname();
-       _collection_rmattr(cid, name.c_str());
+       r = _collection_rmattr(cid, name.c_str());
       }
       break;
 
@@ -1304,7 +1305,7 @@ unsigned FileStore::_do_transaction(Transaction& t)
       {
        coll_t cid(t.get_cid());
        coll_t ncid(t.get_cid());
-       _collection_rename(cid, ncid);
+       r = _collection_rename(cid, ncid);
       }
       break;
 
@@ -1312,6 +1313,15 @@ unsigned FileStore::_do_transaction(Transaction& t)
       cerr << "bad op " << op << std::endl;
       assert(0);
     }
+
+    if (r == -ENOSPC) {
+      // For now, if we hit _any_ ENOSPC, crash, before we do any damage
+      // by partially applying transactions.
+      assert(0 == "ENOSPC handling not implemented");
+    }
+    if (r == -EIO) {
+      assert(0 == "EIO handling not implemented");
+    }
   }
   
   return 0;  // FIXME count errors