[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260203060748.GE16426@lst.de>
Date: Tue, 3 Feb 2026 07:07:48 +0100
From: Christoph Hellwig <hch@....de>
To: Namjae Jeon <linkinjeon@...nel.org>
Cc: viro@...iv.linux.org.uk, brauner@...nel.org, hch@....de, tytso@....edu,
willy@...radead.org, jack@...e.cz, djwong@...nel.org,
josef@...icpanda.com, sandeen@...deen.net, rgoldwyn@...e.com,
xiang@...nel.org, dsterba@...e.com, pali@...nel.org,
ebiggers@...nel.org, neil@...wn.name, amir73il@...il.com,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
iamjoonsoo.kim@....com, cheol.lee@....com, jay.sim@....com,
gunho.lee@....com, Hyunchul Lee <hyc.lee@...il.com>
Subject: Re: [PATCH v6 08/16] ntfs: update file operations
Suggested commit message:
Rewrite the file operations to utilize the iomap infrastructure,
replacing the legacy buffer-head based implementation.
Implement ntfs_setattr() with size change handling, uid/gid/mode.
Add support for Direct I/O.
Add support for fallocate with the FALLOC_FL_KEEP_SIZE,
FALLOC_FL_PUNCH_HOLE, FALLOC_FL_COLLAPSE_RANGE, FALLOC_FL_INSERT_RANGE
and FALLOC_FL_ALLOCATE_RANGE modes.
Implement .llseek with SEEK_DATA / SEEK_HOLE support.
Implement ntfs_fiemap() using iomap_fiemap().
Add FS_IOC_SHUTDOWN, FS_IOC_[GS]ETFSLABEL, FITRIM ioctl support.
> static int ntfs_file_open(struct inode *vi, struct file *filp)
> {
> + struct ntfs_inode *ni = NTFS_I(vi);
> +
> + if (NVolShutdown(ni->vol))
> + return -EIO;
> +
> if (sizeof(unsigned long) < 8) {
> if (i_size_read(vi) > MAX_LFS_FILESIZE)
> return -EOVERFLOW;
> }
> + if (filp->f_flags & O_TRUNC && NInoNonResident(ni)) {
> + int err;
>
> + mutex_lock(&ni->mrec_lock);
> + down_read(&ni->runlist.lock);
> + if (!ni->runlist.rl) {
> + err = ntfs_attr_map_whole_runlist(ni);
> + if (err) {
> + up_read(&ni->runlist.lock);
> + mutex_unlock(&ni->mrec_lock);
> + return err;
> + }
> }
> + ni->lcn_seek_trunc = ni->runlist.rl->lcn;
> + up_read(&ni->runlist.lock);
> + mutex_unlock(&ni->mrec_lock);
> }
Do you ever hits this? O_TRUNC should call into ->setattr to do
the truncation long before calling into ->open.
> +
> + filp->f_mode |= FMODE_NOWAIT;
This should also set FMODE_CAN_ODIRECT instead of setting the noop
direct I/O method.
> +static int ntfs_file_release(struct inode *vi, struct file *filp)
> {
> + struct ntfs_inode *ni = NTFS_I(vi);
> + struct ntfs_volume *vol = ni->vol;
> + s64 aligned_data_size = round_up(ni->data_size, vol->cluster_size);
> +
> + if (NInoCompressed(ni))
> + return 0;
> +
> + inode_lock(vi);
> + mutex_lock(&ni->mrec_lock);
> + down_write(&ni->runlist.lock);
> + if (aligned_data_size < ni->allocated_size) {
Splitting the compresse handling into a helper would really help
the code maintainability here. Also please add a comment why
this does work on final release, which is highly unusual. And
even more unusual then doing it in ->flush which is called for
every close.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@....de>
Powered by blists - more mailing lists