well, this patch isn't for everyone then. only those that, possibly as far
back as assignment 1, realized that panicing in lock/bitmap_create is
probably not desirable behavior.
one bit of dumb code is not an excuse for more.
-gwa-
Actually, if you look at thread/synch.c in the
lock_create function,
you'll notice that it panics and dies if kmalloc returns NULL. Unless
of course you changed lock create to not do this. If you are patching
against asst3-alpha, then you will never get to the code that kfrees the
filesystem and returns ENOMEM. bitmap_create has the same panic
behavior.
So, long story short, this patch should be
unnecessary. If it changes
anything behavior in any way, then, well, stranger things are happening
that memory allocation failing.
Jay
On Tue, 24 Apr 2001, gwa wrote:
> this one goes against asst3-alpha and fixes some
problems with memory
> allocation that MIGHT be biting people who are pushing their cache
> pretty hard... and not using ram_stealmem(). ;-)
>
> patch attached.
>
> -gwa-
>
> --- sfs_fs.c.old Tue Apr 24 21:50:08 2001
> +++ tarballs/asst3-sol-alpha/kern/fs/sfs/sfs_fs.c Tue Apr 24
21:55:17 2001
> @@ -328,8 +328,15 @@
> sfs->sfs_device = dev;
>
> /* Create and acquire the locks so various stuff works right */
> - sfs->sfs_vnlock = lock_create("sfs_vnlock");
> - sfs->sfs_bitlock = lock_create("sfs_bitlock");
> + if (!(sfs->sfs_vnlock = lock_create("sfs_vnlock"))) {
> + kfree(sfs);
> + return ENOMEM;
> + }
> + if (!(sfs->sfs_bitlock = lock_create("sfs_bitlock"))) {
> + lock_destroy(sfs->sfs_vnlock);
> + kfree(sfs);
> + return ENOMEM;
> + }
> lock_acquire(sfs->sfs_vnlock);
> lock_acquire(sfs->sfs_bitlock);
>
> @@ -368,7 +375,16 @@
> sfs->sfs_super.sp_volname[sizeof(sfs->sfs_super.sp_volname)-1] =
0;
>
> /* Load free space bitmap */
> - sfs->sfs_freemap = bitmap_create(SFS_FS_BITMAPSIZE(sfs));
> + if (!(sfs->sfs_freemap = bitmap_create(SFS_FS_BITMAPSIZE(sfs))))
{
+
lock_release(sfs->sfs_vnlock);
+ lock_release(sfs->sfs_bitlock);
+ lock_destroy(sfs->sfs_vnlock);
+ lock_destroy(sfs->sfs_bitlock);
+ bitmap_destroy(sfs->sfs_freemap);
+ kfree(sfs);
+ return ENOMEM;
+ }
+
result = sfs_mapio(sfs, UIO_READ);
if (result) {
lock_release(sfs->sfs_vnlock);
==
== Jay Moorthi * 617.584.2537 (cell) * moorthi(a)fas.harvard.edu
==
==
==
== "Happiness consists in getting enough sleep." RAH, Starship Troopers
==
==