From: Hongchao Zhang Date: Fri, 9 Sep 2011 11:00:39 +0000 (+0800) Subject: LU-662 fix conflict between seq_client_flush and seq_client_alloc_fid X-Git-Tag: 2.1.0~4 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d1feb5c774d4690a4d4c4828d734a2604438f923 LU-662 fix conflict between seq_client_flush and seq_client_alloc_fid seq_client_flush modifies the lu_client_seq.lcs_space by holding the lu_client_seq.lcs_sem, but seq_client_alloc_fid uses lcs_update to exclude other concurrent modification. Change-Id: Ibc3335841b9a045360283e15aab9b6c36b7a39af Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/1364 Reviewed-by: Andreas Dilger Tested-by: Hudson Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index 5419f8c..214f542 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -316,8 +316,24 @@ EXPORT_SYMBOL(seq_client_alloc_fid); */ void seq_client_flush(struct lu_client_seq *seq) { + cfs_waitlink_t link; + LASSERT(seq != NULL); + cfs_waitlink_init(&link); cfs_down(&seq->lcs_sem); + + while (seq->lcs_update) { + cfs_waitq_add(&seq->lcs_waitq, &link); + cfs_set_current_state(CFS_TASK_UNINT); + cfs_up(&seq->lcs_sem); + + cfs_waitq_wait(&link, CFS_TASK_UNINT); + + cfs_down(&seq->lcs_sem); + cfs_waitq_del(&seq->lcs_waitq, &link); + cfs_set_current_state(CFS_TASK_RUNNING); + } + fid_zero(&seq->lcs_fid); /** * this id shld not be used for seq range allocation. diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index 70b5c9c..633607d 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -272,8 +272,10 @@ seq_client_proc_write_width(struct file *file, const char *buffer, cfs_down(&seq->lcs_sem); rc = lprocfs_write_helper(buffer, count, &val); - if (rc) + if (rc) { + cfs_up(&seq->lcs_sem); RETURN(rc); + } if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) { seq->lcs_width = val;