xfs
[Top] [All Lists]

Re: [PATCH] xfs_io: actually issue 0 size writes

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH] xfs_io: actually issue 0 size writes
From: Felix Blyakher <felixb@xxxxxxx>
Date: Thu, 13 Aug 2009 17:52:28 -0500
Cc: xfs mailing list <xfs@xxxxxxxxxxx>
In-reply-to: <4A849096.1010600@xxxxxxxxxxx>
References: <4A849096.1010600@xxxxxxxxxxx>

On Aug 13, 2009, at 5:15 PM, Eric Sandeen wrote:

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.

As I understand the desire to be able to issue 0 size writes
from xfs_io is to test the possibility of writing to a given fd.
What kind of errors would you expect to test for?

Otherwise looks good.

Felix



So fix that up.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxxx>
---

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@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs

<Prev in Thread] Current Thread [Next in Thread>