linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: "Czarnowska, Anna" <anna.czarnowska@intel.com>
Cc: "linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
	"Williams, Dan J" <dan.j.williams@intel.com>,
	"Grabowski, Grzegorz" <grzegorz.grabowski@intel.com>,
	"Ciechanowski, Ed" <ed.ciechanowski@intel.com>
Subject: Re: [PATCH 1/6] imsm: avoid overflows for disks over 1TB
Date: Mon, 2 Apr 2012 10:14:55 +1000	[thread overview]
Message-ID: <20120402101455.189f614e@notabene.brown> (raw)
In-Reply-To: <3F8F31A3BFD1664EAB894D1BD6AF32B918A205CE@IRSMSX102.ger.corp.intel.com>

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

On Thu, 29 Mar 2012 12:43:00 +0000 "Czarnowska, Anna"
<anna.czarnowska@intel.com> wrote:


> +static unsigned long long total_blocks(struct imsm_disk *disk)
> +{
> +	if (disk == 0)
> +		return 0;

I changed this and some others to
        if (disk == NULL)
                return 0;


> +	return join_u32(disk->total_blocks_lo, disk->total_blocks_hi);
> +}
> +
> +static unsigned long long pba_of_lba0(struct imsm_map *map)
> +{
> +	if (map == 0)
> +		return 0;
> +	return join_u32(map->pba_of_lba0_lo, map->pba_of_lba0_hi);
> +}
> +
> +static unsigned long long blocks_per_member(struct imsm_map *map)
> +{
> +	if (map == 0)
> +		return 0;
> +	return join_u32(map->blocks_per_member_lo, map->blocks_per_member_hi);
> +}
> +
> +static unsigned long long num_data_stripes(struct imsm_map *map)
> +{
> +	if (map == 0)
> +		return 0;
> +	return join_u32(map->num_data_stripes_lo, map->num_data_stripes_hi);
> +}
> +
> +static void set_total_blocks(struct imsm_disk *disk, unsigned long long n)
> +{
> +	split_ull(n, &disk->total_blocks_lo, &disk->total_blocks_hi);
> +}
> +
> +static void set_pba_of_lba0(struct imsm_map *map, unsigned long long n)
> +{
> +	split_ull(n, &map->pba_of_lba0_lo, &map->pba_of_lba0_hi);
> +}
> +
> +static void set_blocks_per_member(struct imsm_map *map, unsigned long long n)
> +{
> +	split_ull(n, &map->blocks_per_member_lo, &map->blocks_per_member_hi);
> +}
> +
> +static void set_num_data_stripes(struct imsm_map *map, unsigned long long n)
> +{
> +	split_ull(n, &map->num_data_stripes_lo, &map->num_data_stripes_hi);
> +}
> +
>  static struct extent *get_extents(struct intel_super *super, struct dl *dl)
>  {
>  	/* find a list of used extents on the given physical device */
> @@ -897,8 +964,8 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl)
>  		struct imsm_map *map = get_imsm_map(dev, MAP_0);
>  
>  		if (get_imsm_disk_slot(map, dl->index) >= 0) {
> -			e->start = __le32_to_cpu(map->pba_of_lba0);
> -			e->size = __le32_to_cpu(map->blocks_per_member);
> +			e->start = pba_of_lba0(map);
> +			e->size = blocks_per_member(map);
>  			e++;
>  		}
>  	}
> @@ -911,10 +978,9 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl)
>  	 */
>  	if (memberships) {
>  		struct extent *last = &rv[memberships - 1];
> -		__u32 remainder;
> +		unsigned long long remainder;
>  
> -		remainder = __le32_to_cpu(dl->disk.total_blocks) - 
> -			    (last->start + last->size);
> +		remainder = total_blocks(&dl->disk) - (last->start + last->size);
>  		/* round down to 1k block to satisfy precision of the kernel
>  		 * 'size' interface
>  		 */
> @@ -925,7 +991,7 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl)
>  		if (reservation > remainder)
>  			reservation = remainder;
>  	}
> -	e->start = __le32_to_cpu(dl->disk.total_blocks) - reservation;
> +	e->start = total_blocks(&dl->disk) - reservation;
>  	e->size = 0;
>  	return rv;
>  }
> @@ -954,7 +1020,7 @@ static __u32 imsm_reserved_sectors(struct intel_super *super, struct dl *dl)
>  	for (i = 0; e[i].size; i++)
>  		continue;
>  
> -	rv = __le32_to_cpu(dl->disk.total_blocks) - e[i].start;
> +	rv = total_blocks(&dl->disk) - e[i].start;
>  
>  	free(e);
>  
> @@ -984,7 +1050,8 @@ static __u32 imsm_min_reserved_sectors(struct intel_super *super)
>  {
>  	struct extent *e;
>  	int i;
> -	__u32 min_active, remainder;
> +	unsigned long long min_active;
> +	__u32 remainder;

I'm a bit concerned that 'remainder' is still a '__u32'.  It is calculated as
the difference of two 'unsigned long long'....
I'll take the patch as is, but you might like to fix this up.

Applied.

Thanks,
NeilBrown


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

  reply	other threads:[~2012-04-02  0:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-29 12:43 [PATCH 1/6] imsm: avoid overflows for disks over 1TB Czarnowska, Anna
2012-04-02  0:14 ` NeilBrown [this message]
2012-04-02  7:51   ` Czarnowska, Anna

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=20120402101455.189f614e@notabene.brown \
    --to=neilb@suse.de \
    --cc=anna.czarnowska@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=grzegorz.grabowski@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).