diff options
author | Andrew Stribblehill <a.d.stribblehill@durham.ac.uk> | 2005-09-09 16:02:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 16:57:32 -0400 |
commit | fac92becdaecff64dd91daab0292c5131de92f0d (patch) | |
tree | 6c91bdbbe527682813d7c27ed13bdb0531298146 /fs/bfs/file.c | |
parent | 383f2835eb9afb723af71850037b2f074ac9db60 (diff) |
[PATCH] bfs: fix endianness, signedness; add trivial bugfix
* Makes BFS code endianness-clean.
* Fixes some signedness warnings.
* Fixes a problem in fs/bfs/inode.c:164 where inodes not synced to disk
don't get fully marked as clean. Here's how to reproduce it:
# mount -o loop -t bfs /bfs.img /mnt
# df -i /mnt
Filesystem Inodes IUsed IFree IUse% Mounted on
/bfs.img 48 1 47 3% /mnt
# df -k /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/bfs.img 512 5 508 1% /mnt
# cp 60k-archive.zip /mnt/mt.zip
# df -k /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/bfs.img 512 65 447 13% /mnt
# df -i /mnt
Filesystem Inodes IUsed IFree IUse% Mounted on
/bfs.img 48 2 46 5% /mnt
# rm /mnt/mt.zip
# echo $?
0
[If the unlink happens before the buffers flush, the following happens:]
# df -i /mnt
Filesystem Inodes IUsed IFree IUse% Mounted on
/bfs.img 48 2 46 5% /mnt
# df -k /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/bfs.img 512 65 447 13% /mnt
fs/bfs/bfs.h | 1
Signed-off-by: Andrew Stribblehill <ads@wompom.org>
Cc: <tigran@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/bfs/file.c')
-rw-r--r-- | fs/bfs/file.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 747fd1ea55e0..807723b65daf 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c | |||
@@ -40,8 +40,8 @@ static int bfs_move_block(unsigned long from, unsigned long to, struct super_blo | |||
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned long end, | 43 | static int bfs_move_blocks(struct super_block *sb, unsigned long start, |
44 | unsigned long where) | 44 | unsigned long end, unsigned long where) |
45 | { | 45 | { |
46 | unsigned long i; | 46 | unsigned long i; |
47 | 47 | ||
@@ -57,20 +57,21 @@ static int bfs_move_blocks(struct super_block *sb, unsigned long start, unsigned | |||
57 | static int bfs_get_block(struct inode * inode, sector_t block, | 57 | static int bfs_get_block(struct inode * inode, sector_t block, |
58 | struct buffer_head * bh_result, int create) | 58 | struct buffer_head * bh_result, int create) |
59 | { | 59 | { |
60 | long phys; | 60 | unsigned long phys; |
61 | int err; | 61 | int err; |
62 | struct super_block *sb = inode->i_sb; | 62 | struct super_block *sb = inode->i_sb; |
63 | struct bfs_sb_info *info = BFS_SB(sb); | 63 | struct bfs_sb_info *info = BFS_SB(sb); |
64 | struct bfs_inode_info *bi = BFS_I(inode); | 64 | struct bfs_inode_info *bi = BFS_I(inode); |
65 | struct buffer_head *sbh = info->si_sbh; | 65 | struct buffer_head *sbh = info->si_sbh; |
66 | 66 | ||
67 | if (block < 0 || block > info->si_blocks) | 67 | if (block > info->si_blocks) |
68 | return -EIO; | 68 | return -EIO; |
69 | 69 | ||
70 | phys = bi->i_sblock + block; | 70 | phys = bi->i_sblock + block; |
71 | if (!create) { | 71 | if (!create) { |
72 | if (phys <= bi->i_eblock) { | 72 | if (phys <= bi->i_eblock) { |
73 | dprintf("c=%d, b=%08lx, phys=%08lx (granted)\n", create, block, phys); | 73 | dprintf("c=%d, b=%08lx, phys=%09lx (granted)\n", |
74 | create, (unsigned long)block, phys); | ||
74 | map_bh(bh_result, sb, phys); | 75 | map_bh(bh_result, sb, phys); |
75 | } | 76 | } |
76 | return 0; | 77 | return 0; |
@@ -80,7 +81,7 @@ static int bfs_get_block(struct inode * inode, sector_t block, | |||
80 | of blocks allocated for this file, we can grant it */ | 81 | of blocks allocated for this file, we can grant it */ |
81 | if (inode->i_size && phys <= bi->i_eblock) { | 82 | if (inode->i_size && phys <= bi->i_eblock) { |
82 | dprintf("c=%d, b=%08lx, phys=%08lx (interim block granted)\n", | 83 | dprintf("c=%d, b=%08lx, phys=%08lx (interim block granted)\n", |
83 | create, block, phys); | 84 | create, (unsigned long)block, phys); |
84 | map_bh(bh_result, sb, phys); | 85 | map_bh(bh_result, sb, phys); |
85 | return 0; | 86 | return 0; |
86 | } | 87 | } |
@@ -88,11 +89,12 @@ static int bfs_get_block(struct inode * inode, sector_t block, | |||
88 | /* the rest has to be protected against itself */ | 89 | /* the rest has to be protected against itself */ |
89 | lock_kernel(); | 90 | lock_kernel(); |
90 | 91 | ||
91 | /* if the last data block for this file is the last allocated block, we can | 92 | /* if the last data block for this file is the last allocated |
92 | extend the file trivially, without moving it anywhere */ | 93 | block, we can extend the file trivially, without moving it |
94 | anywhere */ | ||
93 | if (bi->i_eblock == info->si_lf_eblk) { | 95 | if (bi->i_eblock == info->si_lf_eblk) { |
94 | dprintf("c=%d, b=%08lx, phys=%08lx (simple extension)\n", | 96 | dprintf("c=%d, b=%08lx, phys=%08lx (simple extension)\n", |
95 | create, block, phys); | 97 | create, (unsigned long)block, phys); |
96 | map_bh(bh_result, sb, phys); | 98 | map_bh(bh_result, sb, phys); |
97 | info->si_freeb -= phys - bi->i_eblock; | 99 | info->si_freeb -= phys - bi->i_eblock; |
98 | info->si_lf_eblk = bi->i_eblock = phys; | 100 | info->si_lf_eblk = bi->i_eblock = phys; |
@@ -114,7 +116,8 @@ static int bfs_get_block(struct inode * inode, sector_t block, | |||
114 | } else | 116 | } else |
115 | err = 0; | 117 | err = 0; |
116 | 118 | ||
117 | dprintf("c=%d, b=%08lx, phys=%08lx (moved)\n", create, block, phys); | 119 | dprintf("c=%d, b=%08lx, phys=%08lx (moved)\n", |
120 | create, (unsigned long)block, phys); | ||
118 | bi->i_sblock = phys; | 121 | bi->i_sblock = phys; |
119 | phys += block; | 122 | phys += block; |
120 | info->si_lf_eblk = bi->i_eblock = phys; | 123 | info->si_lf_eblk = bi->i_eblock = phys; |