Skip to content

use compounding to speed up readdir()

Ronnie Sahlberg linux-cifs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3cifs: prepare SMB2_query_directory to be used with compoundingfs/cifs/smb2pdu.c fs/cifs/smb2pdu.h fs/cifs/smb2proto.h+80 -352 replies
2/3cifs: create a helper function to parse the query-directory response bufferfs/cifs/smb2pdu.c+63 -470 replies
3/3cifs: use compounding for open and first query-dir for readdir()fs/cifs/cifsproto.h fs/cifs/smb2ops.c+87 -120 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] use compounding to speed up readdir()

Steve, List

This three patches are the first step in using compounding to speed up readdir() which currently takes a minimum of 4 roundtrips for any non-empty directory.
With these patches we reduce one roundtrip and we can list a directory in just 3, instead of 4, roundtrips which will benefit use-cases where latency to the server is high.

I.e. this changes the sequence of operations for a small directory from 1, Open
2, Query and get data
3, Query loop until we get STATUS_NO_MORE_FILES
4, Close

To be the slightly better
1, Open + Query and get data
2, Query and get STATUS_NO_MORE_FILES
3, Close

In later patches we can do even better and drive this down to just 2 roundtrips for a small nonempty directory by using
1, Open + Query + Query
2, Close
for the case where we get STATUS_NO_MORE_FILES for the second Query. And bring it down to just two roundtrips.

That is probably the best we can do for Windows based servers since without support for the SMB2_INDEX_SPECIFIED flag in the QueryDirectory request we can not put the Close() as part of the compound.

IF we had SMB2_INDEX_SPECIFIED support on some server (Azure?) and IF we
had a way to reliably detect if the server supports this flag or not then
we could change the sequence to be
Open + Query + Query + Close
and if the second Query returned STATUS_NO_MORE_FILES we would have finished thereaddir() in a single roundtrip. If the directory is large and the second query did not return this error then
we could just continue and use this compound instead to loop until we get to the end :
Open() + Query(SMB2_INDEX_SPECIFIED, Index) + Close()

regards
Ronnie Sahlberg