libceph: use memalloc flags for net IO

This patch has ceph's lib code use the memalloc flags.

If the VM layer needs to write data out to free up memory to handle new
allocation requests, the block layer must be able to make forward progress.
To handle that requirement we use structs like mempools to reserve memory for
objects like bios and requests.

The problem is when we send/receive block layer requests over the network
layer, net skb allocations can fail and the system can lock up.
To solve this, the memalloc related flags were added. NBD, iSCSI
and NFS uses these flags to tell the network/vm layer that it should
use memory reserves to fullfill allcation requests for structs like
skbs.

I am running ceph in a bunch of VMs in my laptop, so this patch was
not tested very harshly.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Ilya Dryomov <idryomov@redhat.com>
rbd: Fix error recovery in rbd_obj_read_sync()

When we fail to allocate page vector in rbd_obj_read_sync() we just
basically ignore the problem and continue which will result in an oops
later. Fix the problem by returning proper error.

CC: Yehuda Sadeh <yehuda@inktank.com>
CC: Sage Weil <sage@inktank.com>
CC: ceph-devel@vger.kernel.org
CC: stable@vger.kernel.org
Coverity-id: 1226882
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
ceph: introduce a new inode flag indicating if cached dentries are ordered

After creating/deleting/renaming file, offsets of sibling dentries may
change. So we can not use cached dentries to satisfy readdir. But we can
still use the cached dentries to conclude -ENOENT for lookup.

This patch introduces a new inode flag indicating if child dentries are
ordered. The flag is set at the same time marking a directory complete.
After creating/deleting/renaming file, we clear the flag on directory
inode. This prevents ceph_readdir() from using cached dentries to satisfy
readdir syscall.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
libceph: do not crash on huge auth tickets

Huge (currently greater than 32k) auth tickets will have their buffers
vmalloc'ed, which leads to a crash in crypto code because we set up
crypto scatterlists as if all buffers were kmalloc'ed.  Fix it.

Cc: stable@vger.kernel.org
Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
client: fix flush tid comparision

TID of cap flush ack is 64 bits, but ceph_inode_info::flushing_cap_tid
is only 16 bits. 16 bits should be plenty to let the cap flush updates
pipeline appropriately, but we need to cast in the proper direction when
comparing these differently-sized versions. So downcast the 64-bits one
to 16 bits.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
Revert "btrfs: Use right extent length when inserting overlap extent map."

This reverts commit 51f395ad4058883e4273b02fdebe98072dbdc0d2.
ceph: add ceph_osdc_cancel_writes

To allow us to abort writes in ENOSPC conditions.

Signed-off-by: John Spray <john.spray@redhat.com>
ceph: handle full condition by cancelling ops

Signed-off-by: John Spray <john.spray@redhat.com>
HACK: don't populate statfs from mon

 - to get around the ENOSPC check
 that VFS does on our behalf before
 we even see the osd map.
ceph: implement ceph_osdc_wait_for_map

For use in the filesystem client when receiving
capabilities whose use is contigent on having
a particular OSD map.

Signed-off-by: John Spray <john.spray@redhat.com>
ceph: update ceph_msg_header structure

2 bytes of what was reserved space is now used by
userspace for the compat_version field.

Signed-off-by: John Spray <john.spray@redhat.com>
ceph: update CAPRELEASE message format

Version 2 includes the new osd epoch barrier
field.

Signed-off-by: John Spray <john.spray@redhat.com>
ceph: handle new osdmap barrier field in CLIENTCAPS

Signed-off-by: John Spray <john.spray@redhat.com>
ceph: include osd epoch barrier in debugfs

Signed-off-by: John Spray <john.spray@redhat.com>
ceph: delay cap messages on epoch_barrier

Signed-off-by: John Spray <john.spray@redhat.com>