host: add "readonly" state to override device "alive" state

Marking an entire host as "readonly" before a host maintenance
window can useful and easier than marking each device "readonly"
and reduces the likelyhood a device will be incorrectly marked
as "alive" again when it is intended to stay down.
enable TCP keepalives for iostat watcher sockets

This allows the monitor to eventually notice a client socket is
totally gone if a machine death was not detected earlier.  We enable
TCP keepalive everywhere else, too.
add conn_pool_size configuration option

This defines the size of the HTTP connection pool.  This affects
all workers at the moment, but is likely most interesting to the
Monitor as it affects the number of devices the monitor may
concurrently update.

This defaults to 20 (the long-existing, hard-coded value).

In the future, there may be a(n easy) way to specify this on a
a per-worker basis, but for now it affects all workers.
connection/poolable: do not write before event_write

Blindly attempting to write to a socket before a TCP connection can be
established returns EAGAIN on Linux, but not on FreeBSD 8/9.  This
causes Danga::Socket to error out, as it won't attempt to buffer on
anything but EAGAIN on write() attempts.

Now, we buffer writes explicitly after the initial socket creation and
connect(), and only call Danga::Socket::write when we've established
writability.  This works on Linux, too, and avoids an unnecessary
syscall in most cases.

Reported-by: Alex Yakovenko <aleksey.yakovenko@gmail.com>
connection/poolable: disable watch_write before retrying write

Otherwise we'll end up constantly waking up when there's nothing
to write.
connection/poolable: defer expiry of timed out connections

The timeout check may run on a socket before epoll_wait/kevent has
a chance to run, giving the application no chance for any readiness
callbacks to fire.

This prevents timeouts in the monitor if the database is slow during
synchronous UPDATE device calls (or there are just thousands of active
connections).
monitor: defer DB updates until all HTTP requests are done

HTTP requests time out because we had to wait synchronously for DBI,
this is very noticeable on a high-latency connection.  So avoid
running synchronous code while asynchronous code (which is subject
to timeouts) is running..
monitor: ping parent during deferred DB updates

With enough devices and high enough network latency to the DB,
we bump into the watchdog timeout of 30s easily.
monitor: batch MySQL device table updates

Issuing many UPDATE statements slow down monitoring on high latency
connections between the monitor and DB.  Under MySQL, it is possible
to do multiple UPDATEs in a single statement using CASE/WHEN
syntax.

We limit ourselves to 10000 devices per update for now, this should
keep us comfortably under most the max_allowed_packet size of most
MySQL deployments (where the default is 1M).

A compatibility function is provided for SQLite and Postgres users.
SQLite users are not expected to run this over high-latency NFS, and
interested Postgres users should submit their own implementation.
remove users of unreachable_fids table

mark_fidid_unreachable has not been used since MogileFS 2.35
commit 53528c71ca95a04cf031c39848c38b47389d039f
("Wipe out old replication code.", r1432)
remove update_host_property

No longer used since commit ebf8a5a8dc9b4452671f7816b99583bf7934e9b1
("Mass nuke unused code and fix most tests") in MogileFS 2.50
Work with DBD::SQLite's latest lock errors

"is not unique" => "UNIQUE constraint failed". String matching is lovely.