Commit fc4ed3fb authored by Junxiao Bi's avatar Junxiao Bi Committed by Kelsey Skunberg

ocfs2: change slot number type s16 to u16

BugLink: https://bugs.launchpad.net/bugs/1892822

commit 38d51b2d upstream.

Dan Carpenter reported the following static checker warning.

	fs/ocfs2/super.c:1269 ocfs2_parse_options() warn: '(-1)' 65535 can't fit into 32767 'mopt->slot'
	fs/ocfs2/suballoc.c:859 ocfs2_init_inode_steal_slot() warn: '(-1)' 65535 can't fit into 32767 'osb->s_inode_steal_slot'
	fs/ocfs2/suballoc.c:867 ocfs2_init_meta_steal_slot() warn: '(-1)' 65535 can't fit into 32767 'osb->s_meta_steal_slot'

That's because OCFS2_INVALID_SLOT is (u16)-1. Slot number in ocfs2 can be
never negative, so change s16 to u16.

Fixes: 9277f833 ("ocfs2: fix value of OCFS2_INVALID_SLOT")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: default avatarGang He <ghe@suse.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/20200627001259.19757-1-junxiao.bi@oracle.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent f1a6a038
...@@ -337,8 +337,8 @@ struct ocfs2_super ...@@ -337,8 +337,8 @@ struct ocfs2_super
spinlock_t osb_lock; spinlock_t osb_lock;
u32 s_next_generation; u32 s_next_generation;
unsigned long osb_flags; unsigned long osb_flags;
s16 s_inode_steal_slot; u16 s_inode_steal_slot;
s16 s_meta_steal_slot; u16 s_meta_steal_slot;
atomic_t s_num_inodes_stolen; atomic_t s_num_inodes_stolen;
atomic_t s_num_meta_stolen; atomic_t s_num_meta_stolen;
......
...@@ -895,9 +895,9 @@ static void __ocfs2_set_steal_slot(struct ocfs2_super *osb, int slot, int type) ...@@ -895,9 +895,9 @@ static void __ocfs2_set_steal_slot(struct ocfs2_super *osb, int slot, int type)
{ {
spin_lock(&osb->osb_lock); spin_lock(&osb->osb_lock);
if (type == INODE_ALLOC_SYSTEM_INODE) if (type == INODE_ALLOC_SYSTEM_INODE)
osb->s_inode_steal_slot = slot; osb->s_inode_steal_slot = (u16)slot;
else if (type == EXTENT_ALLOC_SYSTEM_INODE) else if (type == EXTENT_ALLOC_SYSTEM_INODE)
osb->s_meta_steal_slot = slot; osb->s_meta_steal_slot = (u16)slot;
spin_unlock(&osb->osb_lock); spin_unlock(&osb->osb_lock);
} }
......
...@@ -96,7 +96,7 @@ struct mount_options ...@@ -96,7 +96,7 @@ struct mount_options
unsigned long commit_interval; unsigned long commit_interval;
unsigned long mount_opt; unsigned long mount_opt;
unsigned int atime_quantum; unsigned int atime_quantum;
signed short slot; unsigned short slot;
int localalloc_opt; int localalloc_opt;
unsigned int resv_level; unsigned int resv_level;
int dir_resv_level; int dir_resv_level;
...@@ -1372,7 +1372,7 @@ static int ocfs2_parse_options(struct super_block *sb, ...@@ -1372,7 +1372,7 @@ static int ocfs2_parse_options(struct super_block *sb,
goto bail; goto bail;
} }
if (option) if (option)
mopt->slot = (s16)option; mopt->slot = (u16)option;
break; break;
case Opt_commit: case Opt_commit:
option = 0; option = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment