mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kari Argillander <kari.argillander@gmail.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/4] fs/ntfs3: Fix fiemap + fix shrink file size (to remove preallocated space)
Date: Wed, 27 Oct 2021 00:18:51 +0300	[thread overview]
Message-ID: <20211026211851.merrsc662mhzqghm@kari-VirtualBox> (raw)
In-Reply-To: <e206b37a-9d71-67d5-5144-58033036a744@paragon-software.com>

On Mon, Oct 25, 2021 at 07:58:57PM +0300, Konstantin Komarov wrote:
> Two problems:
> 1. ntfs3_setattr can't truncate preallocated space;
> 2. if allocated fragment "cross" valid size, then fragment splits into two parts:
> - normal part;
> - unwritten part (here we must return FIEMAP_EXTENT_LAST).
> Before this commit we returned FIEMAP_EXTENT_LAST for whole fragment.
> Fixes xfstest generic/092

I do not have time for now to got through more. Maybe you have some
ideas here.

generic/092		[21:16:19][   18.906951] run fstests generic/092 at 2021-10-26 21:16:19
 [21:16:22]- output mismatch (see /results/ntfs3/results-default/generic/092.out.bad)
    --- tests/generic/092.out	2021-08-03 00:08:10.000000000 +0000
    +++ /results/ntfs3/results-default/generic/092.out.bad	2021-10-26 21:16:22.127859289 +0000
    @@ -2,5 +2,6 @@
     wrote 5242880/5242880 bytes at offset 0
     XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
     0: [0..10239]: data
    +1: [10240..20479]: unwritten
     0: [0..10239]: data
     1: [10240..20479]: unwritten

  Argillander

> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>  fs/ntfs3/file.c    |  2 +-
>  fs/ntfs3/frecord.c | 10 +++++++---
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index 43b1451bff53..5418e5ba64b3 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -761,7 +761,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
>  		}
>  		inode_dio_wait(inode);
>  
> -		if (attr->ia_size < oldsize)
> +		if (attr->ia_size <= oldsize)
>  			err = ntfs_truncate(inode, attr->ia_size);
>  		else if (attr->ia_size > oldsize)
>  			err = ntfs_extend(inode, attr->ia_size, 0, NULL);
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 6f47a9c17f89..18842998c8fa 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -1964,10 +1964,8 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
>  
>  		vcn += clen;
>  
> -		if (vbo + bytes >= end) {
> +		if (vbo + bytes >= end)
>  			bytes = end - vbo;
> -			flags |= FIEMAP_EXTENT_LAST;
> -		}
>  
>  		if (vbo + bytes <= valid) {
>  			;
> @@ -1977,6 +1975,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
>  			/* vbo < valid && valid < vbo + bytes */
>  			u64 dlen = valid - vbo;
>  
> +			if (vbo + dlen >= end)
> +				flags |= FIEMAP_EXTENT_LAST;
> +
>  			err = fiemap_fill_next_extent(fieinfo, vbo, lbo, dlen,
>  						      flags);
>  			if (err < 0)
> @@ -1995,6 +1996,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
>  			flags |= FIEMAP_EXTENT_UNWRITTEN;
>  		}
>  
> +		if (vbo + bytes >= end)
> +			flags |= FIEMAP_EXTENT_LAST;
> +
>  		err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, flags);
>  		if (err < 0)
>  			break;
> -- 
> 2.33.0
> 
> 
> 

  reply	other threads:[~2021-10-26 21:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 16:57 [PATCH 0/4] fs/ntfs3: Various fixes for xfstests problems Konstantin Komarov
2021-10-25 16:58 ` [PATCH 1/4] fs/ntfs3: In function ntfs_set_acl_ex do not change inode->i_mode if called from function ntfs_init_acl Konstantin Komarov
2021-10-25 17:13   ` Joe Perches
2021-10-26 18:40   ` Kari Argillander
2021-10-25 16:58 ` [PATCH 2/4] fs/ntfs3: Fix fiemap + fix shrink file size (to remove preallocated space) Konstantin Komarov
2021-10-26 21:18   ` Kari Argillander [this message]
2021-10-25 16:59 ` [PATCH 3/4] fs/ntfs3: Check new size for limits Konstantin Komarov
2021-10-26 21:22   ` Kari Argillander
2021-10-25 16:59 ` [PATCH 4/4] fs/ntfs3: Update valid size if -EIOCBQUEUED Konstantin Komarov
2021-10-26 21:31   ` Kari Argillander
2021-10-26 21:37 ` [PATCH 0/4] fs/ntfs3: Various fixes for xfstests problems Kari Argillander

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=20211026211851.merrsc662mhzqghm@kari-VirtualBox \
    --to=kari.argillander@gmail.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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

all inboxes | Powered by JetHome®