mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-21 06:50:25 +00:00
md/md-bitmap: add 'sync_size' into struct md_bitmap_stats
To avoid dereferencing bitmap directly in md-cluster to prepare inventing a new bitmap. BTW, also fix following checkpatch warnings: WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead Signed-off-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20240826074452.1490072-7-yukuai1@huaweicloud.com Signed-off-by: Song Liu <song@kernel.org>
This commit is contained in:
parent
82697ccf7e
commit
ec6bb299c7
3 changed files with 27 additions and 14 deletions
|
@ -2097,10 +2097,15 @@ EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
|
||||||
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
|
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
|
||||||
{
|
{
|
||||||
struct bitmap_counts *counts;
|
struct bitmap_counts *counts;
|
||||||
|
bitmap_super_t *sb;
|
||||||
|
|
||||||
if (!bitmap)
|
if (!bitmap)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
|
sb = kmap_local_page(bitmap->storage.sb_page);
|
||||||
|
stats->sync_size = le64_to_cpu(sb->sync_size);
|
||||||
|
kunmap_local(sb);
|
||||||
|
|
||||||
counts = &bitmap->counts;
|
counts = &bitmap->counts;
|
||||||
stats->missing_pages = counts->missing_pages;
|
stats->missing_pages = counts->missing_pages;
|
||||||
stats->pages = counts->pages;
|
stats->pages = counts->pages;
|
||||||
|
@ -2110,6 +2115,7 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(md_bitmap_get_stats);
|
||||||
|
|
||||||
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
|
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
|
||||||
int chunksize, int init)
|
int chunksize, int init)
|
||||||
|
|
|
@ -237,6 +237,7 @@ struct bitmap {
|
||||||
struct md_bitmap_stats {
|
struct md_bitmap_stats {
|
||||||
u64 events_cleared;
|
u64 events_cleared;
|
||||||
unsigned long missing_pages;
|
unsigned long missing_pages;
|
||||||
|
unsigned long sync_size;
|
||||||
unsigned long pages;
|
unsigned long pages;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1207,18 +1207,21 @@ out:
|
||||||
*/
|
*/
|
||||||
static int cluster_check_sync_size(struct mddev *mddev)
|
static int cluster_check_sync_size(struct mddev *mddev)
|
||||||
{
|
{
|
||||||
int i, rv;
|
|
||||||
bitmap_super_t *sb;
|
|
||||||
unsigned long my_sync_size, sync_size = 0;
|
|
||||||
int node_num = mddev->bitmap_info.nodes;
|
|
||||||
int current_slot = md_cluster_ops->slot_number(mddev);
|
int current_slot = md_cluster_ops->slot_number(mddev);
|
||||||
|
int node_num = mddev->bitmap_info.nodes;
|
||||||
struct bitmap *bitmap = mddev->bitmap;
|
struct bitmap *bitmap = mddev->bitmap;
|
||||||
char str[64];
|
|
||||||
struct dlm_lock_resource *bm_lockres;
|
struct dlm_lock_resource *bm_lockres;
|
||||||
|
struct md_bitmap_stats stats;
|
||||||
|
unsigned long sync_size = 0;
|
||||||
|
unsigned long my_sync_size;
|
||||||
|
char str[64];
|
||||||
|
int i, rv;
|
||||||
|
|
||||||
sb = kmap_atomic(bitmap->storage.sb_page);
|
rv = md_bitmap_get_stats(bitmap, &stats);
|
||||||
my_sync_size = le64_to_cpu(sb->sync_size);
|
if (rv)
|
||||||
kunmap_atomic(sb);
|
return rv;
|
||||||
|
|
||||||
|
my_sync_size = stats.sync_size;
|
||||||
|
|
||||||
for (i = 0; i < node_num; i++) {
|
for (i = 0; i < node_num; i++) {
|
||||||
if (i == current_slot)
|
if (i == current_slot)
|
||||||
|
@ -1247,15 +1250,18 @@ static int cluster_check_sync_size(struct mddev *mddev)
|
||||||
md_bitmap_update_sb(bitmap);
|
md_bitmap_update_sb(bitmap);
|
||||||
lockres_free(bm_lockres);
|
lockres_free(bm_lockres);
|
||||||
|
|
||||||
sb = kmap_atomic(bitmap->storage.sb_page);
|
rv = md_bitmap_get_stats(bitmap, &stats);
|
||||||
if (sync_size == 0)
|
if (rv) {
|
||||||
sync_size = le64_to_cpu(sb->sync_size);
|
md_bitmap_free(bitmap);
|
||||||
else if (sync_size != le64_to_cpu(sb->sync_size)) {
|
return rv;
|
||||||
kunmap_atomic(sb);
|
}
|
||||||
|
|
||||||
|
if (sync_size == 0) {
|
||||||
|
sync_size = stats.sync_size;
|
||||||
|
} else if (sync_size != stats.sync_size) {
|
||||||
md_bitmap_free(bitmap);
|
md_bitmap_free(bitmap);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
kunmap_atomic(sb);
|
|
||||||
md_bitmap_free(bitmap);
|
md_bitmap_free(bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue