All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
To: Eric Sandeen <sandeen@redhat.com>
Cc: Andreas Dilger <adilger@whamcloud.com>,
	linux-ext4@vger.kernel.org, Fan Yong <yong.fan@whamcloud.com>,
	bfields@redhat.com
Subject: Re: [PATCH 5 2/4] Return 32/64-bit dir name hash according to usage type
Date: Tue, 24 Apr 2012 23:07:14 +0200	[thread overview]
Message-ID: <4F971602.7090005@itwm.fraunhofer.de> (raw)
In-Reply-To: <4F96FD45.9080902@redhat.com>

On 04/24/2012 09:21 PM, Eric Sandeen wrote:
> On 4/24/12 11:10 AM, Bernd Schubert wrote:
>> On 04/24/2012 12:42 AM, Andreas Dilger wrote:
>>> On 2012-04-23, at 5:23 PM, Eric Sandeen wrote:
>>>> I'm curious about the above as well as:
>>>>
>>>>         case SEEK_END:
>>>>                 if (unlikely(offset>  0))
>>>>                         goto out_err; /* not supported for directories */
>>>>
>>>> The previous .llseek handler, and the generic handler for other
>>>> filesystems, allow seeking past the end of the dir AFAICT. (not
>>>> sure why you'd want to, but I don't see that you'd get an error
>>>> back).
>>>>
>>>> Is there a reason to uniquely exclude it in ext4?  Does that line up with POSIX?
>>>
>>> I don't know what the origin of this was... I don't think there is
>>> a real reason for it except that it doesn't make any sense to do
>>> so.
>>>
>>
>> I think I added that. According to pubs.opengroup.org:
>> (http://pubs.opengroup.org/onlinepubs/009695399/functions/seekdir.html)
>>
>> void seekdir(DIR *dirp, long loc);
>>
>> <quote>
>>
>> If the value of loc was not obtained from an earlier call to
>> telldir(), or if a call to rewinddir() occurred between the call to
>> telldir() and the call to seekdir(), the results of subsequent calls
>> to readdir() are unspecified.
>>
>> </quote>
>>
>>
>> As telldir(), which should correlate to 'case SEEK_CUR' will not
>> provide invalid values, the behaviour is undefined.
>>
>>
>> Also,
>>
>>
>> case SEEK_END:
>> [...]
>>                 if (dx_dir)
>>                         offset += ext4_get_htree_eof(file);
>>                 else
>>                         offset += inode->i_size;
>> [...]
>>
>>
>>         if (!dx_dir) {
>>                 if (offset > inode->i_sb->s_maxbytes)
>>                         goto out_err;
>>         } else if (offset > ext4_get_htree_eof(file))
>>                 goto out_err;
>>
>>
>>
>>
>> Hence, the additional:
>>
>>          case SEEK_END:
>>                  if (unlikely(offset>  0))
>>                       goto out_err; /* not supported for directories */
>>
>>     
>> is just a shortcut to avoid useless calculations.
>>
>> Unless I missed something, it only remains the question if could
>> break existing applications relying on undefined behaviour. However,
>> I have no idea how an application might trigger that?
> 
> (other lists removed at this point, this is ext4-specific)
> 
> I know I'm being a little pedantic w/ the late review here....

That is fine, lets better be pedantic now than cause trouble to ext4
users...

> 
> It seems like the only differences between ext4_dir_llseek and the old ext4_llseek are these:
> 
> 1) For SEEK_END, we now return -EINVAL for a positive offset (i.e. past EOF)

I definitely introduces that one, as I cannot see how an application
might ever run into it. Especially as ext4 directories cannot shrink. So
if an application tries to exceed the directory size limit, it looks to
me as some of attempt to break something or as an error in the
application. However, if there should be the slightest chance to break
existing applications relying on that, we need to remove that.



I thought about 2) and 3) it on my way home and I think I remembered the
reason for it.

> 2) For SEEK_END, we seek to ext4_get_htree_eof() not to inode->i_size

Lets assume an application wants to seek to the last directory entry. If
it would seek to inode->i_size and then would attempt another readdir
from that offset, we probably would succeed, as inode->i_size is
probably just an arbitrary value in between two hashes, or even smaller
than the very first hash  value, so the next readdir() probably even
would read the very first  directory entry. I think i_size and
ext4_get_htree_eof()  makes a very big difference here.

