|
Panu Matilainen |
d06308 |
diff --git a/lib/transaction.c b/lib/transaction.c
|
|
Panu Matilainen |
d06308 |
index 7adf60b..5acc08e 100644
|
|
Panu Matilainen |
d06308 |
--- a/lib/transaction.c
|
|
Panu Matilainen |
d06308 |
+++ b/lib/transaction.c
|
|
Panu Matilainen |
d06308 |
@@ -227,46 +227,12 @@ static void rpmtsUpdateDSI(const rpmts ts, dev_t dev, const char *dirName,
|
|
Panu Matilainen |
d06308 |
if (dsi->ineeded < dsi->oineeded) dsi->oineeded = dsi->ineeded;
|
|
Panu Matilainen |
d06308 |
}
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
-/* return DSI of the device the rpmdb lives on */
|
|
Panu Matilainen |
d06308 |
-static rpmDiskSpaceInfo rpmtsDbDSI(const rpmts ts) {
|
|
Panu Matilainen |
d06308 |
- const char *dbhome = rpmdbHome(rpmtsGetRdb(ts));
|
|
Panu Matilainen |
d06308 |
- struct stat sb;
|
|
Panu Matilainen |
d06308 |
- int rc;
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
- rc = stat(dbhome, &sb);
|
|
Panu Matilainen |
d06308 |
- if (rc) {
|
|
Panu Matilainen |
d06308 |
- return NULL;
|
|
Panu Matilainen |
d06308 |
- }
|
|
Panu Matilainen |
d06308 |
- return rpmtsGetDSI(ts, sb.st_dev, dbhome);
|
|
Panu Matilainen |
d06308 |
-}
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
-/* Update DSI for changing size of the rpmdb */
|
|
Panu Matilainen |
d06308 |
-static void rpmtsUpdateDSIrpmDBSize(const rpmte p,
|
|
Panu Matilainen |
d06308 |
- rpmDiskSpaceInfo dsi) {
|
|
Panu Matilainen |
d06308 |
- rpm_loff_t headerSize;
|
|
Panu Matilainen |
d06308 |
- int64_t bneeded;
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
- /* XXX somehow we can end up here with bsize 0 (RhBug:671056) */
|
|
Panu Matilainen |
d06308 |
- if (dsi == NULL || dsi->bsize == 0) return;
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
- headerSize = rpmteHeaderSize(p);
|
|
Panu Matilainen |
d06308 |
- bneeded = BLOCK_ROUND(headerSize, dsi->bsize);
|
|
Panu Matilainen |
d06308 |
- /* REMOVE doesn't neccessarily shrink the database */
|
|
Panu Matilainen |
d06308 |
- if (rpmteType(p) == TR_ADDED) {
|
|
Panu Matilainen |
d06308 |
- /* guessing that db grows 4 times more than the header size */
|
|
Panu Matilainen |
d06308 |
- dsi->bneeded += (bneeded * 4);
|
|
Panu Matilainen |
d06308 |
- }
|
|
Panu Matilainen |
d06308 |
-}
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
static void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
|
|
Panu Matilainen |
d06308 |
{
|
|
Panu Matilainen |
d06308 |
rpmDiskSpaceInfo dsi = ts->dsi;
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
if (dsi == NULL || !dsi->bsize)
|
|
Panu Matilainen |
d06308 |
return;
|
|
Panu Matilainen |
d06308 |
- if (rpmfiFC(rpmteFI(te)) <= 0)
|
|
Panu Matilainen |
d06308 |
- return;
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
for (; dsi->bsize; dsi++) {
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
@@ -1294,11 +1260,12 @@ static int rpmtsPrepare(rpmts ts)
|
|
Panu Matilainen |
d06308 |
rpmfi fi;
|
|
Panu Matilainen |
d06308 |
int rc = 0;
|
|
Panu Matilainen |
d06308 |
uint64_t fileCount = countFiles(ts);
|
|
Panu Matilainen |
d06308 |
+ const char *dbhome = NULL;
|
|
Panu Matilainen |
d06308 |
+ struct stat dbstat;
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
fingerPrintCache fpc = fpCacheCreate(fileCount/2 + 10001);
|
|
Panu Matilainen |
d06308 |
rpmFpHash ht = rpmFpHashCreate(fileCount/2+1, fpHashFunction, fpEqual,
|
|
Panu Matilainen |
d06308 |
NULL, NULL);
|
|
Panu Matilainen |
d06308 |
- rpmDiskSpaceInfo dsi;
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount);
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
@@ -1326,7 +1293,10 @@ static int rpmtsPrepare(rpmts ts)
|
|
Panu Matilainen |
d06308 |
/* check against files in the rpmdb */
|
|
Panu Matilainen |
d06308 |
checkInstalledFiles(ts, fileCount, ht, fpc);
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
- dsi = rpmtsDbDSI(ts);
|
|
Panu Matilainen |
d06308 |
+ dbhome = rpmdbHome(rpmtsGetRdb(ts));
|
|
Panu Matilainen |
d06308 |
+ /* If we can't stat, ignore db growth. Probably not right but... */
|
|
Panu Matilainen |
d06308 |
+ if (dbhome && stat(dbhome, &dbstat))
|
|
Panu Matilainen |
d06308 |
+ dbhome = NULL;
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
pi = rpmtsiInit(ts);
|
|
Panu Matilainen |
d06308 |
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
Panu Matilainen |
d06308 |
@@ -1338,10 +1308,18 @@ static int rpmtsPrepare(rpmts ts)
|
|
Panu Matilainen |
d06308 |
needs on each partition for this package. */
|
|
Panu Matilainen |
d06308 |
handleOverlappedFiles(ts, ht, p, fi);
|
|
Panu Matilainen |
d06308 |
|
|
Panu Matilainen |
d06308 |
- rpmtsUpdateDSIrpmDBSize(p, dsi);
|
|
Panu Matilainen |
d06308 |
-
|
|
Panu Matilainen |
d06308 |
/* Check added package has sufficient space on each partition used. */
|
|
Panu Matilainen |
d06308 |
if (rpmteType(p) == TR_ADDED) {
|
|
Panu Matilainen |
d06308 |
+ /*
|
|
Panu Matilainen |
d06308 |
+ * Try to estimate space needed for rpmdb growth: guess that the
|
|
Panu Matilainen |
d06308 |
+ * db grows 4 times the header size (indexes and all).
|
|
Panu Matilainen |
d06308 |
+ */
|
|
Panu Matilainen |
d06308 |
+ if (dbhome) {
|
|
Panu Matilainen |
d06308 |
+ int64_t hsize = rpmteHeaderSize(p) * 4;
|
|
Panu Matilainen |
d06308 |
+ rpmtsUpdateDSI(ts, dbstat.st_dev, dbhome,
|
|
Panu Matilainen |
d06308 |
+ hsize, 0, 0, FA_CREATE);
|
|
Panu Matilainen |
d06308 |
+ }
|
|
Panu Matilainen |
d06308 |
+
|
|
Panu Matilainen |
d06308 |
rpmtsCheckDSIProblems(ts, p);
|
|
Panu Matilainen |
d06308 |
}
|
|
Panu Matilainen |
d06308 |
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|