From: Volker Lendecke Date: Fri, 16 Jun 2023 11:45:57 +0000 (+0200) Subject: smbd: Remove a smb1-only optimization findfirst/findnext X-Git-Tag: talloc-2.4.1~337 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=079aad50ef47f34453eee9911655872397635c88;p=thirdparty%2Fsamba.git smbd: Remove a smb1-only optimization findfirst/findnext 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index c365f3b821a..96dee78119f 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -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); diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index bb64e7e73ae..b13afd288f8 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -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 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); } diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c index 3ac152a96dd..2017c03cae5 100644 --- a/source3/smbd/smb2_query_directory.c +++ b/source3/smbd/smb2_query_directory.c @@ -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); diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 955aee68fb5..aac58c7b598 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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,