Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
pali@kernel.org, dsterba@suse.cz, aaptel@suse.com,
willy@infradead.org, rdunlap@infradead.org, joe@perches.com,
mark@harmstone.com
Subject: Re: [PATCH v3 04/10] fs/ntfs3: Add file operations and implementation
Date: Fri, 28 Aug 2020 16:55:31 +0100 [thread overview]
Message-ID: <20200828155531.GK1236603@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200828143938.102889-5-almaz.alexandrovich@paragon-software.com>
On Fri, Aug 28, 2020 at 07:39:32AM -0700, Konstantin Komarov wrote:
> +static int ntfs_atomic_open(struct inode *dir, struct dentry *dentry,
> + struct file *file, u32 flags, umode_t mode)
> +{
> + int err;
> + bool excl = !!(flags & O_EXCL);
> + struct inode *inode;
> + struct ntfs_fnd *fnd = NULL;
> + struct ntfs_inode *ni = ntfs_i(dir);
> +
> + ni_lock(ni);
> +
> + if (d_in_lookup(dentry)) {
> + struct dentry *d;
> +
> + fnd = fnd_get(&ntfs_i(dir)->dir);
> + if (!fnd) {
> + err = -ENOMEM;
> + goto out;
> + }
> +
> + d = __ntfs_lookup(dir, dentry, fnd);
> + if (IS_ERR(d)) {
> + err = PTR_ERR(d);
> + d = NULL;
> + goto out1;
> + }
> +
> + if (d)
> + dentry = d;
> +
> + if (d_really_is_positive(dentry)) {
> + if (file->f_mode & FMODE_OPENED) {
How do we get FMODE_OPENED here?
> + dput(d);
> + err = 0;
> + } else
> + err = finish_no_open(file, d);
> + goto out1;
> + }
> + WARN_ON(d);
> + }
> +
> + if (!(flags & O_CREAT)) {
> + err = -ENOENT;
> + goto out1;
> + }
Just return finish_no_open() in that case. And let the caller handle
that.
> + err = ntfs_create_inode(dir, dentry, file, mode, 0, NULL, 0, excl, fnd,
> + &inode);
> +
> +out1:
> + fnd_put(fnd);
> +out:
> + ni_unlock(ni);
> +
> + return err;
> +}
BTW, what's the point of that ni_lock() here? d_in_lookup() is stable
regardless of that and any attempts to create something in the parent
are serialized by ->i_rwsem. If you want it around the actual file
creation, why not take it just there, and replace the open-coded
ntfs_lookup() with the call of the real thing? As in
if (d_in_lookup(dentry)) {
d = ntfs_lookup(....);
if (IS_ERR(d))
return d;
if (d)
dentry = d;
}
if (!(flags & O_CREAT) || d_really_is_positive(dentry))
return finish_no_open(file, d);
/* deal with creation of file */
ni_lock(...);
....
next prev parent reply other threads:[~2020-08-28 15:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-28 14:39 [PATCH v3 00/10] NTFS read-write driver GPL implementation by Paragon Software Konstantin Komarov
2020-08-28 14:39 ` [PATCH v3 01/10] fs/ntfs3: Add headers and misc files Konstantin Komarov
2020-08-28 14:39 ` [PATCH v3 03/10] fs/ntfs3: Add bitmap Konstantin Komarov
2020-08-28 14:39 ` [PATCH v3 05/10] fs/ntfs3: Add attrib operations Konstantin Komarov
2020-08-28 16:14 ` Mark Harmstone
2020-08-28 14:39 ` [PATCH v3 06/10] fs/ntfs3: Add compression Konstantin Komarov
2020-08-28 14:39 ` [PATCH v3 08/10] fs/ntfs3: Add Kconfig, Makefile and doc Konstantin Komarov
2020-08-28 14:39 ` [PATCH v3 09/10] fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile Konstantin Komarov
2020-09-01 4:45 ` kernel test robot
2020-08-28 14:39 ` [PATCH v3 10/10] fs/ntfs3: Add MAINTAINERS Konstantin Komarov
[not found] ` <20200828143938.102889-5-almaz.alexandrovich@paragon-software.com>
2020-08-28 15:45 ` [PATCH v3 04/10] fs/ntfs3: Add file operations and implementation Al Viro
2020-09-04 12:41 ` Konstantin Komarov
2020-08-28 15:55 ` Al Viro [this message]
2020-09-04 12:49 ` Konstantin Komarov
2020-09-04 11:50 ` Pali Rohár
2020-09-11 16:52 ` Konstantin Komarov
2020-09-21 13:36 ` Pali Rohár
2020-09-22 10:26 ` Aurélien Aptel
2020-09-25 16:39 ` Konstantin Komarov
2020-08-29 11:31 ` [PATCH v3 00/10] NTFS read-write driver GPL implementation by Paragon Software Nikolay Borisov
2020-09-04 12:55 ` Konstantin Komarov
[not found] ` <20200828143938.102889-3-almaz.alexandrovich@paragon-software.com>
2020-09-04 12:06 ` [PATCH v3 02/10] fs/ntfs3: Add initialization of super block Pali Rohár
2020-09-11 16:59 ` Konstantin Komarov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200828155531.GK1236603@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=aaptel@suse.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=dsterba@suse.cz \
--cc=joe@perches.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@harmstone.com \
--cc=pali@kernel.org \
--cc=rdunlap@infradead.org \
--cc=willy@infradead.org \
--subject='Re: [PATCH v3 04/10] fs/ntfs3: Add file operations and implementation' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).