Alistair Riddoch writes:
>
> Phil Kos writes:
> >
> > Chris Starling wrote:
> > > And the nifty thing is that I always get the message upon creating the
> > > 63rd file and any file thereafter.
> >
> > Sounds like this message happens when the function goes from the first
> > to the second allocation unit of the directory. (62 files plus entries
> > for . and .. is 64, which fills the first allocation unit.) That is
> > assuming a 1024-byte allocation unit and a 16-byte direntry. If this
> > isn't true, then I'm drinking too much Dr Pepper also.
> >
> >
>
> All makes sense that this is what is happening. I think I put in the
> printk() line at some point quite a while ago because I thought there
> should have been a call to unmap_buffer() at this point. I was waiting for
> the message to appear before I altered the code. I will go through it
> thoroughly and make sure the call is required. Thanks for the bug report.
>
I have been through this function and made sure I am happy with what is
going on. The function was not calling unmap_buffer() correctly, and the
printk() was put in to catch this if it ever happened. As it turns out,
the function was even worse than I thought. It called map_buffer() for each
entry in the directory, so when we get up to large directories, the
mapcount is increased by 60 or more each time a new entry is created, and
never decremented. This means that if you are creating files in multiple
directories, the buffers involved will all get permanently mapped into L1
cache space, and there are only 8 buffers in L1 space, meaning things got
bad pretty quickly.
My patch is included below, which not only fixes the problem, but also only
maps the buffer once for each block making the code much more efficient.
Al
--
diff -u -d -r1.6 namei.c
--- namei.c 1999/09/14 20:15:01 1.6
+++ namei.c 1999/09/20 13:05:53
@@ -225,8 +225,8 @@
bh = minix_bread(dir,block,1);
if (!bh)
return -ENOSPC;
+ map_buffer(bh);
}
- map_buffer(bh);
de = (struct minix_dir_entry *) (bh->b_data + offset);
offset += info->s_dirsize;
#ifdef BLOAT_FS
@@ -269,8 +269,7 @@
if (offset < 1024)
continue;
#endif
- printk("minix_add_entry may need another unmap_buffer :)");
- brelse(bh);
+ unmap_brelse(bh);
bh = NULL;
offset = 0;
block++;