All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Jonathan Brassow <jbrassow@redhat.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH] MD RAID5: Avoid accessing gendisk or queue structs when not available
Date: Mon, 11 Mar 2013 11:35:10 +1100	[thread overview]
Message-ID: <20130311113510.5eb480f4@notabene.brown> (raw)
In-Reply-To: <1362694921.28152.4.camel@f16>

[-- Attachment #1: Type: text/plain, Size: 3836 bytes --]

On Thu, 07 Mar 2013 16:22:01 -0600 Jonathan Brassow <jbrassow@redhat.com>
wrote:

> MD RAID5:  Fix kernel oops when RAID4/5/6 is used via device-mapper
> 
> Commit a9add5d (v3.8-rc1) added blktrace calls to the RAID4/5/6 driver.
> However, when device-mapper is used to create RAID4/5/6 arrays, the
> mddev->gendisk and mddev->queue fields are not setup.  Therefore, calling
> things like trace_block_bio_remap will cause a kernel oops.  This patch
> conditionalizes those calls on whether the proper fields exist to make
> the calls.  (Device-mapper will call trace_block_bio_remap on its own.)
> 
> Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
> 
> Index: linux-upstream/drivers/md/raid5.c
> ===================================================================
> --- linux-upstream.orig/drivers/md/raid5.c
> +++ linux-upstream/drivers/md/raid5.c
> @@ -671,9 +671,11 @@ static void ops_run_io(struct stripe_hea
>  			bi->bi_next = NULL;
>  			if (rrdev)
>  				set_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags);
> -			trace_block_bio_remap(bdev_get_queue(bi->bi_bdev),
> -					      bi, disk_devt(conf->mddev->gendisk),
> -					      sh->dev[i].sector);
> +
> +			if (conf->mddev->gendisk)
> +				trace_block_bio_remap(bdev_get_queue(bi->bi_bdev),
> +						      bi, disk_devt(conf->mddev->gendisk),
> +						      sh->dev[i].sector);
>  			generic_make_request(bi);
>  		}
>  		if (rrdev) {
> @@ -701,9 +703,10 @@ static void ops_run_io(struct stripe_hea
>  			rbi->bi_io_vec[0].bv_offset = 0;
>  			rbi->bi_size = STRIPE_SIZE;
>  			rbi->bi_next = NULL;
> -			trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev),
> -					      rbi, disk_devt(conf->mddev->gendisk),
> -					      sh->dev[i].sector);
> +			if (conf->mddev->gendisk)
> +				trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev),
> +						      rbi, disk_devt(conf->mddev->gendisk),
> +						      sh->dev[i].sector);
>  			generic_make_request(rbi);
>  		}
>  		if (!rdev && !rrdev) {
> @@ -2862,8 +2865,10 @@ static void handle_stripe_dirtying(struc
>  	set_bit(STRIPE_HANDLE, &sh->state);
>  	if (rmw < rcw && rmw > 0) {
>  		/* prefer read-modify-write, but need to get some data */
> -		blk_add_trace_msg(conf->mddev->queue, "raid5 rmw %llu %d",
> -				  (unsigned long long)sh->sector, rmw);
> +		if (conf->mddev->queue)
> +			blk_add_trace_msg(conf->mddev->queue,
> +					  "raid5 rmw %llu %d",
> +					  (unsigned long long)sh->sector, rmw);
>  		for (i = disks; i--; ) {
>  			struct r5dev *dev = &sh->dev[i];
>  			if ((dev->towrite || i == sh->pd_idx) &&
> @@ -2913,7 +2918,7 @@ static void handle_stripe_dirtying(struc
>  				}
>  			}
>  		}
> -		if (rcw)
> +		if (rcw && conf->mddev->queue)
>  			blk_add_trace_msg(conf->mddev->queue, "raid5 rcw %llu %d %d %d",
>  					  (unsigned long long)sh->sector,
>  					  rcw, qread, test_bit(STRIPE_DELAYED, &sh->state));
> @@ -4018,9 +4023,10 @@ static int chunk_aligned_read(struct mdd
>  		atomic_inc(&conf->active_aligned_reads);
>  		spin_unlock_irq(&conf->device_lock);
>  
> -		trace_block_bio_remap(bdev_get_queue(align_bi->bi_bdev),
> -				      align_bi, disk_devt(mddev->gendisk),
> -				      raid_bio->bi_sector);
> +		if (mddev->gendisk)
> +			trace_block_bio_remap(bdev_get_queue(align_bi->bi_bdev),
> +					      align_bi, disk_devt(mddev->gendisk),
> +					      raid_bio->bi_sector);
>  		generic_make_request(align_bi);
>  		return 1;
>  	} else {
> @@ -4114,7 +4120,8 @@ static void raid5_unplug(struct blk_plug
>  		}
>  		spin_unlock_irq(&conf->device_lock);
>  	}
> -	trace_block_unplug(mddev->queue, cnt, !from_schedule);
> +	if (mddev->queue)
> +		trace_block_unplug(mddev->queue, cnt, !from_schedule);
>  	kfree(cb);
>  }
>  
> 


Applied, thanks (and sorry for breaking it...)

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2013-03-11  0:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07 22:22 [PATCH] MD RAID5: Avoid accessing gendisk or queue structs when not available Jonathan Brassow
2013-03-11  0:35 ` NeilBrown [this message]

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=20130311113510.5eb480f4@notabene.brown \
    --to=neilb@suse.de \
    --cc=jbrassow@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.