Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/lfs_cleanerd In lfs_cleanerd, check errno earlier, t...
details: https://anonhg.NetBSD.org/src/rev/e347779c7e1b
branches: trunk
changeset: 772411:e347779c7e1b
user: perseant <perseant%NetBSD.org@localhost>
date: Mon Jan 02 21:35:17 2012 +0000
description:
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:
libexec/lfs_cleanerd/coalesce.c | 4 +++-
libexec/lfs_cleanerd/lfs_cleanerd.c | 23 ++++++++++++++++-------
2 files changed, 19 insertions(+), 8 deletions(-)
diffs (90 lines):
diff -r 16f07020fc5c -r e347779c7e1b libexec/lfs_cleanerd/coalesce.c
--- a/libexec/lfs_cleanerd/coalesce.c Mon Jan 02 21:29:55 2012 +0000
+++ b/libexec/lfs_cleanerd/coalesce.c Mon Jan 02 21:35:17 2012 +0000
@@ -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 @@
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 -r 16f07020fc5c -r e347779c7e1b libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c Mon Jan 02 21:29:55 2012 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c Mon Jan 02 21:35:17 2012 +0000
@@ -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 @@
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 @@
++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 @@
#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 @@
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 @@
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 @@
if (error) {
if (errno == ESHUTDOWN) {
for (i = 0; i < nfss; i++) {
+ syslog(LOG_INFO, "%s: shutdown",
+ getprogname());
handle_error(fsp, i);
assert(nfss == 0);
}
Home |
Main Index |
Thread Index |
Old Index