16 #include <linux/bitops.h>
17 #include <linux/sched.h>
26 static __u32 count_free(
struct buffer_head *
map[],
unsigned blocksize,
__u32 numbits)
32 unsigned words = blocksize / 2;
45 struct buffer_head *bh;
50 printk(
"Trying to free block not in datazone\n");
54 bit = zone & ((1<<
k) - 1);
57 printk(
"minix_free_block: nonexistent bitmap buffer\n");
61 spin_lock(&bitmap_lock);
63 printk(
"minix_free_block (%s:%lu): bit already cleared\n",
65 spin_unlock(&bitmap_lock);
73 int bits_per_zone = 8 * inode->
i_sb->s_blocksize;
77 struct buffer_head *bh = sbi->
s_zmap[
i];
80 spin_lock(&bitmap_lock);
82 if (j < bits_per_zone) {
84 spin_unlock(&bitmap_lock);
87 if (j < sbi->s_firstdatazone || j >= sbi->
s_nzones)
91 spin_unlock(&bitmap_lock);
113 printk(
"Bad inode number on dev %s: %ld is out of range\n",
114 sb->
s_id, (
long)ino);
120 *bh = sb_bread(sb, block);
122 printk(
"Unable to read inode block\n");
125 p = (
void *)(*bh)->b_data;
139 printk(
"Bad inode number on dev %s: %ld is out of range\n",
140 sb->
s_id, (
long)ino);
145 ino / minix2_inodes_per_block;
146 *bh = sb_bread(sb, block);
148 printk(
"Unable to read inode block\n");
151 p = (
void *)(*bh)->b_data;
152 return p + ino % minix2_inodes_per_block;
157 static void minix_clear_inode(
struct inode *
inode)
159 struct buffer_head *bh =
NULL;
186 struct buffer_head *bh;
192 printk(
"minix_free_inode: inode 0 or nonexistent inode\n");
195 bit = ino & ((1<<
k) - 1);
198 printk(
"minix_free_inode: nonexistent imap in superblock\n");
202 minix_clear_inode(inode);
205 spin_lock(&bitmap_lock);
207 printk(
"minix_free_inode: bit %lu already cleared\n", bit);
208 spin_unlock(&bitmap_lock);
217 struct buffer_head * bh;
229 spin_lock(&bitmap_lock);
233 if (j < bits_per_zone)
236 if (!bh || j >= bits_per_zone) {
237 spin_unlock(&bitmap_lock);
242 spin_unlock(&bitmap_lock);
243 printk(
"minix_new_inode: bit already set\n");
247 spin_unlock(&bitmap_lock);
249 j += i * bits_per_zone;
258 memset(&minix_i(inode)->
u, 0,
sizeof(minix_i(inode)->
u));
259 insert_inode_hash(inode);
260 mark_inode_dirty(inode);