s3:smbd: don't use the directory cache for SMB2/3
[metze/samba/wip.git] / source3 / smbd / dir.c
index 2ed71752977a7d8e4d494cac33470f40f1bb7226..8bb66b8193617d6b094c1e54df96543e50a21334 100644 (file)
@@ -1224,7 +1224,15 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
                        mask, smb_fname_str_dbg(&smb_fname),
                        dname, fname));
 
-               DirCacheAdd(dirptr->dir_hnd, dname, cur_offset);
+               if (!conn->sconn->using_smb2) {
+                       /*
+                        * The dircache is only needed for SMB1 because SMB1
+                        * uses a name for the resume wheras SMB2 always
+                        * continues from the next position (unless it's told to
+                        * restart or close-and-reopen the listing).
+                        */
+                       DirCacheAdd(dirptr->dir_hnd, dname, cur_offset);
+               }
 
                TALLOC_FREE(dname);
 
@@ -1651,7 +1659,16 @@ static struct smb_Dir *OpenDir_internal(TALLOC_CTX *mem_ctx,
        }
 
        dirp->conn = conn;
-       dirp->name_cache_size = lp_directory_name_cache_size(SNUM(conn));
+
+       if (!conn->sconn->using_smb2) {
+               /*
+                * The dircache is only needed for SMB1 because SMB1 uses a name
+                * for the resume wheras SMB2 always continues from the next
+                * position (unless it's told to restart or close-and-reopen the
+                * listing).
+                */
+               dirp->name_cache_size = lp_directory_name_cache_size(SNUM(conn));
+       }
 
        if (sconn && !sconn->using_smb2) {
                sconn->searches.dirhandles_open++;
@@ -1773,7 +1790,16 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
        }
 
        dirp->conn = conn;
-       dirp->name_cache_size = lp_directory_name_cache_size(SNUM(conn));
+
+       if (!conn->sconn->using_smb2) {
+               /*
+                * The dircache is only needed for SMB1 because SMB1 uses a name
+                * for the resume wheras SMB2 always continues from the next
+                * position (unless it's told to restart or close-and-reopen the
+                * listing).
+                */
+               dirp->name_cache_size = lp_directory_name_cache_size(SNUM(conn));
+       }
 
        dirp->dir_smb_fname = cp_smb_filename(dirp, fsp->fsp_name);
        if (!dirp->dir_smb_fname) {