xfs
[Top] [All Lists]

Re: [PATCH 3/3] xfs_fsr: test for more potential failures in packfile()

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH 3/3] xfs_fsr: test for more potential failures in packfile()
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Mon, 9 Jun 2014 09:02:49 -0400
Cc: Eric Sandeen <sandeen@xxxxxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <53922D67.2060906@xxxxxxxxxxx>
References: <53922B49.1050005@xxxxxxxxxx> <53922D67.2060906@xxxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
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@xxxxxxxxxx>
> ---

Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>

> 
> 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@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

<Prev in Thread] Current Thread [Next in Thread>