afs: Avoid SetupVolume panic
authorAndrew Deason <adeason@sinenomine.net>
Fri, 8 Feb 2013 23:24:28 +0000 (17:24 -0600)
committerDerrick Brashear <shadow@your-file-system.com>
Tue, 12 Feb 2013 19:39:19 +0000 (11:39 -0800)
Currently SetupVolume panics if it cannot successfully read a
volumeinfo entry from disk. Try to return an error instead, so we
don't panic the machine.

Change-Id: Iad3c2c857f1b736fcf4a142338d9e219bab68969
Reviewed-on: http://gerrit.openafs.org/9094
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/afs/afs_volume.c

index 9953f5a..ef0d825 100644 (file)
@@ -592,9 +592,18 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
                err =
                    afs_osi_Read(tfile, sizeof(struct fvolume) * j,
                                 &staticFVolume, sizeof(struct fvolume));
-               if (err != sizeof(struct fvolume))
-                   osi_Panic("read volumeinfo2");
                osi_UFSClose(tfile);
+               if (err != sizeof(struct fvolume)) {
+                   afs_warn("afs_SetupVolume: error %d reading volumeinfo\n",
+                            (int)err);
+                   /* put tv back on the free list; the data in it is not valid */
+                   tv->next = afs_freeVolList;
+                   afs_freeVolList = tv;
+                   /* staticFVolume contents are not valid */
+                   afs_FVIndex = -1;
+                   ReleaseWriteLock(&afs_xvolume);
+                   return NULL;
+               }
                afs_FVIndex = j;
            }
            tf = &staticFVolume;