Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
07a9abc8
Commit
07a9abc8
authored
Apr 02, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Apr 02, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] minixfs cleanups (4/4)
Clean up minix/bitmap.c
parent
ae99fb7c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
72 deletions
+41
-72
fs/minix/bitmap.c
fs/minix/bitmap.c
+36
-57
fs/minix/inode.c
fs/minix/inode.c
+3
-13
fs/minix/minix.h
fs/minix/minix.h
+2
-2
No files found.
fs/minix/bitmap.c
View file @
07a9abc8
...
...
@@ -12,9 +12,7 @@
/* bitmap.c contains the code that handles the inode and block bitmaps */
#include "minix.h"
#include <linux/locks.h>
#include <linux/smp_lock.h>
#include <asm/bitops.h>
static
int
nibblemap
[]
=
{
4
,
3
,
3
,
2
,
3
,
2
,
2
,
1
,
3
,
2
,
2
,
1
,
2
,
1
,
1
,
0
};
...
...
@@ -56,12 +54,7 @@ void minix_free_block(struct inode * inode, int block)
struct
buffer_head
*
bh
;
unsigned
int
bit
,
zone
;
if
(
!
sb
)
{
printk
(
"trying to free block on nonexistent device
\n
"
);
return
;
}
if
(
block
<
sbi
->
s_firstdatazone
||
block
>=
sbi
->
s_nzones
)
{
if
(
block
<
sbi
->
s_firstdatazone
||
block
>=
sbi
->
s_nzones
)
{
printk
(
"trying to free block not in datazone
\n
"
);
return
;
}
...
...
@@ -84,44 +77,30 @@ void minix_free_block(struct inode * inode, int block)
int
minix_new_block
(
struct
inode
*
inode
)
{
struct
super_block
*
sb
=
inode
->
i_sb
;
struct
minix_sb_info
*
sbi
=
minix_sb
(
sb
);
struct
buffer_head
*
bh
;
int
i
,
j
;
struct
minix_sb_info
*
sbi
=
minix_sb
(
inode
->
i_sb
);
int
i
;
if
(
!
sb
)
{
printk
(
"trying to get new block from nonexistent device
\n
"
);
return
0
;
}
lock_kernel
();
repeat:
j
=
8192
;
bh
=
NULL
;
for
(
i
=
0
;
i
<
sbi
->
s_zmap_blocks
;
i
++
)
{
bh
=
sbi
->
s_zmap
[
i
];
if
((
j
=
minix_find_first_zero_bit
(
bh
->
b_data
,
8192
))
<
8192
)
struct
buffer_head
*
bh
=
sbi
->
s_zmap
[
i
];
int
j
;
lock_kernel
();
if
((
j
=
minix_find_first_zero_bit
(
bh
->
b_data
,
8192
))
<
8192
)
{
minix_set_bit
(
j
,
bh
->
b_data
);
unlock_kernel
();
mark_buffer_dirty
(
bh
);
j
+=
i
*
8192
+
sbi
->
s_firstdatazone
-
1
;
if
(
j
<
sbi
->
s_firstdatazone
||
j
>=
sbi
->
s_nzones
)
break
;
return
j
;
}
if
(
!
bh
||
j
>=
8192
)
{
unlock_kernel
();
return
0
;
}
if
(
minix_test_and_set_bit
(
j
,
bh
->
b_data
))
{
printk
(
"new_block: bit already set"
);
goto
repeat
;
}
unlock_kernel
();
mark_buffer_dirty
(
bh
);
j
+=
i
*
8192
+
sbi
->
s_firstdatazone
-
1
;
if
(
j
<
sbi
->
s_firstdatazone
||
j
>=
sbi
->
s_nzones
)
return
0
;
return
j
;
}
unsigned
long
minix_count_free_blocks
(
struct
super_block
*
sb
)
unsigned
long
minix_count_free_blocks
(
struct
minix_sb_info
*
sbi
)
{
struct
minix_sb_info
*
sbi
=
minix_sb
(
sb
);
return
(
count_free
(
sbi
->
s_zmap
,
sbi
->
s_zmap_blocks
,
sbi
->
s_nzones
-
sbi
->
s_firstdatazone
+
1
)
<<
sbi
->
s_log_zone_size
);
...
...
@@ -204,36 +183,38 @@ static void minix_clear_inode(struct inode *inode)
void
minix_free_inode
(
struct
inode
*
inode
)
{
struct
minix_sb_info
*
sbi
=
minix_sb
(
inode
->
i_sb
);
struct
buffer_head
*
bh
;
unsigned
long
ino
;
if
(
inode
->
i_ino
<
1
||
inode
->
i_ino
>
minix_sb
(
inode
->
i_sb
)
->
s_ninodes
)
{
if
(
inode
->
i_ino
<
1
||
inode
->
i_ino
>
sbi
->
s_ninodes
)
{
printk
(
"free_inode: inode 0 or nonexistent inode
\n
"
);
return
;
}
ino
=
inode
->
i_ino
;
if
((
ino
>>
13
)
>=
minix_sb
(
inode
->
i_sb
)
->
s_imap_blocks
)
{
if
((
ino
>>
13
)
>=
sbi
->
s_imap_blocks
)
{
printk
(
"free_inode: nonexistent imap in superblock
\n
"
);
return
;
}
bh
=
minix_sb
(
inode
->
i_sb
)
->
s_imap
[
ino
>>
13
];
bh
=
sbi
->
s_imap
[
ino
>>
13
];
minix_clear_inode
(
inode
);
clear_inode
(
inode
);
lock_kernel
();
if
(
!
minix_test_and_clear_bit
(
ino
&
8191
,
bh
->
b_data
))
printk
(
"free_inode: bit %lu already cleared.
\n
"
,
ino
);
unlock_kernel
();
mark_buffer_dirty
(
bh
);
}
struct
inode
*
minix_new_inode
(
const
struct
inode
*
dir
,
int
*
error
)
{
struct
super_block
*
sb
;
struct
inode
*
inode
;
struct
super_block
*
sb
=
dir
->
i_sb
;
struct
minix_sb_info
*
sbi
=
minix_sb
(
sb
);
struct
inode
*
inode
=
new_inode
(
sb
);
struct
buffer_head
*
bh
;
int
i
,
j
;
sb
=
dir
->
i_sb
;
inode
=
new_inode
(
sb
);
if
(
!
inode
)
{
*
error
=
-
ENOMEM
;
return
NULL
;
...
...
@@ -241,28 +222,28 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)
j
=
8192
;
bh
=
NULL
;
*
error
=
-
ENOSPC
;
lock_
super
(
sb
);
for
(
i
=
0
;
i
<
minix_sb
(
sb
)
->
s_imap_blocks
;
i
++
)
{
bh
=
minix_sb
(
inode
->
i_sb
)
->
s_imap
[
i
];
lock_
kernel
(
);
for
(
i
=
0
;
i
<
sbi
->
s_imap_blocks
;
i
++
)
{
bh
=
sbi
->
s_imap
[
i
];
if
((
j
=
minix_find_first_zero_bit
(
bh
->
b_data
,
8192
))
<
8192
)
break
;
}
if
(
!
bh
||
j
>=
8192
)
{
unlock_kernel
();
iput
(
inode
);
unlock_super
(
sb
);
return
NULL
;
}
if
(
minix_test_and_set_bit
(
j
,
bh
->
b_data
))
{
/* shouldn't happen */
printk
(
"new_inode: bit already set"
);
unlock_kernel
();
iput
(
inode
);
unlock_super
(
sb
);
return
NULL
;
}
unlock_kernel
();
mark_buffer_dirty
(
bh
);
j
+=
i
*
8192
;
if
(
!
j
||
j
>
minix_sb
(
inode
->
i_sb
)
->
s_ninodes
)
{
if
(
!
j
||
j
>
sbi
->
s_ninodes
)
{
iput
(
inode
);
unlock_super
(
sb
);
return
NULL
;
}
inode
->
i_uid
=
current
->
fsuid
;
...
...
@@ -274,13 +255,11 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)
insert_inode_hash
(
inode
);
mark_inode_dirty
(
inode
);
unlock_super
(
sb
);
*
error
=
0
;
return
inode
;
}
unsigned
long
minix_count_free_inodes
(
struct
super_block
*
sb
)
unsigned
long
minix_count_free_inodes
(
struct
minix_sb_info
*
sbi
)
{
return
count_free
(
minix_sb
(
sb
)
->
s_imap
,
minix_sb
(
sb
)
->
s_imap_blocks
,
minix_sb
(
sb
)
->
s_ninodes
+
1
);
return
count_free
(
sbi
->
s_imap
,
sbi
->
s_imap_blocks
,
sbi
->
s_ninodes
+
1
);
}
fs/minix/inode.c
View file @
07a9abc8
...
...
@@ -10,14 +10,11 @@
*/
#include <linux/module.h>
#include "minix.h"
#include <linux/slab.h>
#include <linux/locks.h>
#include <linux/init.h>
#include <linux/smp_lock.h>
#include <linux/highuid.h>
#include <linux/blkdev.h>
static
void
minix_read_inode
(
struct
inode
*
inode
);
static
void
minix_write_inode
(
struct
inode
*
inode
,
int
wait
);
...
...
@@ -28,9 +25,7 @@ static void minix_delete_inode(struct inode *inode)
{
inode
->
i_size
=
0
;
minix_truncate
(
inode
);
lock_kernel
();
minix_free_inode
(
inode
);
unlock_kernel
();
}
static
void
minix_put_super
(
struct
super_block
*
sb
)
...
...
@@ -304,10 +299,10 @@ static int minix_statfs(struct super_block *sb, struct statfs *buf)
buf
->
f_type
=
sb
->
s_magic
;
buf
->
f_bsize
=
sb
->
s_blocksize
;
buf
->
f_blocks
=
(
sbi
->
s_nzones
-
sbi
->
s_firstdatazone
)
<<
sbi
->
s_log_zone_size
;
buf
->
f_bfree
=
minix_count_free_blocks
(
sb
);
buf
->
f_bfree
=
minix_count_free_blocks
(
sb
i
);
buf
->
f_bavail
=
buf
->
f_bfree
;
buf
->
f_files
=
sbi
->
s_ninodes
;
buf
->
f_ffree
=
minix_count_free_inodes
(
sb
);
buf
->
f_ffree
=
minix_count_free_inodes
(
sb
i
);
buf
->
f_namelen
=
sbi
->
s_namelen
;
return
0
;
}
...
...
@@ -498,12 +493,7 @@ static struct buffer_head *minix_update_inode(struct inode *inode)
static
void
minix_write_inode
(
struct
inode
*
inode
,
int
wait
)
{
struct
buffer_head
*
bh
;
lock_kernel
();
bh
=
minix_update_inode
(
inode
);
unlock_kernel
();
brelse
(
bh
);
brelse
(
minix_update_inode
(
inode
));
}
int
minix_sync_inode
(
struct
inode
*
inode
)
...
...
fs/minix/minix.h
View file @
07a9abc8
...
...
@@ -50,10 +50,10 @@ extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, stru
extern
struct
minix2_inode
*
minix_V2_raw_inode
(
struct
super_block
*
,
ino_t
,
struct
buffer_head
**
);
extern
struct
inode
*
minix_new_inode
(
const
struct
inode
*
dir
,
int
*
error
);
extern
void
minix_free_inode
(
struct
inode
*
inode
);
extern
unsigned
long
minix_count_free_inodes
(
struct
super_block
*
sb
);
extern
unsigned
long
minix_count_free_inodes
(
struct
minix_sb_info
*
sbi
);
extern
int
minix_new_block
(
struct
inode
*
inode
);
extern
void
minix_free_block
(
struct
inode
*
inode
,
int
block
);
extern
unsigned
long
minix_count_free_blocks
(
struct
super_block
*
sb
);
extern
unsigned
long
minix_count_free_blocks
(
struct
minix_sb_info
*
sbi
);
extern
void
V1_minix_truncate
(
struct
inode
*
);
extern
void
V2_minix_truncate
(
struct
inode
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment