From: David van Moolenbroek Date: Thu, 2 Aug 2012 13:03:23 +0000 (+0000) Subject: MFS: fix block estimation computation X-Git-Tag: v3.2.1~415 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=2d2008888183c9c04b351df4b24cf1ffc14b522d;p=minix.git MFS: fix block estimation computation --- diff --git a/servers/mfs/stadir.c b/servers/mfs/stadir.c index 5fc84ded0..0c1dfe0fd 100644 --- a/servers/mfs/stadir.c +++ b/servers/mfs/stadir.c @@ -18,25 +18,25 @@ static blkcnt_t estimate_blocks(struct inode *rip) * indirect blocks is too costly for a stat call, so we disregard holes and * return a conservative estimation. */ - unsigned int zone_size, zones; - blkcnt_t sindirs, dindirs, nr_indirs, sq_indirs; + blkcnt_t zones, sindirs, dindirs, nr_indirs, sq_indirs; + unsigned int zone_size; /* Compute the number of zones used by the file. */ zone_size = rip->i_sp->s_block_size << rip->i_sp->s_log_zone_size; - zones = (rip->i_size + zone_size - 1) / zone_size; + zones = (blkcnt_t) ((rip->i_size + zone_size - 1) / zone_size); /* Compute the number of indirect blocks needed for that zone count. */ nr_indirs = (blkcnt_t) rip->i_nindirs; sq_indirs = nr_indirs * nr_indirs; - sindirs = (blkcnt_t) (zones - rip->i_ndzones + nr_indirs - 1) / nr_indirs; - dindirs = (blkcnt_t) (sindirs - 1 + sq_indirs - 1) / sq_indirs; + sindirs = (zones - (blkcnt_t) rip->i_ndzones + nr_indirs - 1) / nr_indirs; + dindirs = (sindirs - 1 + sq_indirs - 1) / sq_indirs; /* Return the number of 512-byte blocks corresponding to the number of data * zones and indirect blocks. */ - return((blkcnt_t) (zones + sindirs + dindirs) * (zone_size / 512)); + return (zones + sindirs + dindirs) * (blkcnt_t) (zone_size / 512); } /*===========================================================================*