public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, hch@lst.de,
	tytso@mit.edu, willy@infradead.org, jack@suse.cz,
	djwong@kernel.org, josef@toxicpanda.com, sandeen@sandeen.net,
	rgoldwyn@suse.com, xiang@kernel.org, dsterba@suse.com,
	pali@kernel.org, ebiggers@kernel.org, neil@brown.name,
	amir73il@gmail.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, iamjoonsoo.kim@lge.com,
	cheol.lee@lge.com, jay.sim@lge.com, gunho.lee@lge.com,
	Hyunchul Lee <hyc.lee@gmail.com>
Subject: Re: [PATCH v6 09/16] ntfs: update iomap and address space operations
Date: Tue, 3 Feb 2026 07:20:18 +0100	[thread overview]
Message-ID: <20260203062018.GF16426@lst.de> (raw)
In-Reply-To: <20260202220202.10907-10-linkinjeon@kernel.org>

Suggested commit message:

Update the address space operations to use the iomap framework,
replacing legacy buffer-head based code.

> +#include <linux/mpage.h>

This include should not be needed (same in iomap.c).

> +#include <linux/uio.h>

This should not be needed either (same in iomap.c).

> -};
> +static void ntfs_readahead(struct readahead_control *rac)
> +{
> +	struct address_space *mapping = rac->mapping;
> +	struct inode *inode = mapping->host;
> +	struct ntfs_inode *ni = NTFS_I(inode);
>  
> +	if (!NInoNonResident(ni) || NInoCompressed(ni)) {
> +		/* No readahead for resident and compressed. */

As-is this comment is useless ads it states the obvious.  If you
want to make it useful add why it is not implemented.

> +static int ntfs_writepages(struct address_space *mapping,
> +		struct writeback_control *wbc)
> +{
> +	struct inode *inode = mapping->host;
> +	struct ntfs_inode *ni = NTFS_I(inode);
> +	struct iomap_writepage_ctx wpc = {
> +		.inode		= mapping->host,
> +		.wbc		= wbc,
> +		.ops		= &ntfs_writeback_ops,
> +	};
> +
> +	if (NVolShutdown(ni->vol))
> +		return -EIO;
>  
> +	if (!NInoNonResident(ni))
> +		return 0;
>  
> +	/* If file is encrypted, deny access, just like NT4. */

I don't understand this comment.

> +void mark_ntfs_record_dirty(struct folio *folio)
> +{
> +	iomap_dirty_folio(folio->mapping, folio);
> +}

Should this be in mft.c and have a mft_ compoenent in the name?

> +	if (!NInoNonResident(ni))
> +		goto out;

Split the resident handling into a helper to keep the method
simple?

> +static int __ntfs_read_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
> +		unsigned int flags, struct iomap *iomap, struct iomap *srcmap,
> +		bool need_unwritten)
> +{
> +	struct ntfs_inode *ni = NTFS_I(inode);
> +	int ret;
> +
> +	if (NInoNonResident(ni))
> +		ret = ntfs_read_iomap_begin_non_resident(inode, offset, length,
> +				flags, iomap, need_unwritten);
> +	else
> +		ret = ntfs_read_iomap_begin_resident(inode, offset, length,
> +				flags, iomap);
> +
> +	return ret;

This could be simplified to:

	if (NInoNonResident(NTFS_I(inode)))
		return ntfs_read_iomap_begin_non_resident(inode, offset, length,
				flags, iomap, need_unwritten);
	return ntfs_read_iomap_begin_resident(inode, offset, length, flags,
			iomap);

> +int ntfs_zero_range(struct inode *inode, loff_t offset, loff_t length, bool bdirect)
> +{
> +	if (bdirect) {
> +		if ((offset | length) & (SECTOR_SIZE - 1))
> +			return -EINVAL;
> +
> +		return  blkdev_issue_zeroout(inode->i_sb->s_bdev,
> +					     offset >> SECTOR_SHIFT,
> +					     length >> SECTOR_SHIFT,
> +					     GFP_NOFS,
> +					     BLKDEV_ZERO_NOUNMAP);
> +	}
> +
> +	return iomap_zero_range(inode,
> +				offset, length,
> +				NULL,
> +				&ntfs_zero_read_iomap_ops,
> +				&ntfs_zero_iomap_folio_ops,
> +				NULL);
> +}

This really should be two separate helpers.

> +	if (NInoNonResident(ni)) {

As separate non-resident helper would be useful here.

> +		if (ntfs_iomap_flags & NTFS_IOMAP_FLAGS_BEGIN)
> +			ret = ntfs_write_iomap_begin_non_resident(inode, offset,
> +					length, iomap);
> +		else
> +			ret = ntfs_write_da_iomap_begin_non_resident(inode,
> +					offset, length, flags, iomap,
> +					ntfs_iomap_flags);
> +	} else {
> +		mutex_lock(&ni->mrec_lock);
> +		ret = ntfs_write_iomap_begin_resident(inode, offset, iomap);
> +	}
> +
> +	return ret;

But eveven without that, direct returns would really help here:

	if (!NInoNonResident(ni)) {
		mutex_lock(&ni->mrec_lock);
		return ntfs_write_iomap_begin_resident(inode, offset, iomap);
	}

	...

	if (ntfs_iomap_flags & NTFS_IOMAP_FLAGS_BEGIN)
		return ntfs_write_iomap_begin_non_resident(inode, offset,
				length, iomap);
	return ntfs_write_da_iomap_begin_non_resident(inode, offset, length,
			flags, iomap,

> +static int ntfs_write_iomap_end(struct inode *inode, loff_t pos, loff_t length,
> +		ssize_t written, unsigned int flags, struct iomap *iomap)
> +{
> +	if (iomap->type == IOMAP_INLINE) {

A separate inline helper would help here as well.


  reply	other threads:[~2026-02-03  6:20 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02 22:01 [PATCH v6 00/16] ntfs filesystem remake Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 01/16] Revert "fs: Remove NTFS classic" Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 02/16] Documentation: filesystems: update NTFS driver documentation Namjae Jeon
2026-02-03  5:44   ` Christoph Hellwig
2026-02-03 13:01     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 03/16] fs: add generic FS_IOC_SHUTDOWN definitions Namjae Jeon
2026-02-02 22:36   ` Darrick J. Wong
2026-02-03  5:38     ` Christoph Hellwig
2026-02-03  8:54   ` Jan Kara
2026-02-02 22:01 ` [PATCH v6 04/16] ntfs: update in-memory, on-disk structures and headers Namjae Jeon
2026-02-03  5:47   ` Christoph Hellwig
2026-02-03 13:03     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 05/16] ntfs: update super block operations Namjae Jeon
2026-02-03  5:52   ` Christoph Hellwig
2026-02-03 13:04     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 07/16] ntfs: update directory operations Namjae Jeon
2026-02-03  5:55   ` Christoph Hellwig
2026-02-03 13:04     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 08/16] ntfs: update file operations Namjae Jeon
2026-02-03  6:07   ` Christoph Hellwig
2026-02-03 13:08     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 09/16] ntfs: update iomap and address space operations Namjae Jeon
2026-02-03  6:20   ` Christoph Hellwig [this message]
2026-02-03 14:05     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 10/16] ntfs: update attrib operations Namjae Jeon
2026-02-03  6:22   ` Christoph Hellwig
2026-02-03 14:06     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 11/16] ntfs: update runlist handling and cluster allocator Namjae Jeon
2026-02-03  6:34   ` Christoph Hellwig
2026-02-03 14:22     ` Namjae Jeon
2026-02-02 22:01 ` [PATCH v6 12/16] ntfs: add reparse and ea operations Namjae Jeon
2026-02-03  6:37   ` Christoph Hellwig
2026-02-03 14:17     ` Namjae Jeon
2026-02-02 22:02 ` [PATCH v6 14/16] ntfs3: remove legacy ntfs driver support Namjae Jeon
2026-02-02 22:02 ` [PATCH v6 15/16] ntfs: add Kconfig and Makefile Namjae Jeon
2026-02-03  6:38   ` Christoph Hellwig
2026-02-02 22:02 ` [PATCH v6 16/16] MAINTAINERS: update ntfs filesystem entry Namjae Jeon

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=20260203062018.GF16426@lst.de \
    --to=hch@lst.de \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cheol.lee@lge.com \
    --cc=djwong@kernel.org \
    --cc=dsterba@suse.com \
    --cc=ebiggers@kernel.org \
    --cc=gunho.lee@lge.com \
    --cc=hyc.lee@gmail.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jack@suse.cz \
    --cc=jay.sim@lge.com \
    --cc=josef@toxicpanda.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=pali@kernel.org \
    --cc=rgoldwyn@suse.com \
    --cc=sandeen@sandeen.net \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=xiang@kernel.org \
    /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