CIFS: Reopen the file if reconnect durable handle failed
authorPavel Shilovsky <pshilovsky@samba.org>
Thu, 11 Jul 2013 06:58:30 +0000 (10:58 +0400)
committerSteve French <smfrench@gmail.com>
Thu, 11 Jul 2013 23:05:08 +0000 (18:05 -0500)
This is a follow-on patch for 8/8 patch from the durable handles
series. It fixes the problem when durable file handle timeout
expired on the server and reopen returns -ENOENT for such files.
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/file.c

index ba7eed2ee6627d24aec664b8ee07c10ef2f89176..1dc9dea2ae70d0506f3112bd13627a2fa0da6028 100644 (file)
@@ -681,6 +681,13 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
         * not dirty locally we could do this.
         */
        rc = server->ops->open(xid, &oparms, &oplock, NULL);
+       if (rc == -ENOENT && oparms.reconnect == false) {
+               /* durable handle timeout is expired - open the file again */
+               rc = server->ops->open(xid, &oparms, &oplock, NULL);
+               /* indicate that we need to relock the file */
+               oparms.reconnect = true;
+       }
+
        if (rc) {
                mutex_unlock(&cfile->fh_mutex);
                cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc);
@@ -1510,7 +1517,6 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
                if (!rc)
                        goto out;
 
-
                /*
                 * Windows 7 server can delay breaking lease from read to None
                 * if we set a byte-range lock on a file - break it explicitly