Skip to content

Commit

Permalink
hpfs: remove the BKL
Browse files Browse the repository at this point in the history
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: Arnd Bergmann <arnd@arndb.de>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: linux-fsdevel@vger.kernel.org
  • Loading branch information
Arnd Bergmann committed Mar 2, 2011
1 parent 5edc341 commit 9a311b9
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 62 deletions.
2 changes: 1 addition & 1 deletion fs/hpfs/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config HPFS_FS
tristate "OS/2 HPFS file system support"
depends on BLOCK
depends on BKL # nontrivial to fix
depends on BROKEN || !PREEMPT
help
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
Expand Down
23 changes: 11 additions & 12 deletions fs/hpfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
* directory VFS functions
*/

#include <linux/smp_lock.h>
#include <linux/slab.h>
#include "hpfs_fn.h"

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_write_if_changed(inode);*/
unlock_kernel();
hpfs_unlock(inode->i_sb);
return 0;
}

Expand All @@ -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 super_block *s = i->i_sb;

lock_kernel();
hpfs_lock(s);

/*printk("dir lseek\n");*/
if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
Expand All @@ -43,12 +42,12 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
}
mutex_unlock(&i->i_mutex);
ok:
unlock_kernel();
hpfs_unlock(s);
return filp->f_pos = new_off;
fail:
mutex_unlock(&i->i_mutex);
/*printk("illegal lseek: %016llx\n", new_off);*/
unlock_kernel();
hpfs_unlock(s);
return -ESPIPE;
}

Expand All @@ -64,7 +63,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
int c1, c2 = 0;
int ret = 0;

lock_kernel();
hpfs_lock(inode->i_sb);

if (hpfs_sb(inode->i_sb)->sb_chk) {
if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
Expand Down Expand Up @@ -167,7 +166,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
hpfs_brelse4(&qbh);
}
out:
unlock_kernel();
hpfs_unlock(inode->i_sb);
return ret;
}

Expand Down Expand Up @@ -197,10 +196,10 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
struct inode *result = NULL;
struct hpfs_inode_info *hpfs_result;

lock_kernel();
hpfs_lock(dir->i_sb);
if ((err = hpfs_chk_name(name, &len))) {
if (err == -ENAMETOOLONG) {
unlock_kernel();
hpfs_unlock(dir->i_sb);
return ERR_PTR(-ENAMETOOLONG);
}
goto end_add;
Expand Down Expand Up @@ -298,7 +297,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name

end:
end_add:
unlock_kernel();
hpfs_unlock(dir->i_sb);
d_add(dentry, result);
return NULL;

Expand All @@ -311,7 +310,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name

/*bail:*/

unlock_kernel();
hpfs_unlock(dir->i_sb);
return ERR_PTR(-ENOENT);
}

Expand Down
9 changes: 4 additions & 5 deletions fs/hpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
* file VFS functions
*/

#include <linux/smp_lock.h>
#include "hpfs_fn.h"

#define BLOCKS(size) (((size) + 511) >> 9)

static int hpfs_file_release(struct inode *inode, struct file *file)
{
lock_kernel();
hpfs_lock(inode->i_sb);
hpfs_write_if_changed(inode);
unlock_kernel();
hpfs_unlock(inode->i_sb);
return 0;
}

Expand Down Expand Up @@ -49,14 +48,14 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno)
static void hpfs_truncate(struct inode *i)
{
if (IS_IMMUTABLE(i)) return /*-EPERM*/;
lock_kernel();
hpfs_lock(i->i_sb);
hpfs_i(i)->i_n_secs = 0;
i->i_blocks = 1 + ((i->i_size + 511) >> 9);
hpfs_i(i)->mmu_private = i->i_size;
hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
hpfs_write_inode(i);
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)
Expand Down
22 changes: 22 additions & 0 deletions fs/hpfs/hpfs_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,25 @@ static inline time32_t gmt_to_local(struct super_block *s, time_t t)
extern struct timezone sys_tz;
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)
{
}
9 changes: 4 additions & 5 deletions fs/hpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* inode VFS functions
*/

#include <linux/smp_lock.h>
#include <linux/slab.h>
#include "hpfs_fn.h"

Expand Down Expand Up @@ -267,7 +266,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
struct inode *inode = dentry->d_inode;
int error = -EINVAL;

lock_kernel();
hpfs_lock(inode->i_sb);
if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
goto out_unlock;
if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
Expand All @@ -290,7 +289,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
hpfs_write_inode(inode);

out_unlock:
unlock_kernel();
hpfs_unlock(inode->i_sb);
return error;
}

Expand All @@ -307,8 +306,8 @@ void hpfs_evict_inode(struct inode *inode)
truncate_inode_pages(&inode->i_data, 0);
end_writeback(inode);
if (!inode->i_nlink) {
lock_kernel();
hpfs_lock(inode->i_sb);
hpfs_remove_fnode(inode->i_sb, inode->i_ino);
unlock_kernel();
hpfs_unlock(inode->i_sb);
}
}
Loading

0 comments on commit 9a311b9

Please sign in to comment.