Initial commit
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
22
modules/cas_cache/utils/utils_blk.c
Normal file
22
modules/cas_cache/utils/utils_blk.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2019 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||
*/
|
||||
|
||||
#include "utils_blk.h"
|
||||
|
||||
int cas_blk_get_part_count(struct block_device *bdev)
|
||||
{
|
||||
struct disk_part_tbl *ptbl;
|
||||
int i, count = 0;
|
||||
|
||||
rcu_read_lock();
|
||||
ptbl = rcu_dereference(bdev->bd_disk->part_tbl);
|
||||
for (i = 0; i < ptbl->len; ++i) {
|
||||
if (rcu_access_pointer(ptbl->part[i]))
|
||||
count++;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
return count;
|
||||
}
|
Reference in New Issue
Block a user