From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: eguan@redhat.com
Cc: Luis Henriques <lhenriques@suse.com>,
linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH] fsstress: avoid infinite loops in clonerange_f
Date: Fri, 23 Feb 2018 08:22:24 -0800 [thread overview]
Message-ID: <20180223162224.GD14582@magnolia> (raw)
From: Darrick J. Wong <darrick.wong@oracle.com>
Evidently ceph will report a 4M blocksize, which trips clonerange_f's
clumsy attempt to avoid reflinking an extent on top of itself. The
original code assumed that "pick a random destination up to 1MB past the
end of the file" would suffice, but that clearly won't with a 4M
blocksize. Instead, we'll change it to 1024*blksize.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Tested-by: Luis Henriques <lhenriques@suse.com>
---
ltp/fsstress.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 935f5de..e107099 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -2222,6 +2222,7 @@ clonerange_f(
off64_t lr;
off64_t off1;
off64_t off2;
+ off64_t max_off2;
size_t len;
int v1;
int v2;
@@ -2305,9 +2306,10 @@ clonerange_f(
* If srcfile == destfile, randomly generate destination ranges
* until we find one that doesn't overlap the source range.
*/
+ max_off2 = MIN(stat2.st_size + (1024ULL * stat2.st_blksize), MAXFSIZE);
do {
lr = ((int64_t)random() << 32) + random();
- off2 = (off64_t)(lr % MIN(stat2.st_size + (1024 * 1024), MAXFSIZE));
+ off2 = (off64_t)(lr % max_off2);
off2 %= maxfsize;
off2 &= ~(stat2.st_blksize - 1);
} while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len);
reply other threads:[~2018-02-23 16:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20180223162224.GD14582@magnolia \
--to=darrick.wong@oracle.com \
--cc=eguan@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=lhenriques@suse.com \
--cc=linux-xfs@vger.kernel.org \
/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).