| To: | xfs@xxxxxxxxxxx |
|---|---|
| Subject: | [PATCH] xfs_io: Prevent devide by zero from {pread,pwrite}_random |
| From: | Dmitry Monakhov <dmonakhov@xxxxxxxxxx> |
| Date: | Thu, 25 Feb 2016 19:20:53 +0400 |
| Delivered-to: | xfs@xxxxxxxxxxx |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:user-agent:date:message-id:mime-version :content-type; bh=zXu0cSDzNLPSQrmX1PI/TbHovlphFxRyS++29u1I6dE=; b=ciHFBjNwLzxHAHo7obfwI0G44tPEXDMAtElKH9c7asF+9uQUfQ15n6KA6Ohp9g3JRY 73DcFypGi5KoSxYzXtNRpp5+zUSHNioFUwYrtEZgfoKeQvUZq7jljkHdo8iyxkAw94tR JH6B1iOplKJ5/ekzdtSyF2htjB3n0fKMb2/bn6osg4BUEUfQXa9cYHUoMcw12O00g3ZD +dVfspc36EEbI1j7Zx6KbJXx/WfR17h4oSRHAUmgmwkAYf+o1xq3M5XJkyy/5bAaifoE 03Rgl9CCOtqVs1zVWr+7tEoRJiVeWG1uaJo8L155yEsxaPlsxQemqw12YaJMhrKQFKoL IpyQ== |
| Sender: | Dmitry Monakhov <rjevskiy@xxxxxxxxx> |
| User-agent: | Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-redhat-linux-gnu) |
Math is wrong if range requested is less or equals to block size
xfs_io -c 'pwrite -b 4k 8k 4k -R' \
-c 'pread -b 4k 4k 4k -R' -f file
Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
io/pread.c | 6 +++++-
io/pwrite.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/io/pread.c b/io/pread.c
index f16c86c..b98355f 100644
--- a/io/pread.c
+++ b/io/pread.c
@@ -245,7 +245,11 @@ read_random(
*total = 0;
while (count > 0) {
- off = ((offset + (random() % range)) / buffersize) * buffersize;
+ if (range)
+ off = ((offset + (random() % range)) / buffersize) *
+ buffersize;
+ else
+ off = offset;
bytes = do_pread(fd, off, buffersize, buffersize);
if (bytes == 0)
break;
diff --git a/io/pwrite.c b/io/pwrite.c
index 4fc8de6..67631ce 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -128,7 +128,11 @@ write_random(
*total = 0;
while (count > 0) {
- off = ((offset + (random() % range)) / buffersize) * buffersize;
+ if (range)
+ off = ((offset + (random() % range)) / buffersize) *
+ buffersize;
+ else
+ off = offset;
bytes = do_pwrite(file->fd, off, buffersize, buffersize);
if (bytes == 0)
break;
--
1.8.3.1
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH] xfs: remove impossible condition, Luis de Bethencourt |
|---|---|
| Next by Date: | Re: backport 7a29ac474a47eb8cf212b45917683ae89d6fa13b to stable ?, Jean-Tiare Le Bigot |
| Previous by Thread: | [PATCH] xfs: remove impossible condition, Luis de Bethencourt |
| Next by Thread: | How to copy files with preserving reflinks ?, Prasanna Kumar Kalever |
| Indexes: | [Date] [Thread] [Top] [All Lists] |