From: Mark Fasheh <mfasheh@suse.de>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH] ocfs2: fix BUG in ocfs2_downconvert_thread_do_work
Date: Fri, 8 May 2015 15:37:13 -0700 [thread overview]
Message-ID: <20150508223713.GA25729@wotan.suse.de> (raw)
In-Reply-To: <5549F736.7000405@huawei.com>
Thanks Joseph,
This seems like a convoluted way of fixing the problem. The reason
downconvert_thread_do_work is saving the # of blocked locks is so it doesn't
spin forever while another process continually adds them - basically we want
to do a certain amount of work and then move on. Instead why not just change
the while loop condition (and add a nice comment explaining it):
/*
* blocked lock processing in this loop might call iput which can
* remove items off osb->blocked_lock_list. Downconvert up to
* 'processed' number of locks, but stop short if we had some
* removed by another thread.
*/
while (processed && !list_empty(&osb->blocked_lock_list)) {
...
}
As a bonus, we can remove the now-useless BUG_ON().
--Mark
On Wed, May 06, 2015 at 07:12:54PM +0800, Joseph Qi wrote:
> BUG_ON(list_empty(&osb->blocked_lock_list)) in
> ocfs2_downconvert_thread_do_work can be triggered in the following case:
> ocfs2dc has firstly saved osb->blocked_lock_count to local varibale
> processed, and then processes the dentry lockres.
> During the dentry put, it calls iput and then deletes rw, inode and
> open lockres from blocked list in ocfs2_mark_lockres_freeing.
> And this casues the variable processed is not the number of blocked
> lockres to be processed and then triggers the BUG.
>
> Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
> Cc: <stable@vger.kernel.org>
> ---
> fs/ocfs2/dlmglue.c | 10 ++++------
> fs/ocfs2/ocfs2.h | 1 +
> fs/ocfs2/super.c | 1 +
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index 8b23aa2..846547c 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -3198,6 +3198,7 @@ void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,
> spin_lock_irqsave(&osb->dc_task_lock, flags2);
> list_del_init(&lockres->l_blocked_list);
> osb->blocked_lock_count--;
> + osb->blocked_lock_processed--;
> spin_unlock_irqrestore(&osb->dc_task_lock, flags2);
> /*
> * Warn if we recurse into another post_unlock call. Strictly
> @@ -4015,7 +4016,6 @@ static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
>
> static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb)
> {
> - unsigned long processed;
> unsigned long flags;
> struct ocfs2_lock_res *lockres;
>
> @@ -4024,19 +4024,17 @@ static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb)
> * wake happens part-way through our work */
> osb->dc_work_sequence = osb->dc_wake_sequence;
>
> - processed = osb->blocked_lock_count;
> - while (processed) {
> + osb->blocked_lock_processed = osb->blocked_lock_count;
> + while (osb->blocked_lock_processed) {
> BUG_ON(list_empty(&osb->blocked_lock_list));
>
> lockres = list_entry(osb->blocked_lock_list.next,
> struct ocfs2_lock_res, l_blocked_list);
> list_del_init(&lockres->l_blocked_list);
> osb->blocked_lock_count--;
> + osb->blocked_lock_processed--;
> spin_unlock_irqrestore(&osb->dc_task_lock, flags);
>
> - BUG_ON(!processed);
> - processed--;
> -
> ocfs2_process_blocked_lock(osb, lockres);
>
> spin_lock_irqsave(&osb->dc_task_lock, flags);
> diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
> index 460c6c3..2aebe94 100644
> --- a/fs/ocfs2/ocfs2.h
> +++ b/fs/ocfs2/ocfs2.h
> @@ -424,6 +424,7 @@ struct ocfs2_super
> */
> struct list_head blocked_lock_list;
> unsigned long blocked_lock_count;
> + unsigned long blocked_lock_processed;
>
> /* List of dquot structures to drop last reference to */
> struct llist_head dquot_drop_list;
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 403c566..914ce8b 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -2089,6 +2089,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
> osb->dc_wake_sequence = 0;
> INIT_LIST_HEAD(&osb->blocked_lock_list);
> osb->blocked_lock_count = 0;
> + osb->blocked_lock_processed = 0;
> spin_lock_init(&osb->osb_lock);
> spin_lock_init(&osb->osb_xattr_lock);
> ocfs2_init_steal_slots(osb);
> --
> 1.8.4.3
>
--
Mark Fasheh
next prev parent reply other threads:[~2015-05-08 22:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 11:12 [Ocfs2-devel] [PATCH] ocfs2: fix BUG in ocfs2_downconvert_thread_do_work Joseph Qi
2015-05-06 22:25 ` Andrew Morton
2015-05-08 22:37 ` Mark Fasheh [this message]
2015-05-11 1:29 ` Joseph Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150508223713.GA25729@wotan.suse.de \
--to=mfasheh@suse.de \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox