smbd: Reset O_NONBLOCK on open files
authorVolker Lendecke <vl@samba.org>
Mon, 29 Aug 2016 07:58:45 +0000 (09:58 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 19 Sep 2016 11:44:01 +0000 (13:44 +0200)
See the comment inline :-)

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12268
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Simo <simo@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Sep 15 20:21:41 CEST 2016 on sn-devel-144

(cherry picked from commit e69b17d603e5f09ac1e7ee05fc1f5ad67288c484)

Autobuild-User(v4-4-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-4-test): Mon Sep 19 13:44:01 CEST 2016 on sn-devel-144

source3/smbd/open.c

index 5935ff569a5452de5abb9ff10b9285266637858d..90155bde99d9839e8af4a25f85dff5558e0bb313 100644 (file)
@@ -883,6 +883,25 @@ static NTSTATUS open_file(files_struct *fsp,
                        return status;
                }
 
+               if (local_flags & O_NONBLOCK) {
+                       /*
+                        * GPFS can return ETIMEDOUT for pread on
+                        * nonblocking file descriptors when files
+                        * migrated to tape need to be recalled. I
+                        * could imagine this happens elsehwere
+                        * too. With blocking file descriptors this
+                        * does not happen.
+                        */
+                       ret = set_blocking(fsp->fh->fd, true);
+                       if (ret == -1) {
+                               status = map_nt_error_from_unix(errno);
+                               DBG_WARNING("Could not set fd to blocking: "
+                                           "%s\n", strerror(errno));
+                               fd_close(fsp);
+                               return status;
+                       }
+               }
+
                ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
                if (ret == -1) {
                        /* If we have an fd, this stat should succeed. */