ufs: sb mutex merge + mutex_destroy
Commit788257d610
("ufs: remove the BKL") replaced BKL with mutex protection using functions lock_ufs, unlock_ufs and struct mutex 'mutex' in sb_info. Commitb6963327e0
("ufs: drop lock/unlock super") removed lock/unlock super and added struct mutex 's_lock' in sb_info. Those 2 mutexes are generally locked/unlocked at the same time except in allocation (balloc, ialloc). This patch merges the 2 mutexes and propagates first commit solution. It also adds mutex destruction before kfree during ufs_fill_super failure and ufs_put_super. [akpm@linux-foundation.org: avoid ifdefs, return -EROFS not -EINVAL] Signed-off-by: Fabian Frederick <fabf@skynet.be> Cc: Evgeniy Dushistov <dushistov@mail.ru> Cc: "Chen, Jet" <jet.chen@intel.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
0d2b7ea928
commit
0244756edc
@@ -69,11 +69,11 @@ void ufs_free_inode (struct inode * inode)
|
||||
|
||||
ino = inode->i_ino;
|
||||
|
||||
mutex_lock(&UFS_SB(sb)->s_lock);
|
||||
lock_ufs(sb);
|
||||
|
||||
if (!((ino > 1) && (ino < (uspi->s_ncg * uspi->s_ipg )))) {
|
||||
ufs_warning(sb, "ufs_free_inode", "reserved inode or nonexistent inode %u\n", ino);
|
||||
mutex_unlock(&UFS_SB(sb)->s_lock);
|
||||
unlock_ufs(sb);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void ufs_free_inode (struct inode * inode)
|
||||
bit = ufs_inotocgoff (ino);
|
||||
ucpi = ufs_load_cylinder (sb, cg);
|
||||
if (!ucpi) {
|
||||
mutex_unlock(&UFS_SB(sb)->s_lock);
|
||||
unlock_ufs(sb);
|
||||
return;
|
||||
}
|
||||
ucg = ubh_get_ucg(UCPI_UBH(ucpi));
|
||||
@@ -115,7 +115,7 @@ void ufs_free_inode (struct inode * inode)
|
||||
ubh_sync_block(UCPI_UBH(ucpi));
|
||||
|
||||
ufs_mark_sb_dirty(sb);
|
||||
mutex_unlock(&UFS_SB(sb)->s_lock);
|
||||
unlock_ufs(sb);
|
||||
UFSD("EXIT\n");
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
|
||||
sbi = UFS_SB(sb);
|
||||
uspi = sbi->s_uspi;
|
||||
|
||||
mutex_lock(&sbi->s_lock);
|
||||
lock_ufs(sb);
|
||||
|
||||
/*
|
||||
* Try to place the inode in its parent directory
|
||||
@@ -328,21 +328,20 @@ cg_found:
|
||||
sync_dirty_buffer(bh);
|
||||
brelse(bh);
|
||||
}
|
||||
|
||||
mutex_unlock(&sbi->s_lock);
|
||||
unlock_ufs(sb);
|
||||
|
||||
UFSD("allocating inode %lu\n", inode->i_ino);
|
||||
UFSD("EXIT\n");
|
||||
return inode;
|
||||
|
||||
fail_remove_inode:
|
||||
mutex_unlock(&sbi->s_lock);
|
||||
unlock_ufs(sb);
|
||||
clear_nlink(inode);
|
||||
iput(inode);
|
||||
UFSD("EXIT (FAILED): err %d\n", err);
|
||||
return ERR_PTR(err);
|
||||
failed:
|
||||
mutex_unlock(&sbi->s_lock);
|
||||
unlock_ufs(sb);
|
||||
make_bad_inode(inode);
|
||||
iput (inode);
|
||||
UFSD("EXIT (FAILED): err %d\n", err);
|
||||
|
Reference in New Issue
Block a user