Skip to contentSkip to conversation

Fix cast from unsigned int to s64

PATCH New Andrew Price 2 participants 2 messages May 1, 2008 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix cast from unsigned int to s64

This fixes bz 444829 where allocating a new block caused gfs2 file systems to report 0 bytes used in df. It was caused by a broken cast from an unsigned int in gfs2_block_alloc() to a negative s64 in gfs2_statfs_change(). This patch casts the unsigned int to an s64 before the unary minus is applied.

---
 fs/gfs2/rgrp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/gfs2/rgrp.c +1 -1
index 7e8f0b1..6387523 100644
@@ -1495,7 +1495,7 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n)
 
 	al->al_alloced += *n;
 
-	gfs2_statfs_change(sdp, 0, -*n, 0);
+	gfs2_statfs_change(sdp, 0, -(s64)*n, 0);
 	gfs2_quota_change(ip, *n, ip->i_inode.i_uid, ip->i_inode.i_gid);
 
 	spin_lock(&sdp->sd_rindex_spin);
Signature · 1 line
1.5.5
#1 lore raw

PATCH 1/1 Fix cast from unsigned int to s64

Hi,

Now in the GFS2 -nme git tree. Thanks,

Steve.

Quoted 23 lines · Andrew Price

This fixes bz 444829 where allocating a new block caused gfs2 file systems to report 0 bytes used in df. It was caused by a broken cast from an unsigned int in gfs2_block_alloc() to a negative s64 in gfs2_statfs_change(). This patch casts the unsigned int to an s64 before the unary minus is applied.

---
 fs/gfs2/rgrp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/gfs2/rgrp.c +1 -1
index 7e8f0b1..6387523 100644
@@ -1495,7 +1495,7 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n)
 
 	al->al_alloced += *n;
 
-	gfs2_statfs_change(sdp, 0, -*n, 0);
+	gfs2_statfs_change(sdp, 0, -(s64)*n, 0);
 	gfs2_quota_change(ip, *n, ip->i_inode.i_uid, ip->i_inode.i_gid);
 
 	spin_lock(&sdp->sd_rindex_spin);