linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Artem Blagodarenko <artem.blagodarenko@seagate.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH v2] mke2fs: fix coping of empty file using fiemap
Date: Tue, 17 Jan 2017 08:49:02 -0800	[thread overview]
Message-ID: <20170117164902.GD14029@birch.djwong.org> (raw)
In-Reply-To: <CAO3qy=EeD4y6cX3JaA4ZKptoL9JH0Kc9zYqPWj-UZ+ythC6LXw@mail.gmail.com>

On Tue, Jan 17, 2017 at 06:14:19PM +0300, Artem Blagodarenko wrote:
> Hello,
> 
> Darrick J. Wong, thank you for inspection. Here is second version of the patch.
> 
> Changes since v1:
> * errno is returned in case failed ioctl
> * loop is terminated any time fm_mapped_extents == 0
> 
> 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>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  misc/create_inode.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/misc/create_inode.c b/misc/create_inode.c
> index 5122e56..d9e9b9b 100644
> --- a/misc/create_inode.c
> +++ b/misc/create_inode.c
> @@ -510,10 +510,12 @@ 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) {
>              err = errno;
>              goto out;
> -        }
> +        } else if (fiemap_buf->fm_mapped_extents == 0)
> +            goto out;
> +
>          for (i = 0, ext = ext_buf; i < fiemap_buf->fm_mapped_extents;
>               i++, ext++) {
>              err = copy_file_range(fs, fd, e2_file, ext->fe_logical,
> --
> --
> 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

  reply	other threads:[~2017-01-17 16:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 15:14 [PATCH v2] mke2fs: fix coping of empty file using fiemap Artem Blagodarenko
2017-01-17 16:49 ` Darrick J. Wong [this message]
2017-01-31  2:52 ` [v2] " Theodore Ts'o

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=20170117164902.GD14029@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=artem.blagodarenko@seagate.com \
    --cc=linux-ext4@vger.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;
as well as URLs for NNTP newsgroup(s).