提交 9a311b96 编写于 作者: A Arnd Bergmann

hpfs: remove the BKL

This removes the BKL in hpfs in a rather awful
way, by making the code only work on uniprocessor
systems without kernel preemption, as suggested
by Andi Kleen.

The HPFS code probably has close to zero remaining
users on current kernels, all archeological uses of
the file system can probably be done with the significant
restrictions.

The hpfs_lock/hpfs_unlock functions are left in the
code, sincen Mikulas has indicated that he is still
interested in fixing it in a better way.
Signed-off-by: NArnd Bergmann <arnd@arndb.de>
Acked-by: NAndi Kleen <ak@linux.intel.com>
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: linux-fsdevel@vger.kernel.org
上级 5edc3413
config HPFS_FS config HPFS_FS
tristate "OS/2 HPFS file system support" tristate "OS/2 HPFS file system support"
depends on BLOCK depends on BLOCK
depends on BKL # nontrivial to fix depends on BROKEN || !PREEMPT
help help
OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS
is the file system used for organizing files on OS/2 hard disk is the file system used for organizing files on OS/2 hard disk
......
...@@ -6,16 +6,15 @@ ...@@ -6,16 +6,15 @@
* directory VFS functions * directory VFS functions
*/ */
#include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "hpfs_fn.h" #include "hpfs_fn.h"
static int hpfs_dir_release(struct inode *inode, struct file *filp) static int hpfs_dir_release(struct inode *inode, struct file *filp)
{ {
lock_kernel(); hpfs_lock(inode->i_sb);
hpfs_del_pos(inode, &filp->f_pos); hpfs_del_pos(inode, &filp->f_pos);
/*hpfs_write_if_changed(inode);*/ /*hpfs_write_if_changed(inode);*/
unlock_kernel(); hpfs_unlock(inode->i_sb);
return 0; return 0;
} }
...@@ -30,7 +29,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) ...@@ -30,7 +29,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
struct hpfs_inode_info *hpfs_inode = hpfs_i(i); struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
struct super_block *s = i->i_sb; struct super_block *s = i->i_sb;
lock_kernel(); hpfs_lock(s);
/*printk("dir lseek\n");*/ /*printk("dir lseek\n");*/
if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok; if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
...@@ -43,12 +42,12 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) ...@@ -43,12 +42,12 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
} }
mutex_unlock(&i->i_mutex); mutex_unlock(&i->i_mutex);
ok: ok:
unlock_kernel(); hpfs_unlock(s);
return filp->f_pos = new_off; return filp->f_pos = new_off;
fail: fail:
mutex_unlock(&i->i_mutex); mutex_unlock(&i->i_mutex);
/*printk("illegal lseek: %016llx\n", new_off);*/ /*printk("illegal lseek: %016llx\n", new_off);*/
unlock_kernel(); hpfs_unlock(s);
return -ESPIPE; return -ESPIPE;
} }
...@@ -64,7 +63,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -64,7 +63,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
int c1, c2 = 0; int c1, c2 = 0;
int ret = 0; int ret = 0;
lock_kernel(); hpfs_lock(inode->i_sb);
if (hpfs_sb(inode->i_sb)->sb_chk) { if (hpfs_sb(inode->i_sb)->sb_chk) {
if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) { if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
...@@ -167,7 +166,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -167,7 +166,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
} }
out: out:
unlock_kernel(); hpfs_unlock(inode->i_sb);
return ret; return ret;
} }
...@@ -197,10 +196,10 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name ...@@ -197,10 +196,10 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
struct inode *result = NULL; struct inode *result = NULL;
struct hpfs_inode_info *hpfs_result; struct hpfs_inode_info *hpfs_result;
lock_kernel(); hpfs_lock(dir->i_sb);
if ((err = hpfs_chk_name(name, &len))) { if ((err = hpfs_chk_name(name, &len))) {
if (err == -ENAMETOOLONG) { if (err == -ENAMETOOLONG) {
unlock_kernel(); hpfs_unlock(dir->i_sb);
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
} }
goto end_add; goto end_add;
...@@ -298,7 +297,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name ...@@ -298,7 +297,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
end: end:
end_add: end_add:
unlock_kernel(); hpfs_unlock(dir->i_sb);
d_add(dentry, result); d_add(dentry, result);
return NULL; return NULL;
...@@ -311,7 +310,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name ...@@ -311,7 +310,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
/*bail:*/ /*bail:*/
unlock_kernel(); hpfs_unlock(dir->i_sb);
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
} }
......
...@@ -6,16 +6,15 @@ ...@@ -6,16 +6,15 @@
* file VFS functions * file VFS functions
*/ */
#include <linux/smp_lock.h>
#include "hpfs_fn.h" #include "hpfs_fn.h"
#define BLOCKS(size) (((size) + 511) >> 9) #define BLOCKS(size) (((size) + 511) >> 9)
static int hpfs_file_release(struct inode *inode, struct file *file) static int hpfs_file_release(struct inode *inode, struct file *file)
{ {
lock_kernel(); hpfs_lock(inode->i_sb);
hpfs_write_if_changed(inode); hpfs_write_if_changed(inode);
unlock_kernel(); hpfs_unlock(inode->i_sb);
return 0; return 0;
} }
...@@ -49,14 +48,14 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno) ...@@ -49,14 +48,14 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno)
static void hpfs_truncate(struct inode *i) static void hpfs_truncate(struct inode *i)
{ {
if (IS_IMMUTABLE(i)) return /*-EPERM*/; if (IS_IMMUTABLE(i)) return /*-EPERM*/;
lock_kernel(); hpfs_lock(i->i_sb);
hpfs_i(i)->i_n_secs = 0; hpfs_i(i)->i_n_secs = 0;
i->i_blocks = 1 + ((i->i_size + 511) >> 9); i->i_blocks = 1 + ((i->i_size + 511) >> 9);
hpfs_i(i)->mmu_private = i->i_size; hpfs_i(i)->mmu_private = i->i_size;
hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9)); hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
hpfs_write_inode(i); hpfs_write_inode(i);
hpfs_i(i)->i_n_secs = 0; hpfs_i(i)->i_n_secs = 0;
unlock_kernel(); hpfs_unlock(i->i_sb);
} }
static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
......
...@@ -342,3 +342,25 @@ static inline time32_t gmt_to_local(struct super_block *s, time_t t) ...@@ -342,3 +342,25 @@ static inline time32_t gmt_to_local(struct super_block *s, time_t t)
extern struct timezone sys_tz; extern struct timezone sys_tz;
return t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift; return t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift;
} }
/*
* Locking:
*
* hpfs_lock() is a leftover from the big kernel lock.
* Right now, these functions are empty and only left
* for documentation purposes. The file system no longer
* works on SMP systems, so the lock is not needed
* any more.
*
* If someone is interested in making it work again, this
* would be the place to start by adding a per-superblock
* mutex and fixing all the bugs and performance issues
* caused by that.
*/
static inline void hpfs_lock(struct super_block *s)
{
}
static inline void hpfs_unlock(struct super_block *s)
{
}
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
* inode VFS functions * inode VFS functions
*/ */
#include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "hpfs_fn.h" #include "hpfs_fn.h"
...@@ -267,7 +266,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -267,7 +266,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error = -EINVAL; int error = -EINVAL;
lock_kernel(); hpfs_lock(inode->i_sb);
if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
goto out_unlock; goto out_unlock;
if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
...@@ -290,7 +289,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -290,7 +289,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
hpfs_write_inode(inode); hpfs_write_inode(inode);
out_unlock: out_unlock:
unlock_kernel(); hpfs_unlock(inode->i_sb);
return error; return error;
} }
...@@ -307,8 +306,8 @@ void hpfs_evict_inode(struct inode *inode) ...@@ -307,8 +306,8 @@ void hpfs_evict_inode(struct inode *inode)
truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode); end_writeback(inode);
if (!inode->i_nlink) { if (!inode->i_nlink) {
lock_kernel(); hpfs_lock(inode->i_sb);
hpfs_remove_fnode(inode->i_sb, inode->i_ino); hpfs_remove_fnode(inode->i_sb, inode->i_ino);
unlock_kernel(); hpfs_unlock(inode->i_sb);
} }
} }
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
* adding & removing files & directories * adding & removing files & directories
*/ */
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp_lock.h>
#include "hpfs_fn.h" #include "hpfs_fn.h"
static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
...@@ -25,7 +24,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -25,7 +24,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
struct hpfs_dirent dee; struct hpfs_dirent dee;
int err; int err;
if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
lock_kernel(); hpfs_lock(dir->i_sb);
err = -ENOSPC; err = -ENOSPC;
fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
if (!fnode) if (!fnode)
...@@ -103,7 +102,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -103,7 +102,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
} }
d_instantiate(dentry, result); d_instantiate(dentry, result);
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return 0; return 0;
bail3: bail3:
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
...@@ -115,7 +114,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -115,7 +114,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
brelse(bh); brelse(bh);
hpfs_free_sectors(dir->i_sb, fno, 1); hpfs_free_sectors(dir->i_sb, fno, 1);
bail: bail:
unlock_kernel(); hpfs_unlock(dir->i_sb);
return err; return err;
} }
...@@ -132,7 +131,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc ...@@ -132,7 +131,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
int err; int err;
if ((err = hpfs_chk_name(name, &len))) if ((err = hpfs_chk_name(name, &len)))
return err==-ENOENT ? -EINVAL : err; return err==-ENOENT ? -EINVAL : err;
lock_kernel(); hpfs_lock(dir->i_sb);
err = -ENOSPC; err = -ENOSPC;
fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
if (!fnode) if (!fnode)
...@@ -195,7 +194,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc ...@@ -195,7 +194,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
} }
d_instantiate(dentry, result); d_instantiate(dentry, result);
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return 0; return 0;
bail2: bail2:
...@@ -205,7 +204,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc ...@@ -205,7 +204,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
brelse(bh); brelse(bh);
hpfs_free_sectors(dir->i_sb, fno, 1); hpfs_free_sectors(dir->i_sb, fno, 1);
bail: bail:
unlock_kernel(); hpfs_unlock(dir->i_sb);
return err; return err;
} }
...@@ -224,7 +223,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t ...@@ -224,7 +223,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM; if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM;
if (!new_valid_dev(rdev)) if (!new_valid_dev(rdev))
return -EINVAL; return -EINVAL;
lock_kernel(); hpfs_lock(dir->i_sb);
err = -ENOSPC; err = -ENOSPC;
fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
if (!fnode) if (!fnode)
...@@ -274,7 +273,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t ...@@ -274,7 +273,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
d_instantiate(dentry, result); d_instantiate(dentry, result);
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
brelse(bh); brelse(bh);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return 0; return 0;
bail2: bail2:
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
...@@ -283,7 +282,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t ...@@ -283,7 +282,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
brelse(bh); brelse(bh);
hpfs_free_sectors(dir->i_sb, fno, 1); hpfs_free_sectors(dir->i_sb, fno, 1);
bail: bail:
unlock_kernel(); hpfs_unlock(dir->i_sb);
return err; return err;
} }
...@@ -299,9 +298,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy ...@@ -299,9 +298,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
struct inode *result; struct inode *result;
int err; int err;
if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
lock_kernel(); hpfs_lock(dir->i_sb);
if (hpfs_sb(dir->i_sb)->sb_eas < 2) { if (hpfs_sb(dir->i_sb)->sb_eas < 2) {
unlock_kernel(); hpfs_unlock(dir->i_sb);
return -EPERM; return -EPERM;
} }
err = -ENOSPC; err = -ENOSPC;
...@@ -354,7 +353,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy ...@@ -354,7 +353,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
hpfs_write_inode_nolock(result); hpfs_write_inode_nolock(result);
d_instantiate(dentry, result); d_instantiate(dentry, result);
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return 0; return 0;
bail2: bail2:
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
...@@ -363,7 +362,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy ...@@ -363,7 +362,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
brelse(bh); brelse(bh);
hpfs_free_sectors(dir->i_sb, fno, 1); hpfs_free_sectors(dir->i_sb, fno, 1);
bail: bail:
unlock_kernel(); hpfs_unlock(dir->i_sb);
return err; return err;
} }
...@@ -380,7 +379,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -380,7 +379,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
int rep = 0; int rep = 0;
int err; int err;
lock_kernel(); hpfs_lock(dir->i_sb);
hpfs_adjust_length(name, &len); hpfs_adjust_length(name, &len);
again: again:
mutex_lock(&hpfs_i(inode)->i_parent_mutex); mutex_lock(&hpfs_i(inode)->i_parent_mutex);
...@@ -416,7 +415,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -416,7 +415,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
dentry_unhash(dentry); dentry_unhash(dentry);
if (!d_unhashed(dentry)) { if (!d_unhashed(dentry)) {
dput(dentry); dput(dentry);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return -ENOSPC; return -ENOSPC;
} }
if (generic_permission(inode, MAY_WRITE, 0, NULL) || if (generic_permission(inode, MAY_WRITE, 0, NULL) ||
...@@ -435,7 +434,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -435,7 +434,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
if (!err) if (!err)
goto again; goto again;
} }
unlock_kernel(); hpfs_unlock(dir->i_sb);
return -ENOSPC; return -ENOSPC;
default: default:
drop_nlink(inode); drop_nlink(inode);
...@@ -448,7 +447,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -448,7 +447,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
out: out:
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
mutex_unlock(&hpfs_i(inode)->i_parent_mutex); mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return err; return err;
} }
...@@ -466,7 +465,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -466,7 +465,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
int r; int r;
hpfs_adjust_length(name, &len); hpfs_adjust_length(name, &len);
lock_kernel(); hpfs_lock(dir->i_sb);
mutex_lock(&hpfs_i(inode)->i_parent_mutex); mutex_lock(&hpfs_i(inode)->i_parent_mutex);
mutex_lock(&hpfs_i(dir)->i_mutex); mutex_lock(&hpfs_i(dir)->i_mutex);
err = -ENOENT; err = -ENOENT;
...@@ -508,7 +507,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -508,7 +507,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
out: out:
mutex_unlock(&hpfs_i(dir)->i_mutex); mutex_unlock(&hpfs_i(dir)->i_mutex);
mutex_unlock(&hpfs_i(inode)->i_parent_mutex); mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
unlock_kernel(); hpfs_unlock(dir->i_sb);
return err; return err;
} }
...@@ -521,21 +520,21 @@ static int hpfs_symlink_readpage(struct file *file, struct page *page) ...@@ -521,21 +520,21 @@ static int hpfs_symlink_readpage(struct file *file, struct page *page)
int err; int err;
err = -EIO; err = -EIO;
lock_kernel(); hpfs_lock(i->i_sb);
if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh)))
goto fail; goto fail;
err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE); err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE);
brelse(bh); brelse(bh);
if (err) if (err)
goto fail; goto fail;
unlock_kernel(); hpfs_unlock(i->i_sb);
SetPageUptodate(page); SetPageUptodate(page);
kunmap(page); kunmap(page);
unlock_page(page); unlock_page(page);
return 0; return 0;
fail: fail:
unlock_kernel(); hpfs_unlock(i->i_sb);
SetPageError(page); SetPageError(page);
kunmap(page); kunmap(page);
unlock_page(page); unlock_page(page);
...@@ -567,7 +566,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -567,7 +566,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
err = 0; err = 0;
hpfs_adjust_length(old_name, &old_len); hpfs_adjust_length(old_name, &old_len);
lock_kernel(); hpfs_lock(i->i_sb);
/* order doesn't matter, due to VFS exclusion */ /* order doesn't matter, due to VFS exclusion */
mutex_lock(&hpfs_i(i)->i_parent_mutex); mutex_lock(&hpfs_i(i)->i_parent_mutex);
if (new_inode) if (new_inode)
...@@ -659,7 +658,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -659,7 +658,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
mutex_unlock(&hpfs_i(i)->i_parent_mutex); mutex_unlock(&hpfs_i(i)->i_parent_mutex);
if (new_inode) if (new_inode)
mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex);
unlock_kernel(); hpfs_unlock(i->i_sb);
return err; return err;
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <linux/statfs.h> #include <linux/statfs.h>
#include <linux/magic.h> #include <linux/magic.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -103,15 +102,11 @@ static void hpfs_put_super(struct super_block *s) ...@@ -103,15 +102,11 @@ static void hpfs_put_super(struct super_block *s)
{ {
struct hpfs_sb_info *sbi = hpfs_sb(s); struct hpfs_sb_info *sbi = hpfs_sb(s);
lock_kernel();
kfree(sbi->sb_cp_table); kfree(sbi->sb_cp_table);
kfree(sbi->sb_bmp_dir); kfree(sbi->sb_bmp_dir);
unmark_dirty(s); unmark_dirty(s);
s->s_fs_info = NULL; s->s_fs_info = NULL;
kfree(sbi); kfree(sbi);
unlock_kernel();
} }
unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
...@@ -143,7 +138,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -143,7 +138,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
struct super_block *s = dentry->d_sb; struct super_block *s = dentry->d_sb;
struct hpfs_sb_info *sbi = hpfs_sb(s); struct hpfs_sb_info *sbi = hpfs_sb(s);
u64 id = huge_encode_dev(s->s_bdev->bd_dev); u64 id = huge_encode_dev(s->s_bdev->bd_dev);
lock_kernel(); hpfs_lock(s);
/*if (sbi->sb_n_free == -1) {*/ /*if (sbi->sb_n_free == -1) {*/
sbi->sb_n_free = count_bitmaps(s); sbi->sb_n_free = count_bitmaps(s);
...@@ -160,7 +155,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -160,7 +155,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_fsid.val[1] = (u32)(id >> 32); buf->f_fsid.val[1] = (u32)(id >> 32);
buf->f_namelen = 254; buf->f_namelen = 254;
unlock_kernel(); hpfs_unlock(s);
return 0; return 0;
} }
...@@ -406,7 +401,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) ...@@ -406,7 +401,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
*flags |= MS_NOATIME; *flags |= MS_NOATIME;
lock_kernel(); hpfs_lock(s);
lock_super(s); lock_super(s);
uid = sbi->sb_uid; gid = sbi->sb_gid; uid = sbi->sb_uid; gid = sbi->sb_gid;
umask = 0777 & ~sbi->sb_mode; umask = 0777 & ~sbi->sb_mode;
...@@ -441,12 +436,12 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) ...@@ -441,12 +436,12 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
replace_mount_options(s, new_opts); replace_mount_options(s, new_opts);
unlock_super(s); unlock_super(s);
unlock_kernel(); hpfs_unlock(s);
return 0; return 0;
out_err: out_err:
unlock_super(s); unlock_super(s);
unlock_kernel(); hpfs_unlock(s);
kfree(new_opts); kfree(new_opts);
return -EINVAL; return -EINVAL;
} }
...@@ -484,13 +479,15 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) ...@@ -484,13 +479,15 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
int o; int o;
lock_kernel(); if (num_possible_cpus() > 1) {
printk(KERN_ERR "HPFS is not SMP safe\n");
return -EINVAL;
}
save_mount_options(s, options); save_mount_options(s, options);
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi) { if (!sbi) {
unlock_kernel();
return -ENOMEM; return -ENOMEM;
} }
s->s_fs_info = sbi; s->s_fs_info = sbi;
...@@ -677,7 +674,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) ...@@ -677,7 +674,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
root->i_blocks = 5; root->i_blocks = 5;
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
} }
unlock_kernel();
return 0; return 0;
bail4: brelse(bh2); bail4: brelse(bh2);
...@@ -689,7 +685,6 @@ bail2: brelse(bh0); ...@@ -689,7 +685,6 @@ bail2: brelse(bh0);
kfree(sbi->sb_cp_table); kfree(sbi->sb_cp_table);
s->s_fs_info = NULL; s->s_fs_info = NULL;
kfree(sbi); kfree(sbi);
unlock_kernel();
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册