[patch] my inode diff against 2.2.2-pre4

Andrea Arcangeli (andrea@e-mind.com)
Wed, 17 Feb 1999 17:17:53 +0100 (CET)


I don't understand why `found = 1' is needed. The asm code generated is
the same (with a `movl $1, %edx' of difference) with both egcs and gcc.

The first hunk of the patch is a static declaration.

The second part avoid me to be able to alloc
NR_OPEN*(NR_TASK-nr_task_running) inodes.

The end of the patch (iput() part) clean and put the inode on the unused
list when iput() is recalled and the inode is not referenced by anything.
Alexander, you had arguments against this iput() change and you're
probably right, but I can't see the exactly line of code (not that I tried
too hard but since you complained I guess you just know it ;) that make my
code to kill the icache even if there's plenty of memory availabe. Here
looking /proc/sys/fs/inode-nr it seems that the icache is always fine
(except when try_to_free_pages() we can't shrink and swapout of course ;).

Index: inode.c
===================================================================
RCS file: /var/cvs/linux/fs/inode.c,v
retrieving revision 1.1.1.4
retrieving revision 1.1.2.14
diff -u -r1.1.1.4 -r1.1.2.14
--- inode.c 1999/02/16 16:59:54 1.1.1.4
+++ inode.c 1999/02/17 14:01:46 1.1.2.14
@@ -54,7 +54,7 @@
* NOTE! You also have to own the lock if you change
* the i_state of an inode while it is in use..
*/
-spinlock_t inode_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t inode_lock = SPIN_LOCK_UNLOCKED;

/*
* Statistics gathering..
@@ -359,10 +359,8 @@
found = 1;
}

- if (found) {
+ if (found)
dispose_list(freeable);
- found = 1; /* silly compiler */
- }

return found;
}
@@ -427,6 +425,13 @@
inode = list_entry(tmp, struct inode, i_list);
return inode;
}
+ if (!capable(CAP_SYS_RESOURCE))
+ {
+ spin_unlock(&inode_lock);
+ printk(KERN_WARNING
+ "grow_inodes: inode-max limit reached\n");
+ return NULL;
+ }
}

spin_unlock(&inode_lock);
@@ -472,7 +477,7 @@
}
spin_unlock(&inode_lock);

- printk("grow_inodes: allocation failed\n");
+ printk(KERN_WARNING "grow_inodes: allocation failed\n");
return NULL;
}

@@ -701,16 +706,23 @@
spin_lock(&inode_lock);
}
}
- if (list_empty(&inode->i_hash)) {
+ if (!inode->i_state) {
list_del(&inode->i_list);
+ list_del(&inode->i_hash);
INIT_LIST_HEAD(&inode->i_list);
+ INIT_LIST_HEAD(&inode->i_hash);
+ dispose:
spin_unlock(&inode_lock);
clear_inode(inode);
spin_lock(&inode_lock);
list_add(&inode->i_list, &inode_unused);
inodes_stat.nr_free_inodes++;
- }
- else if (!(inode->i_state & I_DIRTY)) {
+ } else if (list_empty(&inode->i_hash)) {
+ list_del(&inode->i_list);
+ INIT_LIST_HEAD(&inode->i_list);
+ goto dispose;
+ } else if (!(inode->i_state & I_DIRTY)) {
+ printk(KERN_WARNING "iput: inode under I/O\n");
list_del(&inode->i_list);
list_add(&inode->i_list, &inode_in_use);
}

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/