blkcg: add hash table for each throttle_group

Now blkcg has only 2 bio list to queue read/write bios, if a task sends out many bios
once a time, they will occupy the head position of queue and other tasks will have
little chance to proceed, so it has fairness problem for tasks.

This patch adds a 32 slot hash table for throttle group, and the bio is queued based
on hash value computed by its task pid. Meanwhile, while dispatching throttled bios,
we will selected bio from hash table in round-robin way.

Note, the function can be disabled by a later patch, this is done by modifying hash
function to return 0, then all bios will be queued only on slot 0, which is the same
behavior as before.

Signed-off-by: Sha Zhengju <handai.szj@alibaba-inc.com>
blkcg: special treatement for sequential bios

If blkcg finds the recent bios are sequential in access offset, it will only
charge once in order to try to make them merged by underlying block layer.
Now the number of sequential bio is 2, but can be tunable in next patch.

Signed-off-by: Sha Zhengju <handai.szj@alibaba-inc.com>
blkcg: add new interface to tune the number of sequential bios

Add a new cgroup file interface 'throttle.seq_bios_device' to tune the behavior
of blkcg. This can improve performence for applications which have sequential
access pattern. But the default value is 1, which means don't enable the features
(including hash table and consideration for seq-bios).

Signed-off-by: Sha Zhengju <handai.szj@alibaba-inc.com>
Merge pull request #70 from shazj99/iot_fairness

Io throttle fairness
dm io: fix the sync/async helper

Without this patch they are actually the same thing since the changes
against the rw field does not get passed to the under level routines.

It seems like a mistake during rebase to RHEL 2.6.32-220.

Signed-off-by: Zhu Yanhai <gaoyang.zyh@taobao.com>
pidns: Use task_active_pid_ns where appropriate

The expressions tsk->nsproxy->pid_ns and task_active_pid_ns
aka ns_of_pid(task_pid(tsk)) should have the same number of
cache line misses with the practical difference that
ns_of_pid(task_pid(tsk)) is released later in a processes life.

Furthermore by using task_active_pid_ns it becomes trivial
to write an unshare implementation for the the pid namespace.

So I have used task_active_pid_ns everywhere I can.

In fork since the pid has not yet been attached to the
process I use ns_of_pid, to achieve the same effect.

[Note from Zheng Liu]
We need to backport this patch for fixing a panic in our cgroup system.
It will cause a panic when we stop a instance.

Reference: 17cf22c33e1f1b5e435469c84e43872579497653
Patch-mainline: v3.7-rc3-9-g17cf22c
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
tcp: [BUG] call dst_release() in tcp_v4_conn_request()

Before merging TFO patch set, in tcp_v4_conn_request() we always call
__tcp_v4_send_synack() to send a packet with syn and ack flag.  In
__tcp_v4_send_synack() function it always calls dst_release() to
decrease the ref count for a dst_entry.  But after applying TFO patch
set this function is never called.  So we will meet a bug like below:

unregister_netdevice: waiting for lo to become free.  Usage count = 3

Patch-mainline: in-house
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
ipv4: Don't add TCP-code in inet_sock_destruct

[Note from Zheng Liu]
This patch fixes a bug that meets in our product system in alipay.

Reference: bb68b64724a4fd6b93d83b39aeffa4aadb2562fc
Patch-mainline: v3.6-rc5-987-gbb68b64
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Acked-by: H.K. Jerry Chu <hkchu@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Merge pull request #73 from jesuszhu/dm-fix

dm io: fix the sync/async helper
Merge pull request #76 from gnehzuil/tfo-bug-fix

Tfo bug fix
Merge pull request #74 from gnehzuil/ns-pid

pidns: Use task_active_pid_ns where appropriate