Skip to content

Commit

Permalink
ufs: kill lock_ufs()
Browse files Browse the repository at this point in the history
There were 3 remaining users; in two of them we took ->s_lock immediately
after lock_ufs() and held it until just before unlock_ufs(); the third
one (statfs) could not be called from itself or from other two (remount
and sync_fs).  Just use ->s_lock in statfs and don't bother with lock_ufs
at all.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jul 6, 2015
1 parent 724bb09 commit dff7cfd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
34 changes: 2 additions & 32 deletions fs/ufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,6 @@
#include "swab.h"
#include "util.h"

void lock_ufs(struct super_block *sb)
{
struct ufs_sb_info *sbi = UFS_SB(sb);

mutex_lock(&sbi->mutex);
sbi->mutex_owner = current;
}

void unlock_ufs(struct super_block *sb)
{
struct ufs_sb_info *sbi = UFS_SB(sb);

sbi->mutex_owner = NULL;
mutex_unlock(&sbi->mutex);
}

static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
{
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
Expand Down Expand Up @@ -694,7 +678,6 @@ static int ufs_sync_fs(struct super_block *sb, int wait)
struct ufs_super_block_third * usb3;
unsigned flags;

lock_ufs(sb);
mutex_lock(&UFS_SB(sb)->s_lock);

UFSD("ENTER\n");
Expand All @@ -714,7 +697,6 @@ static int ufs_sync_fs(struct super_block *sb, int wait)

UFSD("EXIT\n");
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);

return 0;
}
Expand Down Expand Up @@ -758,7 +740,6 @@ static void ufs_put_super(struct super_block *sb)

ubh_brelse_uspi (sbi->s_uspi);
kfree (sbi->s_uspi);
mutex_destroy(&sbi->mutex);
kfree (sbi);
sb->s_fs_info = NULL;
UFSD("EXIT\n");
Expand Down Expand Up @@ -801,7 +782,6 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)

UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY));

mutex_init(&sbi->mutex);
mutex_init(&sbi->s_lock);
spin_lock_init(&sbi->work_lock);
INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs);
Expand Down Expand Up @@ -1257,7 +1237,6 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
return 0;

failed:
mutex_destroy(&sbi->mutex);
if (ubh)
ubh_brelse_uspi (uspi);
kfree (uspi);
Expand All @@ -1280,7 +1259,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
unsigned flags;

sync_filesystem(sb);
lock_ufs(sb);
mutex_lock(&UFS_SB(sb)->s_lock);
uspi = UFS_SB(sb)->s_uspi;
flags = UFS_SB(sb)->s_flags;
Expand All @@ -1296,22 +1274,19 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
ufs_set_opt (new_mount_opt, ONERROR_LOCK);
if (!ufs_parse_options (data, &new_mount_opt)) {
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return -EINVAL;
}
if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) {
new_mount_opt |= ufstype;
} else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) {
pr_err("ufstype can't be changed during remount\n");
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return -EINVAL;
}

if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
UFS_SB(sb)->s_mount_opt = new_mount_opt;
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return 0;
}

Expand All @@ -1335,7 +1310,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
#ifndef CONFIG_UFS_FS_WRITE
pr_err("ufs was compiled with read-only support, can't be mounted as read-write\n");
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return -EINVAL;
#else
if (ufstype != UFS_MOUNT_UFSTYPE_SUN &&
Expand All @@ -1345,21 +1319,18 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
ufstype != UFS_MOUNT_UFSTYPE_UFS2) {
pr_err("this ufstype is read-only supported\n");
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return -EINVAL;
}
if (!ufs_read_cylinder_structures(sb)) {
pr_err("failed during remounting\n");
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return -EPERM;
}
sb->s_flags &= ~MS_RDONLY;
#endif
}
UFS_SB(sb)->s_mount_opt = new_mount_opt;
mutex_unlock(&UFS_SB(sb)->s_lock);
unlock_ufs(sb);
return 0;
}

Expand Down Expand Up @@ -1391,8 +1362,7 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
struct ufs_super_block_third *usb3;
u64 id = huge_encode_dev(sb->s_bdev->bd_dev);

lock_ufs(sb);

mutex_lock(&UFS_SB(sb)->s_lock);
usb3 = ubh_get_usb_third(uspi);

if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
Expand All @@ -1413,7 +1383,7 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_fsid.val[0] = (u32)id;
buf->f_fsid.val[1] = (u32)(id >> 32);

unlock_ufs(sb);
mutex_unlock(&UFS_SB(sb)->s_lock);

return 0;
}
Expand Down
5 changes: 0 additions & 5 deletions fs/ufs/ufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct ufs_sb_info {
unsigned s_cgno[UFS_MAX_GROUP_LOADED];
unsigned short s_cg_loaded;
unsigned s_mount_opt;
struct mutex mutex;
struct task_struct *mutex_owner;
struct super_block *sb;
int work_queued; /* non-zero if the delayed work is queued */
struct delayed_work sync_work; /* FS sync delayed work */
Expand Down Expand Up @@ -172,7 +170,4 @@ static inline u32 ufs_dtogd(struct ufs_sb_private_info * uspi, u64 b)
return do_div(b, uspi->s_fpg);
}

extern void lock_ufs(struct super_block *sb);
extern void unlock_ufs(struct super_block *sb);

#endif /* _UFS_UFS_H */

0 comments on commit dff7cfd

Please sign in to comment.