diff options
Diffstat (limited to 'api/src/glfs.c')
| -rw-r--r-- | api/src/glfs.c | 75 | 
1 files changed, 26 insertions, 49 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c index 82873fe7699..efda6b67eae 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -12,11 +12,9 @@  /*    TODO:    - merge locks in glfs_posix_lock for lock self-healing -  - refresh fs->cwd inode on graph switch    - set proper pid/lk_owner to call frames (currently buried in syncop)    - fix logging.c/h to store logfp and loglevel in glusterfs_ctx_t and      reach it via THIS. -  - fd migration on graph switch.    - update syncop functions to accept/return xdata. ???    - protocol/client to reconnect immediately after portmap disconnect.    - handle SEEK_END failure in _lseek() @@ -338,66 +336,41 @@ glfs_fd_new (struct glfs *fs)  	glfd->fs = fs; +	INIT_LIST_HEAD (&glfd->openfds); +  	return glfd;  }  void -glfs_fd_destroy (struct glfs_fd *glfd) +glfs_fd_bind (struct glfs_fd *glfd)  { -	if (!glfd) -		return; -	if (glfd->fd) -		fd_unref (glfd->fd); -	GF_FREE (glfd); -} +	struct glfs *fs = NULL; +	fs = glfd->fs; -xlator_t * -glfs_fd_subvol (struct glfs_fd *glfd) -{ -	xlator_t    *subvol = NULL; - -	if (!glfd) -		return NULL; - -	subvol = glfd->fd->inode->table->xl; - -	return subvol; +	glfs_lock (fs); +	{ +		list_add_tail (&glfd->openfds, &fs->openfds); +	} +	glfs_unlock (fs);  } - -xlator_t * -glfs_active_subvol (struct glfs *fs) +void +glfs_fd_destroy (struct glfs_fd *glfd)  { -	xlator_t      *subvol = NULL; -	inode_table_t *itable = NULL; +	if (!glfd) +		return; -	pthread_mutex_lock (&fs->mutex); +	glfs_lock (glfd->fs);  	{ -		while (!fs->init) -			pthread_cond_wait (&fs->cond, &fs->mutex); - -		subvol = fs->active_subvol; -	} -	pthread_mutex_unlock (&fs->mutex); - -	if (!subvol) -		return NULL; - -	if (!subvol->itable) { -		itable = inode_table_new (0, subvol); -		if (!itable) { -			errno = ENOMEM; -			return NULL; -		} - -		subvol->itable = itable; - -		glfs_first_lookup (subvol); +		list_del_init (&glfd->openfds);  	} +	glfs_unlock (glfd->fs); -	return subvol; +	if (glfd->fd) +		fd_unref (glfd->fd); +	GF_FREE (glfd);  } @@ -456,6 +429,8 @@ glfs_new (const char *volname)  	pthread_mutex_init (&fs->mutex, NULL);  	pthread_cond_init (&fs->cond, NULL); +	INIT_LIST_HEAD (&fs->openfds); +  	return fs;  } @@ -519,7 +494,8 @@ glfs_init_wait (struct glfs *fs)  {  	int   ret = -1; -	pthread_mutex_lock (&fs->mutex); +	/* Always a top-down call, use glfs_lock() */ +	glfs_lock (fs);  	{  		while (!fs->init)  			pthread_cond_wait (&fs->cond, @@ -527,7 +503,7 @@ glfs_init_wait (struct glfs *fs)  		ret = fs->ret;  		errno = fs->err;  	} -	pthread_mutex_unlock (&fs->mutex); +	glfs_unlock (fs);  	return ret;  } @@ -546,6 +522,7 @@ glfs_init_done (struct glfs *fs, int ret)  	init_cbk = fs->init_cbk; +	/* Always a bottom-up call, use mutex_lock() */  	pthread_mutex_lock (&fs->mutex);  	{  		fs->init = 1;  | 
