aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wedgwood <cw@f00f.org>2009-01-02 19:14:59 +0100
committerChristoph Hellwig <hch@brick.lst.de>2009-01-02 19:14:59 +0100
commitedd403b2c78e3df2777e41226c7305a363bdee70 (patch)
tree84c013791c3322559794d3516f9a10d9e35f968d
parent35d5e17222ca1705ca8c3f8750ac267e664e99ad (diff)
downloadxfsdump-dev-edd403b2c78e3df2777e41226c7305a363bdee70.tar.gz
xfs_fsr: fix insufficient space check
The xfs_fsr insufficient check should consider the blocks used not the file length. Without this change it is not possible to reorganize sparse files when file size exceeds the free space. Signed-off-by: Chris Wedgwood <cw@f00f.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--fsr/xfs_fsr.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 01243e21..c5cf0d52 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -880,17 +880,23 @@ fsrfile_common(
}
}
- /* Check if there is room to copy the file */
- if ( statvfs64( (fsname == NULL ? fname : fsname), &vfss) < 0) {
+ /*
+ * Check if there is room to copy the file.
+ *
+ * Note that xfs_bstat.bs_blksize returns the filesystem blocksize,
+ * not the optimal I/O size as struct stat.
+ */
+ if (statvfs64(fsname ? fsname : fname, &vfss) < 0) {
fsrprintf(_("unable to get fs stat on %s: %s\n"),
fname, strerror(errno));
- return (-1);
+ return -1;
}
bsize = vfss.f_frsize ? vfss.f_frsize : vfss.f_bsize;
-
- if (statp->bs_size > ((vfss.f_bfree * bsize) - minimumfree)) {
+ if (statp->bs_blksize * statp->bs_blocks >
+ vfss.f_bfree * bsize - minimumfree) {
fsrprintf(_("insufficient freespace for: %s: "
- "size=%lld: ignoring\n"), fname, statp->bs_size);
+ "size=%lld: ignoring\n"), fname,
+ statp->bs_blksize * statp->bs_blocks);
return 1;
}