Move down the become_root()/unbecome_root() calls into the VFS modules
authorVolker Lendecke <vl@samba.org>
Mon, 18 May 2009 11:30:16 +0000 (13:30 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 18 May 2009 11:51:42 +0000 (13:51 +0200)
The aio_fork module does not need this, as it does not communicate via signals
but with pipes. Watching a strace log with those become_root() calls in aio.c
is absolutely awful, and it does affect performance.

source/modules/vfs_default.c
source/smbd/aio.c

index d46f48a67082ca87a6c5304dccb3a507ae26263d..6505c79b65e70d54c4b83d433d69c0cbbcd16c95 100644 (file)
@@ -1286,12 +1286,20 @@ static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_stru
 
 static int vfswrap_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
 {
-       return sys_aio_read(aiocb);
+       int ret;
+       become_root();
+       ret = sys_aio_read(aiocb);
+       unbecome_root();
+       return ret;
 }
 
 static int vfswrap_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
 {
-       return sys_aio_write(aiocb);
+       int ret;
+       become_root();
+       ret = sys_aio_write(aiocb);
+       unbecome_root();
+       return ret;
 }
 
 static ssize_t vfswrap_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
index c3fd0a2bc0e3f1c3a448b72c4f0738401ca1f426..5c54d270db90d611f9ee37a8cb7c0659e6c98406 100644 (file)
@@ -278,15 +278,12 @@ bool schedule_aio_read_and_X(connection_struct *conn,
        a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
        a->aio_sigevent.sigev_value.sival_int = aio_ex->mid;
 
-       become_root();
        if (SMB_VFS_AIO_READ(fsp,a) == -1) {
                DEBUG(0,("schedule_aio_read_and_X: aio_read failed. "
                         "Error %s\n", strerror(errno) ));
                delete_aio_ex(aio_ex);
-               unbecome_root();
                return False;
        }
-       unbecome_root();
 
        DEBUG(10,("schedule_aio_read_and_X: scheduled aio_read for file %s, "
                  "offset %.0f, len = %u (mid = %u)\n",
@@ -379,15 +376,12 @@ bool schedule_aio_write_and_X(connection_struct *conn,
        a->aio_sigevent.sigev_signo  = RT_SIGNAL_AIO;
        a->aio_sigevent.sigev_value.sival_int = aio_ex->mid;
 
-       become_root();
        if (SMB_VFS_AIO_WRITE(fsp,a) == -1) {
                DEBUG(3,("schedule_aio_wrote_and_X: aio_write failed. "
                         "Error %s\n", strerror(errno) ));
                delete_aio_ex(aio_ex);
-               unbecome_root();
                return False;
        }
-       unbecome_root();
        
        release_level_2_oplocks_on_change(fsp);