From: Matthew Wilcox <willy@infradead.org>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org, pali@kernel.org, dsterba@suse.cz,
aaptel@suse.com, rdunlap@infradead.org, joe@perches.com,
mark@harmstone.com, nborisov@suse.com,
linux-ntfs-dev@lists.sourceforge.net, anton@tuxera.com,
dan.carpenter@oracle.com, hch@lst.de, ebiggers@kernel.org
Subject: Re: [PATCH v16 04/10] fs/ntfs3: Add file operations and implementation
Date: Sun, 27 Dec 2020 11:59:11 +0000 [thread overview]
Message-ID: <20201227115911.GB5479@casper.infradead.org> (raw)
In-Reply-To: <20201225135119.3666763-5-almaz.alexandrovich@paragon-software.com>
On Fri, Dec 25, 2020 at 04:51:13PM +0300, Konstantin Komarov wrote:
> +static int ntfs_readdir(struct file *file, struct dir_context *ctx)
> +{
> + const struct INDEX_ROOT *root;
> + u64 vbo;
> + size_t bit;
> + loff_t eod;
> + int err = 0;
> + struct inode *dir = file_inode(file);
> + struct ntfs_inode *ni = ntfs_i(dir);
> + struct super_block *sb = dir->i_sb;
> + struct ntfs_sb_info *sbi = sb->s_fs_info;
> + loff_t i_size = dir->i_size;
I appreciate directories are never likely to exceed 4GB, but why not
use i_size_read() here?
> + u32 pos = ctx->pos;
> + u8 *name = NULL;
> + struct indx_node *node = NULL;
> + u8 index_bits = ni->dir.index_bits;
> +
> + /* name is a buffer of PATH_MAX length */
> + static_assert(NTFS_NAME_LEN * 4 < PATH_MAX);
> +
> + if (ni->dir.changed) {
> + ni->dir.changed = false;
> + pos = 0;
> + }
I don't think that 'changed' as implemented is all that useful. If you
have one reader and one-or-more writers, the reader will go back to the
start, but if you have two readers and one-or-more writers, only one
reader will see the 'changed' flag before the other one resets it.
You need to use a sequence counter or something if you want this to be
proof against multiple readers, and honestly I don't think it's worth it.
POSIX says:
: If a file is removed from or added to the directory after the most
: recent call to opendir() or rewinddir(), whether a subsequent call to
: readdir() returns an entry for that file is unspecified.
> + eod = i_size + sbi->record_size;
> +
> + if (pos >= eod)
> + return 0;
> +
> + if (!dir_emit_dots(file, ctx))
> + return 0;
> +
> + /* allocate PATH_MAX bytes */
> + name = __getname();
> + if (!name)
> + return -ENOMEM;
> +
> + ni_lock(ni);
What is ni_lock() protecting against here? You're being called under the
protection of dir->i_rwsem, which excludes simultaneous calls to create,
link, mknod, symlink, mkdir, unlink, rmdir and rename.
> +const struct file_operations ntfs_dir_operations = {
> + .llseek = generic_file_llseek,
> + .read = generic_read_dir,
> + .iterate = ntfs_readdir,
This should probably be iterate_shared so multiple calls to readdir can
be in progress at once (see Documentation/filesystems/porting)
next prev parent reply other threads:[~2020-12-27 12:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-25 13:51 [PATCH v16 00/10] NTFS read-write driver GPL implementation by Paragon Software Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 01/10] fs/ntfs3: Add headers and misc files Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 02/10] fs/ntfs3: Add initialization of super block Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 03/10] fs/ntfs3: Add bitmap Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 04/10] fs/ntfs3: Add file operations and implementation Konstantin Komarov
2020-12-27 11:59 ` Matthew Wilcox [this message]
2020-12-25 13:51 ` [PATCH v16 05/10] fs/ntfs3: Add attrib operations Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 06/10] fs/ntfs3: Add compression Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 07/10] fs/ntfs3: Add NTFS journal Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 08/10] fs/ntfs3: Add Kconfig, Makefile and doc Konstantin Komarov
2020-12-25 13:51 ` [PATCH v16 09/10] fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile Konstantin Komarov
2020-12-29 5:12 ` kernel test robot
2020-12-29 7:39 ` kernel test robot
2020-12-25 13:51 ` [PATCH v16 10/10] fs/ntfs3: Add MAINTAINERS 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=20201227115911.GB5479@casper.infradead.org \
--to=willy@infradead.org \
--cc=aaptel@suse.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=anton@tuxera.com \
--cc=dan.carpenter@oracle.com \
--cc=dsterba@suse.cz \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=joe@perches.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
--cc=mark@harmstone.com \
--cc=nborisov@suse.com \
--cc=pali@kernel.org \
--cc=rdunlap@infradead.org \
--cc=viro@zeniv.linux.org.uk \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).