Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a311b96 authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

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: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: linux-fsdevel@vger.kernel.org
parent 5edc3413
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
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
+11 −12
Original line number Diff line number Diff line
@@ -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;
}

@@ -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;
@@ -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;
}

@@ -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")) {
@@ -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;
}

@@ -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;
@@ -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;

@@ -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);
}

+4 −5
Original line number Diff line number Diff line
@@ -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;
}

@@ -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)
+22 −0
Original line number Diff line number Diff line
@@ -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)
{
}
+4 −5
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
 *  inode VFS functions
 */

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

@@ -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)
@@ -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;
}

@@ -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