diff options
author | mpp <mpp@FreeBSD.org> | 1996-02-27 01:53:17 +0000 |
---|---|---|
committer | mpp <mpp@FreeBSD.org> | 1996-02-27 01:53:17 +0000 |
commit | 584fea2f92d8bdbedf4d4b45cff7acd9602ae1ad (patch) | |
tree | 007208e6376137f842e6659b1e7e405c4ca39dd5 /sbin/quotacheck | |
parent | 775be215f5410c57b3c31b91244e51a0429a4ee8 (diff) | |
download | FreeBSD-src-584fea2f92d8bdbedf4d4b45cff7acd9602ae1ad.zip FreeBSD-src-584fea2f92d8bdbedf4d4b45cff7acd9602ae1ad.tar.gz |
Fix quotacheck to not do a bunch of unneeded fseeks if the
quota file information is accurate. This makes it about twice as
fast when the uid name space is very large.
Diffstat (limited to 'sbin/quotacheck')
-rw-r--r-- | sbin/quotacheck/quotacheck.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c index 913e381..823ed46 100644 --- a/sbin/quotacheck/quotacheck.c +++ b/sbin/quotacheck/quotacheck.c @@ -311,6 +311,7 @@ update(fsname, quotafile, type) register struct fileusage *fup; register FILE *qfi, *qfo; register u_long id, lastid; + register off_t offset; struct dqblk dqbuf; static int warned = 0; static struct dqblk zerodqbuf; @@ -343,7 +344,8 @@ update(fsname, quotafile, type) (void)printf("*** Warning: %s\n", "Quotas are not compiled into this kernel"); } - for (lastid = highid[type], id = 0; id <= lastid; id++) { + for (lastid = highid[type], id = 0, offset = 0; id <= lastid; + id++, offset += sizeof(struct dqblk)) { if (fread((char *)&dqbuf, sizeof(struct dqblk), 1, qfi) == 0) dqbuf = zerodqbuf; if ((fup = lookup(id, type)) == 0) @@ -352,7 +354,6 @@ update(fsname, quotafile, type) dqbuf.dqb_curblocks == fup->fu_curblocks) { fup->fu_curinodes = 0; fup->fu_curblocks = 0; - fseek(qfo, (long)sizeof(struct dqblk), 1); continue; } if (vflag) { @@ -381,6 +382,12 @@ update(fsname, quotafile, type) dqbuf.dqb_itime = 0; dqbuf.dqb_curinodes = fup->fu_curinodes; dqbuf.dqb_curblocks = fup->fu_curblocks; + if (fseek(qfo, offset, SEEK_SET) < 0) { + (void) fprintf(stderr, + "quotacheck: %s: seek failed: %s\n", + quotafile, strerror(errno)); + return(1); + } fwrite((char *)&dqbuf, sizeof(struct dqblk), 1, qfo); (void) quotactl(fsname, QCMD(Q_SETUSE, type), id, (caddr_t)&dqbuf); |