« Return to Thread: [PATCH] [CIFS] don't explicitly do a FindClose when directory search has ended

[PATCH] [CIFS] don't explicitly do a FindClose when directory search has ended

by Jeff Layton-2 :: Rate this Message:

Reply to Author | View in Thread

Do the following series of operations on a CIFS share:

    opendir(dir)
    readdir(dir)
    unlink(file in dir)
    rewinddir(dir)
    readdir(dir)

...this will make CIFS throw an error like this:

     CIFS VFS: Send error in FindClose = -9

CIFS sets the "Close at end of search" bit when doing a FindFirst or
FindNext. When we notice that a directory has changed after the last
operation, we attempt to close the directory before reissuing the second
FindFirst above. But, the directory has already been closed because the
first readdir finished. So we only want to issue a FindClose call when
we don't expect it to already be closed.

Signed-off-by: Jeff Layton <jlayton@...>

[0001-CIFS-don-t-explicitly-do-a-FindClose-when-director.patch]

>From f30ac7ea92f304acd3fef098c0f4c4178aca6b8f Mon Sep 17 00:00:00 2001
From: Jeff Layton <jlayton@...>
Date: Tue, 13 May 2008 13:58:13 -0700
Subject: [PATCH] [CIFS] don't explicitly do a FindClose when directory search has ended

Do the following series of operations on a CIFS share:

    opendir(dir)
    readdir(dir)
    unlink(file in dir)
    rewinddir(dir)
    readdir(dir)

...this will make CIFS throw an error like this:

     CIFS VFS: Send error in FindClose = -9

CIFS sets the "Close at end of search" bit when doing a FindFirst or
FindNext. When we notice that a directory has changed after the last
operation, we attempt to close the directory before reissuing the second
FindFirst above. But, the directory has already been closed because the
first readdir finished. So we only want to issue a FindClose call when
we don't expect it to already be closed.

Signed-off-by: Jeff Layton <jlayton@...>
---
 fs/cifs/readdir.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 34ec321..cbd8863 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -670,8 +670,11 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
    (index_to_find < first_entry_in_buffer)) {
  /* close and restart search */
  cFYI(1, ("search backing up - close and restart search"));
- cifsFile->invalidHandle = true;
- CIFSFindClose(xid, pTcon, cifsFile->netfid);
+                if (!cifsFile->srch_inf.endOfSearch &&
+                    !cifsFile->invalidHandle) {
+ cifsFile->invalidHandle = true;
+ CIFSFindClose(xid, pTcon, cifsFile->netfid);
+ }
  kfree(cifsFile->search_resume_name);
  cifsFile->search_resume_name = NULL;
  if (cifsFile->srch_inf.ntwrk_buf_start) {
--
1.5.4.5



_______________________________________________
linux-cifs-client mailing list
linux-cifs-client@...
https://lists.samba.org/mailman/listinfo/linux-cifs-client

 « Return to Thread: [PATCH] [CIFS] don't explicitly do a FindClose when directory search has ended

LightInTheBox - Buy quality products at wholesale price