Check exclusive device access before probing metadata
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
5f65d93a36
commit
2b739d1165
@ -2915,10 +2915,12 @@ int zero_md(const char *cache_device){
|
|||||||
int fd = 0;
|
int fd = 0;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/* check if given cache device exists */
|
/* check if device is available */
|
||||||
fd = open(cache_device, O_RDONLY);
|
fd = open(cache_device, O_WRONLY | O_SYNC | O_EXCL);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
cas_printf(LOG_ERR, "Device '%s' not found.\n", cache_device);
|
cas_printf(LOG_ERR, "Error while opening '%s'exclusively. This can be due to\n"
|
||||||
|
"cache instance running on this device. In such case please "
|
||||||
|
"stop the cache and try again.\n", cache_device);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user