diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2008-10-08 23:12:24 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-10-08 23:12:24 -0400 |
commit | 5c79161689aede2d487d707d5931a22eadf66120 (patch) | |
tree | 994177ca7118a515d23f0375ab080c216159d9c8 | |
parent | 79f0be8d2e6ebde27dfb3beff18eb689d5c4e36c (diff) |
ext4: Signed arithmetic fix
This patch converts some usage of ext4_fsblk_t to s64. This is needed
so that some of the sign conversion works as expected in if loops.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | fs/ext4/balloc.c | 19 | ||||
-rw-r--r-- | fs/ext4/ext4.h | 5 |
2 files changed, 12 insertions, 12 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index edef0023e6e6..a425e78c73eb 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -1603,10 +1603,10 @@ out: | |||
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | int ext4_claim_free_blocks(struct ext4_sb_info *sbi, | 1605 | int ext4_claim_free_blocks(struct ext4_sb_info *sbi, |
1606 | ext4_fsblk_t nblocks) | 1606 | s64 nblocks) |
1607 | { | 1607 | { |
1608 | s64 free_blocks, dirty_blocks; | 1608 | s64 free_blocks, dirty_blocks; |
1609 | ext4_fsblk_t root_blocks = 0; | 1609 | s64 root_blocks = 0; |
1610 | struct percpu_counter *fbc = &sbi->s_freeblocks_counter; | 1610 | struct percpu_counter *fbc = &sbi->s_freeblocks_counter; |
1611 | struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter; | 1611 | struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter; |
1612 | 1612 | ||
@@ -1631,7 +1631,7 @@ int ext4_claim_free_blocks(struct ext4_sb_info *sbi, | |||
1631 | /* Check whether we have space after | 1631 | /* Check whether we have space after |
1632 | * accounting for current dirty blocks | 1632 | * accounting for current dirty blocks |
1633 | */ | 1633 | */ |
1634 | if (free_blocks < ((s64)(root_blocks + nblocks) + dirty_blocks)) | 1634 | if (free_blocks < ((root_blocks + nblocks) + dirty_blocks)) |
1635 | /* we don't have free space */ | 1635 | /* we don't have free space */ |
1636 | return -ENOSPC; | 1636 | return -ENOSPC; |
1637 | 1637 | ||
@@ -1650,10 +1650,10 @@ int ext4_claim_free_blocks(struct ext4_sb_info *sbi, | |||
1650 | * On success, return nblocks | 1650 | * On success, return nblocks |
1651 | */ | 1651 | */ |
1652 | ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi, | 1652 | ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi, |
1653 | ext4_fsblk_t nblocks) | 1653 | s64 nblocks) |
1654 | { | 1654 | { |
1655 | ext4_fsblk_t free_blocks, dirty_blocks; | 1655 | s64 free_blocks, dirty_blocks; |
1656 | ext4_fsblk_t root_blocks = 0; | 1656 | s64 root_blocks = 0; |
1657 | struct percpu_counter *fbc = &sbi->s_freeblocks_counter; | 1657 | struct percpu_counter *fbc = &sbi->s_freeblocks_counter; |
1658 | struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter; | 1658 | struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter; |
1659 | 1659 | ||
@@ -1667,14 +1667,15 @@ ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi, | |||
1667 | 1667 | ||
1668 | if (free_blocks - (nblocks + root_blocks + dirty_blocks) < | 1668 | if (free_blocks - (nblocks + root_blocks + dirty_blocks) < |
1669 | EXT4_FREEBLOCKS_WATERMARK) { | 1669 | EXT4_FREEBLOCKS_WATERMARK) { |
1670 | free_blocks = percpu_counter_sum_positive(fbc); | 1670 | free_blocks = percpu_counter_sum(fbc); |
1671 | dirty_blocks = percpu_counter_sum_positive(dbc); | 1671 | dirty_blocks = percpu_counter_sum(dbc); |
1672 | } | 1672 | } |
1673 | if (free_blocks <= (root_blocks + dirty_blocks)) | 1673 | if (free_blocks <= (root_blocks + dirty_blocks)) |
1674 | /* we don't have free space */ | 1674 | /* we don't have free space */ |
1675 | return 0; | 1675 | return 0; |
1676 | |||
1676 | if (free_blocks - (root_blocks + dirty_blocks) < nblocks) | 1677 | if (free_blocks - (root_blocks + dirty_blocks) < nblocks) |
1677 | return free_blocks - root_blocks; | 1678 | return free_blocks - (root_blocks + dirty_blocks); |
1678 | return nblocks; | 1679 | return nblocks; |
1679 | } | 1680 | } |
1680 | 1681 | ||
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 0154c2d0b242..e13b9deee866 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -983,10 +983,9 @@ extern ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode, | |||
983 | unsigned long *count, int *errp); | 983 | unsigned long *count, int *errp); |
984 | extern ext4_fsblk_t ext4_old_new_blocks(handle_t *handle, struct inode *inode, | 984 | extern ext4_fsblk_t ext4_old_new_blocks(handle_t *handle, struct inode *inode, |
985 | ext4_fsblk_t goal, unsigned long *count, int *errp); | 985 | ext4_fsblk_t goal, unsigned long *count, int *errp); |
986 | extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, | 986 | extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks); |
987 | ext4_fsblk_t nblocks); | ||
988 | extern ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi, | 987 | extern ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi, |
989 | ext4_fsblk_t nblocks); | 988 | s64 nblocks); |
990 | extern void ext4_free_blocks(handle_t *handle, struct inode *inode, | 989 | extern void ext4_free_blocks(handle_t *handle, struct inode *inode, |
991 | ext4_fsblk_t block, unsigned long count, int metadata); | 990 | ext4_fsblk_t block, unsigned long count, int metadata); |
992 | extern void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb, | 991 | extern void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb, |