All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Lachlan McIlroy <lmcilroy@redhat.com>
Cc: xfs mailing list <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs_io: actually issue 0 size writes
Date: Thu, 13 Aug 2009 20:34:02 -0500	[thread overview]
Message-ID: <4A84BF0A.2020003@sandeen.net> (raw)
In-Reply-To: <318271513.1935011250211412750.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>

Lachlan McIlroy wrote:
> ----- "Eric Sandeen" <sandeen@sandeen.net> wrote:
> 
>> Felix Blyakher wrote:
>>> 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?
>> In general EFBIG or ENOSPC.
>>
>> This sort of thing in generic_write_checks():
>>
>>         if (unlikely(*pos >= inode->i_sb->s_maxbytes)) {
>>                 if (*count || *pos > inode->i_sb->s_maxbytes) {
>>                      return -EFBIG;
>>                 }
>>                 /* zero-length writes at ->s_maxbytes are OK */
>>         }
>>
>> Although I'm a little confused about why "*pos == s_maxbytes" is ok;
>> I
>> thought s_maxbytes was a count/size whereas pos is an offset, so it
>> seems to me that pos == s_maxbytes is one past the max.  But anyway,
>> that's mostly unrelated to the patch in this thread.  :)

> pos == s_maxbytes is only okay if count == 0 also.  So even though we
> are writing at the limit we are not actually going to write anything.
> At s_maxbytes-1 we are allowed to write one byte and at s_maxbytes we
> are allowed to write nothing - literally.

I think my confusion over maxbytes is whether it's a size or an offset.

The comment says ... max size.

Also in the above function it does i_size_read on the block device -
again a size.

If it's a max offset you're right; if it's a max -size- then pos ==
s_maxbytes is already off the end, one past the limit.

-eric

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

  reply	other threads:[~2009-08-14  1:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <139598026.1934901250211190252.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-08-14  0:56 ` [PATCH] xfs_io: actually issue 0 size writes Lachlan McIlroy
2009-08-14  1:34   ` Eric Sandeen [this message]
     [not found] <148381776.1936161250214905902.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-08-14  1:55 ` Lachlan McIlroy
2009-08-13 22:15 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

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=4A84BF0A.2020003@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=lmcilroy@redhat.com \
    --cc=xfs@oss.sgi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.