nfs4_deleg_ops.c revision cfae96c24c7523c74c9efb583764b812b6b309c5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <nfs/nfs4_kprot.h>
extern u_longlong_t nfs4_srv_caller_id;
/*
* This file contains the code for the monitors which are placed on the vnodes
* of files that are granted delegations by the nfsV4 server. These monitors
* will detect local access, as well as access from other servers
* (NFS and CIFS), that conflict with the delegations and recall the
* delegation from the client before letting the offending operation continue.
*
* If the caller does not want to block while waiting for the delegation to
* be returned, then it should set CC_DONTBLOCK in the flags of caller context.
* This does not work for vnevnents; remove and rename, they always block.
*/
/*
* This is the function to recall a delegation. It will check if the caller
* wishes to block or not while waiting for the delegation to be returned.
* If the caller context flag has CC_DONTBLOCK set, then it will return
* an error and set CC_WOULDBLOCK instead of waiting for the delegation.
*/
int
{
/* optimization that may not stay */
/* if it has been returned, we're done. */
return (0);
}
return (NFS4ERR_DELAY);
}
}
}
return (0);
}
/* monitor for open on read delegated file */
int
int mode,
{
int rc;
/*
* Now that the NFSv4 server calls VOP_OPEN, we need to check to
* to make sure it is not us calling open (like for DELEG_CUR) or
* we will end up panicing the system.
* Since this monitor is for a read delegated file, we know that
* only an open for write will cause a conflict.
*/
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
/* monitor for open on write delegated file */
int
int mode,
{
int rc;
/*
* Now that the NFSv4 server calls VOP_OPEN, we need to check to
* to make sure it is not us calling open (like for DELEG_CUR) or
* we will end up panicing the system.
* Since this monitor is for a write delegated file, we know that
* any open will cause a conflict.
*/
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
/*
* This is op is for write delegations only and should only be hit
* by the owner of the delegation. If not, then someone is
* doing a read without doing an open first. Like from nfs2/3.
*/
int
int ioflag,
struct caller_context *ct)
{
int rc;
/* Use caller context to compare caller to delegation owner */
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
/*
* If someone is doing a write on a read delegated file, it is a conflict.
* conflicts should be caught at open, but NFSv2&3 don't use OPEN.
*/
int
int ioflag,
struct caller_context *ct)
{
int rc;
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
/*
* The owner of the delegation can write the file, but nobody else can.
* Conflicts should be caught at open, but NFSv2&3 don't use OPEN.
*/
int
int ioflag,
struct caller_context *ct)
{
int rc;
/* Use caller context to compare caller to delegation owner */
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
/* Doing a setattr on a read delegated file is a conflict. */
int
int flags,
{
int rc;
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
/* Only the owner of the write delegation can do a setattr */
int
int flags,
{
int rc;
/*
* Use caller context to compare caller to delegation owner
*/
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
int
int write_lock,
{
int rc;
/*
* If this is a write lock, then we got us a conflict.
*/
if (write_lock) {
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
/* Only the owner of the write delegation should be doing this. */
int
int write_lock,
{
int rc;
/* Use caller context to compare caller to delegation owner */
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
int
int cmd,
int flag,
{
int rc;
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
int
int cmd,
int flag,
{
int rc;
/* Use caller context to compare caller to delegation owner */
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
}
int
int flag,
{
int rc;
/* Changing security attribute triggers recall */
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
int
int flag,
{
int rc;
/* Changing security attribute triggers recall */
if (rc == NFS4ERR_DELAY)
return (EAGAIN);
}
int
char *name,
{
switch (vnevent) {
case VE_REMOVE:
case VE_RENAME_DEST:
/*FALLTHROUGH*/
case VE_RENAME_SRC:
}
}
break;
default:
break;
}
}
int
char *name,
{
switch (vnevent) {
case VE_REMOVE:
case VE_RENAME_DEST:
/*FALLTHROUGH*/
case VE_RENAME_SRC:
}
}
break;
default:
break;
}
}