lkml.org 
[lkml]   [2018]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [CFT][PATCH] kernfs: Correct kernfs directory seeks.
Hello,

On Tue, Jun 05, 2018 at 10:31:36AM -0500, Eric W. Biederman wrote:
> What I have above is not the clearest, and in fact the logic could be
> better.
>
> The fundamental challenge is because hash collisions are possible a file
> offset does not hold complete position information in a directory.
>
> So the kernfs node that is to be read/displayed next is saved in the
> struct file. The it is tested if the saved kernfs node is usable
> for finding the location in the directory. Several things may have
> gone wrong.
>
> - Someone may have called seekdir.
> - The saved kernfs node may have been renamed.
> - The saved kernfs node may have been moved to a different directory in
> kernfs.
> - the saved kernfs node may have been deleted.
>
> If any of those are true the code needs to do the rbtree lookup.

So, given that the whole thing is protected by a mutex which protects
modifications, it could be an option to simply keep track of who's
iterating what and shift them on removals. IOW, always keep cursor
pointing to the next thing to visit and if that gets removed shift the
cursor to the next one.

Thanks.

--
tejun

\
 
 \ /
  Last update: 2018-06-05 17:42    [W:0.035 / U:7.660 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site