mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 13:03:25 +01:00
md/md-bitmap: merge md_bitmap_resize() into bitmap_operations
So that the implementation won't be exposed, and it'll be possible to invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20240826074452.1490072-36-yukuai1@huaweicloud.com Signed-off-by: Song Liu <song@kernel.org>
This commit is contained in:
parent
e1791dae6c
commit
77c09640ee
7 changed files with 18 additions and 15 deletions
|
@ -4068,7 +4068,8 @@ static int raid_preresume(struct dm_target *ti)
|
|||
mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)))) {
|
||||
int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize;
|
||||
|
||||
r = md_bitmap_resize(mddev, mddev->dev_sectors, chunksize, false);
|
||||
r = mddev->bitmap_ops->resize(mddev, mddev->dev_sectors,
|
||||
chunksize, false);
|
||||
if (r)
|
||||
DMERR("Failed to resize bitmap");
|
||||
}
|
||||
|
|
|
@ -2374,8 +2374,8 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
|
||||
bool init)
|
||||
static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
|
||||
bool init)
|
||||
{
|
||||
struct bitmap *bitmap = mddev->bitmap;
|
||||
|
||||
|
@ -2384,7 +2384,6 @@ int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
|
|||
|
||||
return __bitmap_resize(bitmap, blocks, chunksize, init);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(md_bitmap_resize);
|
||||
|
||||
static ssize_t
|
||||
location_show(struct mddev *mddev, char *page)
|
||||
|
@ -2763,6 +2762,7 @@ const struct attribute_group md_bitmap_group = {
|
|||
|
||||
static struct bitmap_operations bitmap_ops = {
|
||||
.create = bitmap_create,
|
||||
.resize = bitmap_resize,
|
||||
.load = bitmap_load,
|
||||
.destroy = bitmap_destroy,
|
||||
.flush = bitmap_flush,
|
||||
|
|
|
@ -248,6 +248,9 @@ struct md_bitmap_stats {
|
|||
|
||||
struct bitmap_operations {
|
||||
int (*create)(struct mddev *mddev, int slot);
|
||||
int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize,
|
||||
bool init);
|
||||
|
||||
int (*load)(struct mddev *mddev);
|
||||
void (*destroy)(struct mddev *mddev);
|
||||
void (*flush)(struct mddev *mddev);
|
||||
|
@ -280,8 +283,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
|
|||
|
||||
/* these are exported */
|
||||
|
||||
int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
|
||||
bool init);
|
||||
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot);
|
||||
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
|
||||
sector_t *lo, sector_t *hi, bool clear_bits);
|
||||
|
|
|
@ -628,8 +628,9 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
|
|||
break;
|
||||
case BITMAP_RESIZE:
|
||||
if (le64_to_cpu(msg->high) != mddev->pers->size(mddev, 0, 0))
|
||||
ret = md_bitmap_resize(mddev, le64_to_cpu(msg->high), 0,
|
||||
false);
|
||||
ret = mddev->bitmap_ops->resize(mddev,
|
||||
le64_to_cpu(msg->high),
|
||||
0, false);
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
|
|
|
@ -3303,7 +3303,7 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors)
|
|||
mddev->array_sectors > newsize)
|
||||
return -EINVAL;
|
||||
|
||||
ret = md_bitmap_resize(mddev, newsize, 0, false);
|
||||
ret = mddev->bitmap_ops->resize(mddev, newsize, 0, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -4210,7 +4210,7 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
|
|||
mddev->array_sectors > size)
|
||||
return -EINVAL;
|
||||
|
||||
ret = md_bitmap_resize(mddev, size, 0, false);
|
||||
ret = mddev->bitmap_ops->resize(mddev, size, 0, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -4479,7 +4479,7 @@ static int raid10_start_reshape(struct mddev *mddev)
|
|||
newsize = raid10_size(mddev, 0, conf->geo.raid_disks);
|
||||
|
||||
if (!mddev_is_clustered(mddev)) {
|
||||
ret = md_bitmap_resize(mddev, newsize, 0, false);
|
||||
ret = mddev->bitmap_ops->resize(mddev, newsize, 0, false);
|
||||
if (ret)
|
||||
goto abort;
|
||||
else
|
||||
|
@ -4494,20 +4494,20 @@ static int raid10_start_reshape(struct mddev *mddev)
|
|||
|
||||
/*
|
||||
* some node is already performing reshape, and no need to
|
||||
* call md_bitmap_resize again since it should be called when
|
||||
* call bitmap_ops->resize again since it should be called when
|
||||
* receiving BITMAP_RESIZE msg
|
||||
*/
|
||||
if ((sb && (le32_to_cpu(sb->feature_map) &
|
||||
MD_FEATURE_RESHAPE_ACTIVE)) || (oldsize == newsize))
|
||||
goto out;
|
||||
|
||||
ret = md_bitmap_resize(mddev, newsize, 0, false);
|
||||
ret = mddev->bitmap_ops->resize(mddev, newsize, 0, false);
|
||||
if (ret)
|
||||
goto abort;
|
||||
|
||||
ret = md_cluster_ops->resize_bitmaps(mddev, newsize, oldsize);
|
||||
if (ret) {
|
||||
md_bitmap_resize(mddev, oldsize, 0, false);
|
||||
mddev->bitmap_ops->resize(mddev, oldsize, 0, false);
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8323,7 +8323,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
|
|||
mddev->array_sectors > newsize)
|
||||
return -EINVAL;
|
||||
|
||||
ret = md_bitmap_resize(mddev, sectors, 0, false);
|
||||
ret = mddev->bitmap_ops->resize(mddev, sectors, 0, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
Loading…
Reference in a new issue