函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:block\genhd.c Create Date:2022-07-27 18:54:23
首页 Copyright©Brick

1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
/**
 * disk_replace_part_tbl - replace disk->part_tbl in RCU-safe way
 * @disk: disk to replace part_tbl for
 * @new_ptbl: new part_tbl to install
 *
 * Replace disk->part_tbl with @new_ptbl in RCU-safe way.  The
 * original ptbl is freed using RCU callback.
 *
 * LOCKING:
 * Matching bd_mutex locked or the caller is the only user of @disk.
 */
static void disk_replace_part_tbl(struct gendisk *disk,
                  struct disk_part_tbl *new_ptbl)
{
    struct disk_part_tbl *old_ptbl =
        rcu_dereference_protected(disk->part_tbl, 1);
 
    rcu_assign_pointer(disk->part_tbl, new_ptbl);
 
    if (old_ptbl) {
        rcu_assign_pointer(old_ptbl->last_lookup, NULL);
        kfree_rcu(old_ptbl, rcu_head);
    }
}