Commit 3ca54671 authored by Steve French's avatar Steve French

fix readdir on empty directories to only issue one network search

parent 5225e3b5
......@@ -199,17 +199,18 @@ struct cifsLockInfo {
struct cifsFileInfo {
struct list_head tlist; /* pointer to next fid owned by tcon */
struct list_head flist; /* next fid (file instance) for this inode */
unsigned int uid; /* allows you to find which FileInfo structure */
unsigned int uid; /* allows finding which FileInfo structure */
__u32 pid; /* process id who opened file */
__u16 netfid; /* file id from remote */
/* BB add lock scope info here if needed */ ;
/* lock scope id (0 if none) */
struct file * pfile; /* needed for writepage */
struct file * pfile; /* needed for writepage */
int endOfSearch:1; /* we have reached end of search */
int closePend:1; /* file is marked to close */
char * search_resume_name;
unsigned int resume_name_length;
__u32 resume_key;
int emptyDir:1;
char * search_resume_name;
unsigned int resume_name_length;
__u32 resume_key;
};
/*
......
......@@ -1109,8 +1109,16 @@ cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
/* fallthrough */
case 2:
if (file->private_data != NULL) {
cFYI(1,("Search rewinding on %s",full_path));
CIFSFindClose(xid, pTcon, cifsFile->netfid);
cifsFile =
(struct cifsFileInfo *) file->private_data;
if (cifsFile->endOfSearch) {
if(cifsFile->emptyDir) {
cFYI(1, ("End of search, empty dir"));
rc = 0;
break;
}
} else
CIFSFindClose(xid, pTcon, cifsFile->netfid);
if(cifsFile->search_resume_name) {
kfree(cifsFile->search_resume_name);
cifsFile->search_resume_name = NULL;
......@@ -1261,10 +1269,12 @@ cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
(FILE_DIRECTORY_INFO *) ((char *) pfindData
+ le32_to_cpu(pfindData->NextEntryOffset));
/* BB also should check to make sure that pointer is not beyond the end of the SMB */
/* if(pfindData > lastFindData) rc = -EIOl; break; */
/* if(pfindData > lastFindData) rc = -EIO; break; */
} /* end for loop */
if ((findParms.EndofSearch != 0) && cifsFile) {
cifsFile->endOfSearch = TRUE;
if(findParms.SearchCount == 2)
cifsFile->emptyDir = TRUE;
}
} else {
if (cifsFile)
......
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