All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 3/3] xfs_fsr: test for more potential failures in packfile()
Date: Mon, 9 Jun 2014 09:02:49 -0400	[thread overview]
Message-ID: <20140609130249.GC31319@bfoster.bfoster> (raw)
In-Reply-To: <53922D67.2060906@sandeen.net>

On Fri, Jun 06, 2014 at 04:06:47PM -0500, Eric Sandeen wrote:
> Test for lseek, ftruncate, and fsync failures in packfile()
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

> 
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index 8b191e6..48629fd 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -1325,7 +1325,11 @@ packfile(char *fname, char *tname, int fd,
>  				fsrprintf(_("could not trunc tmp %s\n"),
>  					   tname);
>  			}
> -			lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR);
> +			if (lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
> +				fsrprintf(_("could not lseek in tmpfile: %s : %s\n"),
> +				   tname, strerror(errno));
> +				goto out;
> +			}
>  			continue;
>  		} else if (outmap[extent].bmv_length == 0) {
>  			/* to catch holes at the beginning of the file */
> @@ -1341,7 +1345,11 @@ packfile(char *fname, char *tname, int fd,
>  					" %s\n"), tname);
>  				goto out;
>  			}
> -			lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR);
> +			if (lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
> +				fsrprintf(_("could not lseek in tmpfile: %s : %s\n"),
> +				   tname, strerror(errno));
> +				goto out;
> +			}
>  		}
>  	} /* end of space allocation loop */
>  
> @@ -1365,8 +1373,16 @@ packfile(char *fname, char *tname, int fd,
>  	for (extent = 0; extent < nextents; extent++) {
>  		pos = outmap[extent].bmv_offset;
>  		if (outmap[extent].bmv_block == -1) {
> -			lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR);
> -			lseek64(fd, outmap[extent].bmv_length, SEEK_CUR);
> +			if (lseek64(tfd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
> +				fsrprintf(_("could not lseek in tmpfile: %s : %s\n"),
> +				   tname, strerror(errno));
> +				goto out;
> +			}
> +			if (lseek64(fd, outmap[extent].bmv_length, SEEK_CUR) < 0) {
> +				fsrprintf(_("could not lseek in file: %s : %s\n"),
> +				   fname, strerror(errno));
> +				goto out;
> +			}
>  			continue;
>  		} else if (outmap[extent].bmv_length == 0) {
>  			/* to catch holes at the beginning of the file */
> @@ -1442,8 +1458,16 @@ packfile(char *fname, char *tname, int fd,
>  			}
>  		}
>  	}
> -	ftruncate64(tfd, statp->bs_size);
> -	fsync(tfd);
> +	if (ftruncate64(tfd, statp->bs_size) < 0) {
> +		fsrprintf(_("could not truncate tmpfile: %s : %s\n"),
> +				fname, strerror(errno));
> +		goto out;
> +	}
> +	if (fsync(tfd) < 0) {
> +		fsrprintf(_("could not fsync tmpfile: %s : %s\n"),
> +				fname, strerror(errno));
> +		goto out;
> +	}
>  
>  	sx.sx_stat     = *statp; /* struct copy */
>  	sx.sx_version  = XFS_SX_VERSION;
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      reply	other threads:[~2014-06-09 13:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 20:57 [PATCH 0/3] xfs_fsr robustification Eric Sandeen
2014-06-06 21:03 ` [PATCH 1/3] xfs_fsr: ensure the line we read from leftofffile is null terminated Eric Sandeen
2014-06-09 13:02   ` Brian Foster
2014-06-09 14:01     ` Eric Sandeen
2014-06-09 14:29       ` Mark Tinguely
2014-06-06 21:04 ` [PATCH 2/3] xfs_fsr: create a cleanup/return target in packfile() Eric Sandeen
2014-06-09 13:02   ` Brian Foster
2014-06-06 21:06 ` [PATCH 3/3] xfs_fsr: test for more potential failures " Eric Sandeen
2014-06-09 13:02   ` Brian Foster [this message]

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=20140609130249.GC31319@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.