Commit graph

343 commits

Author SHA1 Message Date
Casey Bodley
db5e8f9d34 ERR_STALE: skip recovery on NULL path
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 12:11:43 -04:00
Casey Bodley
bb73eec774 bug fix: avoid infinite loops by checking for len=0 on read/write
/* we shouldn't ever see this, but a buggy server could
 * send us into an infinite loop. return NFS4ERR_IO */

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 12:11:38 -04:00
Casey Bodley
e4b1bc6ccc pnfs: set stateid.seqid to 0 for data server io
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 12:11:27 -04:00
Casey Bodley
eefff7c222 max_path: raise MAX_PATH and UPCALL_BUF_SIZE
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:11 -04:00
Casey Bodley
66d4ea8e0b max_path: static buffer for symlink path
added nfs41_abs_path symlink to struct open_upcall_args. we can't write the symlink target back to args->path anymore, since it's a pointer into the upcall buffer

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:11 -04:00
Casey Bodley
6d2b631080 max_path: make an abs_path for lookup on mount
in handle_mount(), the call to nfs41_lookup() requires a mutable nfs41_abs_path because it can change on referrals, so make a copy for it

removed unused fields in struct nfs41_root and related arguments to nfs41_root_create()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:10 -04:00
Casey Bodley
f727a1e4b4 max_path: get_name() avoids copying from upcall buffer
because we no longer have to convert strings from unicode, we can avoid copying them out of the upcall buffer

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:10 -04:00
Casey Bodley
95361423f3 upcall: set upcall.status on parse failure
when open parsing fails, we were still returning upcall.status==NO_ERROR, so the driver assumed the open succeeded.  other operations then sent up an open_state==NULL, and crashed the daemon.  when upcall_parse() returns an error, set upcall.status to notify the driver

upcall_parse() prints a 'parsing of upcall <name> failed with <error>.' message on failure, so i removed redundant messages from the individual upcall parsing functions

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:08 -04:00
Casey Bodley
a0cda354be first stab at impersonation 2010-10-12 10:36:08 -04:00
Casey Bodley
74a704120b symlink: open calls READLINK and updates the path
when handle_open() encounters a file of type NF4LNK and the FILE_OPEN_REPARSE_POINT flag is not present, it calls READLINK for the symlink's target path.  it then calls abs_path_link() to update the filename (args->path), whether the symlink target is an absolute or relative path.  abs_path_link() also takes into account the special characters . and .., though it doesn't allow traversing .. entries below the root of the server's namespace

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:07 -04:00
Casey Bodley
45a14a17ff symlink: open downcall passes symlink target
on last_error == ERROR_REPARSE, the daemon converts args->path back to wchar and passes it down to the driver

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:06 -04:00
Casey Bodley
374e7ad083 symlink: nfs41_readlink() takes buf,len instead of nfs41_abs_path
also changed nfs41_readlink_res.link from a buffer to a pointer to avoid the extra copy

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:06 -04:00
Casey Bodley
77dcd5bc02 symlink: file and volume attributes
handle_volume_attributes() adds FILE_SUPPORTS_REPARSE_POINTS
nfs_file_info_to_attributes() adds FILE_ATTRIBUTE_REPARSE_POINT for type==NF4LNK

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:05 -04:00
Casey Bodley
5dc1b43191 rmdir: use normal delete upcall instead of close
caused memory leaks of nfs41_open_state.  we have the FileDispositionInformation upcall for exactly this, so there's no need to complicate the close code path

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:04 -04:00
Casey Bodley
d1169b1f6b daemon: logging to files 2010-10-12 10:36:04 -04:00
Casey Bodley
c80946b258 first stab at nfsd as a service 2010-10-12 10:36:03 -04:00
Casey Bodley
88c28ec995 creating shared memory mutex in dll 2010-10-12 10:36:03 -04:00
Casey Bodley
86c16a7197 adding SID to upcall 2010-10-12 10:36:02 -04:00
Casey Bodley
04047a9b53 handling NFS4ERR_OPENMODE on read
if read fails with NFS4ERR_OPENMODE, retry th read with a special stateid.
2010-10-12 10:36:01 -04:00
Casey Bodley
06fa6934cb readdir: view broken referrals as directories
if readdir fails to look up a referred entry, set its type to NF4DIR so windows explorer shows it as a directory.  when you double-click on the directory, it gives a message saying that it "refers to a location that is unavailable"

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:36:00 -04:00
Casey Bodley
680e415104 readdir: look up attributes for referral entries
handle rdattr_error == NFS4ERR_MOVED by calling nfs41_lookup() for attributes

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:35:59 -04:00
Casey Bodley
0d3af99159 cosmetic: moved lookup_entry()
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:35:59 -04:00
Casey Bodley
30decd1af7 readdir: generalized lookup_entry() for use with referrals
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:35:58 -04:00
Casey Bodley
827a1b7368 volume: cache volume attr results with vnetroot
moved the FileSystemName definition back down to the kernel, so the daemon is no longer responsible for setting it.  the driver uses the string length to calculate the buffer size needed for NFS41_V_NET_ROOT_EXTENSION.FsAttrs, and copies in the FileSystemName after the first successful volume attributes upcall

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:58 -04:00
Casey Bodley
8172b5f581 timestamps: setattr uses attributes cansettime,time_delta
added time_delta argument to xdr_settime4().  if the normal 'time' argument is within time_delta of the current time (get_nfs_time()), it uses time_how=SET_TO_SERVER_TIME4.  otherwise, it uses SET_TO_CLIENT_TIME4 and encodes the time as usual

