From: David van Moolenbroek Date: Sun, 15 Sep 2013 11:09:00 +0000 (+0200) Subject: libbdev: be less noisy about clean driver restarts X-Git-Tag: v3.3.0~569 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=32c9b6653b4cb5182855909537b98fd2e03275e6;p=minix.git libbdev: be less noisy about clean driver restarts Change-Id: Ie02a459c9b544d361ab00bac431ef99de53b0c5f --- diff --git a/lib/libbdev/ipc.c b/lib/libbdev/ipc.c index ce6403e37..2c4ce2701 100644 --- a/lib/libbdev/ipc.c +++ b/lib/libbdev/ipc.c @@ -36,9 +36,17 @@ static int bdev_recover(dev_t dev, int update_endpt) */ bdev_call_t *call, *next; endpoint_t endpt; - int r, nr_tries; + int r, active, nr_tries; - printf("bdev: recovering from a driver restart on major %d\n", major(dev)); + /* Only print output if there is something to recover. Some drivers may be + * shut down and later restarted legitimately, and if they were not in use + * while that happened, there is no need to flood the console with messages. + */ + active = bdev_minor_is_open(dev) || bdev_call_iter_maj(dev, NULL, &next); + + if (active) + printf("bdev: recovering from a driver restart on major %d\n", + major(dev)); for (nr_tries = 0; nr_tries < RECOVER_TRIES; nr_tries++) { /* First update the endpoint, if necessary. */ @@ -79,7 +87,8 @@ static int bdev_recover(dev_t dev, int update_endpt) /* Recovery seems successful. We can now reissue the current * synchronous request (if any), and continue normal operation. */ - printf("bdev: recovery successful, new driver is at %d\n", endpt); + if (active) + printf("bdev: recovery successful, new driver at %d\n", endpt); return TRUE; } diff --git a/lib/libbdev/minor.c b/lib/libbdev/minor.c index 519da33eb..205f16c89 100644 --- a/lib/libbdev/minor.c +++ b/lib/libbdev/minor.c @@ -118,3 +118,19 @@ void bdev_minor_del(dev_t dev) } } } + +int bdev_minor_is_open(dev_t dev) +{ +/* Return whether any minor is open for the major of the given device. + */ + int i, major; + + major = major(dev); + + for (i = 0; i < NR_OPEN_DEVS; i++) { + if (major(open_dev[i].dev) == major) + return TRUE; + } + + return FALSE; +} diff --git a/lib/libbdev/proto.h b/lib/libbdev/proto.h index 24f11d089..51963a8e7 100644 --- a/lib/libbdev/proto.h +++ b/lib/libbdev/proto.h @@ -29,5 +29,6 @@ extern int bdev_sendrec(dev_t dev, const message *m_orig); extern int bdev_minor_reopen(dev_t dev); extern void bdev_minor_add(dev_t dev, int access); extern void bdev_minor_del(dev_t dev); +extern int bdev_minor_is_open(dev_t dev); #endif /* _BDEV_PROTO_H */