Jeremy Allison
2023-Feb-27 19:07 UTC
[Samba] Missing Files/Missing Folders from an NFS Share
On Mon, Feb 27, 2023 at 08:01:40PM +0100, Conor Armstrong wrote:> I think it has a lot to do with telldir on an NFS share returning a cookie > that is supposed to be unique rather than an actual offset. Problem is, > that cookie is stored as a 31bit hash which can then end up as a negative > signed offset in Samba which is not handled correctly. The cookies are not > necessarily consecutive as you move through a directory. ?We only store the returned cookie as a 'long' from telldir(), and then use it to get to the same position again via seekdir(). There isn't any interpretation of the actual value inside Samba other than 3 'magic' values we use #defined here: /* "Special" directory offsets. */ #define END_OF_DIRECTORY_OFFSET ((long)-1) #define START_OF_DIRECTORY_OFFSET ((long)0) #define DOT_DOT_DIRECTORY_OFFSET ((long)0x80000000) So long as telldir() doesn't return any of these, we should work fine. We don't expect the cookies to be consecutive or in any order for that matter. So I would take issue with your statement: "can then end up as a negative signed offset in Samba which is not handled correctly" :-).
Conor Armstrong
2023-Feb-27 19:10 UTC
[Samba] Missing Files/Missing Folders from an NFS Share
Ok, fair enough, but the debug level 9 logs are showing negative offsets. Can?t explain that other than the signed/unsigned issue. Maybe this relevant here: https://lwn.net/Articles/544520/ On Mon, 27 Feb 2023 at 20:07, Jeremy Allison <jra at samba.org> wrote:> On Mon, Feb 27, 2023 at 08:01:40PM +0100, Conor Armstrong wrote: > > I think it has a lot to do with telldir on an NFS share returning a > cookie > > that is supposed to be unique rather than an actual offset. Problem is, > > that cookie is stored as a 31bit hash which can then end up as a > negative > > signed offset in Samba which is not handled correctly. The cookies are > not > > necessarily consecutive as you move through a directory. > > We only store the returned cookie as a 'long' from telldir(), and then use > it to get to the same position again via seekdir(). There isn't any > interpretation of the actual value inside Samba other than 3 'magic' > values we use #defined here: > > /* "Special" directory offsets. */ > #define END_OF_DIRECTORY_OFFSET ((long)-1) > #define START_OF_DIRECTORY_OFFSET ((long)0) > #define DOT_DOT_DIRECTORY_OFFSET ((long)0x80000000) > > So long as telldir() doesn't return any of these, > we should work fine. We don't expect the cookies > to be consecutive or in any order for that matter. > > So I would take issue with your statement: > > "can then end up as a negative signed offset in Samba which is not handled > correctly" > > :-). >