ShengLi has uploaded this change for review.

View Change

FSAL_CEPH: keep directory streams open between READDIR calls

Each READDIR opened a new libcephfs directory stream. Reopening the
stream discards its buffered entries and causes repeated MDS readdirs
when the directory cannot be served from the libcephfs cache.

Keep the stream and continue on it when a READDIR with the same
credentials resumes within what it read, and the change attribute of
the directory, fetched before reading, is unchanged. The Linux client
keeps only part of a reply and resumes before where the stream is, and
seeking back makes libcephfs drop its buffer. So the stream keeps a
bounded window of recently read entries, with their name, cookie and
inode number, and normally serves such a READDIR from the window and
the libcephfs inode cache instead of seeking back. A stream is kept
even at the end of the directory, unless one READDIR read all of it,
as the client may still resume within the last reply.

Kept streams are limited in number and released when idle, by the next
READDIR or a reaper thread, as they hold inodes in libcephfs. They are
also released when their export goes away, before the connection may be
aborted or shut down, as their directory handles may still be around.

In NFSv4.1 listing tests, 10k and 100k entry directories took 8 and 113
MDS readdirs instead of 138 and 1364. A directory that fits in the
libcephfs cache was also left complete, so the next listing was served
from it as long as it remained valid and was not trimmed.

Change-Id: Iba3c5113a0d002a8f00435d860c6c82c75ba6334
Signed-off-by: Sheng Li <50203418+LiShengG@users.noreply.github.com>
---
M src/FSAL/FSAL_CEPH/export.c
M src/FSAL/FSAL_CEPH/handle.c
M src/FSAL/FSAL_CEPH/internal.c
M src/FSAL/FSAL_CEPH/internal.h
M src/FSAL/FSAL_CEPH/main.c
5 files changed, 627 insertions(+), 45 deletions(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/71/1254771/1

To view, visit change 1254771. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: Iba3c5113a0d002a8f00435d860c6c82c75ba6334
Gerrit-Change-Number: 1254771
Gerrit-PatchSet: 1
Gerrit-Owner: ShengLi <50203418+LiShengG@users.noreply.github.com>