diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-10-28 21:48:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:04:57 -0500 |
commit | 019719595778e0bd0a00781b33407554d1943985 (patch) | |
tree | dd54db0a15f72d5fe4a63a5104d120bcae735fba /source4/ntvfs | |
parent | 94c0b939c4735866945aea8b7a0377be4d814125 (diff) | |
download | samba-019719595778e0bd0a00781b33407554d1943985.tar.gz samba-019719595778e0bd0a00781b33407554d1943985.tar.bz2 samba-019719595778e0bd0a00781b33407554d1943985.zip |
r3336: use a struct ntvfs_async_state to be able to do async chaning of ntvfs modules
the idea is that a passthru module can use ntvfs_async_state_push() before
calling ntvfs_next_*() and in the _send function it calls
ntvfs_async_state_pop() and then call the upper layer send_fn itself
- ntvfs_nbench is now fully async
- the ntvfs_map_*() functions and the trans(2) mapping functions are not converted yet
metze
(This used to be commit fde64c0dc142b53d128c8ba09af048dc58d8ef3a)
Diffstat (limited to 'source4/ntvfs')
-rw-r--r-- | source4/ntvfs/cifs/vfs_cifs.c | 78 | ||||
-rw-r--r-- | source4/ntvfs/nbench/vfs_nbench.c | 565 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs.h | 33 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_base.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_generic.c | 8 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_util.c | 38 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_lock.c | 14 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_wait.c | 2 |
8 files changed, 508 insertions, 232 deletions
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 1a0f1f2f71..9c5cfd9584 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -182,8 +182,8 @@ static void async_simple(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smbcli_request_simple_recv(c_req); - req->async.send_fn(req); + req->async_states->status = smbcli_request_simple_recv(c_req); + req->async_states->send_fn(req); } @@ -199,7 +199,7 @@ static void async_simple(struct smbcli_request *c_req) c_req->async.private = async; \ } \ c_req->async.fn = async_fn; \ - req->control_flags |= REQ_CONTROL_ASYNC; \ + req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; \ return NT_STATUS_OK; \ } while (0) @@ -219,7 +219,7 @@ static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, /* see if the front end will allow us to perform this function asynchronously. */ - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_unlink(private->tree, unl); } @@ -235,8 +235,8 @@ static void async_ioctl(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_ioctl_recv(c_req, req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_ioctl_recv(c_req, req, async->parms); + req->async_states->send_fn(req); } /* @@ -252,7 +252,7 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, /* see if the front end will allow us to perform this function asynchronously. */ - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_ioctl(private->tree, req, io); } @@ -272,7 +272,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_chkpath(private->tree, cp); } @@ -288,8 +288,8 @@ static void async_qpathinfo(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_pathinfo_recv(c_req, req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_pathinfo_recv(c_req, req, async->parms); + req->async_states->send_fn(req); } /* @@ -303,7 +303,7 @@ static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_pathinfo(private->tree, req, info); } @@ -319,8 +319,8 @@ static void async_qfileinfo(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_fileinfo_recv(c_req, req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_fileinfo_recv(c_req, req, async->parms); + req->async_states->send_fn(req); } /* @@ -334,7 +334,7 @@ static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_fileinfo(private->tree, req, info); } @@ -355,7 +355,7 @@ static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_setpathinfo(private->tree, st); } @@ -372,8 +372,8 @@ static void async_open(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_open_recv(c_req, req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_open_recv(c_req, req, async->parms); + req->async_states->send_fn(req); } /* @@ -392,7 +392,7 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, return ntvfs_map_open(req, io, ntvfs); } - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_open(private->tree, req, io); } @@ -412,7 +412,7 @@ static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_mkdir(private->tree, md); } @@ -432,7 +432,7 @@ static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_rmdir(private->tree, rd); } c_req = smb_raw_rmdir_send(private->tree, rd); @@ -451,7 +451,7 @@ static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_rename(private->tree, ren); } @@ -476,8 +476,8 @@ static void async_read(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_read_recv(c_req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_read_recv(c_req, async->parms); + req->async_states->send_fn(req); } /* @@ -496,7 +496,7 @@ static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, return ntvfs_map_read(req, rd, ntvfs); } - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_read(private->tree, rd); } @@ -512,8 +512,8 @@ static void async_write(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_write_recv(c_req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_write_recv(c_req, async->parms); + req->async_states->send_fn(req); } /* @@ -532,7 +532,7 @@ static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, return ntvfs_map_write(req, wr, ntvfs); } - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_write(private->tree, wr); } @@ -552,7 +552,7 @@ static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_seek(private->tree, io); } @@ -572,7 +572,7 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_flush(private->tree, io); } @@ -597,7 +597,7 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, return ntvfs_map_close(req, io, ntvfs); } - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_close(private->tree, io); } @@ -617,7 +617,7 @@ static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_exit(private->tree->session); } @@ -662,7 +662,7 @@ static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs, return ntvfs_map_lock(req, lck, ntvfs); } - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_lock(private->tree, lck); } @@ -682,7 +682,7 @@ static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_setfileinfo(private->tree, info); } c_req = smb_raw_setfileinfo_send(private->tree, info); @@ -698,8 +698,8 @@ static void async_fsinfo(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_fsinfo_recv(c_req, req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_fsinfo_recv(c_req, req, async->parms); + req->async_states->send_fn(req); } /* @@ -713,7 +713,7 @@ static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_fsinfo(private->tree, req, fs); } @@ -777,8 +777,8 @@ static void async_trans2(struct smbcli_request *c_req) { struct async_info *async = c_req->async.private; struct smbsrv_request *req = async->req; - req->async.status = smb_raw_trans2_recv(c_req, req, async->parms); - req->async.send_fn(req); + req->async_states->status = smb_raw_trans2_recv(c_req, req, async->parms); + req->async_states->send_fn(req); } /* raw trans2 */ @@ -790,7 +790,7 @@ static NTSTATUS cvfs_trans2(struct ntvfs_module_context *ntvfs, SETUP_PID; - if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_trans2(private->tree, req, trans2); } diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index 482f0208a2..ab2d7af7b1 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -47,7 +47,7 @@ static void nbench_log(struct nbench_private *private, vasprintf(&s, format, ap); va_end(ap); - write(private->log_fd, s, strlen(s)); + //write(private->log_fd, s, strlen(s)); free(s); } @@ -58,11 +58,39 @@ static void nbench_log(struct nbench_private *private, async calls are a pain for the nbench module as it makes pulling the status code and any result parameters much harder. */ -#define PASS_THRU_REQ(ntvfs, req, op, args) do { \ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; \ +#define PASS_THRU_REQ_PRE_ASYNC(ntvfs, req, op, par1) do { \ + status = ntvfs_async_state_push(req, par1, nbench_##op##_send, ntvfs); \ + if (!NT_STATUS_IS_OK(status)) { \ + return status; \ + } \ +} while (0) + +#define PASS_THRU_REQ_POST_ASYNC(req) do { \ + req->async_states->status = status; \ + if (!(req->async_states->state & NTVFS_ASYNC_STATE_ASYNC)) { \ +DEBUG(0,("NBENCH S 0x%04X: %s: %s 0x%X\n", req->mid, __FUNCTION__, nt_errstr(status),req->async_states->state)); \ + req->async_states->send_fn(req); \ + } else { \ +DEBUG(0,("NBENCH A 0x%04X: %s: %s\n", req->mid, __FUNCTION__, nt_errstr(status))); \ + } \ +} while (0) + +#define PASS_THRU_REQ(ntvfs, req, op, par1, args) do { \ + PASS_THRU_REQ_PRE_ASYNC(ntvfs, req, op, par1); \ status = ntvfs_next_##op args; \ + PASS_THRU_REQ_POST_ASYNC(req); \ } while (0) +#define PASS_THRU_REP_POST(req) do { \ + ntvfs_async_state_pop(req); \ + if (req->async_states->state & NTVFS_ASYNC_STATE_ASYNC) { \ +DEBUG(0,("NBENCH A0x%04X: %s: %s\n", req->mid, __FUNCTION__, nt_errstr(req->async_states->status))); \ + req->async_states->send_fn(req); \ + } \ +} while (0) + +#define PASS_THRU_REP_PRE(req) \ + struct nbench_private *nprivates = req->async_states->ntvfs->private_data /* connect to a share - used when a tree_connect operation comes in. @@ -70,25 +98,25 @@ static void nbench_log(struct nbench_private *private, static NTSTATUS nbench_connect(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, const char *sharename) { - struct nbench_private *private; + struct nbench_private *nprivates; NTSTATUS status; char *logname = NULL; - private = talloc_p(req->tcon, struct nbench_private); - if (!private) { + nprivates = talloc_p(req->tcon, struct nbench_private); + if (!nprivates) { return NT_STATUS_NO_MEMORY; } - +#if 0 asprintf(&logname, "/tmp/nbenchlog%d.%u", ntvfs->depth, getpid()); - private->log_fd = sys_open(logname, O_WRONLY|O_CREAT|O_APPEND, 0644); + nprivates->log_fd = sys_open(logname, O_WRONLY|O_CREAT|O_APPEND, 0644); free(logname); - if (private->log_fd == -1) { + if (nprivates->log_fd == -1) { DEBUG(0,("Failed to open nbench log\n")); return NT_STATUS_UNSUCCESSFUL; } - - ntvfs->private_data = private; +#endif + ntvfs->private_data = nprivates; status = ntvfs_next_connect(ntvfs, req, sharename); @@ -101,13 +129,13 @@ static NTSTATUS nbench_connect(struct ntvfs_module_context *ntvfs, static NTSTATUS nbench_disconnect(struct ntvfs_module_context *ntvfs, struct smbsrv_tcon *tcon) { - struct nbench_private *private = ntvfs->private_data; + struct nbench_private *nprivates = ntvfs->private_data; NTSTATUS status; - close(private->log_fd); + close(nprivates->log_fd); status = ntvfs_next_disconnect(ntvfs, tcon); - + return status; } @@ -115,17 +143,24 @@ static NTSTATUS nbench_disconnect(struct ntvfs_module_context *ntvfs, delete a file - the dirtype specifies the file types to include in the search. The name can contain CIFS wildcards, but rarely does (except with OS/2 clients) */ +static void nbench_unlink_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + struct smb_unlink *unl = req->async_states->private_data; + + nbench_log(nprivates, "Unlink \"%s\" 0x%x %s\n", + unl->in.pattern, unl->in.attrib, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_unlink(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_unlink *unl) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, unlink, (ntvfs, req, unl)); - - nbench_log(private, "Unlink \"%s\" 0x%x %s\n", - unl->in.pattern, unl->in.attrib, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, unlink, unl, (ntvfs, req, unl)); return status; } @@ -133,15 +168,21 @@ static NTSTATUS nbench_unlink(struct ntvfs_module_context *ntvfs, /* ioctl interface */ +static void nbench_ioctl_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Ioctl - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_ioctl(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_ioctl *io) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, ioctl, (ntvfs, req, io)); - - nbench_log(private, "Ioctl - NOT HANDLED\n"); + PASS_THRU_REQ(ntvfs, req, ioctl, io, (ntvfs, req, io)); return status; } @@ -149,17 +190,24 @@ static NTSTATUS nbench_ioctl(struct ntvfs_module_context *ntvfs, /* check if a directory exists */ +static void nbench_chkpath_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + struct smb_chkpath *cp = req->async_states->private_data; + + nbench_log(nprivates, "Chkpath \"%s\" %s\n", + cp->in.path, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_chkpath(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_chkpath *cp) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, chkpath, (ntvfs, req, cp)); - - nbench_log(private, "Chkpath \"%s\" %s\n", - cp->in.path, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, chkpath, cp, (ntvfs, req, cp)); return status; } @@ -167,18 +215,25 @@ static NTSTATUS nbench_chkpath(struct ntvfs_module_context *ntvfs, /* return info on a pathname */ +static void nbench_qpathinfo_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_fileinfo *info = req->async_states->private_data; + + nbench_log(nprivates, "QUERY_PATH_INFORMATION \"%s\" %d %s\n", + info->generic.in.fname, + info->generic.level, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_qpathinfo(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_fileinfo *info) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, qpathinfo, (ntvfs, req, info)); - - nbench_log(private, "QUERY_PATH_INFORMATION \"%s\" %d %s\n", - info->generic.in.fname, - info->generic.level, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, qpathinfo, info, (ntvfs, req, info)); return status; } @@ -186,38 +241,51 @@ static NTSTATUS nbench_qpathinfo(struct ntvfs_module_context *ntvfs, /* query info on a open file */ +static void nbench_qfileinfo_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_fileinfo *info = req->async_states->private_data; + + nbench_log(nprivates, "QUERY_FILE_INFORMATION %d %d %s\n", + info->generic.in.fnum, + info->generic.level, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_qfileinfo(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_fileinfo *info) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, qfileinfo, (ntvfs, req, info)); - - nbench_log(private, "QUERY_FILE_INFORMATION %d %d %s\n", - info->generic.in.fnum, - info->generic.level, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, qfileinfo, info, (ntvfs, req, info)); return status; } - /* set info on a pathname */ +static void nbench_setpathinfo_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_setfileinfo *st = req->async_states->private_data; + + nbench_log(nprivates, "SET_PATH_INFORMATION \"%s\" %d %s\n", + st->generic.file.fname, + st->generic.level, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_setpathinfo(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_setfileinfo *st) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, setpathinfo, (ntvfs, req, st)); - - nbench_log(private, "SET_PATH_INFORMATION \"%s\" %d %s\n", - st->generic.file.fname, - st->generic.level, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, setpathinfo, st, (ntvfs, req, st)); return status; } @@ -225,47 +293,58 @@ static NTSTATUS nbench_setpathinfo(struct ntvfs_module_context *ntvfs, /* open a file */ -static NTSTATUS nbench_open(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_open *io) +static void nbench_open_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, open, (ntvfs, req, io)); - - DEBUG(0,("%d: %s\n", ntvfs->depth, get_nt_error_c_code(status))); + PASS_THRU_REP_PRE(req); + union smb_open *io = req->async_states->private_data; switch (io->generic.level) { case RAW_OPEN_NTCREATEX: - nbench_log(private, "NTCreateX \"%s\" 0x%x 0x%x %d %s\n", + nbench_log(nprivates, "NTCreateX \"%s\" 0x%x 0x%x %d %s\n", io->ntcreatex.in.fname, io->ntcreatex.in.create_options, io->ntcreatex.in.open_disposition, io->ntcreatex.out.fnum, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; default: - nbench_log(private, "Open-%d - NOT HANDLED\n", + nbench_log(nprivates, "Open-%d - NOT HANDLED\n", io->generic.level); break; } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_open(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_open *io) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, open, io, (ntvfs, req, io)); + return status; } /* create a directory */ +static void nbench_mkdir_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Mkdir - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_mkdir(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_mkdir *md) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, mkdir, (ntvfs, req, md)); - - nbench_log(private, "Mkdir - NOT HANDLED\n"); + PASS_THRU_REQ(ntvfs, req, mkdir, md, (ntvfs, req, md)); return status; } @@ -273,17 +352,24 @@ static NTSTATUS nbench_mkdir(struct ntvfs_module_context *ntvfs, /* remove a directory */ +static void nbench_rmdir_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + struct smb_rmdir *rd = req->async_states->private_data; + + nbench_log(nprivates, "Rmdir \"%s\" %s\n", + rd->in.path, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_rmdir(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_rmdir *rd) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, rmdir, (ntvfs, req, rd)); - - nbench_log(private, "Rmdir \"%s\" %s\n", - rd->in.path, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, rmdir, rd, (ntvfs, req, rd)); return status; } @@ -291,43 +377,56 @@ static NTSTATUS nbench_rmdir(struct ntvfs_module_context *ntvfs, /* rename a set of files */ -static NTSTATUS nbench_rename(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_rename *ren) +static void nbench_rename_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, rename, (ntvfs, req, ren)); + PASS_THRU_REP_PRE(req); + union smb_rename *ren = req->async_states->private_data; switch (ren->generic.level) { case RAW_RENAME_RENAME: - nbench_log(private, "Rename \"%s\" \"%s\" %s\n", + nbench_log(nprivates, "Rename \"%s\" \"%s\" %s\n", ren->rename.in.pattern1, ren->rename.in.pattern2, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; default: - nbench_log(private, "Rename-%d - NOT HANDLED\n", + nbench_log(nprivates, "Rename-%d - NOT HANDLED\n", ren->generic.level); break; } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_rename(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_rename *ren) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, rename, ren, (ntvfs, req, ren)); + return status; } /* copy a set of files */ +static void nbench_copy_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Copy - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_copy(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_copy *cp) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, copy, (ntvfs, req, cp)); - - nbench_log(private, "Copy - NOT HANDLED\n"); + PASS_THRU_REQ(ntvfs, req, copy, cp, (ntvfs, req, cp)); return status; } @@ -335,83 +434,103 @@ static NTSTATUS nbench_copy(struct ntvfs_module_context *ntvfs, /* read from a file */ -static NTSTATUS nbench_read(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_read *rd) +static void nbench_read_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, read, (ntvfs, req, rd)); + PASS_THRU_REP_PRE(req); + union smb_read *rd = req->async_states->private_data; switch (rd->generic.level) { case RAW_READ_READX: - nbench_log(private, "ReadX %d %d %d %d %s\n", + nbench_log(nprivates, "ReadX %d %d %d %d %s\n", rd->readx.in.fnum, (int)rd->readx.in.offset, rd->readx.in.maxcnt, rd->readx.out.nread, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; default: - nbench_log(private, "Read-%d - NOT HANDLED\n", + nbench_log(nprivates, "Read-%d - NOT HANDLED\n", rd->generic.level); break; } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_read(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_read *rd) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, read, rd, (ntvfs, req, rd)); + return status; } /* write to a file */ -static NTSTATUS nbench_write(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_write *wr) +static void nbench_write_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, write, (ntvfs, req, wr)); + PASS_THRU_REP_PRE(req); + union smb_write *wr = req->async_states->private_data; switch (wr->generic.level) { case RAW_WRITE_WRITEX: - nbench_log(private, "WriteX %d %d %d %d %s\n", + nbench_log(nprivates, "WriteX %d %d %d %d %s\n", wr->writex.in.fnum, (int)wr->writex.in.offset, wr->writex.in.count, wr->writex.out.nwritten, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; case RAW_WRITE_WRITE: - nbench_log(private, "Write %d %d %d %d %s\n", + nbench_log(nprivates, "Write %d %d %d %d %s\n", wr->write.in.fnum, wr->write.in.offset, wr->write.in.count, wr->write.out.nwritten, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; default: - nbench_log(private, "Write-%d - NOT HANDLED\n", + nbench_log(nprivates, "Write-%d - NOT HANDLED\n", wr->generic.level); break; } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_write(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_write *wr) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, write, wr, (ntvfs, req, wr)); + return status; } /* seek in a file */ +static void nbench_seek_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Seek - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_seek(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_seek *io) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, seek, (ntvfs, req, io)); - - nbench_log(private, "Seek - NOT HANDLED\n"); + PASS_THRU_REQ(ntvfs, req, seek, io, (ntvfs, req, io)); return status; } @@ -419,17 +538,24 @@ static NTSTATUS nbench_seek(struct ntvfs_module_context *ntvfs, /* flush a file */ +static void nbench_flush_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + struct smb_flush *io = req->async_states->private_data; + + nbench_log(nprivates, "Flush %d %s\n", + io->in.fnum, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_flush(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_flush *io) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, flush, (ntvfs, req, io)); - - nbench_log(private, "Flush %d %s\n", - io->in.fnum, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, flush, io, (ntvfs, req, io)); return status; } @@ -437,39 +563,55 @@ static NTSTATUS nbench_flush(struct ntvfs_module_context *ntvfs, /* close a file */ -static NTSTATUS nbench_close(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_close *io) +static void nbench_close_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, close, (ntvfs, req, io)); + PASS_THRU_REP_PRE(req); + union smb_close *io = req->async_states->private_data; switch (io->generic.level) { case RAW_CLOSE_CLOSE: - nbench_log(private, "Close %d %s\n", + nbench_log(nprivates, "Close %d %s\n", io->close.in.fnum, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; default: - nbench_log(private, "Close-%d - NOT HANDLED\n", + nbench_log(nprivates, "Close-%d - NOT HANDLED\n", io->generic.level); break; } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_close(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_close *io) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, close, io, (ntvfs, req, io)); + return status; } /* exit - closing files */ +static void nbench_exit_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Exit - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_exit(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req) { NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, exit, (ntvfs, req)); + PASS_THRU_REQ(ntvfs, req, exit, NULL, (ntvfs, req)); return status; } @@ -477,12 +619,21 @@ static NTSTATUS nbench_exit(struct ntvfs_module_context *ntvfs, /* logoff - closing files */ +static void nbench_logoff_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Logoff - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_logoff(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req) { NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, logoff, (ntvfs, req)); + PASS_THRU_REQ(ntvfs, req, logoff, NULL, (ntvfs, req)); return status; } @@ -500,71 +651,91 @@ static NTSTATUS nbench_async_setup(struct ntvfs_module_context *ntvfs, /* lock a byte range */ -static NTSTATUS nbench_lock(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_lock *lck) +static void nbench_lock_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, lock, (ntvfs, req, lck)); + PASS_THRU_REP_PRE(req); + union smb_lock *lck = req->async_states->private_data; if (lck->generic.level == RAW_LOCK_LOCKX && lck->lockx.in.lock_cnt == 1 && lck->lockx.in.ulock_cnt == 0) { - nbench_log(private, "LockX %d %d %d %s\n", + nbench_log(nprivates, "LockX %d %d %d %s\n", lck->lockx.in.fnum, (int)lck->lockx.in.locks[0].offset, (int)lck->lockx.in.locks[0].count, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); } else if (lck->generic.level == RAW_LOCK_LOCKX && lck->lockx.in.ulock_cnt == 1) { - nbench_log(private, "UnlockX %d %d %d %s\n", + nbench_log(nprivates, "UnlockX %d %d %d %s\n", lck->lockx.in.fnum, (int)lck->lockx.in.locks[0].offset, (int)lck->lockx.in.locks[0].count, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); } else { - nbench_log(private, "Lock-%d - NOT HANDLED\n", lck->generic.level); + nbench_log(nprivates, "Lock-%d - NOT HANDLED\n", lck->generic.level); } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_lock(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_lock *lck) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, lock, lck, (ntvfs, req, lck)); + return status; } /* set info on a open file */ +static void nbench_setfileinfo_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_setfileinfo *info = req->async_states->private_data; + + nbench_log(nprivates, "SET_FILE_INFORMATION %d %d %s\n", + info->generic.file.fnum, + info->generic.level, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_setfileinfo(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_setfileinfo *info) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, setfileinfo, (ntvfs, req, info)); - - nbench_log(private, "SET_FILE_INFORMATION %d %d %s\n", - info->generic.file.fnum, - info->generic.level, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, setfileinfo, info, (ntvfs, req, info)); return status; } - /* return filesystem space info */ +static void nbench_fsinfo_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_fsinfo *fs = req->async_states->private_data; + + nbench_log(nprivates, "QUERY_FS_INFORMATION %d %s\n", + fs->generic.level, + get_nt_error_c_code(req->async_states->status)); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_fsinfo(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_fsinfo *fs) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, fsinfo, (ntvfs, req, fs)); - - nbench_log(private, "QUERY_FS_INFORMATION %d %s\n", - fs->generic.level, - get_nt_error_c_code(status)); + PASS_THRU_REQ(ntvfs, req, fsinfo, fs, (ntvfs, req, fs)); return status; } @@ -572,15 +743,22 @@ static NTSTATUS nbench_fsinfo(struct ntvfs_module_context *ntvfs, /* return print queue info */ +static void nbench_lpq_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_lpq *lpq = req->async_states->private_data; + + nbench_log(nprivates, "Lpq-%d - NOT HANDLED\n", lpq->generic.level); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_lpq(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_lpq *lpq) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, lpq, (ntvfs, req, lpq)); - - nbench_log(private, "Lpq-%d - NOT HANDLED\n", lpq->generic.level); + PASS_THRU_REQ(ntvfs, req, lpq, lpq, (ntvfs, req, lpq)); return status; } @@ -588,74 +766,101 @@ static NTSTATUS nbench_lpq(struct ntvfs_module_context *ntvfs, /* list files in a directory matching a wildcard pattern */ -static NTSTATUS nbench_search_first(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_search_first *io, - void *search_private, - BOOL (*callback)(void *, union smb_search_data *)) +static void nbench_search_first_send(struct smbsrv_request *req) { - struct nbench_private *private = ntvfs->private_data; - NTSTATUS status; - - PASS_THRU_REQ(ntvfs, req, search_first, (ntvfs, req, io, search_private, callback)); - + PASS_THRU_REP_PRE(req); + union smb_search_first *io = req->async_states->private_data; + switch (io->generic.level) { case RAW_SEARCH_BOTH_DIRECTORY_INFO: - nbench_log(private, "FIND_FIRST \"%s\" %d %d %d %s\n", + nbench_log(nprivates, "FIND_FIRST \"%s\" %d %d %d %s\n", io->t2ffirst.in.pattern, io->generic.level, io->t2ffirst.in.max_count, io->t2ffirst.out.count, - get_nt_error_c_code(status)); + get_nt_error_c_code(req->async_states->status)); break; default: - nbench_log(private, "Search-%d - NOT HANDLED\n", io->generic.level); + nbench_log(nprivates, "Search-%d - NOT HANDLED\n", io->generic.level); break; } + PASS_THRU_REP_POST(req); +} + +static NTSTATUS nbench_search_first(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_search_first *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) +{ + NTSTATUS status; + + PASS_THRU_REQ(ntvfs, req, search_first, io, (ntvfs, req, io, search_private, callback)); + return status; } /* continue a search */ +static void nbench_search_next_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_search_next *io = req->async_states->private_data; + + nbench_log(nprivates, "Searchnext-%d - NOT HANDLED\n", io->generic.level); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_search_next(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_search_next *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, search_next, (ntvfs, req, io, search_private, callback)); - - nbench_log(private, "Searchnext-%d - NOT HANDLED\n", io->generic.level); + PASS_THRU_REQ(ntvfs, req, search_next, io, (ntvfs, req, io, search_private, callback)); return status; } /* close a search */ +static void nbench_search_close_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + union smb_search_close *io = req->async_states->private_data; + + nbench_log(nprivates, "Searchclose-%d - NOT HANDLED\n", io->generic.level); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_search_close(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, union smb_search_close *io) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, search_close, (ntvfs, req, io)); - - nbench_log(private, "Searchclose-%d - NOT HANDLED\n", io->generic.level); + PASS_THRU_REQ(ntvfs, req, search_close, io, (ntvfs, req, io)); return status; } /* SMBtrans - not used on file shares */ +static void nbench_trans_send(struct smbsrv_request *req) +{ + PASS_THRU_REP_PRE(req); + + nbench_log(nprivates, "Trans - NOT HANDLED\n"); + + PASS_THRU_REP_POST(req); +} + static NTSTATUS nbench_trans(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans2) { - struct nbench_private *private = ntvfs->private_data; NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, trans, (ntvfs, req, trans2)); - - nbench_log(private, "Trans - NOT HANDLED\n"); + PASS_THRU_REQ(ntvfs, req, trans, trans2, (ntvfs, req, trans2)); return status; } diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index c9fe276f54..04e9b871c7 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -134,12 +134,45 @@ struct ntvfs_context { struct ntvfs_module_context *modules; }; + +/* a set of flags to control handling of request structures */ +#define NTVFS_ASYNC_STATE_ASYNC (1<<1) /* the backend will answer this one later */ +#define NTVFS_ASYNC_STATE_MAY_ASYNC (1<<2) /* the backend is allowed to answer async */ + +/* the ntvfs_async_state structure allows backend functions to + delay replying to requests. To use this, the front end must + set send_fn to a function to be called by the backend + when the reply is finally ready to be sent. The backend + must set status to the status it wants in the + reply. The backend must set the NTVFS_ASYNC_STATE_ASYNC + control_flag on the request to indicate that it wishes to + delay the reply + + If NTVFS_ASYNC_STATE_MAY_ASYNC is not set then the backend cannot + ask for a delayed reply for this request + + note that the private_data pointer is private to the layer which alloced this struct +*/ +struct ntvfs_async_state { + struct ntvfs_async_state *prev, *next; + /* the async handling infos */ + unsigned state; + void *private_data; + void (*send_fn)(struct smbsrv_request *); + NTSTATUS status; + + /* the passthru module's per session private data */ + struct ntvfs_module_context *ntvfs; +}; + /* this structure is used by backends to determine the size of some critical types */ struct ntvfs_critical_sizes { int interface_version; + int sizeof_ntvfs_critical_sizes; int sizeof_ntvfs_context; int sizeof_ntvfs_module_context; int sizeof_ntvfs_ops; + int sizeof_ntvfs_async_state; int sizeof_smbsrv_tcon; int sizeof_smbsrv_request; }; diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index acbd02d915..17900b3dfc 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -100,9 +100,11 @@ const struct ntvfs_critical_sizes *ntvfs_interface_version(void) { static const struct ntvfs_critical_sizes critical_sizes = { NTVFS_INTERFACE_VERSION, + sizeof(struct ntvfs_critical_sizes), sizeof(struct ntvfs_context), sizeof(struct ntvfs_module_context), sizeof(struct ntvfs_ops), + sizeof(struct ntvfs_async_state), sizeof(struct smbsrv_tcon), sizeof(struct smbsrv_request), }; diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 452273cbdb..2639b5ae39 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -71,7 +71,7 @@ NTSTATUS ntvfs_map_open(struct smbsrv_request *req, union smb_open *io, /* must be synchronous, or we won't be called to do the translation */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; switch (io->generic.level) { case RAW_OPEN_GENERIC: @@ -692,7 +692,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *inf /* must be synchronous, or we won't be called to do the translation */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->qpathinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { @@ -768,7 +768,7 @@ NTSTATUS ntvfs_map_write(struct smbsrv_request *req, union smb_write *wr, wr2->generic.level = RAW_WRITE_GENERIC; /* we can't map asynchronously */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; switch (wr->generic.level) { case RAW_WRITE_WRITEX: @@ -874,7 +874,7 @@ NTSTATUS ntvfs_map_read(struct smbsrv_request *req, union smb_read *rd, rd2->generic.level = RAW_READ_GENERIC; /* we can't map asynchronously */ - req->control_flags &= ~REQ_CONTROL_MAY_ASYNC; + req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; switch (rd->generic.level) { case RAW_READ_READX: diff --git a/source4/ntvfs/ntvfs_util.c b/source4/ntvfs/ntvfs_util.c index 4036fb0935..929ec037de 100644 --- a/source4/ntvfs/ntvfs_util.c +++ b/source4/ntvfs/ntvfs_util.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. NTVFS utility code - Copyright (C) Andrew Tridgell 2003 + Copyright (C) Stefan Metzmacher 2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,4 +23,40 @@ #include "includes.h" +NTSTATUS ntvfs_async_state_push(struct smbsrv_request *req, + void *private_data, + void (*send_fn)(struct smbsrv_request *), + struct ntvfs_module_context *ntvfs) +{ + struct ntvfs_async_state *async; + async = talloc_p(req, struct ntvfs_async_state); + if (!async) { + return NT_STATUS_NO_MEMORY; + } + + async->state = req->async_states->state; + async->private_data = private_data; + async->send_fn = send_fn; + async->status = NT_STATUS_INTERNAL_ERROR; + + async->ntvfs = ntvfs; + + DLIST_ADD(req->async_states, async); + + return NT_STATUS_OK; +} + +void ntvfs_async_state_pop(struct smbsrv_request *req) +{ + struct ntvfs_async_state *async; + + async = req->async_states; + + DLIST_REMOVE(req->async_states, async); + + req->async_states->state = async->state; + req->async_states->status = async->status; + + talloc_free(async); +} diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c index 4a4da34b60..3835c9319b 100644 --- a/source4/ntvfs/posix/pvfs_lock.c +++ b/source4/ntvfs/posix/pvfs_lock.c @@ -77,8 +77,8 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs, locks[i].count); f->lock_count--; } - req->async.status = status; - req->async.send_fn(req); + req->async_states->status = status; + req->async_states->send_fn(req); } @@ -192,8 +192,8 @@ static void pvfs_pending_lock_continue(void *private, BOOL timed_out) } /* we've managed to get all the locks. Tell the client */ - req->async.status = NT_STATUS_OK; - req->async.send_fn(req); + req->async_states->status = NT_STATUS_OK; + req->async_states->send_fn(req); } @@ -217,8 +217,8 @@ void pvfs_lock_close(struct pvfs_state *pvfs, struct pvfs_file *f) next = p->next; DLIST_REMOVE(f->pending_list, p); talloc_free(p->wait_handle); - p->req->async.status = NT_STATUS_RANGE_NOT_LOCKED; - p->req->async.send_fn(p->req); + p->req->async_states->status = NT_STATUS_RANGE_NOT_LOCKED; + p->req->async_states->send_fn(p->req); } } @@ -287,7 +287,7 @@ NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs, } if (lck->lockx.in.timeout != 0 && - (req->control_flags & REQ_CONTROL_MAY_ASYNC)) { + (req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { pending = talloc_p(req, struct pvfs_pending_lock); if (pending == NULL) { return NT_STATUS_NO_MEMORY; diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 071ecbce15..2a8cbbbe0d 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -149,7 +149,7 @@ void *pvfs_wait_message(struct pvfs_state *pvfs, /* tell the main smb server layer that we will be replying asynchronously */ - req->control_flags |= REQ_CONTROL_ASYNC; + req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; /* make sure we cleanup the timer and message handler */ talloc_set_destructor(pwait, pvfs_wait_destructor); |