Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Su Yue <l@damenly.su>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/3] btrfs: image: remove the dead stat() call
Date: Fri, 26 Mar 2021 22:08:36 +0800	[thread overview]
Message-ID: <sg4i6m4r.fsf@damenly.su> (raw)
In-Reply-To: <20210326125047.123694-2-wqu@suse.com>


On Fri 26 Mar 2021 at 20:50, Qu Wenruo <wqu@suse.com> wrote:

> In restore_metadump(), we call stat() but never uses the result 
> get.
>
> This call site is left by some code refactor, as the stat() call 
> is now
> moved into fixup_device_size().
>
fixup_device_size() already calls fstat() on out_fd.

Reviewed-by: Su Yue <l@damenly.su>


> So we can safely remove the call.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  image/main.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/image/main.c b/image/main.c
> index 48070e52c21f..24393188e5e3 100644
> --- a/image/main.c
> +++ b/image/main.c
> @@ -2690,7 +2690,6 @@ static int restore_metadump(const char 
> *input, FILE *out, int old_restore,
>  	if (!ret && !multi_devices && !old_restore &&
>  	    btrfs_super_num_devices(mdrestore.original_super) != 1) {
>  		struct btrfs_root *root;
> -		struct stat st;
>
>  		root = open_ctree_fd(fileno(out), target, 0,
>  					  OPEN_CTREE_PARTIAL |
> @@ -2703,13 +2702,6 @@ static int restore_metadump(const char 
> *input, FILE *out, int old_restore,
>  		}
>  		info = root->fs_info;
>
> -		if (stat(target, &st)) {
> -			error("stat %s failed: %m", target);
> -			close_ctree(info->chunk_root);
> -			free(cluster);
> -			return 1;
> -		}
> -
>  		ret = fixup_chunks_and_devices(info, &mdrestore, 
>  fileno(out));
>  		close_ctree(info->chunk_root);
>  		if (ret)


  reply	other threads:[~2021-03-26 14:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 12:50 [PATCH 0/3] btrfs-progs: image: make restored image file to be properly enlarged Qu Wenruo
2021-03-26 12:50 ` [PATCH 1/3] btrfs: image: remove the dead stat() call Qu Wenruo
2021-03-26 14:08   ` Su Yue [this message]
2021-03-26 12:50 ` [PATCH 2/3] btrfs-progs: image: enlarge the output file if no tree modification is needed for restore Qu Wenruo
2021-03-26 13:52   ` Su Yue
2021-03-26 14:29     ` Su Yue
2021-04-16 17:40   ` David Sterba
2021-04-17  0:17     ` Qu Wenruo
2021-03-26 12:50 ` [PATCH 3/3] btrfs-progs: misc-tests: add test to ensure the restored image can be mounted Qu Wenruo
2021-04-16 17:46   ` David Sterba
2021-04-17  0:18     ` Qu Wenruo

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=sg4i6m4r.fsf@damenly.su \
    --to=l@damenly.su \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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