From 7f0e17e9030ad734977f66c2cc27faec501154a2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 May 2006 15:10:39 +0000 Subject: r15718: - split the SMBflush with the 0xFFFF wildcard fnum into a different level metze (This used to be commit 95bf41b4d4ec96349802955e364fe44ef85f9077) --- source4/libcli/raw/interfaces.h | 7 +++++++ source4/libcli/raw/rawfile.c | 12 +++++++++++- source4/ntvfs/nbench/vfs_nbench.c | 13 +++++++++++-- source4/ntvfs/posix/pvfs_flush.c | 22 +++++++++++++--------- source4/ntvfs/simple/vfs_simple.c | 18 ++++++++++++++++-- source4/smb_server/smb/reply.c | 10 +++++++++- source4/torture/basic/delaywrite.c | 1 + source4/torture/nbench/nbio.c | 3 ++- source4/torture/raw/close.c | 11 +++++++---- 9 files changed, 77 insertions(+), 20 deletions(-) diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index d98b5de370..84f897172e 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -1725,13 +1725,20 @@ union smb_ioctl { } ntioctl; }; +enum smb_flush_level {RAW_FLUSH_FLUSH, RAW_FLUSH_ALL}; + /* struct for SMBflush */ union smb_flush { struct { + enum smb_ioctl_level level; struct { union smb_handle file; } in; } flush, generic; + + struct { + enum smb_ioctl_level level; + } flush_all; }; diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c index 2873011aa2..fb3035c0a8 100644 --- a/source4/libcli/raw/rawfile.c +++ b/source4/libcli/raw/rawfile.c @@ -849,9 +849,19 @@ NTSTATUS smb_raw_chkpath(struct smbcli_tree *tree, union smb_chkpath *parms) struct smbcli_request *smb_raw_flush_send(struct smbcli_tree *tree, union smb_flush *parms) { struct smbcli_request *req; + uint16_t fnum; + + switch (parms->generic.level) { + case RAW_FLUSH_FLUSH: + fnum = parms->flush.in.file.fnum; + break; + case RAW_FLUSH_ALL: + fnum = 0xFFFF; + break; + } SETUP_REQUEST(SMBflush, 1, 0); - SSVAL(req->out.vwv, VWV(0), parms->flush.in.file.fnum); + SSVAL(req->out.vwv, VWV(0), fnum); if (!smbcli_request_send(req)) { smbcli_request_destroy(req); diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index 77de979153..963d422cf0 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -534,10 +534,19 @@ static NTSTATUS nbench_seek(struct ntvfs_module_context *ntvfs, static void nbench_flush_send(struct ntvfs_request *req) { union smb_flush *io = req->async_states->private_data; + uint16_t fnum; + + switch (io->generic.level) { + case RAW_FLUSH_FLUSH: + fnum = io->flush.in.file.fnum; + break; + case RAW_FLUSH_ALL: + fnum = 0xFFFF; + break; + } nbench_log(req, "Flush %d %s\n", - io->flush.in.file.fnum, - get_nt_error_c_code(req->async_states->status)); + fnum, get_nt_error_c_code(req->async_states->status)); PASS_THRU_REP_POST(req); } diff --git a/source4/ntvfs/posix/pvfs_flush.c b/source4/ntvfs/posix/pvfs_flush.c index d21f257201..c1d8820c43 100644 --- a/source4/ntvfs/posix/pvfs_flush.c +++ b/source4/ntvfs/posix/pvfs_flush.c @@ -46,23 +46,27 @@ NTSTATUS pvfs_flush(struct ntvfs_module_context *ntvfs, struct pvfs_state *pvfs = ntvfs->private_data; struct pvfs_file *f; - if (io->flush.in.file.fnum != 0xFFFF) { + switch (io->generic.level) { + case RAW_FLUSH_FLUSH: f = pvfs_find_fd(pvfs, req, io->flush.in.file.fnum); if (!f) { return NT_STATUS_INVALID_HANDLE; } pvfs_flush_file(pvfs, f); return NT_STATUS_OK; - } - if (!(pvfs->flags & PVFS_FLAG_STRICT_SYNC)) { - return NT_STATUS_OK; - } + case RAW_FLUSH_ALL: + if (!(pvfs->flags & PVFS_FLAG_STRICT_SYNC)) { + return NT_STATUS_OK; + } - /* they are asking to flush all open files */ - for (f=pvfs->files.list;f;f=f->next) { - pvfs_flush_file(pvfs, f); + /* they are asking to flush all open files */ + for (f=pvfs->files.list;f;f=f->next) { + pvfs_flush_file(pvfs, f); + } + + return NT_STATUS_OK; } - return NT_STATUS_OK; + return NT_STATUS_INVALID_LEVEL; } diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index 35c18e3f1c..1698f57aee 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -549,8 +549,22 @@ static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - fsync(io->flush.in.file.fnum); - return NT_STATUS_OK; + struct svfs_private *private = ntvfs->private_data; + struct svfs_file *f; + + switch (io->generic.level) { + case RAW_FLUSH_FLUSH: + fsync(io->flush.in.file.fnum); + return NT_STATUS_OK; + + case RAW_FLUSH_ALL: + for (f=private->open_files;f;f=f->next) { + fsync(f->fd); + } + return NT_STATUS_OK; + } + + return NT_STATUS_INVALID_LEVEL; } /* diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c index cfd004304a..768fba1319 100644 --- a/source4/smb_server/smb/reply.c +++ b/source4/smb_server/smb/reply.c @@ -1069,13 +1069,21 @@ void smbsrv_reply_lseek(struct smbsrv_request *req) void smbsrv_reply_flush(struct smbsrv_request *req) { union smb_flush *io; + uint16_t fnum; /* parse request */ SMBSRV_CHECK_WCT(req, 1); SMBSRV_TALLOC_IO_PTR(io, union smb_flush); SMBSRV_SETUP_NTVFS_REQUEST(reply_simple_send, NTVFS_ASYNC_STATE_MAY_ASYNC); - io->flush.in.file.fnum = req_fnum(req, req->in.vwv, VWV(0)); + fnum = req_fnum(req, req->in.vwv, VWV(0)); + + if (fnum == 0xFFFF) { + io->flush_all.level = RAW_FLUSH_ALL; + } else { + io->flush.level = RAW_FLUSH_FLUSH; + io->flush.in.file.fnum = fnum; + } SMBSRV_CALL_NTVFS_BACKEND(ntvfs_flush(req->ntvfs, io)); } diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index 7708e1c76d..4063eda6f2 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -253,6 +253,7 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem printf("Doing flush after write\n"); + flsh.flush.level = RAW_FLUSH_FLUSH; flsh.flush.in.file.fnum = fnum1; status = smb_raw_flush(cli->tree, &flsh); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c index e87a138a8e..2e8be5057a 100644 --- a/source4/torture/nbench/nbio.c +++ b/source4/torture/nbench/nbio.c @@ -646,7 +646,8 @@ void nb_flush(int fnum, NTSTATUS status) int i; i = find_handle(fnum); - io.flush.in.file.fnum = i; + io.flush.level = RAW_FLUSH_FLUSH; + io.flush.in.file.fnum = i; ret = smb_raw_flush(c->tree, &io); diff --git a/source4/torture/raw/close.c b/source4/torture/raw/close.c index 41c6956c25..1a3b5f28be 100644 --- a/source4/torture/raw/close.c +++ b/source4/torture/raw/close.c @@ -144,24 +144,27 @@ BOOL torture_raw_close(struct torture_context *torture) printf("testing flush\n"); smbcli_close(cli->tree, fnum); - io_flush.flush.in.file.fnum = fnum; + io_flush.flush.level = RAW_FLUSH_FLUSH; + io_flush.flush.in.file.fnum = fnum; status = smb_raw_flush(cli->tree, &io_flush); CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); - io_flush.flush.in.file.fnum = 0xffff; + io_flush.flush_all.level = RAW_FLUSH_ALL; status = smb_raw_flush(cli->tree, &io_flush); CHECK_STATUS(status, NT_STATUS_OK); REOPEN; - io_flush.flush.in.file.fnum = fnum; + io_flush.flush.level = RAW_FLUSH_FLUSH; + io_flush.flush.in.file.fnum = fnum; status = smb_raw_flush(cli->tree, &io_flush); CHECK_STATUS(status, NT_STATUS_OK); printf("Testing SMBexit\n"); smb_raw_exit(cli->session); - io_flush.flush.in.file.fnum = fnum; + io_flush.flush.level = RAW_FLUSH_FLUSH; + io_flush.flush.in.file.fnum = fnum; status = smb_raw_flush(cli->tree, &io_flush); CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE); -- cgit