[CVS] RPM: rpm/lib/ rpminstall.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 14:25:05 Branch: HEAD Handle: 2009120813250500 Modified files: rpm/lib rpminstall.c Log: - use hdrNum consistently for primary key. Summary: RevisionChanges Path 1.221 +4 -5 rpm/lib/rpminstall.c patch -p0 <<'@@ .' Index: rpm/lib/rpminstall.c $ cvs diff -u -r1.220 -r1.221 rpminstall.c --- rpm/lib/rpminstall.c 15 May 2009 13:40:58 - 1.220 +++ rpm/lib/rpminstall.c 8 Dec 2009 13:25:05 - 1.221 @@ -715,7 +715,6 @@ int rpmErase(rpmts ts, QVA_t ia, const char ** argv) { -int count; const char ** arg; int numFailed = 0; int numRPMS = 0; @@ -769,9 +768,9 @@ numFailed++; } else { Header h; /* XXX iterator owns the reference */ - count = 0; + int count = 0; while ((h = rpmmiNext(mi)) != NULL) { - unsigned int recOffset = rpmmiInstance(mi); + uint32_t hdrNum = rpmmiInstance(mi); if (!(count++ == 0 || (ia->installInterfaceFlags & INSTALL_ALLMATCHES))) { rpmlog(RPMLOG_ERR, _("\"%s\" specifies multiple packages\n"), @@ -779,8 +778,8 @@ numFailed++; /*...@innerbreak@*/ break; } - if (recOffset) { - (void) rpmtsAddEraseElement(ts, h, recOffset); + if (hdrNum) { + (void) rpmtsAddEraseElement(ts, h, hdrNum); numRPMS++; } } @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org
[CVS] RPM: rpm/ CHANGES rpm/rpmdb/ db3.c rpmdb.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 16:37:24 Branch: HEAD Handle: 2009120815372301 Modified files: rpm CHANGES rpm/rpmdb db3.c rpmdb.c Log: - rpmdb: consolidate primary key swabbing to network order. Summary: RevisionChanges Path 1.3185 +1 -0 rpm/CHANGES 1.128 +1 -1 rpm/rpmdb/db3.c 1.349 +38 -46 rpm/rpmdb/rpmdb.c patch -p0 <<'@@ .' Index: rpm/CHANGES $ cvs diff -u -r1.3184 -r1.3185 CHANGES --- rpm/CHANGES 8 Dec 2009 04:41:51 - 1.3184 +++ rpm/CHANGES 8 Dec 2009 15:37:23 - 1.3185 @@ -1,5 +1,6 @@ 5.2b1 -> 5.3a1 +- jbj: rpmdb: consolidate primary key swabbing to network order. - jbj: rpmdb: re-open dbenv w DB_RUNRECOVER rather than remove/verify. - jbj: rpmdb: handle optional .A just like optional -V and -R patterns. - jbj: rpmdb: use RPMTAG_NVRA patterns for RPMDBI_LABEL rpmmi iterators. @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/db3.c $ cvs diff -u -r1.127 -r1.128 db3.c --- rpm/rpmdb/db3.c 8 Dec 2009 04:41:53 - 1.127 +++ rpm/rpmdb/db3.c 8 Dec 2009 15:37:24 - 1.128 @@ -2029,7 +2029,7 @@ default: break; case DB_RUNRECOVERY: - rpmlog(RPMLOG_ERR, _("Re-opening dbenv with DB_RUNRECOVER ...\n")); + rpmlog(RPMLOG_ERR, _("Re-opening dbenv with DB_RECOVER ...\n")); dbi->dbi_eflags |= DB_RECOVER; rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv); dbi->dbi_eflags &= ~DB_RECOVER; @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/rpmdb.c $ cvs diff -u -r1.348 -r1.349 rpmdb.c --- rpm/rpmdb/rpmdb.c 7 Dec 2009 17:53:47 - 1.348 +++ rpm/rpmdb/rpmdb.c 8 Dec 2009 15:37:24 - 1.349 @@ -332,6 +332,19 @@ _b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \ } +static inline uint32_t _ntohl(uint32_t ui) +{ +union _dbswap mi_offset; +mi_offset.ui = ui; +if (_endian.uc[0] == 0x44) + _DBSWAP(mi_offset); +return mi_offset.ui; +} +static inline uint32_t _htonl(uint32_t ui) +{ +return _ntohl(ui); +} + typedef struct _setSwap_s { union _dbswap hdr; union _dbswap tag; @@ -518,8 +531,8 @@ int mi_sorted; int mi_cflags; int mi_modified; -unsigned int mi_prevoffset; /* header instance (big endian) */ -unsigned int mi_offset; /* header instance (big endian) */ +uint32_t mi_prevoffset; /* header instance (big endian) */ +uint32_t mi_offset; /* header instance (big endian) */ /*...@refcounted@*/ /*...@null@*/ rpmbfmi_bf; /* Iterator instance Bloom filter. */ int mi_nre; @@ -1382,7 +1395,7 @@ /* Iterate over all keys, collecting primary keys. */ while ((rc = dbiPget(dbi, dbcursor, &k, &p, &v, _flags)) == 0) { - union _dbswap mi_offset; + uint32_t hdrNum; unsigned ix; if (_flags == DB_SET) _flags = DB_NEXT_DUP; @@ -1412,16 +1425,15 @@ } /* Get a native endian copy of the primary package key. */ - memcpy(&mi_offset, p.data, sizeof(mi_offset.ui)); - if (_endian.uc[0] == 0x44) - _DBSWAP(mi_offset); + memcpy(&hdrNum, p.data, sizeof(hdrNum)); + hdrNum = _ntohl(hdrNum); /* Append primary package key to set. */ if (set == NULL) set = xcalloc(1, sizeof(*set)); ix = set->count; /* XXX TODO: sort/uniqify set? */ - (void) dbiAppendSet(set, &mi_offset.ui, 1, sizeof(mi_offset.ui), 0); + (void) dbiAppendSet(set, &hdrNum, 1, sizeof(hdrNum), 0); if (_jbj_debug) fprintf(stderr, "\tset[%u] = %u\n", ix, dbiIndexRecordOffset(set, ix)); } @@ -1709,12 +1721,8 @@ uint32_t rpmmiInstance(rpmmi mi) { -union _dbswap mi_offset; /* Get a native endian copy of the primary package key. */ -mi_offset.ui = (mi ? mi->mi_offset : 0); -if (_endian.uc[0] == 0x44) - _DBSWAP(mi_offset); -return mi_offset.ui; +return _ntohl(mi ? mi->mi_offset : 0); } unsigned int rpmmiCount(rpmmi mi)
[CVS] RPM: rpm/ CHANGES rpm/rpmdb/ db3.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 18:46:41 Branch: HEAD Handle: 2009120817464000 Modified files: rpm CHANGES rpm/rpmdb db3.c Log: - rpmdb: lazily create non-existent secondary indices. Summary: RevisionChanges Path 1.3186 +1 -0 rpm/CHANGES 1.129 +18 -11 rpm/rpmdb/db3.c patch -p0 <<'@@ .' Index: rpm/CHANGES $ cvs diff -u -r1.3185 -r1.3186 CHANGES --- rpm/CHANGES 8 Dec 2009 15:37:23 - 1.3185 +++ rpm/CHANGES 8 Dec 2009 17:46:40 - 1.3186 @@ -1,5 +1,6 @@ 5.2b1 -> 5.3a1 +- jbj: rpmdb: lazily create non-existent secondary indices. - jbj: rpmdb: consolidate primary key swabbing to network order. - jbj: rpmdb: re-open dbenv w DB_RUNRECOVER rather than remove/verify. - jbj: rpmdb: handle optional .A just like optional -V and -R patterns. @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/db3.c $ cvs diff -u -r1.128 -r1.129 db3.c --- rpm/rpmdb/db3.c 8 Dec 2009 15:37:24 - 1.128 +++ rpm/rpmdb/db3.c 8 Dec 2009 17:46:40 - 1.129 @@ -1531,14 +1531,19 @@ uint32_t i; /* XXX Don't index the header instance counter at record 0. */ -if (key->size == 4 && *(uint32_t *)key->data == 0) - return rc; +{static uint32_t _zero = 0; + if (key->size == 4 && !memcmp(key->data, &_zero, key->size)) + goto exit; +} assert(dbi); rpmdb = dbi->dbi_rpmdb; assert(rpmdb); -h = rpmdb->db_h; -assert(h); +h = headerLink(rpmdb->db_h); +if (h == NULL) { + h = headerLoad(data->data); + if (h == NULL) goto exit; +} memset(_r, 0, sizeof(*_r)); @@ -1553,7 +1558,7 @@ #ifdef NOTYET case RPMTAG_BASENAMES: case RPMTAG_FILEPATHS: - /* Add the pesky trailing '/' to directories. */ + /* XXX Add the pesky trailing '/' to directories. */ FMhe->tag = RPMTAG_FILEMODES; (void) headerGet(h, FMhe, 0); break; @@ -1719,6 +1724,7 @@ #endif Fhe->p.ptr = _free(Fhe->p.ptr); he->p.ptr = _free(he->p.ptr); +h = headerFree(h); DBIDEBUG(dbi, (stderr, "<-- %s(%p, %p, %p, %p) rc %d\n\tdbi %p(%s) rpmdb %p h %p %s\n", __FUNCTION__, db, key, data, _r, rc, dbi, tagName(dbi->dbi_rpmtag), rpmdb, h, _KEYDATA(key, data, _r))); @@ -1876,7 +1882,8 @@ } oflags = (dbi->dbi_oeflags | dbi->dbi_oflags); -oflags &= ~DB_TRUNCATE; /* XXX this is dangerous */ +/* XXX permit DB_TRUNCATE iff a secondary index. */ +if (!dbi->dbi_index) oflags &= ~DB_TRUNCATE; #if 0/* XXX rpmdb: illegal flag combination specified to DB->open */ if ( dbi->dbi_mode & O_EXCL) oflags |= DB_EXCL; @@ -1896,9 +1903,8 @@ oflags |= DB_CREATE; dbi->dbi_oeflags |= DB_CREATE; } -#ifdef DANGEROUS - if ( dbi->dbi_mode & O_TRUNC) oflags |= DB_TRUNCATE; -#endif + /* XXX permit DB_TRUNCATE iff a secondary index. */ + if (dbi->dbi_index && (dbi->dbi_mode & O_TRUNC)) oflags |= DB_TRUNCATE; } /* @@ -2010,9 +2016,9 @@ } /* - * Set db type if creating. + * Set db type if creating or truncating. */ -if (oflags & DB_CREATE) +if (oflags & (DB_CREATE|DB_TRUNCATE)) dbi_type = dbi->dbi_type; /* @@ -2348,6 +2354,7 @@ = db3Acallback; int _flags = (rpmdb->_dbi[0]->dbi_eflags & DB_INIT_TXN) ? DB_AUTO_COMMIT : 0; + if (oflags & (DB_CREATE|DB_TRUNCATE)) _flags |= DB_CREATE; xx = db3associate(rpmdb->_dbi[0], dbi, _callback, _flags); } if (dbi->dbi_seq_id) { @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org
[CVS] RPM: rpm/lib/ depends.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 19:25:39 Branch: HEAD Handle: 2009120818253900 Modified files: rpm/lib depends.c Log: - turn on dependency result caching. Summary: RevisionChanges Path 1.452 +1 -0 rpm/lib/depends.c patch -p0 <<'@@ .' Index: rpm/lib/depends.c $ cvs diff -u -r1.451 -r1.452 depends.c --- rpm/lib/depends.c 4 Dec 2009 04:18:51 - 1.451 +++ rpm/lib/depends.c 8 Dec 2009 18:25:39 - 1.452 @@ -46,6 +46,7 @@ int orIndex; }; +#define CACHE_DEPENDENCY_RESULT 1 #if defined(CACHE_DEPENDENCY_RESULT) /*...@unchecked@*/ int _cacheDependsRC = CACHE_DEPENDENCY_RESULT; @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org
[CVS] RPM: rpm/python/ rpmmi-py.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 19:26:27 Branch: HEAD Handle: 2009120818262700 Modified files: rpm/python rpmmi-py.c Log: - use hdrNum consistently. Summary: RevisionChanges Path 1.26+2 -6 rpm/python/rpmmi-py.c patch -p0 <<'@@ .' Index: rpm/python/rpmmi-py.c $ cvs diff -u -r1.25 -r1.26 rpmmi-py.c --- rpm/python/rpmmi-py.c 15 May 2009 13:40:59 - 1.25 +++ rpm/python/rpmmi-py.c 8 Dec 2009 18:26:27 - 1.26 @@ -122,12 +122,8 @@ rpmmi_Instance(rpmmiObject * s) /*...@*/ { -int rc = 0; - -if (s->mi != NULL) - rc = rpmmiInstance(s->mi); - -return Py_BuildValue("i", rc); +uint32_t hdrNum = (s->mi != NULL) ? rpmmiInstance(s->mi) : 0; +return Py_BuildValue("i", hdrNum); } /** @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org
[CVS] RPM: rpm/rpmdb/ db3.c rpmdb.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 19:30:02 Branch: HEAD Handle: 2009120818300200 Modified files: rpm/rpmdb db3.c rpmdb.c Log: - rpmdb: cruft up the usual swabbing prior to making integer indices big endian. Summary: RevisionChanges Path 1.130 +63 -0 rpm/rpmdb/db3.c 1.350 +64 -26 rpm/rpmdb/rpmdb.c patch -p0 <<'@@ .' Index: rpm/rpmdb/db3.c $ cvs diff -u -r1.129 -r1.130 db3.c --- rpm/rpmdb/db3.c 8 Dec 2009 17:46:40 - 1.129 +++ rpm/rpmdb/db3.c 8 Dec 2009 18:30:02 - 1.130 @@ -43,6 +43,69 @@ /*...@access dbiIndex @*/ /*...@access dbiIndexSet @*/ +union _dbswap { +uint64_t ul; +uint32_t ui; +uint16_t us; +uint8_t uc[8]; +}; +static union _dbswap _endian = { .ui = 0x11223344 }; + +static inline uint64_t _ntoh_ul(uint64_t ul) + /*...@*/ +{ +union _dbswap _a; +_a.ul = ul; +if (_endian.uc[0] == 0x44) { + uint8_t _b, *_c = _a.uc; \ + _b = _c[7]; _c[7] = _c[0]; _c[0] = _b; \ + _b = _c[6]; _c[6] = _c[1]; _c[1] = _b; \ + _b = _c[5]; _c[5] = _c[2]; _c[2] = _b; \ + _b = _c[4]; _c[4] = _c[3]; _c[3] = _b; \ +} +return _a.ul; +} +static inline uint64_t _hton_ul(uint64_t ul) + /*...@*/ +{ +return _ntoh_ul(ul); +} + +static inline uint32_t _ntoh_ui(uint32_t ui) + /*...@*/ +{ +union _dbswap _a; +_a.ui = ui; +if (_endian.uc[0] == 0x44) { + uint8_t _b, *_c = _a.uc; \ + _b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \ + _b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \ +} +return _a.ui; +} +static inline uint32_t _hton_ui(uint32_t ui) + /*...@*/ +{ +return _ntoh_ui(ui); +} + +static inline uint16_t _ntoh_us(uint16_t us) + /*...@*/ +{ +union _dbswap _a; +_a.us = us; +if (_endian.uc[0] == 0x44) { + uint8_t _b, *_c = _a.uc; \ + _b = _c[1]; _c[1] = _c[0]; _c[0] = _b; \ +} +return _a.us; +} +static inline uint16_t _hton_us(uint16_t us) + /*...@*/ +{ +return _ntoh_us(us); +} + #ifdef NOTNOW static const char * bfstring(unsigned int x, const char * xbf) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/rpmdb.c $ cvs diff -u -r1.349 -r1.350 rpmdb.c --- rpm/rpmdb/rpmdb.c 8 Dec 2009 15:37:24 - 1.349 +++ rpm/rpmdb/rpmdb.c 8 Dec 2009 18:30:02 - 1.350 @@ -321,34 +321,72 @@ } union _dbswap { -rpmuint32_t ui; -unsigned char uc[4]; +uint64_t ul; +uint32_t ui; +uint16_t us; +uint8_t uc[8]; }; static union _dbswap _endian = { .ui = 0x11223344 }; -#define _DBSWAP(_a) \ - { unsigned char _b, *_c = (_a).uc; \ -_b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \ -_b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \ - } - -static inline uint32_t _ntohl(uint32_t ui) -{ -union _dbswap mi_offset; -mi_offset.ui = ui; -if (_endian.uc[0] == 0x44) - _DBSWAP(mi_offset); -return mi_offset.ui; +static inline uint64_t _ntoh_ul(uint64_t ul) + /*...@*/ +{ +union _dbswap _a; +_a.ul = ul; +if (_endian.uc[0] == 0x44) { + uint8_t _b, *_c = _a.uc; \ + _b = _c[7]; _c[7] = _c[0]; _c[0] = _b; \ + _b = _c[6]; _c[6] = _c[1]; _c[1] = _b; \ + _b = _c[5]; _c[5] = _c[2]; _c[2] = _b; \ + _b = _c[4]; _c[4] = _c[3]; _c[3] = _b; \ +} +return _a.ul; +} +static inline uint64_t _hton_ul(uint64_t ul) + /*...@*/ +{ +return _ntoh_ul(ul); +} + +static inline uint32_t _ntoh_ui(uint32_t ui) + /*...@*/ +{ +union _dbswap _a; +_a.ui = ui; +if (_endian.uc[0] == 0x44) { + uint8_t _b, *_c = _a.uc; \ + _b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \ + _b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \ +} +return _a.ui; +} +static inline uint32_t _hton_ui(uint32_t ui) + /*...@*/ +{ +return _ntoh_ui(ui); +} + +static inline uint16_t _ntoh_us(uint16_t us) + /*...@*/ +{ +union _dbswap _a; +_a.us = us; +if (_endian.uc[0] == 0x44) { + uint8_t _b, *_c = _a.uc; \ + _b = _c[1]; _c[1] = _c[0]; _c[0] = _b; \ +} +return _a.us; } -static inline uint32_t _htonl(uint32_t ui) +static inline uint16_t _hton_us(uint16_t us) + /*...@*/
[CVS] RPM: rpm/rpmdb/ db3.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 19:49:25 Branch: HEAD Handle: 2009120818492500 Modified files: rpm/rpmdb db3.c Log: - fix: don't pass DB_AUTO_COMMIT to DB->associate(). Summary: RevisionChanges Path 1.131 +1 -2 rpm/rpmdb/db3.c patch -p0 <<'@@ .' Index: rpm/rpmdb/db3.c $ cvs diff -u -r1.130 -r1.131 db3.c --- rpm/rpmdb/db3.c 8 Dec 2009 18:30:02 - 1.130 +++ rpm/rpmdb/db3.c 8 Dec 2009 18:49:25 - 1.131 @@ -2415,8 +2415,7 @@ if (dbi->dbi_index) { int (*_callback)(DB *, const DBT *, const DBT *, DBT *) = db3Acallback; - int _flags = (rpmdb->_dbi[0]->dbi_eflags & DB_INIT_TXN) - ? DB_AUTO_COMMIT : 0; + int _flags = DB_IMMUTABLE_KEY; if (oflags & (DB_CREATE|DB_TRUNCATE)) _flags |= DB_CREATE; xx = db3associate(rpmdb->_dbi[0], dbi, _callback, _flags); } @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org
[CVS] RPM: rpm/ CHANGES rpm/rpmdb/ DB_CONFIG.in rpmdb.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 08-Dec-2009 22:20:35 Branch: HEAD Handle: 2009120821203401 Modified files: rpm CHANGES rpm/rpmdb DB_CONFIG.in rpmdb.c Log: - rpmdb: do in-place rebuilddb, opt-in for now. Summary: RevisionChanges Path 1.3187 +1 -0 rpm/CHANGES 1.8 +3 -3 rpm/rpmdb/DB_CONFIG.in 1.351 +92 -1 rpm/rpmdb/rpmdb.c patch -p0 <<'@@ .' Index: rpm/CHANGES $ cvs diff -u -r1.3186 -r1.3187 CHANGES --- rpm/CHANGES 8 Dec 2009 17:46:40 - 1.3186 +++ rpm/CHANGES 8 Dec 2009 21:20:34 - 1.3187 @@ -1,5 +1,6 @@ 5.2b1 -> 5.3a1 +- jbj: rpmdb: do in-place rebuilddb, opt-in for now. - jbj: rpmdb: lazily create non-existent secondary indices. - jbj: rpmdb: consolidate primary key swabbing to network order. - jbj: rpmdb: re-open dbenv w DB_RUNRECOVER rather than remove/verify. @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/DB_CONFIG.in $ cvs diff -u -r1.7 -r1.8 DB_CONFIG.in --- rpm/rpmdb/DB_CONFIG.in3 Dec 2009 21:44:26 - 1.7 +++ rpm/rpmdb/DB_CONFIG.in8 Dec 2009 21:20:35 - 1.8 @@ -31,8 +31,8 @@ set_mp_mmapsize 16777216 # Locking -set_lk_max_locks 4000 -set_lk_max_lockers 4000 -set_lk_max_objects 4000 +set_lk_max_locks 8000 +set_lk_max_lockers 8000 +set_lk_max_objects 8000 # Replication @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/rpmdb.c $ cvs diff -u -r1.350 -r1.351 rpmdb.c --- rpm/rpmdb/rpmdb.c 8 Dec 2009 18:30:02 - 1.350 +++ rpm/rpmdb/rpmdb.c 8 Dec 2009 21:20:35 - 1.351 @@ -69,6 +69,8 @@ /*...@unchecked@*/ static int _rebuildinprogress = 0; +static int _rebuild_inplace = 1; + #define _DBI_FLAGS 0 #define _DBI_PERMS 0644 #define _DBI_MAJOR -1 @@ -794,6 +796,10 @@ case RPMDBI_ADDED: case RPMDBI_REMOVED: case RPMDBI_DEPENDS: + case RPMDBI_BTREE: + case RPMDBI_HASH: + case RPMDBI_QUEUE: + case RPMDBI_RECNO: continue; /*...@notreached@*/ /*...@switchbreak@*/ break; default: @@ -3182,12 +3188,26 @@ for (i = 0; i < dbiNTags; i++) { const char * dbiBN = (dbiTags[i].str != NULL ? dbiTags[i].str : tagName(dbiTags[i].tag)); +if (_rebuild_inplace) +switch (dbiTags[i].tag) { +case RPMDBI_PACKAGES: +case RPMDBI_SEQNO: +case RPMDBI_BTREE: +case RPMDBI_HASH: +case RPMDBI_QUEUE: +case RPMDBI_RECNO: +continue; +/*...@notreached@*/ break; +default: +break; +} fn = rpmGetPath(prefix, dbpath, "/", dbiBN, NULL); if (rpmioFileExists(fn)) xx = Unlink(fn); fn = _free(fn); } +if (!_rebuild_inplace) { fn = rpmGetPath(prefix, dbpath, "/", "__db.000", NULL); suffix = (char *)(fn + strlen(fn) - (sizeof("000") - 1)); for (i = 0; i < 16; i++) { @@ -3196,6 +3216,7 @@ xx = Unlink(fn); } fn = _free(fn); +} }break; case 2: @@ -3204,9 +3225,11 @@ break; } +if (!_rebuild_inplace) { fn = rpmGetPath(prefix, dbpath, NULL); xx = Rmdir(fn); fn = _free(fn); +} return 0; } @@ -3328,7 +3351,7 @@ return rc; } -int rpmdbRebuild(const char * prefix, rpmts ts) +static int _rpmdbRebuild(const char * prefix, rpmts ts) /*...@globals _rebuildinprogress @*/ /*...@modifies _rebuildinprogress @*/ { @@ -3563,3 +3586,71 @@ return rc; } + +int rpmdbRebuild(const char * prefix, rpmts ts) + /*...@globals _rebuildinprogress @*/ + /*...@modifies _rebuildinprogress @*/ +{ +const char * myprefix = NULL; +rpmdb olddb; +const char * dbpath = NULL; +const char * rootdbpath = NULL; +int _dbapi = rpmExpandNumeric("%{_dbapi}"); +tagStore_t dbiTags = NULL; +size_t dbiNTags = 0; +const char * tfn; +int rc = 1; /* assume failure */ +int xx; + +if (!_rebuild_inplace) + return _rpmdbRebuild(prefix, ts); + +fprintf(stderr, "--> %s(%s, %p)\n",
[CVS] RPM: rpm/ CHANGES rpm/lib/ rpmts.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 09-Dec-2009 04:55:35 Branch: HEAD Handle: 2009120903553302 Modified files: rpm CHANGES rpm/lib rpmts.c Log: - rpmts: take checkpoints beroe and after --rebuilddb. Summary: RevisionChanges Path 1.3188 +1 -0 rpm/CHANGES 2.178 +16 -7 rpm/lib/rpmts.c patch -p0 <<'@@ .' Index: rpm/CHANGES $ cvs diff -u -r1.3187 -r1.3188 CHANGES --- rpm/CHANGES 8 Dec 2009 21:20:34 - 1.3187 +++ rpm/CHANGES 9 Dec 2009 03:55:33 - 1.3188 @@ -1,5 +1,6 @@ 5.2b1 -> 5.3a1 +- jbj: rpmts: take checkpoints beroe and after --rebuilddb. - jbj: rpmdb: do in-place rebuilddb, opt-in for now. - jbj: rpmdb: lazily create non-existent secondary indices. - jbj: rpmdb: consolidate primary key swabbing to network order. @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmts.c $ cvs diff -u -r2.177 -r2.178 rpmts.c --- rpm/lib/rpmts.c 7 Dec 2009 17:53:47 - 2.177 +++ rpm/lib/rpmts.c 9 Dec 2009 03:55:35 - 2.178 @@ -116,10 +116,8 @@ ts->dbmode = dbmode; rc = rpmdbOpen(ts->rootDir, &ts->rdb, ts->dbmode, 0644); if (rc) { - const char * dn; - dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL); - rpmlog(RPMLOG_ERR, - _("cannot open Packages database in %s\n"), dn); + const char * dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL); + rpmlog(RPMLOG_ERR, _("cannot open Packages database in %s\n"), dn); dn = _free(dn); } return rc; @@ -128,11 +126,22 @@ int rpmtsRebuildDB(rpmts ts) { void * lock = rpmtsAcquireLock(ts); -int rc = rpmtsOpenDB(ts, ts->dbmode); +int rc; + +rc = rpmtsOpenDB(ts, O_RDWR); +if (rc) goto exit; -if (rc == 0) - rc = rpmdbRebuild(ts->rootDir, +rc = rpmtxnCheckpoint(rpmtsGetRdb(ts)); +if (rc) goto exit; + +rc = rpmdbRebuild(ts->rootDir, (!(rpmtsVSFlags(ts) & RPMVSF_NOHDRCHK) ? ts : NULL)); +if (rc) goto exit; + +rc = rpmtxnCheckpoint(rpmtsGetRdb(ts)); +if (rc) goto exit; + +exit: lock = rpmtsFreeLock(lock); return rc; } @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org
[CVS] RPM: rpm/ CHANGES rpm/rpmdb/ rpmdb.c
RPM Package Manager, CVS Repository http://rpm5.org/cvs/ Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 09-Dec-2009 04:59:58 Branch: HEAD Handle: 2009120903595700 Modified files: rpm CHANGES rpm/rpmdb rpmdb.c Log: - rpmdb: inline rpmdbOpenAll for inplace --rebuilddb. sadly DB->associate(..., DB_CREATE) is not free threaded w -fopenmp. oh well. Summary: RevisionChanges Path 1.3189 +2 -0 rpm/CHANGES 1.352 +26 -12 rpm/rpmdb/rpmdb.c patch -p0 <<'@@ .' Index: rpm/CHANGES $ cvs diff -u -r1.3188 -r1.3189 CHANGES --- rpm/CHANGES 9 Dec 2009 03:55:33 - 1.3188 +++ rpm/CHANGES 9 Dec 2009 03:59:57 - 1.3189 @@ -1,5 +1,7 @@ 5.2b1 -> 5.3a1 +- jbj: rpmdb: inline rpmdbOpenAll for inplace --rebuilddb. sadly + DB->associate(..., DB_CREATE) is not free threaded w -fopenmp. oh well. - jbj: rpmts: take checkpoints beroe and after --rebuilddb. - jbj: rpmdb: do in-place rebuilddb, opt-in for now. - jbj: rpmdb: lazily create non-existent secondary indices. @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/rpmdb.c $ cvs diff -u -r1.351 -r1.352 rpmdb.c --- rpm/rpmdb/rpmdb.c 8 Dec 2009 21:20:35 - 1.351 +++ rpm/rpmdb/rpmdb.c 9 Dec 2009 03:59:57 - 1.352 @@ -778,20 +778,18 @@ int rpmdbOpenAll(rpmdb db) { -size_t dbix; int rc = 0; if (db == NULL) return -2; -if (db->db_tags != NULL && db->_dbi != NULL) + if (db->db_tags != NULL && db->_dbi != NULL) { +size_t dbix; for (dbix = 0; dbix < db->db_ndbi; dbix++) { - tagStore_t dbiTag = db->db_tags + dbix; - int tag = dbiTag->tag; - if (tag < 0) + if ((int)db->db_tags[dbix].tag < 0) continue; if (db->_dbi[dbix] != NULL) continue; - switch (tag) { + switch (db->db_tags[dbix].tag) { case RPMDBI_AVAILABLE: case RPMDBI_ADDED: case RPMDBI_REMOVED: @@ -805,8 +803,9 @@ default: /*...@switchbreak@*/ break; } - (void) dbiOpen(db, tag, db->db_flags); + (void) dbiOpen(db, db->db_tags[dbix].tag, db->db_flags); } + } return rc; } @@ -3636,13 +3635,28 @@ xx = rpmdbRemoveDatabase(myprefix, dbpath, _dbapi, dbiTags, dbiNTags); /* XXX Seqno update needs O_RDWR. */ -if (rpmdbOpenDatabase(myprefix, dbpath, _dbapi, &olddb, O_RDWR, 0644, 0)) { - rc = 1; +if (rpmdbOpenDatabase(myprefix, dbpath, _dbapi, &olddb, O_RDWR, 0644, 0)) goto exit; -} -_dbapi = olddb->db_api; -xx = rpmdbOpenAll(olddb); + { size_t dbix; +for (dbix = 0; dbix < dbiNTags; dbix++) { + switch (dbiTags[dbix].tag) { + case RPMDBI_AVAILABLE: + case RPMDBI_ADDED: + case RPMDBI_REMOVED: + case RPMDBI_DEPENDS: + case RPMDBI_BTREE: + case RPMDBI_HASH: + case RPMDBI_QUEUE: + case RPMDBI_RECNO: + continue; + /*...@notreached@*/ /*...@switchbreak@*/ break; + default: + /*...@switchbreak@*/ break; + } + (void) dbiOpen(olddb, dbiTags[dbix].tag, olddb->db_flags); +} + } xx = rpmdbClose(olddb); @@ . __ RPM Package Managerhttp://rpm5.org CVS Sources Repositoryrpm-cvs@rpm5.org