From e1dfb0e413bba805ae588e60a77ce278df047ab6 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 14 Aug 2005 14:44:59 +0000 Subject: [PATCH] - per-inode wait queue to wait for I/O completion - never leave non-handled close works (in close thread) --- lustre/include/linux/lustre_lite.h | 2 ++ lustre/llite/llite_close.c | 13 +++++++++---- lustre/llite/llite_internal.h | 1 + lustre/llite/llite_lib.c | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index 41c5bb0..3d2c640 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -121,6 +121,8 @@ struct ll_inode_info { struct lustre_key *lli_key_info; struct lustre_capa *lli_trunc_capa; /* capabiliity for truncate */ + + wait_queue_head_t lli_dirty_wait; }; // FIXME: replace the name of this with LL_I to conform to kernel stuff diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 31ac436..954f448 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -52,6 +52,8 @@ void llap_write_complete(struct inode *inode, struct ll_async_page *llap) spin_lock(&lli->lli_lock); if (!list_empty(&llap->llap_pending_write)) list_del_init(&llap->llap_pending_write); + if (list_empty(&lli->lli_pending_write_llaps)) + wake_up(&lli->lli_dirty_wait); spin_unlock(&lli->lli_lock); } @@ -148,12 +150,14 @@ static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) spin_lock(&lcq->lcq_lock); - if (lcq->lcq_list.next == NULL) - lli = ERR_PTR(-1); - else if (!list_empty(&lcq->lcq_list)) { + /* first, check for queued request. otherwise, we would + * leak them upon umount */ + if (!list_empty(&lcq->lcq_list)) { lli = list_entry(lcq->lcq_list.next, struct ll_inode_info, lli_close_item); list_del_init(&lli->lli_close_item); + } else if (lcq->lcq_stop != 0) { + lli = ERR_PTR(-1); } spin_unlock(&lcq->lcq_lock); @@ -210,6 +214,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret) if (lcq == NULL) return -ENOMEM; + lcq->lcq_stop = 0; spin_lock_init(&lcq->lcq_lock); INIT_LIST_HEAD(&lcq->lcq_list); init_waitqueue_head(&lcq->lcq_waitq); @@ -229,7 +234,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret) void ll_close_thread_stop(struct ll_close_queue *lcq) { init_completion(&lcq->lcq_comp); - lcq->lcq_list.next = NULL; + lcq->lcq_stop = 1; wake_up(&lcq->lcq_waitq); wait_for_completion(&lcq->lcq_comp); OBD_FREE(lcq, sizeof(*lcq)); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index c8144a8..1826223 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -451,6 +451,7 @@ struct ll_close_queue { struct list_head lcq_list; wait_queue_head_t lcq_waitq; struct completion lcq_comp; + int lcq_stop; }; void llap_write_pending(struct inode *inode, struct ll_async_page *llap); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index b91d365..3a0057a 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -582,6 +582,7 @@ void ll_lli_init(struct ll_inode_info *lli) lli->lli_open_fd_exec_count = 0; lli->lli_audit_mask = AUDIT_OFF; lli->lli_key_info = NULL; + init_waitqueue_head(&lli->lli_dirty_wait); } int ll_fill_super(struct super_block *sb, void *data, int silent) @@ -1158,6 +1159,7 @@ void ll_clear_inode(struct inode *inode) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); + LASSERT(ll_is_inode_dirty(inode) == 0); ll_inode2id(&id, inode); clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags)); -- 1.8.3.1