Commit graph

373 commits

Author SHA1 Message Date
Olga Kornievskaia
e09a179f66 fattr4_word0_acl query during nfs41_acl_query upcall
querying the server for the acl attribute during the nfs41_acl_query upcall.

no mapping of the nfs41 acl to the windows dacl yet.
2011-04-12 15:37:49 -04:00
Casey Bodley
cc2efe6a96 callback: replay cache for back channel
nfs41_cb_session stores the last cb_compound reply (whether or not cachethis was set) to handle retry attempts, along with the cb_compound arguments for improved NFS4ERR_SEQ_FALSE_RETRY detection

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-04-12 15:32:47 -04:00
Casey Bodley
ce200a4c2d recovery: fix for expired clientid on retried CREATE_SESSION
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-04-12 14:09:42 -04:00
Casey Bodley
7da9740908 bug fix for DESTROY_CLIENTID sending wrong clientid
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-04-12 14:09:32 -04:00
Olga Kornievskaia
b6d81b3419 xdr encode decode acl and dacl attributes
acls are lists of arbitrary length, so xdr_array() is used to allocate the array
 during decode.  because this memory is allocated by the tirpc library, it needs
 to be freed there as well; added function nfsacl41_free() to do this with XDR_F
REE

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-04-12 14:07:24 -04:00
Olga Kornievskaia
b9e369fac6 adding query for FileInternalInformation infoclass
this query asks for a file index which is unique identifier for a file which
we can satisfy from file attribute called "fileid"
2011-04-12 14:06:13 -04:00
Olga Kornievskaia
6aab42a4b5 adding cancel routine to mount
a user process can start a mount command and ctl-c it before it completes.
the deamon then would have a mount that we can never unmount.
2011-03-25 13:17:23 -04:00
Olga Kornievskaia
ab55e6e8c5 first stab at handling security irp
Basic handling of owner and group security query (no dacl).

Added new upcall for NFS41_ACL_QUERY (driver and daemon code).

Daemon, upon getting NFS41_ACL_QUERY first places a getattr that has
owner, group attribute request. We currently don't cache them!!!

Then, we parse nfs4name format (ie user@domain or group@domain)
into user and domain. We currently ignore domain part!!!

Then, we assume that whatever we are mapping is "known" locally
(ie LookupAccountName() api which retrieves a SID for a given name).
Mapping from name to SID can only be done in the userland. We then
copy the bytes via the upcall pipe to the kernel. If the received
user or group cant be mapped via LookupAccoundName(), we create a
well known null SID as the reply.

Kernel creates a security descriptor in the absolute-format and adds
owner and group sids to it. Important: RtlSetOwner/Group functions only
work with absolute-format security descriptor, however the reply to the
user needs to be in the self-relative format.

The way security query works is that it passes us a buffer to be filled
with the security context. However the user doesn't know how big the
buffer should be so, the user is allowed to pass a null buffer and have
the kernel return how much memory is needed. This leads to 2 security
queries => 2 NFS41_ACL_QUERY upcalls => 2 getattr rpcs... It should be
improved.

TODO:
- need to add caching of owner/group attributes for a file?
- need to add calls to LDAP for more general mapping?
- need to cache reply of the ACL if supplied length is 0?
2011-03-22 17:21:13 -04:00
Olga Kornievskaia
d2ba08614c returning acl support to driver 2011-03-22 17:21:12 -04:00
Olga Kornievskaia
887caeb922 failing rename of onto an opened file
adding a check to see if the destination filename is currently opened by
looking through the list of open states stored for a given client.

