From: Jaegeuk Kim Subject: Re: [PATCH 4/5] f2fs: remove nid_free from f2fs_new_inode Date: Mon, 18 Mar 2013 11:11:27 +0900 Message-ID: <1363572687.14386.66.camel@kjgkr> References: <1363508828-2920-1-git-send-email-linkinjeon@gmail.com> Reply-To: jaegeuk.kim@samsung.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-K6Sjow/yA8bRYHrEt2U8" Cc: linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Namjae Jeon , Amit Sahrawat To: Namjae Jeon Return-path: In-reply-to: <1363508828-2920-1-git-send-email-linkinjeon@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org --=-K6Sjow/yA8bRYHrEt2U8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2013-03-17 (=EC=9D=BC), 17:27 +0900, Namjae Jeon: > From: Namjae Jeon >=20 > we can remove nid_free from new inode allocation part. > Since, nid_free is used to check if we need to free alloced nid > in case of failure. > Instead we can directly call alloc_nid_failed from that point, as > there is no dependency in that path. >=20 > Signed-off-by: Namjae Jeon > Signed-off-by: Amit Sahrawat > --- > fs/f2fs/namei.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) >=20 > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index d4a171b..261d821 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -24,7 +24,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, = umode_t mode) > struct f2fs_sb_info *sbi =3D F2FS_SB(sb); > nid_t ino; > struct inode *inode; > - bool nid_free =3D false; > int err; > =20 > inode =3D new_inode(sb); > @@ -58,7 +57,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, = umode_t mode) > err =3D insert_inode_locked(inode); > if (err) { > err =3D -EINVAL; > - nid_free =3D true; > + alloc_nid_failed(sbi, ino); > goto out; > } > =20 > @@ -70,8 +69,6 @@ out: > unlock_new_inode(inode); > fail: > iput(inode); > - if (nid_free) > - alloc_nid_failed(sbi, ino); We should call alloc_nid_failed() after iput() is completed. Otherwise, another f2fs_new_inode() is able to get this just-released nid before iput(). In such a case, insert_inode_locked() can return -EBUSY or iput() can free this newly allocated inode due to the i_lock race. Thanks, > return ERR_PTR(err); > } > =20 --=20 Jaegeuk Kim Samsung --=-K6Sjow/yA8bRYHrEt2U8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJRRnfPAAoJEEAUqH6CSFDSGHIP/0z2HKYAiICxpB96giIBBcPD 8KPyKpoH/DH50J7QQ8zQdPNvlY/77iPIe60KbnFKsCVuqkfk/4cJAkZwmdvJL4sb DTaWWbeqUyFB1Y+bwBcIXVL7IphxqAcoZnGMkhXGvxo0dXpPb6+npHWIItc7L0tg t6Nv12Ur75EsAWW6I9cpfwuBxGJPBQsz9RrS+clIoE0hobkLMPjSywWqQLU33i6J fuoXutqlCMByewuZUsFD0w3BWj/vohYdeVAXRuRG/qMxFIky5dRzBJxhwSYcM//b PXeWnVGuN+4xVKEQjQVVhHER03lxeyeEULVOhNnAmFnvQgEoL798EBtzZcHKBqlR sS2M1WidKWCICMdnQfkpdnyotIcKRKW8gEHvUZwwrVqq0xP5QkSpKMc3y62gFX8V MTdTeGTjylCfLzBxgPjP0ecxLBT1e6HL4zaKL86BnkZlXOqnYd39SB43tIx3N3lZ qGpDtW9BfsuoRXPKwTTfqawfST1gG2n/HUQiE7V6ZATcj1bVCa5WTVCJhbYAI77o Zib9HDg39i0rxENU7PKqnuFUwQzrAwq2BGaGIgy6wArI98ZYyGsMaiT73Lz0xf1L /8ltIQ5qdDAlQPrnPqIkhYlPeFDfeBPp39W4O3RI12FOdo3XOhQqoCOjDlqLDXmw frWHoc1+wKp5dNuOHqbi =mWtY -----END PGP SIGNATURE----- --=-K6Sjow/yA8bRYHrEt2U8--