linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mke2fs: fix coping of empty file using fiemap
@ 2017-01-16 16:59 Artem Blagodarenko
  2017-01-17  1:37 ` Darrick J. Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Blagodarenko @ 2017-01-16 16:59 UTC (permalink / raw)
  To: linux-ext4

During filesystem creation with -d option files copied from given
directory. If supported, FS_IOC_FIEMAP ioctl is used to get file
extents. For empty file fm_mapped_extents is 0 and no error code
is returned, because this is not fail situation.

Without this patch errno from previous operation is returned and
successful FS_IOC_FIEMAP ioctl call for empty file is interpreted
as error.

Signed-off-by: Artem Blagodarenko <artem.blagodarenko@seagate.com>
---
 misc/create_inode.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/misc/create_inode.c b/misc/create_inode.c
index 5122e56..6083d94 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -510,7 +510,7 @@ static errcode_t try_fiemap_copy(ext2_filsys fs,
int fd, ext2_file_t e2_file,
         if (err < 0 && (errno == EOPNOTSUPP || errno == ENOTTY)) {
             err = EXT2_ET_UNIMPLEMENTED;
             goto out;
-        } else if (err < 0 || fiemap_buf->fm_mapped_extents == 0) {
+        } else if (err < 0 && fiemap_buf->fm_mapped_extents == 0) {
             err = errno;
             goto out;
         }
--

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mke2fs: fix coping of empty file using fiemap
  2017-01-16 16:59 [PATCH] mke2fs: fix coping of empty file using fiemap Artem Blagodarenko
@ 2017-01-17  1:37 ` Darrick J. Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-01-17  1:37 UTC (permalink / raw)
  To: Artem Blagodarenko; +Cc: linux-ext4

On Mon, Jan 16, 2017 at 07:59:17PM +0300, Artem Blagodarenko wrote:
> During filesystem creation with -d option files copied from given
> directory. If supported, FS_IOC_FIEMAP ioctl is used to get file
> extents. For empty file fm_mapped_extents is 0 and no error code
> is returned, because this is not fail situation.
> 
> Without this patch errno from previous operation is returned and
> successful FS_IOC_FIEMAP ioctl call for empty file is interpreted
> as error.
> 
> Signed-off-by: Artem Blagodarenko <artem.blagodarenko@seagate.com>
> ---
>  misc/create_inode.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/misc/create_inode.c b/misc/create_inode.c
> index 5122e56..6083d94 100644
> --- a/misc/create_inode.c
> +++ b/misc/create_inode.c
> @@ -510,7 +510,7 @@ static errcode_t try_fiemap_copy(ext2_filsys fs,
> int fd, ext2_file_t e2_file,
>          if (err < 0 && (errno == EOPNOTSUPP || errno == ENOTTY)) {
>              err = EXT2_ET_UNIMPLEMENTED;
>              goto out;
> -        } else if (err < 0 || fiemap_buf->fm_mapped_extents == 0) {
> +        } else if (err < 0 && fiemap_buf->fm_mapped_extents == 0) {

I think we want the loop to terminate any time fm_mapped_extents == 0,
not just in the case that err < 0 and fiemap_buf still reflects the
earlier memset(0)...

} else if (err < 0) {
	err = errno;
	goto out;
} else if (!fiemap_buf->fm_mapped_extents)
	goto out;

...right?

--D

>              err = errno;
>              goto out;
>          }
> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-17  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-16 16:59 [PATCH] mke2fs: fix coping of empty file using fiemap Artem Blagodarenko
2017-01-17  1:37 ` Darrick J. Wong

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).