xfs
[Top] [All Lists]

[PATCH] xfs: Make the incore inode di_size to xfs_ufsize_t

To: "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfs: Make the incore inode di_size to xfs_ufsize_t
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Wed, 04 Sep 2013 10:41:56 +0800
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1
From: Jie Liu <jeff.liu@xxxxxxxxxx>

Make the incore inode di_size to unsigned, this would be helpful
to catch the negative sizes of it in many cases, so that we don't
need to perform additional check for it being less than ZERO or not.

Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
---
 fs/xfs/xfs_inode_fork.c |    3 +--
 fs/xfs/xfs_log_format.h |    2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_inode_fork.c b/fs/xfs/xfs_inode_fork.c
index 02f1083..2b60a5a 100644
--- a/fs/xfs/xfs_inode_fork.c
+++ b/fs/xfs/xfs_inode_fork.c
@@ -167,8 +167,7 @@ xfs_iformat_fork(
                        }
 
                        di_size = be64_to_cpu(dip->di_size);
-                       if (unlikely(di_size < 0 ||
-                                    di_size > XFS_DFORK_DSIZE(dip, 
ip->i_mount))) {
+                       if (unlikely(di_size > XFS_DFORK_DSIZE(dip, 
ip->i_mount))) {
                                xfs_warn(ip->i_mount,
                        "corrupt inode %Lu (bad size %Ld for local inode).",
                                        (unsigned long long) ip->i_ino,
diff --git a/fs/xfs/xfs_log_format.h b/fs/xfs/xfs_log_format.h
index a49ab2c..2795fc5 100644
--- a/fs/xfs/xfs_log_format.h
+++ b/fs/xfs/xfs_log_format.h
@@ -547,7 +547,7 @@ typedef struct xfs_icdinode {
        xfs_ictimestamp_t di_atime;     /* time last accessed */
        xfs_ictimestamp_t di_mtime;     /* time last modified */
        xfs_ictimestamp_t di_ctime;     /* time created/inode modified */
-       xfs_fsize_t     di_size;        /* number of bytes in file */
+       xfs_ufsize_t    di_size;        /* number of bytes in file */
        xfs_drfsbno_t   di_nblocks;     /* # of direct & btree blocks used */
        xfs_extlen_t    di_extsize;     /* basic/minimum extent size for file */
        xfs_extnum_t    di_nextents;    /* number of extents in data fork */
-- 
1.7.9.5

<Prev in Thread] Current Thread [Next in Thread>