]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove a smb1-only optimization findfirst/findnext
authorVolker Lendecke <vl@samba.org>
Fri, 16 Jun 2023 11:45:57 +0000 (13:45 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 16 Jun 2023 16:14:31 +0000 (16:14 +0000)
I don't think this is an effective optimization at all anymore. It was
intended to speed up non-wildcard readdirs after we found the correct
entry. Nowadays we do the non-wildcard readdirs by a direct fstatat,
and after we successfully found the entry dptr_ReadDirName()
immediately returns without any further action. So my very strong
guess is that this never really kicked in anymore. Not using this flag
can't be *that* bad, smb2 never used it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/globals.h
source3/smbd/smb1_trans2.c
source3/smbd/smb2_query_directory.c
source3/smbd/smb2_trans2.c

index c365f3b821a117731b4693ba55db693906ebafe9..96dee78119fd5c2cd8ce5bea62be56fc0108ac84 100644 (file)
@@ -208,7 +208,6 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               char *end_data,
                               int space_remaining,
                               struct smb_filename **smb_fname,
-                              bool *got_exact_match,
                               int *_last_entry_off,
                               struct ea_list *name_list,
                               struct file_id *file_id);
index bb64e7e73ae32aa15b8ff5961ffd2447d2d8b5fb..b13afd288f8e00c02b22e6baedfcd24129ae2762 100644 (file)
@@ -784,7 +784,6 @@ static NTSTATUS get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                char *base_data,
                                char *end_data,
                                int space_remaining,
-                               bool *got_exact_match,
                                int *last_entry_off,
                                struct ea_list *name_list)
 {
@@ -803,7 +802,6 @@ static NTSTATUS get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                         ppdata, base_data, end_data,
                                         space_remaining,
                                         NULL,
-                                        got_exact_match,
                                         last_entry_off, name_list, NULL);
 }
 
@@ -1114,7 +1112,6 @@ static void call_trans2findfirst(connection_struct *conn,
        ask_sharemode = fsp_search_ask_sharemode(fsp);
 
        for (i=0;(i<maxentries) && !finished && !out_of_space;i++) {
-               bool got_exact_match = False;
 
                ntstatus = get_lanman2_dir_entry(talloc_tos(),
                                                 conn,
@@ -1130,7 +1127,6 @@ static void call_trans2findfirst(connection_struct *conn,
                                                 pdata,
                                                 data_end,
                                                 space_remaining,
-                                                &got_exact_match,
                                                 &last_entry_off,
                                                 ea_list);
                if (NT_STATUS_EQUAL(ntstatus, NT_STATUS_ILLEGAL_CHARACTER)) {
@@ -1150,17 +1146,6 @@ static void call_trans2findfirst(connection_struct *conn,
                        numentries++;
                }
 
-               /*
-                * As an optimisation if we know we aren't looking
-                * for a wildcard name (ie. the name matches the wildcard exactly)
-                * then we can finish on any (first) match.
-                * This speeds up large directory searches. JRA.
-                */
-
-               if (got_exact_match) {
-                       finished = true;
-               }
-
                /* Ensure space_remaining never goes -ve. */
                if (PTR_DIFF(p,pdata) > max_data_bytes) {
                        space_remaining = 0;
@@ -1593,7 +1578,6 @@ static void call_trans2findnext(connection_struct *conn,
        ask_sharemode = fsp_search_ask_sharemode(fsp);
 
        for (i=0;(i<(int)maxentries) && !finished && !out_of_space ;i++) {
-               bool got_exact_match = False;
 
                ntstatus = get_lanman2_dir_entry(ctx,
                                                 conn,
@@ -1609,7 +1593,6 @@ static void call_trans2findnext(connection_struct *conn,
                                                 pdata,
                                                 data_end,
                                                 space_remaining,
-                                                &got_exact_match,
                                                 &last_entry_off,
                                                 ea_list);
                if (NT_STATUS_EQUAL(ntstatus, NT_STATUS_ILLEGAL_CHARACTER)) {
@@ -1629,17 +1612,6 @@ static void call_trans2findnext(connection_struct *conn,
                        numentries++;
                }
 
-               /*
-                * As an optimisation if we know we aren't looking
-                * for a wildcard name (ie. the name matches the wildcard exactly)
-                * then we can finish on any (first) match.
-                * This speeds up large directory searches. JRA.
-                */
-
-               if (got_exact_match) {
-                       finished = true;
-               }
-
                space_remaining = max_data_bytes - PTR_DIFF(p,pdata);
        }
 
index 3ac152a96dd7d9cdfd08c111c07b87276a910e0e..2017c03cae53d0e963bfd89272eb6d3ec96c96bc 100644 (file)
@@ -546,7 +546,6 @@ static bool smb2_query_directory_next_entry(struct tevent_req *req)
        struct smbd_smb2_query_directory_state *state = tevent_req_data(
                req, struct smbd_smb2_query_directory_state);
        struct smb_filename *smb_fname = NULL; /* relative to fsp !! */
-       bool got_exact_match = false;
        int off = state->out_output_buffer.length;
        int space_remaining = state->in_output_buffer_length - off;
        struct file_id file_id;
@@ -574,7 +573,6 @@ static bool smb2_query_directory_next_entry(struct tevent_req *req)
                                           state->end_data,
                                           space_remaining,
                                           &smb_fname,
-                                          &got_exact_match,
                                           &state->last_entry_off,
                                           NULL,
                                           &file_id);
index 955aee68fb5179d1b9db6483b17ba120562c8ba9..aac58c7b598a89e3cb1540ff504181498d4bfa22 100644 (file)
@@ -1912,7 +1912,6 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               char *end_data,
                               int space_remaining,
                               struct smb_filename **_smb_fname,
-                              bool *got_exact_match,
                               int *_last_entry_off,
                               struct ea_list *name_list,
                               struct file_id *file_id)
@@ -1941,8 +1940,6 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
        state.got_exact_match = false;
        state.case_sensitive = dptr_case_sensitive(dirptr);
 
-       *got_exact_match = false;
-
        p = strrchr_m(path_mask,'/');
        if(p != NULL) {
                if(p[1] == '\0') {
@@ -1971,8 +1968,6 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                return NT_STATUS_END_OF_FILE;
        }
 
-       *got_exact_match = state.got_exact_match;
-
        marshall_with_83_names = (mangled_names == MANGLED_NAMES_YES);
 
        status = smbd_marshall_dir_entry(ctx,