From nobody Sun Feb 8 17:37:32 2026 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 935C47D071; Wed, 17 Apr 2024 13:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359244; cv=none; b=o6GrxWJ4eLsCbEEp9TGuNcH5mx00h6RbTzTU7gq6SOlkO4pII/qU3Z/oZfFfBnOYbqeErunvJ/aUJv/FY2gu8o4TDnIa/ApjJMWc/j0HJJ0lFZSdOSM+T4SD1BxmZyYDYEB2y8XqZAiZ0eD/VuIFr2OwGYeoK4FntxBc/I1I88k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359244; c=relaxed/simple; bh=z0IW3/Brxpfkh18MS9+cTaxXo9NVdBoBJ3n5eEgmBjM=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=VV8aDs4vSZdCVDZP7HRaTWHtXQsQn0wQ8Sz0eLtLDZarG+XzkSiwIFCMjD/GT3S7UBwSrdoX7SnyiGzg6PC0s750Ys8cl8Umq2KE3OLA1QjXlKxkE/swOnO3aCacz+4GW1OwTiRsCkRJQmsmG5TWRXeuZOLchyDc6hQUIEZZ6n0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=dQxfV0hr; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="dQxfV0hr" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id CEC6E2126; Wed, 17 Apr 2024 12:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358790; bh=+s6MrL/MryqHMryIwr1o1fGOI0TS7160OkRPd7Inyqg=; h=Date:Subject:From:To:References:In-Reply-To; b=dQxfV0hr+dNtRjMRJ3grudsr3sK5G3NrH0Fv0CHTXEs5+wsSk/7rco53658zI44gb TPUz6tMEnL44M6kzO6jp8l3WMOGsnvrBO0zbR5rwDOEks5xLr/EOA69zoYWO682EOy Q0pvareU23Hr6O6ycMeuQT/WQxAB3JPGEYdpZwBE= Received: from [192.168.211.39] (192.168.211.39) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 17 Apr 2024 16:07:19 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:07:18 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 06/11] fs/ntfs3: Redesign ntfs_create_inode to return error code instead of inode From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0 | 22 +++++++++++----------- =C2=A0fs/ntfs3/namei.c=C2=A0=C2=A0 | 31 ++++++++----------------------- =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 9 ++++----- =C2=A03 files changed, 23 insertions(+), 39 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index eb7a8c9fba01..85a10d4a74c4 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1210,11 +1210,10 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info=20 *sbi, const char *symname, =C2=A0 * =C2=A0 * NOTE: if fnd !=3D NULL (ntfs_atomic_open) then @dir is locked =C2=A0 */ -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct dentry *dentry, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0const struct cpu_str *uni, umode_t mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0dev_t dev, const char *symname, u32 size, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct ntfs_fnd *fnd) +int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t dentry *dentry, const struct cpu_str *uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 umode= _t mode, dev_t dev, const char *symname, u32 size, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t ntfs_fnd *fnd) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D dir->i_sb; @@ -1239,6 +1238,9 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0struct REPARSE_DATA_BUFFER *rp =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0bool rp_inserted =3D false; +=C2=A0=C2=A0 =C2=A0/* New file will be resident or non resident. */ +=C2=A0=C2=A0 =C2=A0const bool new_file_resident =3D 1; + =C2=A0=C2=A0=C2=A0 =C2=A0if (!fnd) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock_dir(dir_ni); @@ -1478,7 +1480,7 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->size =3D cpu_to_le32(SIZ= EOF_RESIDENT); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->name_off =3D SIZEOF_RESI= DENT_LE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->res.data_off =3D SIZEOF_= RESIDENT_LE; -=C2=A0=C2=A0 =C2=A0} else if (S_ISREG(mode)) { +=C2=A0=C2=A0 =C2=A0} else if (!new_file_resident && S_ISREG(mode)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * Regular file. Create empty = non resident data attribute. =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 */ @@ -1715,12 +1717,10 @@ struct inode *ntfs_create_inode(struct mnt_idmap=20 *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0if (!fnd) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(dir_ni); -=C2=A0=C2=A0 =C2=A0if (err) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return ERR_PTR(err); - -=C2=A0=C2=A0 =C2=A0unlock_new_inode(inode); +=C2=A0=C2=A0 =C2=A0if (!err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unlock_new_inode(inode); -=C2=A0=C2=A0 =C2=A0return inode; +=C2=A0=C2=A0 =C2=A0return err; =C2=A0} =C2=A0int ntfs_link_inode(struct inode *inode, struct dentry *dentry) diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index edb6a7141246..71498421ce60 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -107,12 +107,8 @@ static struct dentry *ntfs_lookup(struct inode=20 *dir, struct dentry *dentry, =C2=A0static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 struct dentry *dentry, umode_t mode, bool excl) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct inode *inode; - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFREG | mode, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, S_IF= REG | mode, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL, 0, NULL); =C2=A0} =C2=A0/* @@ -123,12 +119,8 @@ static int ntfs_create(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct dentry *dentry, umode_t mode, dev_t rdev) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct inode *inode; - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, m= ode, rdev,=20 NULL, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, mode= , rdev, NULL, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL); =C2=A0} =C2=A0/* @@ -200,15 +192,12 @@ static int ntfs_symlink(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct dent= ry *dentry, const char *symname) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0u32 size =3D strlen(symname); -=C2=A0=C2=A0 =C2=A0struct inode *inode; =C2=A0=C2=A0=C2=A0 =C2=A0if (unlikely(ntfs3_forced_shutdown(dir->i_sb))) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EIO; -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFLNK | 0777, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 symname, size, NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, S_IF= LNK | 0777, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 symname, size, NULL); =C2=A0} =C2=A0/* @@ -217,12 +206,8 @@ static int ntfs_symlink(struct mnt_idmap *idmap,=20 struct inode *dir, =C2=A0static int ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct dentry *dentry, umode_t mode) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct inode *inode; - -=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(idmap, dir, dentry, NULL, S= _IFDIR | mode, 0, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0 NULL, 0, NULL); - -=C2=A0=C2=A0 =C2=A0return IS_ERR(inode) ? PTR_ERR(inode) : 0; +=C2=A0=C2=A0 =C2=A0return ntfs_create_inode(idmap, dir, dentry, NULL, S_IF= DIR | mode, 0, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 NULL, 0, NULL); =C2=A0} =C2=A0/* diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 79356fd29a14..3db6a61f61dc 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -714,11 +714,10 @@ int ntfs_sync_inode(struct inode *inode); =C2=A0int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= struct inode *i2); =C2=A0int inode_write_data(struct inode *inode, const void *data, size_t b= ytes); -struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct dentry *dentry, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0const struct cpu_str *uni, umode_t mode, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0dev_t dev, const char *symname, u32 size, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0struct ntfs_fnd *fnd); +int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t dentry *dentry, const struct cpu_str *uni, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 umode= _t mode, dev_t dev, const char *symname, u32 size, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struc= t ntfs_fnd *fnd); =C2=A0int ntfs_link_inode(struct inode *inode, struct dentry *dentry); =C2=A0int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry= ); =C2=A0void ntfs_evict_inode(struct inode *inode); --=20 2.34.1