1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvcreate should close the initialised snapshot device immediately.

This commit is contained in:
Alasdair Kergon 2003-11-14 17:55:39 +00:00
parent 17823680fc
commit ee8518bd9c
4 changed files with 29 additions and 7 deletions

View File

@ -406,11 +406,22 @@ static inline void _check_for_open_devices(void)
void dev_cache_exit(void) void dev_cache_exit(void)
{ {
_check_for_open_devices();
pool_destroy(_cache.mem);
if (_cache.names) if (_cache.names)
_check_for_open_devices();
if (_cache.mem) {
pool_destroy(_cache.mem);
_cache.mem = NULL;
}
if (_cache.names) {
hash_destroy(_cache.names); hash_destroy(_cache.names);
_cache.names = NULL;
}
_cache.devices = NULL;
_cache.has_scanned = 0;
list_init(&_cache.dirs);
} }
int dev_cache_add_dir(const char *path) int dev_cache_add_dir(const char *path)

View File

@ -155,7 +155,7 @@ static int _aligned_io(struct device_area *where, void *buffer,
} }
if (!block_size) if (!block_size)
block_size = SECTOR_SIZE * 2; block_size = getpagesize();
_widen_region(block_size, where, &widened); _widen_region(block_size, where, &widened);
@ -353,7 +353,7 @@ static void _close(struct device *dev)
} }
} }
int dev_close(struct device *dev) static int _dev_close(struct device *dev, int immediate)
{ {
if (dev->fd < 0) { if (dev->fd < 0) {
log_error("Attempt to close device '%s' " log_error("Attempt to close device '%s' "
@ -367,12 +367,22 @@ int dev_close(struct device *dev)
#endif #endif
/* FIXME lookup device in cache to get vgname and see if it's locked? */ /* FIXME lookup device in cache to get vgname and see if it's locked? */
if (--dev->open_count < 1 && !vgs_locked()) if (--dev->open_count < 1 && (immediate || !vgs_locked()))
_close(dev); _close(dev);
return 1; return 1;
} }
int dev_close(struct device *dev)
{
return _dev_close(dev, 0);
}
int dev_close_immediate(struct device *dev)
{
return _dev_close(dev, 1);
}
void dev_close_all(void) void dev_close_all(void)
{ {
struct list *doh, *doht; struct list *doh, *doht;

View File

@ -54,6 +54,7 @@ int dev_open(struct device *dev);
int dev_open_quiet(struct device *dev); int dev_open_quiet(struct device *dev);
int dev_open_flags(struct device *dev, int flags, int append, int quiet); int dev_open_flags(struct device *dev, int flags, int append, int quiet);
int dev_close(struct device *dev); int dev_close(struct device *dev);
int dev_close_immediate(struct device *dev);
void dev_close_all(void); void dev_close_all(void);
static inline int dev_fd(struct device *dev) static inline int dev_fd(struct device *dev)

View File

@ -347,7 +347,7 @@ static int _zero_lv(struct cmd_context *cmd, struct logical_volume *lv)
return 0; return 0;
dev_zero(dev, UINT64_C(0), (size_t) 4096); dev_zero(dev, UINT64_C(0), (size_t) 4096);
dev_close(dev); dev_close_immediate(dev);
return 1; return 1;
} }