linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH v10 02/10] fs/ntfs3: Add initialization of super block
Date: Fri, 23 Oct 2020 19:25:03 +0100	[thread overview]
Message-ID: <20201023182503.GE20115@casper.infradead.org> (raw)
In-Reply-To: <20201023154431.1853715-3-almaz.alexandrovich@paragon-software.com>

On Fri, Oct 23, 2020 at 06:44:23PM +0300, Konstantin Komarov wrote:
> +
> +/*ntfs_readpage*/
> +/*ntfs_readpages*/
> +/*ntfs_writepage*/
> +/*ntfs_writepages*/
> +/*ntfs_block_truncate_page*/

What are these for?

> +int ntfs_readpage(struct file *file, struct page *page)
> +{
> +	int err;
> +	struct address_space *mapping = page->mapping;
> +	struct inode *inode = mapping->host;
> +	struct ntfs_inode *ni = ntfs_i(inode);
> +	u64 vbo = (u64)page->index << PAGE_SHIFT;
> +	u64 valid;
> +	struct ATTRIB *attr;
> +	const char *data;
> +	u32 data_size;
> +
[...]
> +
> +	if (is_compressed(ni)) {
> +		if (PageUptodate(page)) {
> +			unlock_page(page);
> +			return 0;
> +		}

You can skip this -- the readpage op won't be called for pages which
are Uptodate.

> +	/* normal + sparse files */
> +	err = mpage_readpage(page, ntfs_get_block);
> +	if (err)
> +		goto out;

It would be nice to use iomap instead of mpage, but that's a big ask.

> +	valid = ni->i_valid;
> +	if (vbo < valid && valid < vbo + PAGE_SIZE) {
> +		if (PageLocked(page))
> +			wait_on_page_bit(page, PG_locked);
> +		if (PageError(page)) {
> +			ntfs_inode_warn(inode, "file garbage at 0x%llx", valid);
> +			goto out;
> +		}
> +		zero_user_segment(page, valid & (PAGE_SIZE - 1), PAGE_SIZE);

Nono, you can't zero data after the page has been unlocked.  You can
handle this case in ntfs_get_block().  If the block is entirely beyond
i_size, returning a hole will cause mpage_readpage() to zero it.  If it
straddles i_size, you can either ensure that the on-media block contains
zeroes after the EOF, or if you can't depend on that, you can read it
in synchronously in your get_block() and then zero the tail and set the
buffer Uptodate.  Not the most appetising solution, but what you have here
is racy with the user writing to it after reading.


  reply	other threads:[~2020-10-23 18:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 15:44 [PATCH v10 00/10] NTFS read-write driver GPL implementation by Paragon Software Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 01/10] fs/ntfs3: Add headers and misc files Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 02/10] fs/ntfs3: Add initialization of super block Konstantin Komarov
2020-10-23 18:25   ` Matthew Wilcox [this message]
2020-10-30 15:54     ` Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 03/10] fs/ntfs3: Add bitmap Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 04/10] fs/ntfs3: Add file operations and implementation Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 05/10] fs/ntfs3: Add attrib operations Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 06/10] fs/ntfs3: Add compression Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 07/10] fs/ntfs3: Add NTFS journal Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 08/10] fs/ntfs3: Add Kconfig, Makefile and doc Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 09/10] fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile Konstantin Komarov
2020-10-23 15:44 ` [PATCH v10 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=20201023182503.GE20115@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=aaptel@suse.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=anton@tuxera.com \
    --cc=dsterba@suse.cz \
    --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).