From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: [PATCH 021 of 29] md: md: use stripe_head_state in ops_run_io() Date: Fri, 27 Jun 2008 16:51:37 +1000 Message-ID: <1080627065137.10652@suse.de> References: <20080627164503.9671.patches@notabene> Return-path: Sender: linux-raid-owner@vger.kernel.org To: Andrew Morton Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Williams List-Id: linux-raid.ids From: Dan Williams In handle_stripe after taking sh->lock we sample some bits into 's' (struct stripe_head_state): s.syncing = test_bit(STRIPE_SYNCING, &sh->state); s.expanding = test_bit(STRIPE_EXPAND_SOURCE, &sh->state); s.expanded = test_bit(STRIPE_EXPAND_READY, &sh->state); Use these values from 's' in ops_run_io() rather than re-sampling the bits. This ensures a consistent snapshot (as seen under sh->lock) is used. Signed-off-by: Dan Williams Signed-off-by: Neil Brown ### Diffstat output ./drivers/md/raid5.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff .prev/drivers/md/raid5.c ./drivers/md/raid5.c --- .prev/drivers/md/raid5.c 2008-06-27 16:22:04.000000000 +1000 +++ ./drivers/md/raid5.c 2008-06-27 16:22:04.000000000 +1000 @@ -390,7 +390,7 @@ raid5_end_read_request(struct bio *bi, i static void raid5_end_write_request(struct bio *bi, int error); -static void ops_run_io(struct stripe_head *sh) +static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) { raid5_conf_t *conf = sh->raid_conf; int i, disks = sh->disks; @@ -425,9 +425,7 @@ static void ops_run_io(struct stripe_hea rcu_read_unlock(); if (rdev) { - if (test_bit(STRIPE_SYNCING, &sh->state) || - test_bit(STRIPE_EXPAND_SOURCE, &sh->state) || - test_bit(STRIPE_EXPAND_READY, &sh->state)) + if (s->syncing || s->expanding || s->expanded) md_sync_acct(rdev->bdev, STRIPE_SECTORS); set_bit(STRIPE_IO_STARTED, &sh->state); @@ -2902,10 +2900,9 @@ static void handle_stripe5(struct stripe if (pending) raid5_run_ops(sh, pending); - ops_run_io(sh); + ops_run_io(sh, &s); return_io(return_bi); - } static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760476AbYF0G6v (ORCPT ); Fri, 27 Jun 2008 02:58:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759273AbYF0Gvr (ORCPT ); Fri, 27 Jun 2008 02:51:47 -0400 Received: from ns2.suse.de ([195.135.220.15]:43253 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757687AbYF0Gvo (ORCPT ); Fri, 27 Jun 2008 02:51:44 -0400 From: NeilBrown To: Andrew Morton Date: Fri, 27 Jun 2008 16:51:37 +1000 Message-Id: <1080627065137.10652@suse.de> X-face: [Gw_3E*Gng}4rRrKRYotwlE?.2|**#s9D Subject: [PATCH 021 of 29] md: md: use stripe_head_state in ops_run_io() References: <20080627164503.9671.patches@notabene> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams In handle_stripe after taking sh->lock we sample some bits into 's' (struct stripe_head_state): s.syncing = test_bit(STRIPE_SYNCING, &sh->state); s.expanding = test_bit(STRIPE_EXPAND_SOURCE, &sh->state); s.expanded = test_bit(STRIPE_EXPAND_READY, &sh->state); Use these values from 's' in ops_run_io() rather than re-sampling the bits. This ensures a consistent snapshot (as seen under sh->lock) is used. Signed-off-by: Dan Williams Signed-off-by: Neil Brown ### Diffstat output ./drivers/md/raid5.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff .prev/drivers/md/raid5.c ./drivers/md/raid5.c --- .prev/drivers/md/raid5.c 2008-06-27 16:22:04.000000000 +1000 +++ ./drivers/md/raid5.c 2008-06-27 16:22:04.000000000 +1000 @@ -390,7 +390,7 @@ raid5_end_read_request(struct bio *bi, i static void raid5_end_write_request(struct bio *bi, int error); -static void ops_run_io(struct stripe_head *sh) +static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) { raid5_conf_t *conf = sh->raid_conf; int i, disks = sh->disks; @@ -425,9 +425,7 @@ static void ops_run_io(struct stripe_hea rcu_read_unlock(); if (rdev) { - if (test_bit(STRIPE_SYNCING, &sh->state) || - test_bit(STRIPE_EXPAND_SOURCE, &sh->state) || - test_bit(STRIPE_EXPAND_READY, &sh->state)) + if (s->syncing || s->expanding || s->expanded) md_sync_acct(rdev->bdev, STRIPE_SECTORS); set_bit(STRIPE_IO_STARTED, &sh->state); @@ -2902,10 +2900,9 @@ static void handle_stripe5(struct stripe if (pending) raid5_run_ops(sh, pending); - ops_run_io(sh); + ops_run_io(sh, &s); return_io(return_bi); - } static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)