if (!(lock->lk_stateowner = alloc_init_lock_stateowner(strhashval, open_sop->so_client, open_stp, lock))) 
lock_sop = alloc_init_lock_stateowner(strhashval, open_sop->so_client, open_stp, lock); if (lock_sop == NULL) 
nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner){	struct nfs4_stateowner *open_sop = NULL;	struct nfs4_stateid *lock_stp;	struct file *filp;	struct file_lock file_lock;	struct file_lock *conflock;	int status = 0;	unsigned int strhashval;	dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",		(long long) lock->lk_offset,		(long long) lock->lk_length);	if (check_lock_length(lock->lk_offset, lock->lk_length))		 return nfserr_inval;	nfs4_lock_state();	if (lock->lk_is_new) {		/*		 * Client indicates that this is a new lockowner.		 * Use open owner and open stateid to create lock owner and		 * lock stateid.		 */		struct nfs4_stateid *open_stp = NULL;		struct nfs4_file *fp;				status = nfserr_stale_clientid;		if (STALE_CLIENTID(&lock->lk_new_clientid))			goto out;		/* validate and update open stateid and open seqid */		status = nfs4_preprocess_seqid_op(current_fh, 				        lock->lk_new_open_seqid,		                        &lock->lk_new_open_stateid,		                        CHECK_FH | OPEN_STATE,		                        &open_sop, &open_stp, lock);		if (status)			goto out;		/* create lockowner and lock stateid */		fp = open_stp->st_file;		strhashval = lock_ownerstr_hashval(fp->fi_inode, 				open_sop->so_client->cl_clientid.cl_id, 				&lock->v.new.owner);		/* XXX: Do we need to check for duplicate stateowners on		 * the same file, or should they just be allowed (and		 * create new stateids)? */		status = nfserr_resource;		if (!(lock->lk_stateowner = alloc_init_lock_stateowner(strhashval, open_sop->so_client, open_stp, lock)))			goto out;		if ((lock_stp = alloc_init_lock_stateid(lock->lk_stateowner, 						fp, open_stp)) == NULL) {			release_stateowner(lock->lk_stateowner);			lock->lk_stateowner = NULL;			goto out;		}		/* bump the open seqid used to create the lock */		open_sop->so_seqid++;	} else {		/* lock (lock owner + lock stateid) already exists */		status = nfs4_preprocess_seqid_op(current_fh,				       lock->lk_old_lock_seqid, 				       &lock->lk_old_lock_stateid, 				       CHECK_FH | LOCK_STATE, 				       &lock->lk_stateowner, &lock_stp, lock);		if (status)			goto out;	}	/* lock->lk_stateowner and lock_stp have been created or found */	filp = lock_stp->st_vfs_file;	if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) {		dprintk("NFSD: nfsd4_lock: permission denied!\n");		goto out;	}	status = nfserr_grace;	if (nfs4_in_grace() && !lock->lk_reclaim)		goto out;	status = nfserr_no_grace;	if (!nfs4_in_grace() && lock->lk_reclaim)		goto out;	locks_init_lock(&file_lock);	switch (lock->lk_type) {		case NFS4_READ_LT:		case NFS4_READW_LT:			file_lock.fl_type = F_RDLCK;		break;		case NFS4_WRITE_LT:		case NFS4_WRITEW_LT:			file_lock.fl_type = F_WRLCK;		break;		default:			status = nfserr_inval;		goto out;	}	file_lock.fl_owner = (fl_owner_t) lock->lk_stateowner;	file_lock.fl_pid = current->tgid;	file_lock.fl_file = filp;	file_lock.fl_flags = FL_POSIX;	file_lock.fl_start = lock->lk_offset;	if ((lock->lk_length == ~(u64)0) || 			LOFF_OVERFLOW(lock->lk_offset, lock->lk_length))		file_lock.fl_end = ~(u64)0;	else		file_lock.fl_end = lock->lk_offset + lock->lk_length - 1;	nfs4_transform_lock_offset(&file_lock);	/*	* Try to lock the file in the VFS.	* Note: locks.c uses the BKL to protect the inode's lock list.	*/	status = posix_lock_file(filp, &file_lock);	if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private)		file_lock.fl_ops->fl_release_private(&file_lock);	dprintk("NFSD: nfsd4_lock: posix_lock_file status %d\n",status);	switch (-status) {	case 0: /* success! */		update_stateid(&lock_stp->st_stateid);		memcpy(&lock->lk_resp_stateid, &lock_stp->st_stateid, 				sizeof(stateid_t));		goto out;	case (EAGAIN):		goto conflicting_lock;	case (EDEADLK):		status = nfserr_deadlock;	default:        		dprintk("NFSD: nfsd4_lock: posix_lock_file() failed! status %d\n",status);		goto out_destroy_new_stateid;	}conflicting_lock:	dprintk("NFSD: nfsd4_lock: conflicting lock found!\n");	status = nfserr_denied;	/* XXX There is a race here. Future patch needed to provide 	 * an atomic posix_lock_and_test_file	 */	if (!(conflock = posix_test_lock(filp, &file_lock))) {		status = nfserr_serverfault;		goto out;	}	nfs4_set_lock_denied(conflock, &lock->lk_denied);out_destroy_new_stateid:	if (lock->lk_is_new) {		dprintk("NFSD: nfsd4_lock: destroy new stateid!\n");		/*		 * An error encountered after instantiation of the new		 * stateid has forced us to destroy it.		 */		if (!seqid_mutating_err(status))			open_sop->so_seqid--;		release_state_owner(lock_stp, LOCK_STATE);	}out:	if (lock->lk_stateowner) {		nfs4_get_stateowner(lock->lk_stateowner);		*replay_owner = lock->lk_stateowner;	}	nfs4_unlock_state();	return status;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b59e3c0e172e3f3a147021aa16b929482b8d5846/nfs4state.c/buggy/fs/nfsd/nfs4state.c