Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 8322
b: refs/heads/master
c: 3178b0d
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Sep 9, 2005
1 parent 2529079 commit bf623ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 585f0dd5a955c420ff3af5193aa07d6f789bf81a
refs/heads/master: 3178b0dbdf67322f6506582e494bdf553cc85c32
33 changes: 24 additions & 9 deletions trunk/drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,17 +1503,14 @@ void bitmap_flush(mddev_t *mddev)
/*
* free memory that was allocated
*/
void bitmap_destroy(mddev_t *mddev)
static void bitmap_free(struct bitmap *bitmap)
{
unsigned long k, pages;
struct bitmap_page *bp;
struct bitmap *bitmap = mddev->bitmap;

if (!bitmap) /* there was no bitmap */
return;

mddev->bitmap = NULL; /* disconnect from the md device */

/* release the bitmap file and kill the daemon */
bitmap_file_put(bitmap);

Expand All @@ -1531,6 +1528,17 @@ void bitmap_destroy(mddev_t *mddev)
kfree(bp);
kfree(bitmap);
}
void bitmap_destroy(mddev_t *mddev)
{
struct bitmap *bitmap = mddev->bitmap;

if (!bitmap) /* there was no bitmap */
return;

mddev->bitmap = NULL; /* disconnect from the md device */

bitmap_free(bitmap);
}

/*
* initialize the bitmap structure
Expand Down Expand Up @@ -1561,23 +1569,23 @@ int bitmap_create(mddev_t *mddev)

spin_lock_init(&bitmap->lock);
bitmap->mddev = mddev;
mddev->bitmap = bitmap;

spin_lock_init(&bitmap->write_lock);
INIT_LIST_HEAD(&bitmap->complete_pages);
init_waitqueue_head(&bitmap->write_wait);
bitmap->write_pool = mempool_create(WRITE_POOL_SIZE, write_pool_alloc,
write_pool_free, NULL);
err = -ENOMEM;
if (!bitmap->write_pool)
return -ENOMEM;
goto error;

bitmap->file = file;
bitmap->offset = mddev->bitmap_offset;
if (file) get_file(file);
/* read superblock from bitmap file (this sets bitmap->chunksize) */
err = bitmap_read_sb(bitmap);
if (err)
return err;
goto error;

bitmap->chunkshift = find_first_bit(&bitmap->chunksize,
sizeof(bitmap->chunksize));
Expand All @@ -1601,8 +1609,9 @@ int bitmap_create(mddev_t *mddev)
#else
bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL);
#endif
err = -ENOMEM;
if (!bitmap->bp)
return -ENOMEM;
goto error;
memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp));

bitmap->flags |= BITMAP_ACTIVE;
Expand All @@ -1617,16 +1626,22 @@ int bitmap_create(mddev_t *mddev)
err = bitmap_init_from_disk(bitmap, start);

if (err)
return err;
goto error;

printk(KERN_INFO "created bitmap (%lu pages) for device %s\n",
pages, bmname(bitmap));

mddev->bitmap = bitmap;

/* kick off the bitmap daemons */
err = bitmap_start_daemons(bitmap);
if (err)
return err;
return bitmap_update_sb(bitmap);

error:
bitmap_free(bitmap);
return err;
}

/* the bitmap API -- for raid personalities */
Expand Down

0 comments on commit bf623ba

Please sign in to comment.