fs/ext3/namei.c | 15 +++++++-------- fs/ext3/namei.c.orig | 21 +++++++++++++++------ fs/ext3/super.c | 1 + include/linux/ext3_fs_sb.h | 1 + include/linux/ext3_fs_sb.h.orig | 2 ++ 5 files changed, 26 insertions(+), 14 deletions(-) --- linux-2.4.22-ac1/fs/ext3/namei.c~ext3-orphan_lock-2.4.22-rh 2003-09-26 00:24:09.000000000 +0400 +++ linux-2.4.22-ac1-alexey/fs/ext3/namei.c 2003-09-26 00:26:36.000000000 +0400 @@ -1748,8 +1748,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; @@ -1797,7 +1797,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; } @@ -1810,20 +1810,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); @@ -1872,7 +1871,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-2.4.22-ac1/fs/ext3/super.c~ext3-orphan_lock-2.4.22-rh 2003-09-26 00:24:09.000000000 +0400 +++ linux-2.4.22-ac1-alexey/fs/ext3/super.c 2003-09-26 00:25:22.000000000 +0400 @@ -1164,6 +1164,7 @@ struct super_block * ext3_read_super (st sb->s_op = &ext3_sops; sb->dq_op = &ext3_qops; INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ + sema_init(&sbi->s_orphan_lock, 1); sb->s_root = 0; --- linux-2.4.22-ac1/include/linux/ext3_fs_sb.h~ext3-orphan_lock-2.4.22-rh 2003-09-26 00:24:08.000000000 +0400 +++ linux-2.4.22-ac1-alexey/include/linux/ext3_fs_sb.h 2003-09-26 00:25:22.000000000 +0400 @@ -72,6 +72,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