fail rename with ERROR_FILE_EXISTS if we find an open.
2011-03-22 14:49:28 -04:00
Olga Kornievskaia
8d171e71a0 send DESTROY_CLIENTID on unmount 2011-03-22 14:49:28 -04:00
Olga Kornievskaia
4355e06153 fixing compile warnings in nfs41_xdr.c 2011-03-22 14:49:26 -04:00
Olga Kornievskaia
b6d6767341 define for nfs4stateid.other constant 2011-03-22 14:49:26 -04:00
Casey Bodley
49f141680a pnfs: validate stripe unit and count to prevent div/0
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-22 14:49:25 -04:00
Casey Bodley
bf53e3dc1a pnfs: new locking model for layouts
exclusive locks are no longer held over LAYOUTGET, LAYOUTRETURN, or GETDEVICEINFO rpcs.  this prevents a deadlock when CB_LAYOUTRECALL needs an exclusive lock while another operation is on the wire

introduced a 'pending' condition variable to protect access to state->layout while the layout's lock is not held

updated file_layout_recall() to compare the stateid sequence numbers to determine if the server has processed an outstanding LAYOUTGET or LAYOUTRETURN, where we're required to reply with NFS4ERR_DELAY

LAYOUTGET, LAYOUTRETURN, and GETDEVICEINFO can now be sent with try_recovery=TRUE because they no longer hold an exclusive lock.  this makes it possible for recover_client_state() to recall all of the client's layouts without deadlocking

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-22 14:49:25 -04:00
Casey Bodley
c9585d937f pnfs: readwrite uses pnfs_layout_state
nfs41_lock_stateid_arg() is now called only once in handle_read()/handle_write(), and pnfs_read()/pnfs_write() no longer depend on nfs41_open_state

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-22 14:49:24 -04:00
Casey Bodley
8c3da98cde pnfs: update layout state on layoutget/return/recall
on a successful LAYOUTGET, file_layout_fetch() calls layout_update() to copy the first layout segment returned and update the layout stateid
on a successful LAYOUTRETURN, file_layout_return() frees the layout segment and updates/clears the stateid

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-22 14:49:24 -04:00
Casey Bodley
159ad405bb pnfs: layoutget, layoutreturn rpcs no longer operate on shared data
LAYOUTGET xdr now supports decoding of multiple layout segments, which are returned in a list with pnfs_layoutget_res_ok
LAYOUTRETURN no longer operates on an existing pnfs_file_layout.  it now takes a copy of the layout stateid, and returns the new stateid with pnfs_layoutreturn_res

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-22 14:49:23 -04:00
Casey Bodley
248c14b6ae pnfs: struct pnfs_layout_state to manage layout state
moved state data (stateid, flags, locks, and reference counts) out of struct pnfs_layout, which should represent a layout segment returned by LAYOUTGET
struct pnfs_layout_state now holds this state, along with a pointer to a single pnfs_file_layout
struct pnfs_file_layout_list is now a list of pnfs_layout_states, and was renamed to pnfs_layout_list

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-22 14:49:22 -04:00
Olga Kornievskaia
21a4fdd563 ignoring errors from BIND_CONN_TO_SESSION 2011-03-10 11:35:58 -05:00
Olga Kornievskaia
c11e5ebce2 query for aclsupport per superblock 2011-03-10 11:31:57 -05:00
Casey Bodley
87f1005ea0 pnfs: avoid LAYOUTCOMMIT for DATA_SYNC or commit to mds
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-09 12:53:22 -05:00
Olga Kornievskaia
79455f9855 OP_GETATTR queries OWNER and OWNER_GROUP 2011-03-08 13:34:25 -05:00
Olga Kornievskaia
741e8bf0bf non-blocking rpc receive
we already drop the lock between sending and receiving the rpc packets. now making it so that receive doesn't block for too long (ie 100ms) before unlocking the socket. this is needed for the callback. original rpc is sent and it triggers a callback from the server. we fork another thread to handle it, ie it needs to send a deleg_return rpc. if original rpc gets control and blocks on trying to receive its reply, it'll timeout and original rpc will return an error. instead we need to not block for long and allow the deleg_return to go thru so that the server can reply successfully to the original rpc.
2011-03-08 11:04:44 -05:00
Casey Bodley
d7e438be5e pnfs: only return-on-close for last close
added pnfs_layout.open_count to count open references, and only return the layout when pnfs_open_state_close() takes the open_count to 0

