Messages in this thread Patch in this message |  | | | Date | Tue, 19 Nov 2002 21:42:52 -0800 | | From | Andrew Morton <> | | Subject | Re: decrement of inodes_stat.nr_inodes in inode.c not SMP safe? |
| |
Rebecca.Callan@ir.com wrote: > > The value for nr_inodes in /proc/sys/fs/inode-state appears to be wrong. > > I think this is probably a bug in all 2.4 smp kernels. I've seen it in > 2.4.8-26mdksmp and 2.4.18-3smp. >
Is true. The 2.5 change needs to be backported.
--- linux-akpm/fs/inode.c~inodes_stat-race Tue Nov 19 21:42:08 2002 +++ linux-akpm-akpm/fs/inode.c Tue Nov 19 21:42:23 2002 @@ -532,22 +532,25 @@ void clear_inode(struct inode *inode) * Dispose-list gets a local list with local inodes in it, so it doesn't * need to worry about list corruption and SMP locks. */ -static void dispose_list(struct list_head * head) +static void dispose_list(struct list_head *head) { - struct list_head * inode_entry; - struct inode * inode; + int nr_disposed = 0; - while ((inode_entry = head->next) != head) - { - list_del(inode_entry); + while (!list_empty(head)) { + struct inode *inode; + + inode = list_entry(head->next, struct inode, i_list); + list_del(&inode->i_list); - inode = list_entry(inode_entry, struct inode, i_list); if (inode->i_data.nrpages) truncate_inode_pages(&inode->i_data, 0); clear_inode(inode); destroy_inode(inode); - inodes_stat.nr_inodes--; + nr_disposed++; } + spin_lock(&inode_lock); + inodes_stat.nr_inodes -= nr_disposed; + spin_unlock(&inode_lock); } /* _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |