ufs: fix truncated values handling 64 bit metadata
authorDan Carpenter <error27@gmail.com>
Thu, 26 May 2011 23:25:12 +0000 (16:25 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 27 May 2011 00:12:33 +0000 (17:12 -0700)
Originally i_lastfrag was 32 bits but then we added support for handling
64 bit metadata and it became a 64 bit variable.  That was during 2007, in
54fb996ac15c "[PATCH] ufs2 write: block allocation update".  Unfortunately
these casts got left behind so the value got truncated to 32 bit again.

[akpm@linux-foundation.org: remove now-unneeded min_t/max_t casting]
Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ufs/balloc.c
fs/ufs/truncate.c

index 46f7a807bbc1ec8313af3df1a4c08c2afb3498eb..42694e11c23de46b25f1177888b97ec2aac1cf32 100644 (file)
@@ -424,8 +424,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
                        ufs_cpu_to_data_ptr(sb, p, result);
                        *err = 0;
                        UFS_I(inode)->i_lastfrag =
-                               max_t(u32, UFS_I(inode)->i_lastfrag,
-                                     fragment + count);
+                               max(UFS_I(inode)->i_lastfrag, fragment + count);
                        ufs_clear_frags(inode, result + oldcount,
                                        newcount - oldcount, locked_page != NULL);
                }
@@ -440,7 +439,8 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
        result = ufs_add_fragments (inode, tmp, oldcount, newcount, err);
        if (result) {
                *err = 0;
-               UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
+               UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag,
+                                               fragment + count);
                ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
                                locked_page != NULL);
                unlock_super(sb);
@@ -479,7 +479,8 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
                                   uspi->s_sbbase + result, locked_page);
                ufs_cpu_to_data_ptr(sb, p, result);
                *err = 0;
-               UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
+               UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag,
+                                               fragment + count);
                unlock_super(sb);
                if (newcount < request)
                        ufs_free_fragments (inode, result + newcount, request - newcount);
index 5f821dbc057905c379df686dfbb2f2ff67609c9a..f04f89fbd4d9914b0a1a16f2cce8c8e0799e020e 100644 (file)
@@ -84,7 +84,7 @@ static int ufs_trunc_direct(struct inode *inode)
        retry = 0;
        
        frag1 = DIRECT_FRAGMENT;
-       frag4 = min_t(u32, UFS_NDIR_FRAGMENT, ufsi->i_lastfrag);
+       frag4 = min_t(u64, UFS_NDIR_FRAGMENT, ufsi->i_lastfrag);
        frag2 = ((frag1 & uspi->s_fpbmask) ? ((frag1 | uspi->s_fpbmask) + 1) : frag1);
        frag3 = frag4 & ~uspi->s_fpbmask;
        block1 = block2 = 0;