handle_nfs41_setattr() ignores times if superblock->cansettime==0.  otherwise, it passes in superblock->time_delta (via info.time_delta) along with the other time attributes, for use with xdr_settime4()

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:54 -04:00
Casey Bodley
a8eca1ca7b timestamps: nfstime4 helper functions
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:35:53 -04:00
Casey Bodley
e67560fd4a timestamps: superblock stores attributes cansettime,time_delta
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:35:52 -04:00
Casey Bodley
cc298599d8 timestamps: bitmap4 helper functions
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:35:52 -04:00
Casey Bodley
d38360672d volume: daemon handles FileFsAttributeInformation
added FILE_FS_ATTRIBUTE_INFORMATION and FileSystemAttributes flags to from_kernel.h
queries case_preserving, case_insensitive attributes to fill in FileSystemAttributes, and uses #defines from nfs41_const.h for MaximumComponentNameLength and FileSystemName

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:51 -04:00
Casey Bodley
c13ed30b9a volume: daemon handles new generic volume size upcall
added FS_INFORMATION_CLASS, FILE_FS_SIZE_INFORMATION, FILE_FS_FULL_SIZE_INFORMATION to from_kernel.h
moved get_volume_size_info() and byte->unit conversion up to the daemon

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:51 -04:00
Casey Bodley
59b4f5410c cosmetic: removed unused fields of readdir_upcall_args
Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:49 -04:00
Casey Bodley
d345a7b12e name cache: bug fix for name_cache_search()
symptom: in certain cases, name_cache_find_or_create() was returning ERROR_FILE_EXISTS, which should never happen!

cause: the string comparisons in name_cache_search() and name_cache_insert() were returning different results when the argument to name_cache_search() is a) not null-terminated, and b) shorter than the other string.  this caused name_cache_search() to search the wrong branch of the rbtree and fail to find the component, while name_cache_insert() would correctly find it and return ERROR_FILE_EXISTS

fix: compare the string lengths before calling strncmp() to avoid comparing past the end of the component.  moved the comparisons to a separate component_cmp() function called by both name_cache_search() and name_cache_insert() to make sure they get the same result!

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:48 -04:00
Casey Bodley
c72007f076 name cache: LINK inserts target to name cache
the link part of basic test7 was failing because LINK's target was still cached as a negative entry, leading to the error "can't stat newfile.0 after link".  the solution is to replace the negative entry with the real fh and attributes of the target file

