]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorcyclonew <cyclonew@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 28 Jun 2005 08:29:48 +0000 (08:29 +0000)
committercyclonew <cyclonew@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 28 Jun 2005 08:29:48 +0000 (08:29 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@353 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/osd/OBFSStore.cc
ceph/osd/OBFSStore.h
ceph/osd/OSD.cc

index f88dd9832acde15c10c6adb391e44ae03b202d7d..77dbbc8d9d2fb0cd196251023327479ca892471b 100644 (file)
@@ -26,7 +26,10 @@ extern "C" {
 OBFSStore::OBFSStore(int whoami, char *param, char *dev)
 {
        this->whoami = whoami;
+       this->mounted = -1;
+       this->bdev_id = -1;
        this->param[0] = 0;
+       this->dev[0] = 0;
        if (dev)
                strcpy(this->dev, dev);
        if (param) 
@@ -35,15 +38,36 @@ OBFSStore::OBFSStore(int whoami, char *param, char *dev)
 
 int OBFSStore::init(void)
 {
-       int     dev_id;
-
+       dout(0) << "OBFS init!" << endl;
        if ((this->bdev_id = device_open(this->dev, 0)) < 0) {
-               dout(1) << "device open FAILED on " << this->dev << ", errno " << errno << endl;
+               dout(0) << "device open FAILED on " << this->dev << ", errno " << errno << endl;
                return -1;
        }
 
-       uofs_mount(dev_id);
+       this->mounted = uofs_mount(this->bdev_id);
+       switch (this->mounted) {
+               case -1:
+                       this->mkfs();
+                       //retry to mount
+                       dout(0) << "remount the OBFS" << endl;
+                       this->mounted = uofs_mount(this->bdev_id);
+                       assert(this->mounted >= 0);
+                       break;
+               case -2: 
+                       //fsck
+                       break;
+               case 0:
+                       //success
+                       break;
+               default:
+                       break;
+       }
 
+       if (this->mounted >= 0) 
+               dout(0) << "successfully mounted!" << endl;
+       else
+               dout(0) << "error in mounting!" << endl;
+       
        return 0;
 }
 
@@ -57,13 +81,17 @@ int OBFSStore::mkfs(void)
                nr_hash_table_buckets   = 1023,
                delay_allocation        = 0,
                flush_interval          = 5;
-               bdev_id;
        FILE    *param;
        
+
+       dout(0) << "OBFS.mkfs!" << endl;
+       if (this->mounted >= 0)
+               return 0;
+
        if (strlen(this->param) > 0) {
                param = fopen(this->param, "r");
                if (param) {
-                       fscanf(param, "Block Device: %s\n", this->dev);
+                       //fscanf(param, "Block Device: %s\n", this->dev);
                        fscanf(param, "Donode Size: %d\n", &donode_size_byte);
                        fscanf(param, "Block vs Donode Ratio: %d\n", &bd_ratio);
                        fscanf(param, "Region Size: %d MB\n", &reg_size_mb);
@@ -72,21 +100,24 @@ int OBFSStore::mkfs(void)
                        fscanf(param, "Hash Table Buckets: %d\n", &nr_hash_table_buckets);
                        fscanf(param, "Delayed Allocation: %d\n", &delay_allocation);
                } else {
-                       dout(1) << "read open FAILED on "<< this->param <<", errno " << errno << endl;
-                       dout(1) << "use default parameters" << endl;
+                       dout(0) << "read open FAILED on "<< this->param <<", errno " << errno << endl;
+                       dout(0) << "use default parameters" << endl;
                }
-       }
+       } else
+               dout(0) << "use default parameters" << endl;
 
-       if ((bdev_id = device_open(this->dev, 0)) < 0) {
-               dout(1) << "device open FAILED on "<< this->dev <<", errno " << errno << endl;
-               return -1;
-       }
-
-       uofs_format(bdev_id, donode_size_byte, bd_ratio, reg_size_mb, sb_size_kb, 
-                   lb_size_kb, nr_hash_table_buckets, delay_allocation, flush_interval);
+       if (this->bdev_id <= 0)
+               if ((this->bdev_id = device_open(this->dev, 0)) < 0) {
+                       dout(0) << "device open FAILED on "<< this->dev <<", errno " << errno << endl;
+                       return -1;
+               }
+       
+       dout(0) << "start formating!" << endl;
 
-       close(bdev_id);
+       uofs_format(this->bdev_id, donode_size_byte, bd_ratio, (reg_size_mb << 20), (sb_size_kb << 10), 
+                       (lb_size_kb << 10), nr_hash_table_buckets, delay_allocation, flush_interval);
 
+       dout(0) << "formatting complete!" << endl;
        return 0;
 }
 
index 308fd8f3d1b0526122bbea0223e96e6735bc33b3..1c57e59f6b06c89ca727f93b94e3e440cc6d0015 100644 (file)
@@ -7,6 +7,7 @@
 class OBFSStore: public ObjectStore {
        int     whoami;
        int     bdev_id;
+       int     mounted;
        char    dev[128];
        char    param[128];
 
index ef3582f46bef688a45549e69376edb206dc85fe4..7e3b6bc64dc4b41b641488c3bd81378f41749d70 100644 (file)
@@ -60,7 +60,7 @@ OSD::OSD(int id, Messenger *m)
 
   // use fake store
 #ifdef USE_OBFS
-  store = new OBFSStore(whoami, "./param.in", NULL);
+  store = new OBFSStore(whoami, NULL, "/dev/sdb3");
 #else
   store = new FakeStore(osd_base_path, whoami);
 #endif