diff options
| author | perseant <perseant@NetBSD.org> | 2012-01-02 21:35:17 +0000 |
|---|---|---|
| committer | perseant <perseant@NetBSD.org> | 2012-01-02 21:35:17 +0000 |
| commit | 49764d70cc7c12670bb69742df86eba6dda7738f (patch) | |
| tree | f47ee0a4b1a0aba7a71281e40edebf319bbf5fd3 /libexec | |
| parent | 8a5635cd2f7118285a2878ab19fdfbff15307b7f (diff) | |
In lfs_cleanerd, check errno earlier, to avoid premature exit when the
real errno was EAGAIN.
When coalescing, check against NULL to avoid seg fault.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/lfs_cleanerd/coalesce.c | 4 | ||||
| -rw-r--r-- | libexec/lfs_cleanerd/lfs_cleanerd.c | 23 |
2 files changed, 19 insertions, 8 deletions
diff --git a/libexec/lfs_cleanerd/coalesce.c b/libexec/lfs_cleanerd/coalesce.c index 96a500e2391..1929a86bd7d 100644 --- a/libexec/lfs_cleanerd/coalesce.c +++ b/libexec/lfs_cleanerd/coalesce.c @@ -1,4 +1,4 @@ -/* $NetBSD: coalesce.c,v 1.18 2009/08/06 00:51:55 pooka Exp $ */ +/* $NetBSD: coalesce.c,v 1.19 2012/01/02 21:35:17 perseant Exp $ */ /*- * Copyright (c) 2002, 2005 The NetBSD Foundation, Inc. @@ -124,6 +124,8 @@ get_dinode(struct clfs *fs, ino_t ino) dip < (struct ufs1_dinode *)(bp->b_data + fs->lfs_ibsize); dip++) if (dip->di_inumber == ino) { r = (struct ufs1_dinode *)malloc(sizeof(*r)); + if (r == NULL) + break; memcpy(r, dip, sizeof(*r)); brelse(bp, 0); return r; diff --git a/libexec/lfs_cleanerd/lfs_cleanerd.c b/libexec/lfs_cleanerd/lfs_cleanerd.c index 40696033448..5dc233c9af3 100644 --- a/libexec/lfs_cleanerd/lfs_cleanerd.c +++ b/libexec/lfs_cleanerd/lfs_cleanerd.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_cleanerd.c,v 1.27 2010/12/23 18:08:41 mlelstv Exp $ */ +/* $NetBSD: lfs_cleanerd.c,v 1.28 2012/01/02 21:35:18 perseant Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -835,7 +835,7 @@ toss_old_blocks(struct clfs *fs, BLOCK_INFO **bipp, int *bic, int *sizep) if (sizep) *sizep += bip[i].bi_size; } - *bic = i; /* XXX realloc bip? */ + *bic = i; /* XXX should we shrink bip? */ *bipp = bip; return; @@ -928,7 +928,7 @@ check_or_add(ino_t ino, int32_t lbn, BLOCK_INFO *bip, int bic, BLOCK_INFO **ebip ++ebic; t = realloc(ebip, ebic * sizeof(BLOCK_INFO)); if (t == NULL) - return 1; /* Note *ebipc is not updated */ + return 1; /* Note *ebicp is unchanged */ ebip = t; ebip[ebic - 1].bi_inode = ino; @@ -1149,9 +1149,12 @@ clean_fs(struct clfs *fs, CLEANERINFO *cip) #endif /* TEST_PATTERN */ dlog("sending blocks %d-%d", mc, mc + lim.blkcnt - 1); if ((r = kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim))<0) { - syslog(LOG_WARNING, "%s: markv returned %d (%m)", - fs->lfs_fsmnt, r); - if (errno != EAGAIN && errno != ESHUTDOWN) { + int oerrno = errno; + syslog(LOG_WARNING, "%s: markv returned %d (errno %d, %m)", + fs->lfs_fsmnt, r, errno); + if (oerrno != EAGAIN && oerrno != ESHUTDOWN) { + syslog(LOG_DEBUG, "%s: errno %d, returning", + fs->lfs_fsmnt, oerrno); fd_release_all(fs->clfs_devvp); return r; } @@ -1558,6 +1561,8 @@ lfs_cleaner_main(int argc, char **argv) cleaned_one = 0; for (i = 0; i < nfss; i++) { if ((error = needs_cleaning(fsp[i], &ci)) < 0) { + syslog(LOG_DEBUG, "%s: needs_cleaning returned %d", + getprogname(), error); handle_error(fsp, i); continue; } @@ -1565,7 +1570,9 @@ lfs_cleaner_main(int argc, char **argv) continue; reload_ifile(fsp[i]); - if (clean_fs(fsp[i], &ci) < 0) { + if ((error = clean_fs(fsp[i], &ci)) < 0) { + syslog(LOG_DEBUG, "%s: clean_fs returned %d", + getprogname(), error); handle_error(fsp, i); continue; } @@ -1584,6 +1591,8 @@ lfs_cleaner_main(int argc, char **argv) if (error) { if (errno == ESHUTDOWN) { for (i = 0; i < nfss; i++) { + syslog(LOG_INFO, "%s: shutdown", + getprogname()); handle_error(fsp, i); assert(nfss == 0); } |
