| To: | Dave Chinner <david@xxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [PATCH 3/5] repair: handle memory allocation failure from blkmap_grow |
| From: | Christoph Hellwig <hch@xxxxxxxxxxxxx> |
| Date: | Sun, 9 Oct 2011 19:51:26 -0400 |
| Cc: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1318201910-11144-4-git-send-email-david@xxxxxxxxxxxxx> |
| References: | <1318201910-11144-1-git-send-email-david@xxxxxxxxxxxxx> <1318201910-11144-4-git-send-email-david@xxxxxxxxxxxxx> |
| User-agent: | Mutt/1.5.21 (2010-09-15) |
> static blkmap_t *
> blkmap_grow(
> - blkmap_t **blkmapp)
> + blkmap_t *blkmap)
> {
> pthread_key_t key = dblkmap_key;
> - blkmap_t *blkmap = *blkmapp;
> + blkmap_t *new_blkmap;
> + int new_naexts = blkmap->naexts + 4;
>
> if (pthread_getspecific(key) != blkmap) {
> key = ablkmap_key;
> ASSERT(pthread_getspecific(key) == blkmap);
> }
>
> - blkmap->naexts += 4;
> - blkmap = realloc(blkmap, BLKMAP_SIZE(blkmap->naexts));
> - if (blkmap == NULL)
> - do_error(_("realloc failed in blkmap_grow\n"));
> - *blkmapp = blkmap;
> - pthread_setspecific(key, blkmap);
> - return blkmap;
> + new_blkmap = realloc(blkmap, BLKMAP_SIZE(new_naexts));
> + if (!new_blkmap) {
> + do_error(_("realloc failed in blkmap_grow\n"));
> + return NULL;
> + }
> + blkmap->naexts = new_naexts;
Why would we modify naexts in the old blkmap?
Otherwise looks fine.
|
| Previous by Date: | Re: [PATCH 4/5] repair: don't cache large blkmap allocations, Christoph Hellwig |
|---|---|
| Next by Date: | Re: [PATCH 1/5] repair: handle repair of image files on large sector size filesystems, Christoph Hellwig |
| Previous by Thread: | [PATCH 3/5] repair: handle memory allocation failure from blkmap_grow, Dave Chinner |
| Next by Thread: | Re: [PATCH 3/5] repair: handle memory allocation failure from blkmap_grow, Dave Chinner |
| Indexes: | [Date] [Thread] [Top] [All Lists] |