From 9c10644d2254076eab5e86e7a707ed94fec303df Mon Sep 17 00:00:00 2001 From: Sam Liddicott Date: Fri, 7 Nov 2008 15:39:58 +0000 Subject: [PATCH] Add fake-validate option For testing allow the proxy to believe that a cache is valid without having to confirm it --- source4/ntvfs/proxy/lib/cache/cache.h | 1 + source4/ntvfs/proxy/vfs_proxy.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/source4/ntvfs/proxy/lib/cache/cache.h b/source4/ntvfs/proxy/lib/cache/cache.h index 8e911245f25..823e08127c9 100644 --- a/source4/ntvfs/proxy/lib/cache/cache.h +++ b/source4/ntvfs/proxy/lib/cache/cache.h @@ -95,6 +95,7 @@ NTSTATUS cache_smb_raw_read(struct cache_file_entry *cache, NTSTATUS cache_smb_raw_checksum(struct cache_file_entry *cache, offset_t offset, ssize_t* length, uint8_t digest[16]); ssize_t cache_raw_read(struct cache_file_entry *cache, uint8_t* data, off_t offset, ssize_t size); +#define cache_handle_len(handle) ((handle && handle->cache)?(cache_len(handle->cache)):(-1)) ssize_t cache_len(struct cache_file_entry *cache); struct cache_file_entry * cache_filename_open(struct cache_context *cache_context, struct proxy_file *f, diff --git a/source4/ntvfs/proxy/vfs_proxy.c b/source4/ntvfs/proxy/vfs_proxy.c index b6095c5ecb4..66a1e9e58ee 100644 --- a/source4/ntvfs/proxy/vfs_proxy.c +++ b/source4/ntvfs/proxy/vfs_proxy.c @@ -74,6 +74,7 @@ struct proxy_private { struct cache_context *cache; int readahead_spare; /* amount of pending non-user generated requests */ bool fake_oplock; /* useful for testing, smbclient never asks for oplock */ + bool fake_valid; /* useful for testing, smbclient never asks for oplock */ uint16_t nttrans_fnum; /* we need a handle for non-proxy operations */ }; @@ -168,6 +169,9 @@ struct async_rpclite_send { #define PROXY_FAKE_OPLOCK "proxy:fake-oplock" #define PROXY_FAKE_OPLOCK_DEFAULT false +#define PROXY_FAKE_VALID "proxy:fake-valid" +#define PROXY_FAKE_VALID_DEFAULT false + /* how many read-ahead requests can be pending per mid */ #define PROXY_REQUEST_LIMIT "proxy:request-limit" #define PROXY_REQUEST_LIMIT_DEFAULT 100 @@ -378,6 +382,7 @@ static NTSTATUS proxy_connect(struct ntvfs_module_context *ntvfs, private->cache_readaheadblock = share_int_option(scfg, PROXY_CACHE_READAHEAD_BLOCK, MIN(private->cache_readahead,PROXY_CACHE_READAHEAD_BLOCK_DEFAULT)); private->fake_oplock = share_bool_option(scfg, PROXY_FAKE_OPLOCK, PROXY_FAKE_OPLOCK_DEFAULT); + private->fake_valid = share_bool_option(scfg, PROXY_FAKE_VALID, PROXY_FAKE_VALID_DEFAULT); private->readahead_spare = share_int_option(scfg, PROXY_REQUEST_LIMIT, PROXY_REQUEST_LIMIT_DEFAULT); private->cache = new_cache_context(private, lp_proxy_cache_root(ntvfs->ctx->lp_ctx), host, remote_share); DEBUG(0,("proxy tree connect caching for: %s (%s : %s) %s read-ahead: %d\n", @@ -775,6 +780,9 @@ static void async_open(struct smbcli_request *c_req) if (proxy->cache_enabled) { bool oplock=(io->generic.out.oplock_level != OPLOCK_NONE) || proxy->fake_oplock; f->cache=cache_open(proxy->cache, f, io, oplock, proxy->cache_readahead); + if (proxy->fake_valid) { + cache_handle_validated(f, cache_handle_len(f)); + } if (! PROXY_REMOTE_SERVER(proxy)) cache_handle_novalidate(f); } @@ -826,6 +834,9 @@ static NTSTATUS proxy_open(struct ntvfs_module_context *ntvfs, bool oplock=(io->generic.out.oplock_level != OPLOCK_NONE) || private->fake_oplock; f->cache=cache_open(private->cache, f, io, oplock, private->cache_readahead); + if (private->fake_valid) { + cache_handle_validated(f, cache_handle_len(f)); + } if (! PROXY_REMOTE_SERVER(private)) cache_handle_novalidate(f); } -- 2.11.4.GIT