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 */