so instead of doing RESTOREFH+GETATTR on the source file and calling nfs41_attr_cache_update(), nfs41_link() uses LOOKUP+GETATTR+GETFH to get attributes for the target file and passes them to nfs41_name_cache_insert() along with dst_dir's changeinfo.  because the source and target file will have the same fileid attribute, nfs41_name_cache_insert() will update the attributes of both at the same time.  added the target file as an optional return parameter

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:48 -04:00
Casey Bodley
7db2d60c3b cosmetic: comment describing negative lookup caching
/* negative lookup caching
 *
 * by caching lookups that result in NOENT, we can avoid sending subsequent
 * lookups over the wire.  a name cache entry is negative when its attributes
 * pointer is NULL.  negative entries are created by three functions:
 * nfs41_name_cache_remove(), _insert() when called with NULL for the fh and
 * attributes, and _rename() for the source entry
 */

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:47 -04:00
Casey Bodley
794dfeca49 name cache: lookup semantics match nfs41_lookup() on NOENT
previously, when the name cache encountered a missing/negative/expired entry, it returned the previous two entries as 'target' and 'parent', and nfs41_lookup() started new lookups from the filehandle in 'target'.  this differs from nfs41_lookup(), which on NOENT will return NULL for the 'target' and the previous entry as 'parent'.  modified name_cache_lookup() to do the same, and updated nfs41_lookup() to start new lookups from the filehandle in 'parent'

now when nfs41_lookup() gets the is_negative flag from nfs41_name_cache_lookup(), it can just return the error without needing to copy the 'target' to 'parent'

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:47 -04:00
Casey Bodley
765bc0284b name cache: rename leaves behind a negative entry
as before, we move the src entry from src_parent to dst_parent.  but instead of unlinking the destination entry if it exists, we recycle it as a negative entry where src used to be.  if the destination entry doesn't exist, we create a new one for this negative entry

if the dst_parent entry is invalidated by the change_info, we just leave the original src entry in place and make it negative

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:46 -04:00
Casey Bodley
bc81c3f6f5 name cache: negative entries ignore change_info
negative lookup entries don't have attributes, so we won't invalidate them based on 'change'.  name_cache_entry_changed() returns false if entry->attributes == NULL

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:46 -04:00
Casey Bodley
61ddf671fa name cache: remove changes entry to negative
instead of calling name_cache_entry_unlink(), nfs41_name_cache_remove() calls name_cache_entry_update() with NULL for fh and info to make it a negative entry, then name_cache_unlink_children_recursive() to remove any children

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:45 -04:00
Casey Bodley
6ee8bba79e name cache: merged entry_has_expired() into entry_invis()
Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:44 -04:00
Casey Bodley
bfae29e9c2 name cache: nfs41_lookup() inserts negative entry on NOENT
Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:44 -04:00
Casey Bodley
6bc86c1bff name cache: insert supports negative entries
marked nfs41_name_cache_insert() parameters fh and info as OPTIONAL; passing NULL designates a negative lookup entry
name_cache_entry_create() no longer calls attr_cache_find_or_create(), and doesn't need the 'fileid' argument
name_cache_entry_update() also makes fh and info OPTIONAL, and handles the cases where we switch from a negative <-> positive entry, calling attr_cache_find_or_create() or attr_cache_entry_deref() as appropriate
removed unused function name_cache_find_or_create(); everything uses name_cache_entry_find_or_create() instead, so renamed that to name_cache_find_or_create()

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:43 -04:00
Casey Bodley
112313bc45 name cache: lookup returns flag is_negative
added function entry_invis() in addition to entry_has_expired().  entry_invis() returns true if entry_has_expired() or for negative entries.  the is_negative flag is set for negative entries (defined as having entry->attributes == NULL), and returned by nfs41_name_cache_lookup().  when nfs41_lookup() sees this flag set, it returns the status without attempting to do any more lookups

Signed-off-by: Casey Bodley <cbodley@umich.edu>
2010-10-12 10:35:43 -04:00
Casey Bodley
0ad4db4fad fresh git tree for public release
we regretfully had to remove our git history for licensing reasons

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-12 10:15:48 -04:00