FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 04-20-2011, 04:29 PM
Steven Whitehouse
 
Default GFS2: Fix ail list traversal

In the recent patches to update the AIL list code, I managed to
forget that the ail list lock got dropped, even though I
added a comment specifically to remind myself

Reported-by: Barry Marson <bmarson@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index ad1f188..0f3046a 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -89,9 +89,9 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
*
*/

-static void gfs2_ail1_start_one(struct gfs2_sbd *sdp,
- struct writeback_control *wbc,
- struct gfs2_ail *ai)
+static int gfs2_ail1_start_one(struct gfs2_sbd *sdp,
+ struct writeback_control *wbc,
+ struct gfs2_ail *ai)
__releases(&sdp->sd_ail_lock)
__acquires(&sdp->sd_ail_lock)
{
@@ -99,6 +99,7 @@ __acquires(&sdp->sd_ail_lock)
struct address_space *mapping;
struct gfs2_bufdata *bd, *s;
struct buffer_head *bh;
+ int ldrop = 0;

restart:
list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, bd_ail_st_list) {
@@ -121,12 +122,15 @@ restart:
list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list);
mapping = bh->b_page->mapping;
spin_unlock(&sdp->sd_ail_lock);
+ ldrop = 1;
generic_writepages(mapping, wbc);
spin_lock(&sdp->sd_ail_lock);
if (wbc->nr_to_write <= 0)
break;
goto restart;
}
+
+ return ldrop;
}


@@ -146,10 +150,12 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)

trace_gfs2_ail_flush(sdp, wbc, 1);
spin_lock(&sdp->sd_ail_lock);
+restart:
list_for_each_entry_reverse(ai, head, ai_list) {
if (wbc->nr_to_write <= 0)
break;
- gfs2_ail1_start_one(sdp, wbc, ai); /* This may drop ail lock */
+ if (gfs2_ail1_start_one(sdp, wbc, ai))
+ goto restart;
}
spin_unlock(&sdp->sd_ail_lock);
trace_gfs2_ail_flush(sdp, wbc, 0);
 
Old 04-21-2011, 10:09 AM
Steven Whitehouse
 
Default GFS2: Fix ail list traversal

Hi,

On Wed, 2011-04-20 at 17:29 +0100, Steven Whitehouse wrote:
> In the recent patches to update the AIL list code, I managed to
> forget that the ail list lock got dropped, even though I
> added a comment specifically to remind myself
>
> Reported-by: Barry Marson <bmarson@redhat.com>
> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
>
This failed some of my tests, but this new version seems to work
correctly,

Steve.

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index ad1f188..cec26c0 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -89,9 +89,9 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
*
*/

-static void gfs2_ail1_start_one(struct gfs2_sbd *sdp,
- struct writeback_control *wbc,
- struct gfs2_ail *ai)
+static int gfs2_ail1_start_one(struct gfs2_sbd *sdp,
+ struct writeback_control *wbc,
+ struct gfs2_ail *ai)
__releases(&sdp->sd_ail_lock)
__acquires(&sdp->sd_ail_lock)
{
@@ -100,7 +100,6 @@ __acquires(&sdp->sd_ail_lock)
struct gfs2_bufdata *bd, *s;
struct buffer_head *bh;

-restart:
list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, bd_ail_st_list) {
bh = bd->bd_bh;

@@ -120,13 +119,17 @@ restart:
gl = bd->bd_gl;
list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list);
mapping = bh->b_page->mapping;
+ if (!mapping)
+ continue;
spin_unlock(&sdp->sd_ail_lock);
generic_writepages(mapping, wbc);
spin_lock(&sdp->sd_ail_lock);
if (wbc->nr_to_write <= 0)
break;
- goto restart;
+ return 1;
}
+
+ return 0;
}


@@ -146,10 +149,12 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)

trace_gfs2_ail_flush(sdp, wbc, 1);
spin_lock(&sdp->sd_ail_lock);
+restart:
list_for_each_entry_reverse(ai, head, ai_list) {
if (wbc->nr_to_write <= 0)
break;
- gfs2_ail1_start_one(sdp, wbc, ai); /* This may drop ail lock */
+ if (gfs2_ail1_start_one(sdp, wbc, ai))
+ goto restart;
}
spin_unlock(&sdp->sd_ail_lock);
trace_gfs2_ail_flush(sdp, wbc, 0);
 
Old 05-19-2011, 08:47 AM
Steven Whitehouse
 
Default GFS2: Fix ail list traversal

In the recent patches to update the AIL list code, I managed to
forget that the ail list lock got dropped, even though I
added a comment specifically to remind myself

Reported-by: Barry Marson <bmarson@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index ad1f188..cec26c0 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -89,9 +89,9 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
*
*/

-static void gfs2_ail1_start_one(struct gfs2_sbd *sdp,
- struct writeback_control *wbc,
- struct gfs2_ail *ai)
+static int gfs2_ail1_start_one(struct gfs2_sbd *sdp,
+ struct writeback_control *wbc,
+ struct gfs2_ail *ai)
__releases(&sdp->sd_ail_lock)
__acquires(&sdp->sd_ail_lock)
{
@@ -100,7 +100,6 @@ __acquires(&sdp->sd_ail_lock)
struct gfs2_bufdata *bd, *s;
struct buffer_head *bh;

-restart:
list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, bd_ail_st_list) {
bh = bd->bd_bh;

@@ -120,13 +119,17 @@ restart:
gl = bd->bd_gl;
list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list);
mapping = bh->b_page->mapping;
+ if (!mapping)
+ continue;
spin_unlock(&sdp->sd_ail_lock);
generic_writepages(mapping, wbc);
spin_lock(&sdp->sd_ail_lock);
if (wbc->nr_to_write <= 0)
break;
- goto restart;
+ return 1;
}
+
+ return 0;
}


@@ -146,10 +149,12 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)

trace_gfs2_ail_flush(sdp, wbc, 1);
spin_lock(&sdp->sd_ail_lock);
+restart:
list_for_each_entry_reverse(ai, head, ai_list) {
if (wbc->nr_to_write <= 0)
break;
- gfs2_ail1_start_one(sdp, wbc, ai); /* This may drop ail lock */
+ if (gfs2_ail1_start_one(sdp, wbc, ai))
+ goto restart;
}
spin_unlock(&sdp->sd_ail_lock);
trace_gfs2_ail_flush(sdp, wbc, 0);
--
1.7.4
 

Thread Tools




All times are GMT. The time now is 05:12 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org