summaryrefslogtreecommitdiff
path: root/source3/smbd/fileio.c
AgeCommit message (Collapse)AuthorFilesLines
2013-02-19s3:smbd: s/struct timed_event/struct tevent_timerStefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-19s3:smbd: s/struct event_context/struct tevent_contextStefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2012-07-12s3: Factor out "mark_file_modified"Volker Lendecke1-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>
2012-06-08s3:smbd: remove unnecessary variable readret from read_file()Michael Adam1-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
2012-06-08s3:smbd: remove ancient DMF_FIX from read_file().Michael Adam1-15/+0
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
2012-06-06s3:smbd: remove typedef for struct write_cacheStefan Metzmacher1-9/+9
metze
2012-06-06s3:smbd: make typedef write_cache private to fileio.cStefan Metzmacher1-0/+8
metze
2012-04-06build: Remove SMB_OFF_T, replace with off_tAndrew Bartlett1-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
2011-12-12s3:smbd/fileio: avoid usage of server_event_context()Stefan Metzmacher1-3/+3
metze
2011-06-01lib/util/time.c: timeval_current_ofs_usecRusty Russell1-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>
2011-05-31s3-globals Remove smbd_event_context() (use server_event_context())Andrew Bartlett1-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
2011-04-29s3-smb Use FILE_ATTRIBUTE_ARCHIVE intead of aARCHAndrew Bartlett1-1/+1
This means we use just one constant for this file attribute. Andrew Bartlett
2011-04-14s3: only include smb profiling where needed.Günther Deschner1-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
2011-03-30s3: include smbd/smbd.h where needed.Günther Deschner1-0/+1
Guenther
2010-12-21Keep track of the sparse status of an open file handle. Allows bypass ofJeremy Allison1-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
2010-09-22Fix bug #7693 - smbd changing mode of files on renameJeremy Allison1-6/+7
When using "map archive", don't change the archive bit on renames or writes with UNIX extensions turned on. Jeremy.
2010-07-29s3: Do the ftruncate write cache optimization in one placeVolker Lendecke1-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.
2010-07-29Revert "s3: Avoid pwrite calls for the 1-byte writes with zero content"Volker Lendecke1-50/+4
This reverts commit 6763730304627a58139450fd3e03a0ce48e31bb9.
2010-07-27s3-smbd: Migrated to new spoolss functions for printing.Simo Sorce1-11/+7
Signed-off-by: Jim McDonough <jmcd@samba.org>
2010-07-19s3: Avoid pwrite calls for the 1-byte writes with zero contentVolker Lendecke1-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!
2010-07-09s3: Optimize the write cache for sequential writesVolker Lendecke1-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.
2010-04-30smbd: move printfile_offset() within write_file()Simo Sorce1-0/+3
2010-04-23s3-smbd: group print relate data in own structureSimo Sorce1-3/+4
2009-11-16Don't overwrite a dynamic pointer with the address of a stackJeremy Allison1-8/+6
variable. Jeremy.
2009-11-05Got the logic simplification worked out so we still passJeremy Allison1-4/+4
BASE-DELAYWRITE and also RAW-CLOSE. Jeremy.
2009-11-05Get closer to an accurate model of Windows timestamp changes.Jeremy Allison1-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.
2009-07-20s3: Change fsp->fsp_name to be an smb_filename struct!Tim Prouty1-29/+28
2009-07-10Remove reply_unixerror() - no longer needed. Should make Metze's refactoring ↵Jeremy Allison1-0/+1
a lot easier. Jeremy.
2009-07-08s3: Plumb smb_filename through dos_mode() and related funtionsTim Prouty1-18/+16
2009-07-06s3: Plumb smb_filename around SMB_VFS_CHFLAGSTim Prouty1-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.
2009-07-01Ensure we don't use delayed writes on POSIX opened files.Jeremy Allison1-0/+10
Don't remove pending writetime changes if no time changes are sent in UNIX_BASIC infolevel. Jeremy
2009-06-24s3: Plumb smb_filename through SMB_VFS_STAT and SMB_VFS_LSTATTim Prouty1-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.
2009-05-26Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STATVolker Lendecke1-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.
2009-03-01Only copy sharename up from rap_to_pjobidVolker Lendecke1-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 :-)
2009-02-09s3 oplocks: Make the level2 oplock contention API more granularTim Prouty1-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.
2009-01-08s3:smbd: move all globals and static variables in globals.[ch]Stefan Metzmacher1-3/+1
The goal is to move all this variables into a big context structure. metze
2009-01-05s3:events: change event_add_timed() prototype to match samba4Stefan Metzmacher1-2/+1
metze
2008-12-23Fix more asprintf warnings and some error path errors.Jeremy Allison1-3/+6
Jeremy.
2008-09-12Modify a comment to make things clearer.Jeremy Allison1-1/+3
Jeremy. (This used to be commit 9d55ca85ffc73e3fa5fb9895fbcb1ee22f4e320d)
2008-09-08smbd: some write time fixesStefan Metzmacher1-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)
2008-09-05Write times code update.Jeremy Allison1-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)
2008-04-07smbd: make it possible to change the write time delay for testingStefan Metzmacher1-1/+7
metze (This used to be commit df8c100c2b53575a0d425a2daf52e2d59904746a)
2008-04-07smbd: implement the strange write time update logicStefan Metzmacher1-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)
2008-01-07Remove redundant parameter fd from SMB_VFS_FTRUNCATE().Michael Adam1-1/+1
Michael (This used to be commit 2ad66050a0452b8e7e08b1e7a01efa00c72fd451)
2008-01-07Remove redundant parameter fd from SMB_VFS_FSTAT().Michael Adam1-2/+2
Michael (This used to be commit 0b86c420be94d295f6917a220b5d699f65b46711)
2008-01-07Remove redundant parameter fd from SMB_VFS_FSYNC().Michael Adam1-1/+1
Michael (This used to be commit 8f83c9a7b245dbfef28195f9a7f33047a8ba95a0)
2008-01-07Remove unneeded parameter fd from SMB_VFS_PREAD().Michael Adam1-2/+2
Michael (This used to be commit 73e28806ce87d829ea7c38ed3440020845bb13bf)
2007-10-31Note when we're setting change time, not write time, and sendJeremy Allison1-1/+2
message accordingly. Apart from not supporting create time we now pass the S4 RAW-NOTIFY torture. Jeremy. (This used to be commit 8a77f520fa03afa60eac2aaeab4babe7dd8db4f0)
2007-10-31Fix some cases where file_set_dosmode was being passedJeremy Allison1-2/+7
False instead of NULL. Fix more of the notifications to be correct for Samba4 RAW-NOTIFY torture (we had missed one when calling set_ea_dos_attribute(). Jeremy. (This used to be commit 39d265375cf55eedddef2c4faa65398df73d5ed2)
2007-10-30Add new parameter, "min receivefile size" (by default setJeremy Allison1-12/+29
to zero). If non-zero, writeX calls greater than this value will be left in the socket buffer for later handling with recvfile (or userspace equivalent). Definition of recvfile for your system is left as an exercise for the reader (I'm working on getting splice working :-). Jeremy. (This used to be commit 11c03b75ddbcb6e36b231bb40a1773d1c550621c)