struct inode *get_empty_inode(void) { static ino_t ino = 0; register struct inode *inode, *best; int i; repeat: inode = first_inode; best = 0; for (inode = inode_block, i = 0; i < nr_inodes; inode++, i++) { if (!inode->i_count && !inode->i_lock && !inode->i_dirt) { best = inode; break; } } if (!best) { printk("VFS: No free inodes - contact somebody other than Linus\n"); list_inode_status(); sleep_on(&inode_wait); goto repeat; } /* Here we are doing the same checks again. There cannot be a significant * * race condition here - no time has passed */ #if 0 if (inode->i_lock) { wait_on_inode(inode); goto repeat; } if (inode->i_dirt) { write_inode(inode); goto repeat; } if (inode->i_count) goto repeat; #endif clear_inode(inode); inode->i_count = inode->i_nlink = 1; #ifdef BLOAT_FS inode->i_version = ++event; #endif inode->i_sem = 0; inode->i_ino = ++ino; inode->i_dev = 0; nr_free_inodes--; if (nr_free_inodes < 0) { printk("VFS: get_empty_inode: bad free inode count.\n"); nr_free_inodes = 0; } return inode; }
static struct inode *get_empty_inode(void) { static ino_t ino = 0; register struct inode *inode; do { inode = first_inode->i_next; do { if (!inode->i_count && !inode->i_dirt && !inode->i_lock) { goto found_empty_inode; } } while ((inode = inode->i_next) != first_inode->i_next); printk("VFS: No free inodes\n"); list_inode_status(); sleep_on(&inode_wait); } while (1); found_empty_inode: /* Here we are doing the same checks again. There cannot be a significant * * race condition here - no time has passed */ #if 0 if (inode->i_lock) { wait_on_inode(inode); goto repeat; } if (inode->i_dirt) { write_inode(inode); goto repeat; } if (inode->i_count) goto repeat; #endif clear_inode(inode); inode->i_count = inode->i_nlink = 1; inode->i_uid = current->euid; #ifdef BLOAT_FS inode->i_version = ++event; #endif inode->i_ino = ++ino; nr_free_inodes--; if (nr_free_inodes < 0) { printk("VFS: get_empty_inode: bad free inode count.\n"); nr_free_inodes = 0; } return inode; }