Linux-CIFS Archive on
 help / color / Atom feed
From: Ronnie Sahlberg <>
To: linux-cifs <>
Subject: [PATCH 0/3] use compounding to speed up readdir()
Date: Thu,  5 Dec 2019 08:54:07 +1000
Message-ID: <> (raw)

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
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()

Ronnie Sahlberg

             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 22:54 Ronnie Sahlberg [this message]
2019-12-04 22:54 ` [PATCH 1/3] cifs: prepare SMB2_query_directory to be used with compounding Ronnie Sahlberg
2019-12-04 22:54 ` [PATCH 2/3] cifs: create a helper function to parse the query-directory response buffer Ronnie Sahlberg
2019-12-04 22:54 ` [PATCH 3/3] cifs: use compounding for open and first query-dir for readdir() Ronnie Sahlberg

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-CIFS Archive on

Archives are clonable:
	git clone --mirror linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ \
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone