patch-1.3.51 linux/fs/inode.c
Next file: linux/fs/nfs/rpcsock.c
Previous file: linux/fs/file_table.c
Back to the patch index
Back to the overall index
- Lines: 45
- Date:
Tue Dec 26 06:15:44 1995
- Orig file:
v1.3.50/linux/fs/inode.c
- Orig date:
Tue Dec 26 04:45:38 1995
diff -u --recursive --new-file v1.3.50/linux/fs/inode.c linux/fs/inode.c
@@ -430,28 +430,38 @@
return;
}
+static inline unsigned long value(struct inode * inode)
+{
+ if (inode->i_lock)
+ return 1000;
+ if (inode->i_dirt)
+ return 1000;
+ return inode->i_nrpages;
+}
+
struct inode * get_empty_inode(void)
{
static int ino = 0;
struct inode * inode, * best;
+ unsigned long badness = ~0UL;
int i;
- if (nr_inodes < NR_INODE && nr_free_inodes < (nr_inodes >> 2))
+ if (nr_inodes < NR_INODE && nr_free_inodes < (nr_inodes >> 1))
grow_inodes();
repeat:
inode = first_inode;
best = NULL;
for (i = 0; i<nr_inodes; inode = inode->i_next, i++) {
if (!inode->i_count) {
- if (!best)
- best = inode;
- if (!inode->i_dirt && !inode->i_lock) {
+ unsigned long i = value(inode);
+ if (i < badness) {
best = inode;
- break;
+ if ((badness = i) == 0)
+ break;
}
}
}
- if (!best || best->i_dirt || best->i_lock)
+ if (badness > 20)
if (nr_inodes < NR_INODE) {
grow_inodes();
goto repeat;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this