From 698d972d8256662dc23a012c4328dca37aaced56 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 19 Apr 2011 04:56:58 +0000 Subject: features/marker-quota: initialize dentry_child_count to total number of children a directory has in a single go. Signed-off-by: Raghavendra G Signed-off-by: Anand Avati BUG: 2809 ([e89f2a1f5daf1513c533a47b90aec8f90702d09f]: glusterfsd crashed in quota_dirty_inode_readdir) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2809 --- xlators/features/marker/src/marker-quota.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'xlators/features/marker') diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index 6230751542c..5fe8ab010da 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -396,8 +396,10 @@ quota_readdir_cbk (call_frame_t *frame, list_for_each_entry (entry, (&entries->list), list) { gf_log (this->name, GF_LOG_DEBUG, "entry = %s", entry->d_name); - if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name, ".."))) { - gf_log (this->name, GF_LOG_DEBUG, "entry = %s", entry->d_name); + if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name, + ".."))) { + gf_log (this->name, GF_LOG_DEBUG, "entry = %s", + entry->d_name); continue; } count++; @@ -405,11 +407,22 @@ quota_readdir_cbk (call_frame_t *frame, local->frame = frame; + if (count > 0) { + LOCK (&local->lock); + { + local->dentry_child_count = count; + } + UNLOCK (&local->lock); + } + + list_for_each_entry (entry, (&entries->list), list) { gf_log (this->name, GF_LOG_DEBUG, "entry = %s", entry->d_name); - if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name, ".."))) { - gf_log (this->name, GF_LOG_DEBUG, "entry = %s", entry->d_name); + if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name, + ".."))) { + gf_log (this->name, GF_LOG_DEBUG, "entry = %s", + entry->d_name); offset = entry->d_off; continue; } @@ -441,8 +454,6 @@ quota_readdir_cbk (call_frame_t *frame, if (ret) goto out; - QUOTA_SAFE_INCREMENT (&local->lock, local->dentry_child_count); - STACK_WIND (newframe, get_child_contribution, FIRST_CHILD(this), -- cgit