Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jan.koester
Linux
Commits
f1fd306a
Commit
f1fd306a
authored
13 years ago
by
Al Viro
Browse files
Options
Downloads
Patches
Plain Diff
minixfs: kill manual hweight(), simplify
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
016e8d44
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fs/minix/bitmap.c
+14
-27
14 additions, 27 deletions
fs/minix/bitmap.c
fs/minix/minix.h
+1
-1
1 addition, 1 deletion
fs/minix/minix.h
with
15 additions
and
28 deletions
fs/minix/bitmap.c
+
14
−
27
View file @
f1fd306a
...
...
@@ -16,39 +16,26 @@
#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
blocksize
,
__u32
numbits
)
/*
* bitmap consists of blocks filled with 16bit words
* bit set == busy, bit clear == free
* endianness is a mess, but for counting zero bits it really doesn't matter...
*/
static
__u32
count_free
(
struct
buffer_head
*
map
[],
unsigned
blocksize
,
__u32
numbits
)
{
unsigned
i
,
j
,
sum
=
0
;
struct
buffer_head
*
bh
;
unsigned
numblocks
=
minix_blocks_needed
(
numbits
,
blocksize
);
for
(
i
=
0
;
i
<
numblocks
-
1
;
i
++
)
{
if
(
!
(
bh
=
map
[
i
]))
return
(
0
);
for
(
j
=
0
;
j
<
bh
->
b_size
;
j
++
)
sum
+=
nibblemap
[
bh
->
b_data
[
j
]
&
0xf
]
+
nibblemap
[(
bh
->
b_data
[
j
]
>>
4
)
&
0xf
];
}
__u32
sum
=
0
;
unsigned
blocks
=
DIV_ROUND_UP
(
numbits
,
blocksize
*
8
);
if
(
numblocks
==
0
||
!
(
bh
=
map
[
numblocks
-
1
]))
return
(
0
);
i
=
((
numbits
-
(
numblocks
-
1
)
*
bh
->
b_size
*
8
)
/
16
)
*
2
;
for
(
j
=
0
;
j
<
i
;
j
++
)
{
sum
+=
nibblemap
[
bh
->
b_data
[
j
]
&
0xf
]
+
nibblemap
[(
bh
->
b_data
[
j
]
>>
4
)
&
0xf
];
while
(
blocks
--
)
{
unsigned
words
=
blocksize
/
2
;
__u16
*
p
=
(
__u16
*
)(
*
map
++
)
->
b_data
;
while
(
words
--
)
sum
+=
16
-
hweight16
(
*
p
++
);
}
i
=
numbits
%
16
;
if
(
i
!=
0
)
{
i
=
*
(
__u16
*
)(
&
bh
->
b_data
[
j
])
|
~
((
1
<<
i
)
-
1
);
sum
+=
nibblemap
[
i
&
0xf
]
+
nibblemap
[(
i
>>
4
)
&
0xf
];
sum
+=
nibblemap
[(
i
>>
8
)
&
0xf
]
+
nibblemap
[(
i
>>
12
)
&
0xf
];
}
return
(
sum
);
return
sum
;
}
void
minix_free_block
(
struct
inode
*
inode
,
unsigned
long
block
)
...
...
This diff is collapsed.
Click to expand it.
fs/minix/minix.h
+
1
−
1
View file @
f1fd306a
...
...
@@ -130,7 +130,7 @@ static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
if
(
!
size
)
return
0
;
size
=
(
size
>>
4
)
+
((
size
&
15
)
>
0
)
;
size
>>
=
4
;
while
(
*
p
++
==
0xffff
)
{
if
(
--
size
==
0
)
return
(
p
-
addr
)
<<
4
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment