Skip to contentSkip to conversation

master - format_text: Use versionsort to sort archive files

PATCH Alasdair Kergon 1 participant 1 message Feb 9, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1b6d0346a37d34394471080ec2aff55cea1bdafe
Commit:        1b6d0346a37d34394471080ec2aff55cea1bdafe
Parent:        d6cabbbc53de615fe92ff6372a570285704b59d2
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Fri Feb 9 01:08:55 2018 +0000
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Fri Feb 9 01:08:55 2018 +0000

format_text: Use versionsort to sort archive files

Ensure that vg_100000-* follows vg_99999-* so that the expiry logic doesn't stop too early.

https://bugzilla.redhat.com/1481085

---
 WHATS_NEW                 |    1 +
 lib/format_text/archive.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
WHATS_NEW +1 -0
index 9e6cb39..197adc3 100644
@@ -1,5 +1,6 @@
 Version 2.02.178 - 
 =====================================
+  Use versionsort to fix archive file expiry beyond 100000 files.
   Add devices/use_aio, aio_max, aio_memory to configure AIO limits.
   Support asynchronous I/O when scanning devices.
   Detect asynchronous I/O capability in configure or accept --disable-aio.
lib/format_text/archive.c +2 -2
index 4d4e7ac..a81a83b 100644
@@ -136,8 +136,8 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
 
 	dm_list_init(results);
 
-	/* Sort fails beyond 5-digit indexes */
-	if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) {
+	/* Use versionsort to handle numbers beyond 5 digits */
+	if ((count = scandir(dir, &dirent, NULL, versionsort)) < 0) {
 		log_error("Couldn't scan the archive directory (%s).", dir);
 		return 0;
 	}