public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_io: actually issue 0 size writes
@ 2009-08-13 22:15 Eric Sandeen
  2009-08-13 22:52 ` Felix Blyakher
  2009-08-26 22:11 ` Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Sandeen @ 2009-08-13 22:15 UTC (permalink / raw)
  To: xfs mailing list

While testing some stuff in generic_write_checks() in the
kernel I realized that you can't actually use xfs_io to send
a 0-byte write in.  This is actually a condition worth testing:

       If  count  is zero and fd refers to a regular file,
       then write() may return a failure status if one  of
       the  errors  below  is  detected.  If no errors are
       detected, 0 will be returned  without  causing  any
       other  effect.

So fix that up.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---

iff --git a/io/pwrite.c b/io/pwrite.c
index 54c3f78..26a7850 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -163,7 +163,7 @@ write_buffer(
 	int		ops = 0;
 
 	*total = 0;
-	while (count > 0) {
+	while (count >= 0) {
 		if (fd > 0) {	/* input file given, read buffer first */
 			if (read_buffer(fd, skip + *total, bs, &bar, 0, 1) < 0)
 				break;
@@ -182,6 +182,8 @@ write_buffer(
 			break;
 		offset += bytes;
 		count -= bytes;
+		if (count == 0)
+			break;
 	}
 	return ops;
 }

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread
[parent not found: <139598026.1934901250211190252.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>]
[parent not found: <148381776.1936161250214905902.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>]

end of thread, other threads:[~2009-08-26 23:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-13 22:15 [PATCH] xfs_io: actually issue 0 size writes Eric Sandeen
2009-08-13 22:52 ` Felix Blyakher
2009-08-14  0:15   ` Eric Sandeen
2009-08-26 22:11 ` Christoph Hellwig
2009-08-26 23:26   ` Eric Sandeen
     [not found] <139598026.1934901250211190252.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-08-14  0:56 ` Lachlan McIlroy
2009-08-14  1:34   ` Eric Sandeen
     [not found] <148381776.1936161250214905902.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-08-14  1:55 ` Lachlan McIlroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox