]> www.infradead.org Git - users/jedix/linux-maple.git/commit
block: fix RO partition with RW disk
authorJunxiao Bi <junxiao.bi@oracle.com>
Mon, 5 Aug 2019 17:24:34 +0000 (10:24 -0700)
committerBrian Maly <brian.maly@oracle.com>
Wed, 21 Aug 2019 17:11:47 +0000 (13:11 -0400)
commit24ad5b209a47575ea47ba1857c25e8aeb4648292
tree614296fe74e6142dc988993e7c0555196b108053
parent751f0307d534f0cd33110de4ba1c86a8499cee65
block: fix RO partition with RW disk

When md raid1 was used with imsm metadata, during the boot stage,
the raid device will first be set to readonly, then mdmon will set
it read-write later. When there were some partitions in this device,
the following race would make some partition left ro and fail to mount.

CPU 1:                                                 CPU 2:
add_partition()                                        set_disk_ro() //set disk RW
 //disk was RO, so partition set to RO
 p->policy = get_disk_ro(disk);
                                                        if (disk->part0.policy != flag) {
                                                            set_disk_ro_uevent(disk, flag);
                                                            // disk set to RW
                                                            disk->part0.policy = flag;
                                                        }
                                                        // set all exit partition to RW
                                                        while ((part = disk_part_iter_next(&piter)))
                                                            part->policy = flag;
 // this part was not yet added, so it was still RO
 rcu_assign_pointer(ptbl->part[partno], p);

Move RO status setting of partitions after they were added into partition
table and introduce a mutex to sync RO status between disk and partitions.

Orabug: 30159928

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
block/genhd.c
block/partition-generic.c
include/linux/genhd.h