From: xiakaixu1987@gmail.com
To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: djwong@kernel.org, hch@infradead.org, Kaixu Xia <kaixuxia@tencent.com>
Subject: [PATCH] iomap: set did_zero to true when zeroing successfully
Date: Tue, 14 Jun 2022 17:14:22 +0800 [thread overview]
Message-ID: <1655198062-13288-1-git-send-email-kaixuxia@tencent.com> (raw)
From: Kaixu Xia <kaixuxia@tencent.com>
It is unnecessary to check and set did_zero value in while() loop,
we can set did_zero to true only when zeroing successfully at last.
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
fs/dax.c | 4 ++--
fs/iomap/buffered-io.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/dax.c b/fs/dax.c
index 4155a6107fa1..649ff51c9a26 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1088,10 +1088,10 @@ static s64 dax_zero_iter(struct iomap_iter *iter, bool *did_zero)
pos += size;
length -= size;
written += size;
- if (did_zero)
- *did_zero = true;
} while (length > 0);
+ if (did_zero)
+ *did_zero = true;
return written;
}
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index d2a9f699e17e..1cadb24a1498 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -917,10 +917,10 @@ static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
pos += bytes;
length -= bytes;
written += bytes;
- if (did_zero)
- *did_zero = true;
} while (length > 0);
+ if (did_zero)
+ *did_zero = true;
return written;
}
--
2.27.0
next reply other threads:[~2022-06-14 9:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 9:14 xiakaixu1987 [this message]
2022-06-15 22:07 ` [PATCH] iomap: set did_zero to true when zeroing successfully Chaitanya Kulkarni
2022-06-16 7:28 ` Christoph Hellwig
2022-06-16 11:14 ` Kaixu Xia
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=1655198062-13288-1-git-send-email-kaixuxia@tencent.com \
--to=xiakaixu1987@gmail.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=kaixuxia@tencent.com \
--cc=linux-fsdevel@vger.kernel.org \
--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).