>From Frank Filz <ffilz...@mindspring.com>:

Frank Filz has uploaded this change for review. ( 
https://review.gerrithub.io/405345


Change subject: VFS: Use d_off from previous dirent as cookie
......................................................................

VFS: Use d_off from previous dirent as cookie

The POSIX spec for struct dirent has a d_off field. That value is
presented to lseek on the directory fd to get the next dirent. The
way filesystems seem to compute d_off is a name hash of the name
of the next dirent, which sort of makes sense, if you will lseek to
the next entry, you want an "offset" or "address" of that entry, not
the one you just processed.

The problem is that when creates and deletes race with readdir, the
"next" entry may change. It is actually possible to wind up with two
dirents showing the same d_off if an entry was inserted.

What this patch does is remember the previous d_off (using FIRST_COOKIE
as the "previous" d_off for the first dirent) and use that as the cookie
for a given dirent. Now the cookie for each dirent should be stable and
unique (baring hash collisions, but that was all but eliminated with the
expansion of d_off from 32 bits to 64 bits - well actually 31 to 63...).

The downside is that when presented a cookie to continue readdir from,
we will use it in lseek, and fetch an entry already fetched. We just
skip that entry and start presenting the next entry.

This should result in much more stable dirent cache.

Change-Id: Ic7ca96e79f285d41797cfdd49028f27113fa8dc0
Signed-off-by: Frank S. Filz <ffilz...@mindspring.com>
---
M src/FSAL/FSAL_VFS/handle.c
1 file changed, 42 insertions(+), 4 deletions(-)



  git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha 
refs/changes/45/405345/1
-- 
To view, visit https://review.gerrithub.io/405345
To unsubscribe, visit https://review.gerrithub.io/settings

Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7ca96e79f285d41797cfdd49028f27113fa8dc0
Gerrit-Change-Number: 405345
Gerrit-PatchSet: 1
Gerrit-Owner: Frank Filz <ffilz...@mindspring.com>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to