Commit e40b34c7 authored by Marco Stornelli's avatar Marco Stornelli Committed by Al Viro

fat: drop lock/unlock super

Removed lock/unlock super. Added a new private s_lock mutex.
Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 67e2c19a
...@@ -571,7 +571,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent, ...@@ -571,7 +571,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
int short_len = 0, fill_len = 0; int short_len = 0, fill_len = 0;
int ret = 0; int ret = 0;
lock_super(sb); mutex_lock(&sbi->s_lock);
cpos = filp->f_pos; cpos = filp->f_pos;
/* Fake . and .. for the root directory. */ /* Fake . and .. for the root directory. */
...@@ -693,7 +693,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent, ...@@ -693,7 +693,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
if (unicode) if (unicode)
__putname(unicode); __putname(unicode);
out: out:
unlock_super(sb); mutex_unlock(&sbi->s_lock);
return ret; return ret;
} }
......
...@@ -71,8 +71,9 @@ struct msdos_sb_info { ...@@ -71,8 +71,9 @@ struct msdos_sb_info {
unsigned long root_cluster; /* first cluster of the root directory */ unsigned long root_cluster; /* first cluster of the root directory */
unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */ unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
struct mutex fat_lock; struct mutex fat_lock;
unsigned int prev_free; /* previously allocated cluster number */ struct mutex s_lock;
unsigned int free_clusters; /* -1 if undefined */ unsigned int prev_free; /* previously allocated cluster number */
unsigned int free_clusters; /* -1 if undefined */
unsigned int free_clus_valid; /* is free_clusters valid? */ unsigned int free_clus_valid; /* is free_clusters valid? */
struct fat_mount_options options; struct fat_mount_options options;
struct nls_table *nls_disk; /* Codepage used on disk */ struct nls_table *nls_disk; /* Codepage used on disk */
......
...@@ -673,9 +673,9 @@ static int fat_write_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -673,9 +673,9 @@ static int fat_write_inode(struct inode *inode, struct writeback_control *wbc)
if (inode->i_ino == MSDOS_FSINFO_INO) { if (inode->i_ino == MSDOS_FSINFO_INO) {
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = fat_clusters_flush(sb); err = fat_clusters_flush(sb);
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
} else } else
err = __fat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL); err = __fat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
...@@ -1268,6 +1268,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, ...@@ -1268,6 +1268,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
b = (struct fat_boot_sector *) bh->b_data; b = (struct fat_boot_sector *) bh->b_data;
} }
mutex_init(&sbi->s_lock);
sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus; sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus;
sbi->cluster_bits = ffs(sbi->cluster_size) - 1; sbi->cluster_bits = ffs(sbi->cluster_size) - 1;
sbi->fats = b->fats; sbi->fats = b->fats;
......
...@@ -208,7 +208,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry, ...@@ -208,7 +208,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
struct inode *inode; struct inode *inode;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
switch (err) { switch (err) {
case -ENOENT: case -ENOENT:
...@@ -221,7 +221,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry, ...@@ -221,7 +221,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
default: default:
inode = ERR_PTR(err); inode = ERR_PTR(err);
} }
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
...@@ -273,7 +273,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -273,7 +273,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
unsigned char msdos_name[MSDOS_NAME]; unsigned char msdos_name[MSDOS_NAME];
int err, is_hid; int err, is_hid;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
msdos_name, &MSDOS_SB(sb)->options); msdos_name, &MSDOS_SB(sb)->options);
...@@ -302,7 +302,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -302,7 +302,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
if (!err) if (!err)
err = fat_flush_inodes(sb, dir, inode); err = fat_flush_inodes(sb, dir, inode);
return err; return err;
...@@ -316,7 +316,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -316,7 +316,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
struct fat_slot_info sinfo; struct fat_slot_info sinfo;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
/* /*
* Check whether the directory is not in use, then check * Check whether the directory is not in use, then check
* whether it is empty. * whether it is empty.
...@@ -337,7 +337,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -337,7 +337,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
fat_detach(inode); fat_detach(inode);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
if (!err) if (!err)
err = fat_flush_inodes(sb, dir, inode); err = fat_flush_inodes(sb, dir, inode);
...@@ -354,7 +354,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -354,7 +354,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
struct timespec ts; struct timespec ts;
int err, is_hid, cluster; int err, is_hid, cluster;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
msdos_name, &MSDOS_SB(sb)->options); msdos_name, &MSDOS_SB(sb)->options);
...@@ -392,14 +392,14 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -392,14 +392,14 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
fat_flush_inodes(sb, dir, inode); fat_flush_inodes(sb, dir, inode);
return 0; return 0;
out_free: out_free:
fat_free_clusters(dir, cluster); fat_free_clusters(dir, cluster);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return err; return err;
} }
...@@ -411,7 +411,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry) ...@@ -411,7 +411,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
struct fat_slot_info sinfo; struct fat_slot_info sinfo;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
if (err) if (err)
goto out; goto out;
...@@ -423,7 +423,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry) ...@@ -423,7 +423,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
fat_detach(inode); fat_detach(inode);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
if (!err) if (!err)
err = fat_flush_inodes(sb, dir, inode); err = fat_flush_inodes(sb, dir, inode);
...@@ -606,7 +606,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -606,7 +606,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME]; unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
int err, is_hid; int err, is_hid;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = msdos_format_name(old_dentry->d_name.name, err = msdos_format_name(old_dentry->d_name.name,
old_dentry->d_name.len, old_msdos_name, old_dentry->d_name.len, old_msdos_name,
...@@ -625,7 +625,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -625,7 +625,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
err = do_msdos_rename(old_dir, old_msdos_name, old_dentry, err = do_msdos_rename(old_dir, old_msdos_name, old_dentry,
new_dir, new_msdos_name, new_dentry, is_hid); new_dir, new_msdos_name, new_dentry, is_hid);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
if (!err) if (!err)
err = fat_flush_inodes(sb, old_dir, new_dir); err = fat_flush_inodes(sb, old_dir, new_dir);
return err; return err;
......
...@@ -721,7 +721,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -721,7 +721,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
struct dentry *alias; struct dentry *alias;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = vfat_find(dir, &dentry->d_name, &sinfo); err = vfat_find(dir, &dentry->d_name, &sinfo);
if (err) { if (err) {
...@@ -752,13 +752,13 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -752,13 +752,13 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
d_move(alias, dentry); d_move(alias, dentry);
iput(inode); iput(inode);
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return alias; return alias;
} else } else
dput(alias); dput(alias);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
dentry->d_time = dentry->d_parent->d_inode->i_version; dentry->d_time = dentry->d_parent->d_inode->i_version;
dentry = d_splice_alias(inode, dentry); dentry = d_splice_alias(inode, dentry);
if (dentry) if (dentry)
...@@ -766,7 +766,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, ...@@ -766,7 +766,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
return dentry; return dentry;
error: error:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -779,7 +779,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -779,7 +779,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
struct timespec ts; struct timespec ts;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
ts = CURRENT_TIME_SEC; ts = CURRENT_TIME_SEC;
err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo); err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
...@@ -800,7 +800,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -800,7 +800,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
dentry->d_time = dentry->d_parent->d_inode->i_version; dentry->d_time = dentry->d_parent->d_inode->i_version;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return err; return err;
} }
...@@ -811,7 +811,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -811,7 +811,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
struct fat_slot_info sinfo; struct fat_slot_info sinfo;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = fat_dir_empty(inode); err = fat_dir_empty(inode);
if (err) if (err)
...@@ -829,7 +829,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -829,7 +829,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
fat_detach(inode); fat_detach(inode);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return err; return err;
} }
...@@ -841,7 +841,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry) ...@@ -841,7 +841,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
struct fat_slot_info sinfo; struct fat_slot_info sinfo;
int err; int err;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = vfat_find(dir, &dentry->d_name, &sinfo); err = vfat_find(dir, &dentry->d_name, &sinfo);
if (err) if (err)
...@@ -854,7 +854,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry) ...@@ -854,7 +854,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
fat_detach(inode); fat_detach(inode);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return err; return err;
} }
...@@ -867,7 +867,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -867,7 +867,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
struct timespec ts; struct timespec ts;
int err, cluster; int err, cluster;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
ts = CURRENT_TIME_SEC; ts = CURRENT_TIME_SEC;
cluster = fat_alloc_new_dir(dir, &ts); cluster = fat_alloc_new_dir(dir, &ts);
...@@ -896,13 +896,13 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -896,13 +896,13 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
dentry->d_time = dentry->d_parent->d_inode->i_version; dentry->d_time = dentry->d_parent->d_inode->i_version;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return 0; return 0;
out_free: out_free:
fat_free_clusters(dir, cluster); fat_free_clusters(dir, cluster);
out: out:
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return err; return err;
} }
...@@ -921,7 +921,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -921,7 +921,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
old_inode = old_dentry->d_inode; old_inode = old_dentry->d_inode;
new_inode = new_dentry->d_inode; new_inode = new_dentry->d_inode;
lock_super(sb); mutex_lock(&MSDOS_SB(sb)->s_lock);
err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo); err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo);
if (err) if (err)
goto out; goto out;
...@@ -996,7 +996,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -996,7 +996,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
brelse(sinfo.bh); brelse(sinfo.bh);
brelse(dotdot_bh); brelse(dotdot_bh);
brelse(old_sinfo.bh); brelse(old_sinfo.bh);
unlock_super(sb); mutex_unlock(&MSDOS_SB(sb)->s_lock);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment