Whamcloud - gitweb
Updated snapshot indexes in superblock to not depend on index "0" as being
authorbraam <braam>
Thu, 2 Dec 1999 00:11:46 +0000 (00:11 +0000)
committerbraam <braam>
Thu, 2 Dec 1999 00:11:46 +0000 (00:11 +0000)
the current snapshot.  We still need to push the inode attributes to the
snap copy so that size/times are correct.

lustre/include/linux/obd_snap.h
lustre/obdclass/obdcontrol
lustre/obdfs/super.c

index cf03c00..4289bac 100644 (file)
@@ -4,11 +4,17 @@
 #define OBD_SNAP_MAGIC 0x47224722
 
 #define SNAP_MAX  8 /* must fit in "u" area of struct inode */
+
+/* if time is 0 this designates the "current" snapshot, i.e.
+   the head of the tree 
+*/
+
 struct snap {
        time_t time;
        int index;
 };
 
+/* snap ioctl data for attach */
 struct snap_obd_data {
        int snap_dev;             /* which device contains the data */
        unsigned int snap_no;     /* which snapshot are we accessing */
@@ -16,13 +22,18 @@ struct snap_obd_data {
        struct snap snap_snaps[SNAP_MAX]; /* times must be incr or attach will fail */
 };
 
+
+/* this is the obd device descriptor */
 struct snap_obd {
-       unsigned int snap_no;    /* which snapshot are we accessing */
+       unsigned int snap_no;    /* which snapshot index are we accessing */
+       unsigned int snap_current;
        unsigned int snap_count; /* how many snapshots exist */
        time_t snap_times[SNAP_MAX];
        int snap_index[SNAP_MAX];
 };
 
+
+/* stored as inline data in the objects */
 struct snap_object_data {
        int od_magic;
        /* id of snaps of object; slot 0 has the current data */
index a399b7e..e866cc6 100755 (executable)
@@ -307,6 +307,11 @@ sub SnapAttach {
 
     $snapcount = keys %{$table};
     print "Snapcount $snapcount\n";
+
+    if ( ! defined $table->{0} ) {
+       print "No current snapshot in table! First make one\n";
+       return ;
+    }
     $data = pack("iii", $snapdev, $snapno, $snapcount);
     $datalen = 3 * 4;
     foreach my $time (sort keys %{$table}) {
@@ -318,7 +323,6 @@ sub SnapAttach {
     my $cl = length($data);
     my $add = pack("p", $data);
     print "type $type (len $len), datalen $datalen ($cl)\n";
-    printf "Addr of data %x\n", $add; 
     my $packed = pack("ipip", length($type), $type, $datalen, $data);
 
     my $rc = ioctl(DEV_OBD, &OBD_IOC_ATTACH, $packed);
@@ -350,11 +354,19 @@ sub SnapShotTable  {
     goto again;
 
   add:
-    my $idx = &readl("enter new index: ");
-    my $time = &readl("enter time (hit RET for \"now\"): ");
+    my $idx = &readl("enter index where you want this snapshot: ");
+    my $time = &readl("enter time or 'now' or 'current': ");
     my $oldtime = SnapFindTimeFromIdx($idx, $table);
-    delete $table->{$oldtime} if defined $oldtime;
-    $time = time unless $time;
+    if (defined $oldtime) {
+       print "This already exists, first clean up\n";
+       goto again;
+    }
+
+    if ( $time  eq 'now' ) {
+       $time = time;
+    } elsif ( $time eq 'current' ) { 
+       $time = 0;
+    }
     $table->{$time} = $idx;
     goto again;
 
@@ -389,6 +401,9 @@ sub PrintSnapShotTable {
     
     foreach  $time ( sort keys %{$table} ) {
        my $stime = localtime($time);
+       if ( ! $time ) { 
+           $stime = "current";
+       }
        printf "Time: %s -- Index %d\n", $stime, $table->{$time};
     }
 }
@@ -404,6 +419,9 @@ sub ReadSnapShotTable {
        $table->{$time} = $index;
     }
     close FH;
+
+    PrintSnapShotTable($table);
+
     return $table;
 }
 
index f8c5415..a58949a 100644 (file)
@@ -146,24 +146,28 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
        if ( !device ) {
                printk("No device\n");
                MOD_DEC_USE_COUNT;
+               EXIT;
                return NULL;
        }
 
        if ( (err = obdfs_getdev(device, &devno)) ) {
                printk("Cannot get devno of %s, error %d\n", device, err);
                MOD_DEC_USE_COUNT;
+               EXIT;
                return NULL;
        }
 
        if ( MAJOR(devno) != OBD_PSDEV_MAJOR ) {
                printk("Wrong major number!\n");
                MOD_DEC_USE_COUNT;
+               EXIT;
                return NULL;
        }
                
        if ( MINOR(devno) >= MAX_OBD_DEVICES ) {
                printk("Minor of %s too high (%d)\n", device, MINOR(devno));
                MOD_DEC_USE_COUNT;
+               EXIT;
                return NULL;
        } 
 
@@ -171,7 +175,10 @@ static struct super_block * obdfs_read_super(struct super_block *sb,
 
        if ( ! (obddev->obd_flags & OBD_ATTACHED) || 
             ! (obddev->obd_flags & OBD_SET_UP) ){
+               printk("Device %s not attached or not set up (%d)\n", 
+                      device, MINOR(devno));
                MOD_DEC_USE_COUNT;
+               EXIT;
                return NULL;
        }