use InterlockedIncrement/Decrement to avoid an exclusive lock on the layout

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:43 -05:00
Olga Kornievskaia
e0fc4cf985 check for null client session before BIND_CONN 2011-03-08 11:04:42 -05:00
Casey Bodley
0c2148da5b pnfs: support for mdsthreshold attribute
hacked up and tested against bluearc server

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:41 -05:00
Casey Bodley
e3c67c0bfa volume: use actual fh instead of rootfh for volume queries
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:40 -05:00
Casey Bodley
db5983734d cosmetic: removed unused nfs41_renew_in_progress()
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:40 -05:00
Casey Bodley
f0607487d6 cosmetic: remove ; from #define
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:39 -05:00
Casey Bodley
b7e1be5dc1 recovery: recover from BAD_STATEID errors
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:38 -05:00
Casey Bodley
d06b3997ec xdr: encode CREATE_SESSION4args.csa_sec_parms
encode an array of { AUTH_NONE } for callback security params

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-03-08 11:04:38 -05:00
Olga Kornievskaia
47b0ccda9c turning callback off for krb5p
sspi requires strict ordering of messages. we can't have more than 1 outstanding rpc thus, hold the lock over send and receive and turn off callbacks.
2011-02-03 13:13:10 -05:00
Olga Kornievskaia
b6120b41fd setting error status in rpc_reconnect if send_null fails
we were checking for error result of send_null but not setting
status, then going to "out_unlock" and since status is NO_ERROR
trying to send bind_conn_to_session
2011-01-17 11:55:36 -05:00
Olga Kornievskaia
3a60f23c91 cosmetic changing printouts in check_execute_access
adding the filename to the printouts and changing eprintf back to dprintf as it it happens too often.
2011-01-13 11:41:49 -05:00
Casey Bodley
089a52906b rpc: don't malloc server_name for getnameinfo()
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-12 12:40:40 -05:00
Casey Bodley
9c960aa409 rpc: rebind back channel on reconnect
after reestablishing an rpc connection, send BIND_CONN_TO_SESSION if we need a back channel

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-12 12:40:40 -05:00
Casey Bodley
9c59af4da5 fixes for bind_conn_to_session()
fixes for xdr encoding of bind_conn_to_session, after testing against linux server

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-12 12:40:39 -05:00
Casey Bodley
eb60a1ee6d check_execute_access() prints errors with eprintf()
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:18 -05:00
Casey Bodley
238a8a7015 callback: handles xdr decode errors
instead of ignoring errors from proc_cb_compound_args(), return NFS4ERR_BADXDR.  note that we still need to allocate the cb_compound_res structure to return this error

added null checks to the end of handle_cb_compound(); if the cb_compound_res allocation fails, we'd crash trying to access res->status and res->resarray_count

also fixed some indenting

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:18 -05:00
Casey Bodley
034b2b4ea2 nfs41_session_renew() error handling
on failure to renew a session, we don't need to free the session (this leads to crashes).  if we simply return the error to compound_encode_send_decode(), we'll fail any subsequent operations on the session, but still be able to unmount and remain stable

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:18 -05:00
Casey Bodley
757b637607 create_session uses compound_encode_send_decode()
send CREATE_SESSION with compound_encode_send_decode() instead of nfs41_send_compound() for its NFS4ERR_DELAY and NFS4ERR_STALE_CLIENTID handling

