diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-02-29 12:52:05 +0100 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-03-11 11:06:01 +0100 |
commit | 0c0f09cb035b6a27a1d11c54836742a9945a5014 (patch) | |
tree | b9437d6c55abdb7a0ed37fdbfeb4aef3111f6ce4 /mdadm.h | |
parent | Detail: remove duplicated code (diff) | |
download | mdadm-0c0f09cb035b6a27a1d11c54836742a9945a5014.tar.xz mdadm-0c0f09cb035b6a27a1d11c54836742a9945a5014.zip |
mdadm: Add functions for spare criteria verification
It is done similar way in few places. As a result, two almost identical
functions (dev_size_from_id() and dev_sector_size_from_id()) are
removed. Now, it uses same file descriptor to send two ioctls.
Two extern functions are added, in next patches
disk_fd_matches_criteria() is used.
Next optimization is inline zeroing struct spare_criteria. With that,
we don't need to reset values in get_spare_criteria_imsm().
Dedicated boolean field for checking if criteria are filled is added.
We don't need to execute the code if it is not set.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'mdadm.h')
-rw-r--r-- | mdadm.h | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -430,6 +430,7 @@ struct createinfo { }; struct spare_criteria { + bool criteria_set; unsigned long long min_size; unsigned int sector_size; }; @@ -1368,8 +1369,6 @@ extern struct supertype *dup_super(struct supertype *st); extern int get_dev_size(int fd, char *dname, unsigned long long *sizep); extern int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep); extern int must_be_container(int fd); -extern int dev_size_from_id(dev_t id, unsigned long long *size); -extern int dev_sector_size_from_id(dev_t id, unsigned int *size); void wait_for(char *dev, int fd); /* @@ -1708,6 +1707,9 @@ extern int assemble_container_content(struct supertype *st, int mdfd, #define INCR_UNSAFE 2 #define INCR_ALREADY 4 #define INCR_YES 8 + +extern bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc); +extern bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc); extern struct mdinfo *container_choose_spares(struct supertype *st, struct spare_criteria *criteria, struct domainlist *domlist, |