From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: david@fromorbit.com, darrick.wong@oracle.com
Cc: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org, xfs@oss.sgi.com
Subject: [PATCH 2/3] punch-alternating: use the block size reported by the fs for punching
Date: Mon, 15 Feb 2016 12:46:21 -0800 [thread overview]
Message-ID: <20160215204621.7977.91236.stgit@birch.djwong.org> (raw)
In-Reply-To: <20160215204608.7977.2802.stgit@birch.djwong.org>
When we're trying to punch alternating blocks out of a file, use the
bsize reported by fstatfs so that we can punch out single blocks.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
src/punch-alternating.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
index 9566310..4148622 100644
--- a/src/punch-alternating.c
+++ b/src/punch-alternating.c
@@ -14,6 +14,7 @@
int main(int argc, char *argv[])
{
struct stat s;
+ struct statfs sf;
off_t offset;
int fd;
blksize_t blksz;
@@ -35,8 +36,12 @@ int main(int argc, char *argv[])
if (error)
goto err;
+ error = fstatfs(fd, &sf);
+ if (error)
+ goto err;
+
sz = s.st_size;
- blksz = s.st_blksize;
+ blksz = sf.f_bsize;
mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
for (offset = 0; offset < sz; offset += blksz * 2) {
next prev parent reply other threads:[~2016-02-15 20:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 20:46 [PATCH v4.3 0/3] xfstests: minor fixes for the reflink/dedupe tests Darrick J. Wong
2016-02-15 20:46 ` [PATCH 1/3] generic/304: fix high offset Darrick J. Wong
2016-02-17 9:56 ` Christoph Hellwig
2016-02-17 10:04 ` Filipe Manana
2016-02-17 10:10 ` Christoph Hellwig
2016-02-15 20:46 ` Darrick J. Wong [this message]
2016-02-17 9:57 ` [PATCH 2/3] punch-alternating: use the block size reported by the fs for punching Christoph Hellwig
2016-02-15 20:46 ` [PATCH 3/3] xfs/24[356]: check for -c switch to xfs_io bmap command Darrick J. Wong
2016-02-17 9:58 ` Christoph Hellwig
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=20160215204621.7977.91236.stgit@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--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 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).