f2fs: fix a race condition in next_free_nid
authorHuang Ying <ying.huang@intel.com>
Fri, 12 Sep 2014 11:21:11 +0000 (19:21 +0800)
committerIan Chang <ianc@nvidia.com>
Wed, 27 Jan 2016 10:04:14 +0000 (18:04 +0800)
commit809b77d74b0ef08adbeb64cd51f6f04374e2fb8a
tree7b1121c7f344aec35b3bfed4e9a6f2b2b2c6dc53
parent4e32c35f4a09076916b7e8592f67c4e2ffa612b3
f2fs: fix a race condition in next_free_nid

The nm_i->fcnt checking is executed before spin_lock, so if another
thread delete the last free_nid from the list, the wrong nid may be
gotten.  So fix the race condition by moving the nm_i->fnct checking
into spin_lock.

Signed-off-by: Huang, Ying <ying.huang@intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/node.h