added 'try_recovery' argument to nfs41_create_session(), which is passed on to compound_encode_send_decode().  nfs41_session_renew() uses try_recovery=FALSE, because it handles the NFS4ERR_STALE_CLIENTID error on its own.  nfs41_session_create() uses try_recovery=TRUE to make use of the NFS4ERR_STALE_CLIENTID error handling.  modified the NFS4ERR_STALE_CLIENTID block to call nfs41_client_renew() and retry the operation (i.e. CREATE_SESSION), instead of falling through to session recovery

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:17 -05:00
Casey Bodley
f2095915aa cosmetic changes to lookup.c
removed unused variable 'buffer_size' in lookup_rpc()
renamed map_lookup_error()'s parameter 'is_last_component' to 'last_component' to avoid conflicting with function is_last_component()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:17 -05:00
Casey Bodley
7ccdf2ba47 mount: memory leak on path overflow
changed goto out -> out_err, so the root is freed on buffer overflow
updated error messages for nfs41_root_create() and nfs41_root_mount_addrs()
if the root lookup fails, return ERROR_BAD_NETPATH instead of ERROR_FILE_NOT_FOUND

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:17 -05:00
Casey Bodley
229ec94c5c propagate errors from nfs41_name_cache_create()
server_create() was ignoring the return value of nfs41_name_cache_create(), but it needs to be propagated all the way back through nfs41_server_find_or_create() to nfs41_client_create() and nfs41_client_renew()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-10 15:16:17 -05:00
Casey Bodley
81051ddce1 recovery: revoke all layouts and device info on client recovery
12.7.4. Recovery from Metadata Server Restart
"The client MUST stop using layouts and delete the device ID to device address mappings it previously received from the metadata server."

during client state recovery, call pnfs_file_layout_recall() to revoke all layouts and devices held by the client

LAYOUTGET, LAYOUTRETURN, and GETDEVICEINFO are all sent under their respective locks, and pnfs_file_layout_recall() requires a lock on each layout and device it operates on, so this would cause a deadlock if one of those operations triggered the recovery.  to avoid this, LAYOUTGET, LAYOUTRETURN, and GETDEVICEINFO are all sent with try_recovery=FALSE.  this behavior is preferable for recovery, because errors in the pnfs path cause us to fall back to the metadata server

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-04 14:26:28 -05:00
Casey Bodley
9cd9744567 pnfs: revoke device info on bulk layout recall
20.3. CB_LAYOUTRECALL
"LAYOUTRECALL4_FSID and LAYOUTRECALL4_ALL specify that all the storage device ID to storage device address mappings in the affected file system(s) are also recalled."

pnfs_file_layout_recall() now takes a nfs41_client instead of just the pnfs_file_layout_list, because both the layout list and device list are accessible from nfs41_client.  for bulk recalls, calls new function pnfs_file_device_list_invalidate().  each device with layout_count=0 is removed and freed, and devices in use are flagged as REVOKED and freed when layout_count->0

layout_recall_return() now takes a pnfs_file_layout instead of pnfs_layout for access to pnfs_file_layout.device.  pnfs_layout_io_start() and pnfs_layout_io_finish() do the same, because pnfs_layout_io_finish() calls layout_recall_return().  layout_recall_return() calls pnfs_file_device_put() to release its reference on the device

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-04 14:26:26 -05:00
Casey Bodley
e3119c281e pnfs: added status flags and ref count to struct pnfs_device
pnfs_device.status remembers whether a given device has been GRANTED/REVOKED

pnfs_device.layout_count tracks the number of layouts using the device, incremented by pnfs_file_device_get() and decremented by pnfs_file_device_put().  when pnfs_file_device_put() takes layout_count to 0, remove and free the device only if it's flagged as REVOKED

because pnfs_file_device_get() modifies pnfs_device.layout_count, we can no longer use a shared lock; changed pnfs_file_device.lock from SRWLOCK to CRITICAL_SECTION, and moved to pnfs_device.lock to document the fact that it's used for pnfs_device.status and pnfs_device.layout_count

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2011-01-04 14:26:23 -05:00
Casey Bodley
4ea730c881 fix for daemon version checking crash on close
upcall_cleanup() is called after every upcall regardless of errors.  if we get a CLOSE upcall after a daemon restart, we still call cleanup_close() and crash attempting to access the invalid open state pointer.  avoid calling upcall-specific cancel routines for these version mismatch errors

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-12-17 14:26:17 -05:00
Casey Bodley
853dcc385e recovery: lock_owner to open_owner
if we're recovering a lock stateid for a LOCK operation, and the file has no outstanding locks, we won't be able to recover a lock stateid.  resend the LOCK with an open stateid instead

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-12-13 13:35:56 -05:00