Refactor conn buffer members into struct

Move the various read & write buffer members (buf, curr, size, bytes) into their
own struct. This allows a pointer to whole buffer to be passed around,
simplifying some of the buffer management changes coming for MB-11067.

Change-Id: Iaa8daa83a5dd84e0ffd995b46a69f4c4dc7b5cf6
Reviewed-on: http://review.couchbase.org/38554
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Show current open file & connection limits when we hit then.

Make it easier to diagnose when we hit these limits - include the
current and maximum values in the log messages (if possible).

Change-Id: I75451d016cd38019831efe6429d31172c32d17d6
Reviewed-on: http://review.couchbase.org/38557
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11067: Return read/write buffers back to thread when connection goes idle

Change the buffer management for connections / threads - instead of
allocating a read & write buffer to every connection object, have
per-worker buffers which are "loaned" to the connection which is
currenlty running. When that connection goes idle, return the buffers
back to the thread. In the (uncommon) case where a buffer was only
partially read, leave it loaned to the connection.

This reduces the buffer footprint from O(established_connections) to
O(worker_threads).

Test results:

Simulate a high number of connections / low throughput workload:
create 8,000 connections, perform 3 set / 7 get operations (4k size),
then leave the connections idle. Measure the VSZ and RSS of memcached
after 4 iterations of the test workload.

Measured with tcmalloc disabled (using OS X stock malloc), to avoid
any effects of tcmalloc holding onto memory after it has been freed.

Baseline (ebcbd79b30db0fe6dbe4ff1b4a40632fae061f2f):

    UCOMM                 VSZ    RSS
    memcached         2740964 211840

With this patch:

    UCOMM                 VSZ    RSS
    memcached         2641640  80856

Change-Id: I4a34e56561811e4a264c7616b2b84e342cdc9ee5
Reviewed-on: http://review.couchbase.org/38555
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
MB-11067: Add stats for # buffers loaned / allocated.

To allow us to measure the effect of the buffer change in MB-11067,
add two pairs of new stats:

 * {r,w}bufs_allocated: Number of times a {read,write} buffer was
                        fulfilled by malloc()ing a new buffer.

 * {r,w}bufs_loaned: Number of times a read buffer was fulfilled by
                     loaning out the worker threads' buffer.

Change-Id: If373c40491d46627468410e22d2fb0d8ae2cd53b
Reviewed-on: http://review.couchbase.org/38556
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Remove "unused" stat command "connections"

The information don't make much sense for the average user

Change-Id: I9176640af30a2ae2d1931d0790ffea0e1a5b3c6c
Reviewed-on: http://review.couchbase.org/38737
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
MB-10287: Add backwards compatibility for some options

Change-Id: Ib93b5b16fcb491f1a95226e91a236f08b5ce627f
Reviewed-on: http://review.couchbase.org/38763
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Initialize control cas to 0xdeadbeef

If its default value is 0 there is no way to change it without
using 0 as the cas value (which means override) introducing
the possibility for race conditions. With a non-null value it
may be changed by someone who requested its value and protects
against race conditions.

Allow for using cas value 0 to override cas for setting the cas
(to make it behave consistently with the rest of the cas usage)

Change-Id: I637104df4f65527d8ad10636c01a0e7f53930c53
Reviewed-on: http://review.couchbase.org/38784
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Merge remote-tracking branch 'membase/3.0'

* membase/3.0:
  Initialize control cas to 0xdeadbeef
  MB-10287: Add backwards compatibility for some options

Change-Id: I55ddf137204973eedb10974d6e12ebb0bcec2239
Merge remote-tracking branch 'membase/3.0.1'

* membase/3.0.1:
  Initialize control cas to 0xdeadbeef
  MB-10287: Add backwards compatibility for some options
  Remove "unused" stat command "connections"
  MB-11067: Add stats for # buffers loaned / allocated.
  MB-11067: Return read/write buffers back to thread when connection goes idle
  Show current open file & connection limits when we hit then.
  Refactor conn buffer members into struct

Change-Id: Id88dd8caca3db9114f289529a56f7b3729b0b8e8