Whamcloud - gitweb
LU-662 fix conflict between seq_client_flush and seq_client_alloc_fid
authorHongchao Zhang <hongchao.zhang@whamcloud.com>
Fri, 9 Sep 2011 11:00:39 +0000 (19:00 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 13 Sep 2011 19:59:29 +0000 (15:59 -0400)
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 <hongchao.zhang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1364
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/fid/fid_request.c
lustre/fid/lproc_fid.c

index 5419f8c..214f542 100644 (file)
@@ -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.
index 70b5c9c..633607d 100644 (file)
@@ -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;