summaryrefslogtreecommitdiffstats
path: root/source3/smbd/fileio.c
Commit message (Collapse)AuthorAgeFilesLines
* s3:smbd: document the interaction between "smb2 leases" and "write cache size"Stefan Metzmacher2014-12-041-0/+5
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: improve writecache profilingStefan Metzmacher2014-11-191-6/+33
| | | | | | | | | | | | | | | | | In order to have useful profiling counters should never be decremented. We need a separate counter for deallocation events. The current value can be calculated by allocations - deallocations. We also use better names and avoid having an array for the flush reasons. This will simplify further profiling improvements a lot. The value writecache_num_write_caches (this was similar to writecache_allocations) is replaced by writecache_cached_writes, which counts the amount of writes which were completely handled by the cache. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* profiling: Remove a big DEBUG statementVolker Lendecke2014-10-031-25/+0
| | | | | | | | | | | | | | | | | | | | | I would like to have the freedom to play with the profiling implementation. This is kindof in the way. This code is from pre-SVN days: > commit 7914e9351abb5271ebb4990c3b1fe495d15a4eda > Author: Jeremy Allison <jra@samba.org> > AuthorDate: Thu Oct 5 18:50:18 2000 +0000 > Commit: Jeremy Allison <jra@samba.org> > CommitDate: Thu Oct 5 18:50:18 2000 +0000 > > Herb's fixes for profiling & compiler warnings. > Jeremy. Herb, please speak up quickly if you still need this :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* profiling: Remove some #ifdefsVolker Lendecke2014-10-031-6/+0
| | | | | | | | | The DO_PROFILE_INC thingies already #define to nothing without WITH_PROFILE, and any sane compiler will just not compile the if-condition if there is no body to be executed. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* param: rename lp function and variable from "syncalways" to "sync_always"Garming Sam2014-02-071-1/+1
| | | | | | Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Rename the profile enums with a SAMBA_ prefix to avoid conflict with system ↵Jeremy Allison2013-11-221-13/+13
| | | | | | | | | files. WRITE_FLUSH is defined in fs.h in Linux. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:smbd: s/struct timed_event/struct tevent_timerStefan Metzmacher2013-02-191-1/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:smbd: s/struct event_context/struct tevent_contextStefan Metzmacher2013-02-191-1/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3: Factor out "mark_file_modified"Volker Lendecke2012-07-121-25/+42
| | | | | | This is in preparation of making us survive base-delaywrite with async I/O activated Signed-off-by: Jeremy Allison <jra@samba.org>
* s3:smbd: remove unnecessary variable readret from read_file()Michael Adam2012-06-081-7/+3
| | | | | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Fri Jun 8 18:08:09 CEST 2012 on sn-devel-104
* s3:smbd: remove ancient DMF_FIX from read_file().Michael Adam2012-06-081-15/+0
| | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org>
* s3:smbd: remove typedef for struct write_cacheStefan Metzmacher2012-06-061-9/+9
| | | | metze
* s3:smbd: make typedef write_cache private to fileio.cStefan Metzmacher2012-06-061-0/+8
| | | | metze
* build: Remove SMB_OFF_T, replace with off_tAndrew Bartlett2012-04-061-7/+7
| | | | | | | | | Now that we always require a 64 bit off_t, we no longer need SMB_OFF_T. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Fri Apr 6 01:47:43 CEST 2012 on sn-devel-104
* s3:smbd/fileio: avoid usage of server_event_context()Stefan Metzmacher2011-12-121-3/+3
| | | | metze
* lib/util/time.c: timeval_current_ofs_usecRusty Russell2011-06-011-1/+1
| | | | | | | | | | | | | | | Several places want "microseconds from current time", and several were simply handing "usecs" values which could be over a million. Using a helper to do this is safer and more readable. I didn't replace any obviously correct callers (ie. constants). I also renamed wait_nsec in source3/lib/util_sock.c; it's actually microseconds not nanoseconds (introduced with this code in Volker's 19b783cc Async wrapper for open_socket_out_send/recv). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* s3-globals Remove smbd_event_context() (use server_event_context())Andrew Bartlett2011-05-311-1/+1
| | | | | | | | This has been a wrapper around server_event_context() for some time now, and removing this from dummmysmbd.c assists with library dependencies. Andrew Bartlett
* s3-smb Use FILE_ATTRIBUTE_ARCHIVE intead of aARCHAndrew Bartlett2011-04-291-1/+1
| | | | | | This means we use just one constant for this file attribute. Andrew Bartlett
* s3: only include smb profiling where needed.Günther Deschner2011-04-141-0/+1
| | | | | | | Guenther Autobuild-User: Günther Deschner <gd@samba.org> Autobuild-Date: Thu Apr 14 01:31:39 CEST 2011 on sn-devel-104
* s3: include smbd/smbd.h where needed.Günther Deschner2011-03-301-0/+1
| | | | Guenther
* Keep track of the sparse status of an open file handle. Allows bypass ofJeremy Allison2010-12-211-1/+2
| | | | | | | | strict allocation on sparse files. Files opened as POSIX opens are always sparse. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Tue Dec 21 04:12:22 CET 2010 on sn-devel-104
* Fix bug #7693 - smbd changing mode of files on renameJeremy Allison2010-09-221-6/+7
| | | | | | | When using "map archive", don't change the archive bit on renames or writes with UNIX extensions turned on. Jeremy.
* s3: Do the ftruncate write cache optimization in one placeVolker Lendecke2010-07-291-0/+31
| | | | | Instead of hand-tuning all the cases that are below this piece of code, this is a general case that we can catch upfront.
* Revert "s3: Avoid pwrite calls for the 1-byte writes with zero content"Volker Lendecke2010-07-291-50/+4
| | | | This reverts commit 6763730304627a58139450fd3e03a0ce48e31bb9.
* s3-smbd: Migrated to new spoolss functions for printing.Simo Sorce2010-07-271-11/+7
| | | | Signed-off-by: Jim McDonough <jmcd@samba.org>
* s3: Avoid pwrite calls for the 1-byte writes with zero contentVolker Lendecke2010-07-191-4/+50
| | | | | | | | | When a write cache is empty and we write one 0, there is no point in actually writing into the write cache, which would trigger a potentially superfluous write cache flush. We can rely on posix semantics to give us 0's when subsequent read calls want to read from file areas not written yet. Jeremy, please check!
* s3: Optimize the write cache for sequential writesVolker Lendecke2010-07-091-0/+20
| | | | | | In case of the one-byte allocating writes we don't work work optimally because we start the write cache at the current offset. This patch tries to avoid this case.
* smbd: move printfile_offset() within write_file()Simo Sorce2010-04-301-0/+3
|
* s3-smbd: group print relate data in own structureSimo Sorce2010-04-231-3/+4
|
* Don't overwrite a dynamic pointer with the address of a stackJeremy Allison2009-11-161-8/+6
| | | | | variable. Jeremy.
* Got the logic simplification worked out so we still passJeremy Allison2009-11-051-4/+4
| | | | | BASE-DELAYWRITE and also RAW-CLOSE. Jeremy.
* Get closer to an accurate model of Windows timestamp changes.Jeremy Allison2009-11-051-8/+30
| | | | | | | | "Normal" non truncate writes always cause the timestamp to be set on close. Once a close is done on a handle this can reset the sticky write time to current time also. Updated smbtorture4 confirms this. Jeremy.
* s3: Change fsp->fsp_name to be an smb_filename struct!Tim Prouty2009-07-201-29/+28
|
* Remove reply_unixerror() - no longer needed. Should make Metze's refactoring ↵Jeremy Allison2009-07-101-0/+1
| | | | | | a lot easier. Jeremy.
* s3: Plumb smb_filename through dos_mode() and related funtionsTim Prouty2009-07-081-18/+16
|
* s3: Plumb smb_filename around SMB_VFS_CHFLAGSTim Prouty2009-07-061-4/+16
| | | | | | | | | | | SMB_VFS_CHFLAGS isn't actually getting the smb_filename struct for now since it only operates on the basefile. This is the strategy for all path-based operations that will never actually operate on a stream. By clarifying the meaning of path based operations that don't take an smb_filename struct, modules that implement streams such as vfs_onefs no longer need to implement SMB_VFS_CHFLAGS to ensure it's only called on the base_name.
* Ensure we don't use delayed writes on POSIX opened files.Jeremy Allison2009-07-011-0/+10
| | | | | | Don't remove pending writetime changes if no time changes are sent in UNIX_BASIC infolevel. Jeremy
* s3: Plumb smb_filename through SMB_VFS_STAT and SMB_VFS_LSTATTim Prouty2009-06-241-1/+1
| | | | | | | | | | | | | This patch introduces two new temporary helper functions vfs_stat_smb_fname and vfs_lstat_smb_fname. They basically allowed me to call the new smb_filename version of stat, while avoiding plumbing it through callers that are still too inconvenient. As the conversion moves along, I will be able to remove callers of this, with the goal being to remove all callers. There was also a bug in create_synthetic_smb_fname_split (also a temporary utility function) that caused it to incorrectly handle filenames with ':'s in them when in posix mode. This is now fixed.
* Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STATVolker Lendecke2009-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces struct stat_ex { dev_t st_ex_dev; ino_t st_ex_ino; mode_t st_ex_mode; nlink_t st_ex_nlink; uid_t st_ex_uid; gid_t st_ex_gid; dev_t st_ex_rdev; off_t st_ex_size; struct timespec st_ex_atime; struct timespec st_ex_mtime; struct timespec st_ex_ctime; struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; }; typedef struct stat_ex SMB_STRUCT_STAT; It is really large because due to the friendly libc headers playing macro tricks with fields like st_ino, so I renamed them to st_ex_xxx. Why this change? To support birthtime, we already have quite a few #ifdef's at places where it does not really belong. With a stat struct that we control, we can consolidate the nanosecond timestamps and the birthtime deep in the VFS stat calls. At this moment it is triggered by a request to support the birthtime field for GPFS. GPFS does not extend the system level struct stat, but instead has a separate call that gets us the additional information beyond posix. Without being able to do that within the VFS stat calls, that support would have to be scattered around the main smbd code. It will very likely break all the onefs modules, but I think the changes will be reasonably easy to do.
* Only copy sharename up from rap_to_pjobidVolker Lendecke2009-03-011-2/+1
| | | | | | | | | | | | | | Why?? :-) Another one of the little micro-optimizations that I just came across: If you allocate a variable in a sub-block like the "fstring sharename" in write_file(), gcc even with -O3 will allocate this variable unconditionally on the stack at the beginning of the routine. So with eliminating this fstring we cut 256 bytes of stack in a very hot code path writing to a file. It might make us a bit more cache-friendly. This would probably not be worth a second look if it involved larger code changes, but this one was just too simple to let it pass :-)
* s3 oplocks: Make the level2 oplock contention API more granularTim Prouty2009-02-091-1/+3
| | | | | | | | | | | | | | | | | | This replaces release_level2_oplocks_on_change with contend_level2_oplock_begin/end in order to contend level2 oplocks throughout an operation rather than just at the begining. This is necessary for some kernel oplock implementations, and also lays the groundwork for better correctness in Samba's standard level2 oplock handling. The next step for non-kernel oplocks is to add additional state to the share mode lock struct that prevents any new opens from granting oplocks while a contending operation is in progress. All operations that contend level 2 oplocks are now correctly spanned except for aio and synchronous writes. The two write paths both have non-trivial error paths that need extra care to get right. RAW-OPLOCK and the rest of 'make test' are still passing with this change.
* s3:smbd: move all globals and static variables in globals.[ch]Stefan Metzmacher2009-01-081-3/+1
| | | | | | The goal is to move all this variables into a big context structure. metze
* s3:events: change event_add_timed() prototype to match samba4Stefan Metzmacher2009-01-051-2/+1
| | | | metze
* Fix more asprintf warnings and some error path errors.Jeremy Allison2008-12-231-3/+6
| | | | Jeremy.
* Modify a comment to make things clearer.Jeremy Allison2008-09-121-1/+3
| | | | | Jeremy. (This used to be commit 9d55ca85ffc73e3fa5fb9895fbcb1ee22f4e320d)
* smbd: some write time fixesStefan Metzmacher2008-09-081-8/+7
| | | | | | | | | | | | | | | - only the first non truncating write causes the write time update with 2 seconds delay. It's not enough to check for an existing update event as it will be NULL after the event was triggered. - SMBwrite truncates always update the write time unless the sticky write time is set. - SMBwrite truncates don't trigger a write time update on close. metze (This used to be commit 3d17089b6dc773303c8c553f3f6140e60e348fb7)
* Write times code update.Jeremy Allison2008-09-051-8/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ok, here's the fix for the write times breakage with the new tests in S4 smbtorture. The key is keeping in the share mode struct the "old_file_time" as the real write time, set by all the write and allocation calls, and the "changed_write_time" as the "sticky" write time - set by the SET_FILE_TIME calls. We can set them independently (although I kept the optimization of not setting the "old_file_time" is a "changed_write_time" was already set, as we'll never see it. This allows us to update the write time immediately on the SMBwrite truncate case, SET_END_OF_FILE and SET_ALLOCATION_SIZE calls, whilst still have the 2 second delay on the "normal" SMBwrite, SMBwriteX calls. I think in a subsequent patch I'd like to change the name of these from "old_file_time" to "write_time" and "changed_write_time" to "sticky_write_time" to make this clearer. I think I also fixed a bug in Metze's original code in that once a write timestamp had been set from a "normal" SMBwriteX call the fsp->update_write_time_triggered variable was set and then never reset - thus meaning the write timestamp would never get updated again on subsequent SMBwriteX's. The new code checks the update_write_time_event event instead, and doesn't update is there's an event already scheduled. Metze especially, please check this over for your understanding. Jeremy. (This used to be commit 6f20585419046c4aca1f7d6c863cf79eb6ae53b0)
* smbd: make it possible to change the write time delay for testingStefan Metzmacher2008-04-071-1/+7
| | | | | metze (This used to be commit df8c100c2b53575a0d425a2daf52e2d59904746a)
* smbd: implement the strange write time update logicStefan Metzmacher2008-04-071-22/+38
| | | | | | | | | | | | | | | | | | | | | We now never call file_ntimes() directly, every update is done via smb_set_file_time(). This let samba3 pass the BASE-DELAYWRITE test. The write time is only updated 2 seconds after the first write() on any open handle to the current time (not the time of the first write). Each handle which had write requests updates the write time to the current time on close(). If the write time is set explicit via setfileinfo or setpathinfo the write time is visible directly and a following close on the same handle doesn't update the write time. metze (This used to be commit 2eab212ea2e1bfd8fa716c2c89b2c042f7ba12ea)
* Remove redundant parameter fd from SMB_VFS_FTRUNCATE().Michael Adam2008-01-071-1/+1
| | | | | Michael (This used to be commit 2ad66050a0452b8e7e08b1e7a01efa00c72fd451)