> 3) For SEEK_SET, we impose different limits for max offset
>   - s_maxbytes / ext4_get_htree_eof for !dx/dx, vs. s_bitmap_maxbytes/s_maxbytes

Its a bit too late for me to check that today (and I'm almost
starving...), but is it possible that s_maxbytes is smaller than
ext4_get_htree_eof? So is possible that valid hash values get larger
than s_maxbytes? I will check that tomorrow morning.

> 
> Do any of these changes relate to the hash collision problem?  Are any of them uniquely
> required for ext4, enough to warrant cut & paste of the vfs llseek code (again?)
> 
> What I'm getting at is: what are the reasons that we cannot use generic_file_llseek_size(),
> maybe with a new argument to specify a non-standard location for SEEK_END.  Such
> a change would require a solid explanation, but it'd probably go in if it meant
> one less seek implementation to worry about.


I think we probably need to extent generic_file_llseek_size() by a
parameter 'max_fs_limit' (well something like that name, I don't find a
better one now) and then it should be possible to use it.


Cheers,
Bernd



  reply	other threads:[~2012-04-24 21:07 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 13:21 [PATCH 0/4] [RESEND] 32/64 bit llseek hashes (v5) Bernd Schubert
2012-01-09 13:21 ` [PATCH 5 1/4] Add new FMODE flags: FMODE_32bithash and FMODE_64bithash Bernd Schubert
2012-01-09 13:21 ` [PATCH 5 2/4] Return 32/64-bit dir name hash according to usage type Bernd Schubert
2012-03-05 15:59   ` Ted Ts'o
     [not found]     ` <20120305155939.GE21356-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-06  0:40       ` Bernd Schubert
2012-03-06  0:40         ` Bernd Schubert
2012-03-06  2:28         ` Ted Ts'o
     [not found]           ` <20120306022838.GA24323-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-06  9:59             ` Bernd Schubert
2012-03-06  9:59               ` Bernd Schubert
     [not found]               ` <4F55E01B.3060105-mPn0NPGs4xGatNDF+KUbs4QuADTiUCJX@public.gmane.org>
2012-03-06 15:15                 ` Ted Ts'o
2012-03-06 15:15                   ` Ted Ts'o
     [not found]                   ` <20120306151543.GA32282-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-07  9:01                     ` Bernd Schubert
2012-03-07  9:01                       ` Bernd Schubert
     [not found]   ` <20120109132148.2616029.68798.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2012-04-20 20:04     ` Eric Sandeen
2012-04-20 20:04       ` Eric Sandeen
     [not found]       ` <4F91C15B.6070200-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-22 12:51         ` Bernd Schubert
2012-04-22 12:51           ` Bernd Schubert
2012-04-23 20:37           ` Eric Sandeen
     [not found]             ` <4F95BD72.6090200-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-23 20:52               ` Bernd Schubert
2012-04-23 20:52                 ` Bernd Schubert
2012-04-23 21:22                 ` Eric Sandeen
     [not found]                 ` <4F95C109.1030401-mPn0NPGs4xGatNDF+KUbs4QuADTiUCJX@public.gmane.org>
2012-04-23 22:23                   ` Eric Sandeen
2012-04-23 22:23                     ` Eric Sandeen
2012-04-23 22:42                     ` Andreas Dilger
     [not found]                       ` <A754D23B-B946-4E80-ACEA-0E2C2E6FAA2E-KloliPT79xf2eFz/2MeuCQ@public.gmane.org>
2012-04-24 16:10                         ` Bernd Schubert
2012-04-24 16:10                           ` Bernd Schubert
2012-04-24 19:21                           ` Eric Sandeen
2012-04-24 21:07                             ` Bernd Schubert [this message]
2012-04-24 22:24                               ` Andreas Dilger
2012-04-25 15:05                                 ` Eric Sandeen
2012-04-25 15:12                                   ` Bernd Schubert
2012-04-25 15:36                                     ` Eric Sandeen
2012-04-24 21:28                             ` Andreas Dilger
2012-04-24 21:26                               ` Eric Sandeen
2012-01-09 13:21 ` [PATCH 5 3/4] nfsd_open(): rename 'int access' to 'int may_flags' in nfsd_open() Bernd Schubert
2012-01-09 13:21 ` [PATCH 5 4/4] nfsd: vfs_llseek() with 32 or 64 bit offsets (hashes) Bernd Schubert
     [not found]   ` <20120109132158.2616029.30467.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
     [not found]     ` <20120109132153.2616029.26302.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2012-03-06  0:08       ` [PATCH 5 3/4] nfsd_open(): rename 'int access' to 'int may_flags' in nfsd_open() Ted Ts'o
2012-03-06  0:08         ` Ted Ts'o
     [not found]         ` <20120306000837.GA17164-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-06  2:08           ` J. Bruce Fields
2012-03-06  2:08             ` J. Bruce Fields
2012-03-06 15:18             ` Ted Ts'o
2012-03-06 15:28               ` J. Bruce Fields
2012-03-09 20:51                 ` Ted Ts'o
     [not found]                   ` <20120309205148.GB5635-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-12 15:09                     ` Ted Ts'o
2012-03-12 15:09                       ` Ted Ts'o
     [not found]                       ` <20120312150912.GB12440-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-12 15:49                         ` J. Bruce Fields
2012-03-12 15:49                           ` J. Bruce Fields
2012-03-12 22:22                           ` J. Bruce Fields
2012-03-13 20:01                             ` J. Bruce Fields
     [not found]                               ` <20120313200117.GA21991-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-03-13 20:03                                 ` Bernd Schubert
2012-03-13 20:03                                   ` Bernd Schubert
     [not found]                                   ` <4F5FA827.8020606-mPn0NPGs4xGatNDF+KUbs4QuADTiUCJX@public.gmane.org>
2012-03-13 20:34                                     ` J. Bruce Fields
2012-03-13 20:34                                       ` J. Bruce Fields
2012-03-13 21:09                                       ` Bernd Schubert
2012-03-13 21:29                                         ` J. Bruce Fields
     [not found]                                           ` <20120313212947.GK31995-spRCxval1Z7TsXDwO4sDpg@public.gmane.org>
2012-03-14 14:32                                             ` Bernd Schubert
2012-03-14 14:32                                               ` Bernd Schubert
     [not found]                                               ` <4F60AC0D.9020204-mPn0NPGs4xGatNDF+KUbs4QuADTiUCJX@public.gmane.org>
2012-03-14 16:05                                                 ` J. Bruce Fields
2012-03-14 16:05                                                   ` J. Bruce Fields
     [not found]                                                   ` <20120314160529.GB31194-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-03-16 21:22                                                     ` Bernd Schubert
2012-03-16 21:22                                                       ` Bernd Schubert
2012-03-19  2:54                                                       ` Ted Ts'o
     [not found]                                                         ` <20120319025455.GD31682-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-19 20:00                                                           ` J. Bruce Fields
2012-03-19 20:00                                                             ` J. Bruce Fields
     [not found]                                                             ` <20120319200041.GA25161-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-03-20  0:10                                                               ` Ted Ts'o
2012-03-20  0:10                                                                 ` Ted Ts'o
2012-04-12 20:49                                                 ` J. Bruce Fields
2012-04-12 20:49                                                   ` J. Bruce Fields
     [not found]                                                   ` <20120412204948.GE6667-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-04-12 21:22                                                     ` Bernd Schubert
2012-04-12 21:22                                                       ` Bernd Schubert
     [not found]                                                       ` <4F8747A1.8060800-97jfqw80gc6171pxa8y+qA@public.gmane.org>
2012-04-12 21:25                                                         ` J. Bruce Fields
2012-04-12 21:25                                                           ` J. Bruce Fields
     [not found]                                       ` <20120313203446.GB21991-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-03-13 21:10                                         ` Ted Ts'o
2012-03-13 21:10                                           ` Ted Ts'o
     [not found]                                           ` <20120313211009.GA11969-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-03-13 21:27                                             ` J. Bruce Fields
2012-03-13 21:27                                               ` J. Bruce Fields
2012-01-10 11:27 ` [PATCH 0/4] [RESEND] 32/64 bit llseek hashes (v5) Andreas Dilger
2012-01-11 14:48   ` J. Bruce Fields
     [not found]     ` <20120111144827.GA32381-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-01-11 15:31       ` Ted Ts'o
2012-01-11 15:31         ` Ted Ts'o
2012-03-05 12:23         ` Bernd Schubert

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=4F971602.7090005@itwm.fraunhofer.de \
    --to=bernd.schubert@itwm.fraunhofer.de \
    --cc=adilger@whamcloud.com \
    --cc=bfields@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=yong.fan@whamcloud.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.