LU-2263 ptlrpc: decrease ptlrpcd threads number

By default Lustre creates ptlrpcd for each hyper-thread which is
too many for fat-core machine, this patch changed the default
value to CPU core number, and set the upper limit to 32.

Another change in this patch is, ptlrpc_abort_inflight() may release
imp_lock and reschedule when it's necessary, to avoid one thread
holding imp_lock for too long.

This patch didn't apply CPU partition APIs to ptlrpcd, that will
need more efforts.

Signed-off-by: Liang Zhen <liang@whamcloud.com>
Change-Id: I9c395d086258a66f8853dc432b11d49d0db03659
Revision-Id: 2
LU-2139 osc: Move cl_client_lru to cl_client_cache

The cl_client_lru structure was renamed to cl_client_cache. This is
intended as a purely cosmetic change motivated by the future inclusion
of other, non LRU, information in that structure. For example, the plan
is to include "unstable" page information in this structure; which is
unrelated to the LRU list of clean pages, but still part of a client's
cache.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Change-Id: I286a1bbb2fb0d7dc52f007407bb823f960ae7c62
Revision-Id: 1
LU-2139 osc: Track number of "unstable" pages on client

This change adds per file system counters to track the number of
"unstable" pages held by a client. An "unstable" page is defined as
page which is sent to the server as part of a bulk request, but is
uncommitted to stable storage.

In addition to simply tracking the unstable pages, a limit can be
imposed to prevent a client from holding "too many" unstable pages; and
any unmount operation will block until these unstable pages are
committed to stable storage.

The current number of, and maximum allowed, pages are stored in the
ll_sb_info structure. When the current number of unstable pages reaches
the maximum, calls to osc_page_init will sleep until pages are committed
on the server, and the last_committed value reaches the client.

In addition to tracking the number of pages in the ll_sb_info structure,
the NR_UNSTABLE_NFS memory zone is also incremented and decremented
for easy monitoring using the "NFS_Unstable:" field in /proc/meminfo.
This field is also used internally by the kernel to limit the total
amount of unstable pages on the system.

The motivation for this change is twofold. First, the client must not
allow itself to disconnect from an OST while still holding unstable
pages. Otherwise, these unstable pages can get lost due to an OST
failure, and replay is not possible due to the disconnect via unmount.

Secondly, The client needs a mechanism to prevent it from allocating too
much of its available RAM to unreclaimable pages pinned by the ptlrpc
layer. If this case occurs, out of memory events can trigger as a side
effect, which we need to avoid. By default, this per filesystem limit is
disabled, and the kernel's global limit of unstable pages is used.

The number of unstable pages tracked in the ll_sb_info structure are
exported by the max_unstable_mb proc file, contained under each
filesystem's llite namespace. This file can also be written to, allowing
the upper bound of Lustre's unstable pages on the system to be modified
dynamically.

For example:

	# Set unstable page limit to 512 MB
	lctl set_param llite.*.max_unstable_mb=512

	# Disable the unstable page limit
	lctl set_param llite.*.max_unstable_mb=disabled

	# Read unstable page limit in MB
	lctl get_param llite.*.max_unstable_mb

	# Read unstable limit, number of unstable pages, and number of waiters
	lctl get_param llite.*.unstable_stats

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Change-Id: Ic43d34bfa39da9ac4fe159000c7db5908467fd7b
Revision-Id: 13
LU-2139 osc: Track number of "unstable" pages per osc

This change adds simple accounting hooks for "unstable" pages on a per
OSC basis. Now, in addition to the per filesystem tracking, each OSC
will maintain a running total of its unstable pages. These counters are
exported through the proc interface, and can be read using the lctl
command.

For example:

    # Read number of unstable pages contained by each OSC
    lctl get_param osc.*.unstable_stats

The motivation for this change is in anticipation of implementing a
"soft sync" functionality, urging servers to commit these unstable
pages to stable storage. The per OSC accounting allows a client to
limit the soft sync request to only the OSCs which have outstanding
unstable pages.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Change-Id: Ife1f90515cb60ba9f85daba5d50483562f2697d1
Revision-Id: 5
LU-2139 osc: Add OBD_BRW_SOFT_SYNC page flag

This change adds a BRW page flag, OBD_BRW_SOFT_SYNC. This flag is
intended to urge the server to commit a client's unstable pages to
stable storage. Until this happens, then unstable pages are pinned
in the client's cache.

A client will add this flag to any BRW requests while it is in a
state where it has "many" unstable pages pinned in its cache. The
server, upon receiving a page with this flag set, will begin an
async commit.

Currently, there is no optimization to proactively send the
last_committed value to the client immediately after the commit
operation succeeds. It must be piggybacked on any future IO or
pings by the client.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Change-Id: I08946a5ec6afab390655643f6d3c8320bf010aea
Revision-Id: 9