FreeBSD/sys/fs/nfsclient/nfs_clstate.c
/*
 * Search for a layout by MDS file handle.
 * If one is found, it is returned with a refcnt (shared lock) iff
 * retflpp returned non-NULL and locked (exclusive locked) iff retflpp is
 * returned NULL.
 */
Search for a layout by MDS file handle.
If one is found, it is returned with a refcnt (shared lock) iff
retflpp returned non-NULL and locked (exclusive locked) iff retflpp is
returned NULL.
Search for a layout by MDS file handle . If one is found it is returned with a refcnt ( shared lock ) iff retflpp returned non - NULL and locked ( exclusive locked ) iff retflpp is returned NULL .
struct nfscllayout *
nfscl_getlayout(struct nfsclclient *clp, uint8_t *fhp, int fhlen,
    uint64_t off, struct nfsclflayout **retflpp, int *recalledp)
{
	struct nfscllayout *lyp;
	mount_t mp;
	int error, igotlock;
	mp = clp->nfsc_nmp->nm_mountp;
	*recalledp = 0;
	*retflpp = NULL;
	NFSLOCKCLSTATE();
	lyp = nfscl_findlayout(clp, fhp, fhlen);
	if (lyp != NULL) {
		if ((lyp->nfsly_flags & NFSLY_RECALL) == 0) {
			TAILQ_REMOVE(&clp->nfsc_layout, lyp, nfsly_list);
			TAILQ_INSERT_HEAD(&clp->nfsc_layout, lyp, nfsly_list);
			lyp->nfsly_timestamp = NFSD_MONOSEC + 120;
			error = nfscl_findlayoutforio(lyp, off,
			    NFSV4OPEN_ACCESSREAD, retflpp);
			if (error == 0)
				nfsv4_getref(&lyp->nfsly_lock, NULL,
				    NFSCLSTATEMUTEXPTR, mp);
			else {
				do {
					igotlock = nfsv4_lock(&lyp->nfsly_lock,
					    1, NULL, NFSCLSTATEMUTEXPTR, mp);
				} while (igotlock == 0 &&
				    (mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0);
				*retflpp = NULL;
			}
			if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
				lyp = NULL;
				*recalledp = 1;
			}
		} else {
			lyp = NULL;
			*recalledp = 1;
		}
	}
	NFSUNLOCKCLSTATE();
	return (lyp);
}
struct nfscllayout * nfscl_getlayout ( struct nfsclclient * clp , uint8_t * fhp , int fhlen , uint64_t off , struct nfsclflayout * * retflpp , int * recalledp ) { struct nfscllayout * lyp ; mount_t mp ; int error , igotlock ; mp = clp -> nfsc_nmp -> nm_mountp ; * recalledp = 0 ; * retflpp = NULL ; NFSLOCKCLSTATE ( ) ; lyp = nfscl_findlayout ( clp , fhp , fhlen ) ; if ( lyp != NULL ) { if ( ( lyp -> nfsly_flags & NFSLY_RECALL ) == 0 ) { TAILQ_REMOVE ( & clp -> nfsc_layout , lyp , nfsly_list ) ; TAILQ_INSERT_HEAD ( & clp -> nfsc_layout , lyp , nfsly_list ) ; lyp -> nfsly_timestamp = NFSD_MONOSEC + 120 ; error = nfscl_findlayoutforio ( lyp , off , NFSV4OPEN_ACCESSREAD , retflpp ) ; if ( error == 0 ) nfsv4_getref ( & lyp -> nfsly_lock , NULL , NFSCLSTATEMUTEXPTR , mp ) ; else { do { igotlock = nfsv4_lock ( & lyp -> nfsly_lock , 1 , NULL , NFSCLSTATEMUTEXPTR , mp ) ; } while ( igotlock == 0 && ( mp -> mnt_kern_flag & MNTK_UNMOUNTF ) == 0 ) ; * retflpp = NULL ; } if ( ( mp -> mnt_kern_flag & MNTK_UNMOUNTF ) != 0 ) { lyp = NULL ; * recalledp = 1 ; } } else { lyp = NULL ; * recalledp = 1 ; } } NFSUNLOCKCLSTATE ( ) ; return ( lyp ) ; }
Search for a layout by MDS file handle.
Search for a layout by MDS file handle .