From: Eric Sandeen <sandeen@sandeen.net>
To: Alex Elder <aelder@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>,
xfs mailing list <xfs@oss.sgi.com>,
tobias@lists.yoper.com
Subject: Re: [PATCH V2] fix readahead calculations in xfs_dir2_leaf_getdents()
Date: Wed, 07 Oct 2009 17:24:54 -0500 [thread overview]
Message-ID: <4ACD1536.9060004@sandeen.net> (raw)
In-Reply-To: <1AB9A794DBDDF54A8A81BE2296F7BDFE83AD38@cf--amer001e--3.americas.sgi.com>
Alex Elder wrote:
> Eric Sandeen wrote:
>> Christoph Hellwig wrote:
>>> On Fri, Sep 25, 2009 at 02:42:26PM -0500, Eric Sandeen wrote:
>>>> V2: use min() as suggested by Jeff, it's tidier.
>>> I disagree with that, with the cast it looks pretty horrible.
>>> At least use min_t to avoid the case, but what's wrong with:
>>>
>>>> + /* bufsize may have just been a guess; don't go negative */
>>>> + bufsize = min((bufsize - length), (size_t)0);
>>> bufsize = bufsize - length > 0 ? bufsize - length : 0;
>> ok, that's fine too.
>>
>> I'll pick one.
>>
>>> Anyway, takes this as a
>>>
>>>
>>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>>>
>>> for any variant.
>>>
>> thanks,
>> -Eric
>
> I'm going to put in this version:
>
> bufsize = bufsize > length ? bufsize - length : 0;
Fine by me, thanks!
-Eric
> I.e.:
>
> --- a/fs/xfs/xfs_dir2_leaf.c
> +++ b/fs/xfs/xfs_dir2_leaf.c
> @@ -854,6 +854,7 @@ xfs_dir2_leaf_getdents(
> */
> ra_want = howmany(bufsize + mp->m_dirblksize,
> mp->m_sb.sb_blocksize) - 1;
> + ASSERT(ra_want >= 0);
>
> /*
> * If we don't have as many as we want, and we haven't
> @@ -1088,7 +1089,8 @@ xfs_dir2_leaf_getdents(
> */
> ptr += length;
> curoff += length;
> - bufsize -= length;
> + /* bufsize may have just been a guess; don't go negative */
> + bufsize = bufsize > length ? bufsize - length : 0;
> }
>
> /*
>
> -Alex
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2009-10-07 22:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-23 16:49 [PATCH] fix readahead calculations in xfs_dir2_leaf_getdents() Eric Sandeen
2009-09-23 18:42 ` Eric Sandeen
2009-09-23 20:29 ` Michael Monnerie
2009-09-25 19:42 ` [PATCH V2] " Eric Sandeen
2009-09-26 17:04 ` Christoph Hellwig
2009-09-26 18:03 ` Eric Sandeen
2009-10-07 22:22 ` Alex Elder
2009-10-07 22:24 ` Eric Sandeen [this message]
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=4ACD1536.9060004@sandeen.net \
--to=sandeen@sandeen.net \
--cc=aelder@sgi.com \
--cc=hch@infradead.org \
--cc=tobias@lists.yoper.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox