fs/ext3/namei.c | 15 +++++++-------- fs/ext3/super.c | 1 + include/linux/ext3_fs_sb.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) --- linux-rh-2.4.20-8/fs/ext3/namei.c~ext3_orphan_lock-2.4.20-rh 2003-05-05 19:49:15.000000000 +0800 +++ linux-rh-2.4.20-8-root/fs/ext3/namei.c 2003-05-05 20:01:28.000000000 +0800 @@ -1747,8 +1747,8 @@ int ext3_orphan_add(handle_t *handle, st struct super_block *sb = inode->i_sb; struct ext3_iloc iloc; int err = 0, rc; - - lock_super(sb); + + down(&EXT3_SB(sb)->s_orphan_lock); if (!list_empty(&EXT3_I(inode)->i_orphan)) goto out_unlock; @@ -1796,7 +1796,7 @@ int ext3_orphan_add(handle_t *handle, st jbd_debug(4, "orphan inode %ld will point to %d\n", inode->i_ino, NEXT_ORPHAN(inode)); out_unlock: - unlock_super(sb); + up(&EXT3_SB(sb)->s_orphan_lock); ext3_std_error(inode->i_sb, err); return err; } @@ -1809,20 +1809,19 @@ int ext3_orphan_del(handle_t *handle, st { struct list_head *prev; struct ext3_inode_info *ei = EXT3_I(inode); - struct ext3_sb_info *sbi; + struct ext3_sb_info *sbi = EXT3_SB(inode->i_sb); unsigned long ino_next; struct ext3_iloc iloc; int err = 0; - lock_super(inode->i_sb); + down(&sbi->s_orphan_lock); if (list_empty(&ei->i_orphan)) { - unlock_super(inode->i_sb); + up(&sbi->s_orphan_lock); return 0; } ino_next = NEXT_ORPHAN(inode); prev = ei->i_orphan.prev; - sbi = EXT3_SB(inode->i_sb); jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino); @@ -1871,7 +1870,7 @@ int ext3_orphan_del(handle_t *handle, st out_err: ext3_std_error(inode->i_sb, err); out: - unlock_super(inode->i_sb); + up(&sbi->s_orphan_lock); return err; out_brelse: --- linux-rh-2.4.20-8/fs/ext3/super.c~ext3_orphan_lock-2.4.20-rh 2003-05-05 19:49:15.000000000 +0800 +++ linux-rh-2.4.20-8-root/fs/ext3/super.c 2003-05-05 19:54:09.000000000 +0800 @@ -1151,6 +1151,7 @@ struct super_block * ext3_read_super (st */ sb->s_op = &ext3_sops; INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ + sema_init(&sbi->s_orphan_lock, 1); sb->s_root = 0; --- linux-rh-2.4.20-8/include/linux/ext3_fs_sb.h~ext3_orphan_lock-2.4.20-rh 2003-05-05 19:49:07.000000000 +0800 +++ linux-rh-2.4.20-8-root/include/linux/ext3_fs_sb.h 2003-05-05 19:54:09.000000000 +0800 @@ -69,6 +69,7 @@ struct ext3_sb_info { struct inode * s_journal_inode; struct journal_s * s_journal; struct list_head s_orphan; + struct semaphore s_orphan_lock; unsigned long s_commit_interval; struct block_device *journal_bdev; #ifdef CONFIG_JBD_DEBUG _