nfs4_shadow.c revision bbf2a467fb32eb69d2254866ccab51e89829ff38
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The contents of this file are subject to the terms of the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Common Development and Distribution License (the "License").
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You may not use this file except in compliance with the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * When distributing Covered Code, include this CDDL HEADER in each
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * If applicable, add the following below this CDDL HEADER, with the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * fields enclosed by brackets "[]" replaced with your own identifying
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * information: Portions Copyright [yyyy] [name of copyright owner]
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER END
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic int sv_match(nfs4_fname_t *, nfs4_sharedfh_t *, svnode_t *);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Map a vnode back to the shadow which points to it. This is
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * hard now that the vnode is not embedded in the shadow vnode.
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna /* Check to see if it's the master shadow vnode first. */
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna for (svp = rp->r_svnode.sv_forw; svp != &rp->r_svnode;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * sv_activate - find and activate the shadow vnode for the given
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * directory file handle and name. May replace *vpp with a held reference
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * to a different vnode, in which case the reference to the previous one is
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * released.
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatnasv_activate(vnode_t **vpp, vnode_t *dvp, nfs4_fname_t **namepp, int newnode)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * If make_rnode made a new rnode (ie. newnode != 0), then
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the master vnode was (partially) initialized there. If
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * it was not a new rnode, then it returns the master vnode.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Call sv_find to find and/or initialize the shadow
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Initialize the shadow vnode.
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna } else if ((*vpp)->v_type == VREG && !((*vpp)->v_flag & VROOT)) {
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * Directories only have a single shadow vnode which
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * is the master shadow vnode. This is because directories
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * can't have hard links. If sv_activate() is
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * called for an existing rnode (newnode isn't set)
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * but with a new name the fname needs to be updated
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * and the old one released.
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * fname mismatches can occur due to server side renames,
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * here is a chance to update the fname in case there is
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * a mismatch. Since this is not a newnode we hold r_svlock
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * to protect sv_name.
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * Call fn_rele() to release the hold for the
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * previous shadow vnode reference. Don't
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * release the hold on the fname pointed to by
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * namepp as we have new reference to it from
1107ea9346159bcc8ea154084897667347c4e6d5Sriharsha Basavapatna * this shadow vnode.
vnode_t *
return (mvp);
return (vp);
return (vp);
nfs4_shadow_init(void)
nfs4_shadow_fini(void)