Commit d1542cf6 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: compute full_path already in cifs_readdir()

Cleanup patch for followon to cache additional information for the root directory
when directory lease held.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 9e81e8ff
...@@ -360,11 +360,11 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb, ...@@ -360,11 +360,11 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb,
*/ */
static int static int
initiate_cifs_search(const unsigned int xid, struct file *file) initiate_cifs_search(const unsigned int xid, struct file *file,
char *full_path)
{ {
__u16 search_flags; __u16 search_flags;
int rc = 0; int rc = 0;
char *full_path = NULL;
struct cifsFileInfo *cifsFile; struct cifsFileInfo *cifsFile;
struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
struct tcon_link *tlink = NULL; struct tcon_link *tlink = NULL;
...@@ -400,12 +400,6 @@ initiate_cifs_search(const unsigned int xid, struct file *file) ...@@ -400,12 +400,6 @@ initiate_cifs_search(const unsigned int xid, struct file *file)
cifsFile->invalidHandle = true; cifsFile->invalidHandle = true;
cifsFile->srch_inf.endOfSearch = false; cifsFile->srch_inf.endOfSearch = false;
full_path = build_path_from_dentry(file_dentry(file));
if (full_path == NULL) {
rc = -ENOMEM;
goto error_exit;
}
cifs_dbg(FYI, "Full path: %s start at: %lld\n", full_path, file->f_pos); cifs_dbg(FYI, "Full path: %s start at: %lld\n", full_path, file->f_pos);
ffirst_retry: ffirst_retry:
...@@ -444,7 +438,6 @@ initiate_cifs_search(const unsigned int xid, struct file *file) ...@@ -444,7 +438,6 @@ initiate_cifs_search(const unsigned int xid, struct file *file)
goto ffirst_retry; goto ffirst_retry;
} }
error_exit: error_exit:
kfree(full_path);
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
return rc; return rc;
} }
...@@ -688,7 +681,8 @@ static int cifs_save_resume_key(const char *current_entry, ...@@ -688,7 +681,8 @@ static int cifs_save_resume_key(const char *current_entry,
*/ */
static int static int
find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos, find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
struct file *file, char **current_entry, int *num_to_ret) struct file *file, char *full_path,
char **current_entry, int *num_to_ret)
{ {
__u16 search_flags; __u16 search_flags;
int rc = 0; int rc = 0;
...@@ -741,7 +735,7 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos, ...@@ -741,7 +735,7 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
ntwrk_buf_start); ntwrk_buf_start);
cfile->srch_inf.ntwrk_buf_start = NULL; cfile->srch_inf.ntwrk_buf_start = NULL;
} }
rc = initiate_cifs_search(xid, file); rc = initiate_cifs_search(xid, file, full_path);
if (rc) { if (rc) {
cifs_dbg(FYI, "error %d reinitiating a search on rewind\n", cifs_dbg(FYI, "error %d reinitiating a search on rewind\n",
rc); rc);
...@@ -925,15 +919,22 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) ...@@ -925,15 +919,22 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)
char *tmp_buf = NULL; char *tmp_buf = NULL;
char *end_of_smb; char *end_of_smb;
unsigned int max_len; unsigned int max_len;
char *full_path = NULL;
xid = get_xid(); xid = get_xid();
full_path = build_path_from_dentry(file_dentry(file));
if (full_path == NULL) {
rc = -ENOMEM;
goto rddir2_exit;
}
/* /*
* Ensure FindFirst doesn't fail before doing filldir() for '.' and * Ensure FindFirst doesn't fail before doing filldir() for '.' and
* '..'. Otherwise we won't be able to notify VFS in case of failure. * '..'. Otherwise we won't be able to notify VFS in case of failure.
*/ */
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = initiate_cifs_search(xid, file); rc = initiate_cifs_search(xid, file, full_path);
cifs_dbg(FYI, "initiate cifs search rc %d\n", rc); cifs_dbg(FYI, "initiate cifs search rc %d\n", rc);
if (rc) if (rc)
goto rddir2_exit; goto rddir2_exit;
...@@ -960,8 +961,8 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) ...@@ -960,8 +961,8 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)
} */ } */
tcon = tlink_tcon(cifsFile->tlink); tcon = tlink_tcon(cifsFile->tlink);
rc = find_cifs_entry(xid, tcon, ctx->pos, file, &current_entry, rc = find_cifs_entry(xid, tcon, ctx->pos, file, full_path,
&num_to_fill); &current_entry, &num_to_fill);
if (rc) { if (rc) {
cifs_dbg(FYI, "fce error %d\n", rc); cifs_dbg(FYI, "fce error %d\n", rc);
goto rddir2_exit; goto rddir2_exit;
...@@ -1019,6 +1020,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) ...@@ -1019,6 +1020,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)
kfree(tmp_buf); kfree(tmp_buf);
rddir2_exit: rddir2_exit:
kfree(full_path);
free_xid(xid); free_xid(xid);
return rc; return rc;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment