/* bitmap.c contains the code that handles the inode and block bitmaps */
#include "minix.h"
-#include <linux/smp_lock.h>
#include <linux/buffer_head.h>
#include <linux/bitops.h>
#include <linux/sched.h>
static const int nibblemap[] = { 4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0 };
+static DEFINE_SPINLOCK(bitmap_lock);
+
static unsigned long count_free(struct buffer_head *map[], unsigned numblocks, __u32 numbits)
{
unsigned i, j, sum = 0;
return;
}
bh = sbi->s_zmap[zone];
- lock_kernel();
+ spin_lock(&bitmap_lock);
if (!minix_test_and_clear_bit(bit, bh->b_data))
printk("minix_free_block (%s:%lu): bit already cleared\n",
sb->s_id, block);
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
mark_buffer_dirty(bh);
return;
}
struct buffer_head *bh = sbi->s_zmap[i];
int j;
- lock_kernel();
+ spin_lock(&bitmap_lock);
j = minix_find_first_zero_bit(bh->b_data, bits_per_zone);
if (j < bits_per_zone) {
minix_set_bit(j, bh->b_data);
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
mark_buffer_dirty(bh);
j += i * bits_per_zone + sbi->s_firstdatazone-1;
if (j < sbi->s_firstdatazone || j >= sbi->s_nzones)
break;
return j;
}
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
}
return 0;
}
minix_clear_inode(inode); /* clear on-disk copy */
bh = sbi->s_imap[ino];
- lock_kernel();
+ spin_lock(&bitmap_lock);
if (!minix_test_and_clear_bit(bit, bh->b_data))
printk("minix_free_inode: bit %lu already cleared\n", bit);
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
mark_buffer_dirty(bh);
out:
clear_inode(inode); /* clear in-memory copy */
j = bits_per_zone;
bh = NULL;
*error = -ENOSPC;
- lock_kernel();
+ spin_lock(&bitmap_lock);
for (i = 0; i < sbi->s_imap_blocks; i++) {
bh = sbi->s_imap[i];
j = minix_find_first_zero_bit(bh->b_data, bits_per_zone);
break;
}
if (!bh || j >= bits_per_zone) {
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
iput(inode);
return NULL;
}
if (minix_test_and_set_bit(j, bh->b_data)) { /* shouldn't happen */
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
printk("minix_new_inode: bit already set\n");
iput(inode);
return NULL;
}
- unlock_kernel();
+ spin_unlock(&bitmap_lock);
mark_buffer_dirty(bh);
j += i * bits_per_zone;
if (!j || j > sbi->s_ninodes) {
#include "minix.h"
#include <linux/buffer_head.h>
#include <linux/highmem.h>
-#include <linux/smp_lock.h>
#include <linux/swap.h>
typedef struct minix_dir_entry minix_dirent;
static int minix_readdir(struct file *, void *, filldir_t);
const struct file_operations minix_dir_operations = {
+ .llseek = generic_file_llseek,
.read = generic_read_dir,
.readdir = minix_readdir,
.fsync = simple_fsync,
char *name;
__u32 inumber;
- lock_kernel();
-
pos = (pos + chunk_size-1) & ~(chunk_size-1);
if (pos >= inode->i_size)
goto done;
done:
filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
- unlock_kernel();
return 0;
}