orangefs: delay freeing slot until cancel completes

Make cancels reuse the aborted read/write op, to make sure they do not
fail on lack of memory.

Don't issue a cancel unless the daemon has seen our read/write, has not
replied and isn't being shut down.

If cancel *is* issued, don't wait for it to complete; stash the slot
in there and just have it freed when cancel is finally replied to or
purged (and delay dropping the reference until then, obviously).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c
index 37278f5..6a7df12 100644
--- a/fs/orangefs/devorangefs-req.c
+++ b/fs/orangefs/devorangefs-req.c
@@ -438,6 +438,8 @@
 		}
 	}
 out:
+	if (unlikely(op_is_cancel(op)))
+		put_cancel(op);
 	op_release(op);
 	return ret;
 
@@ -546,6 +548,11 @@
 	return in_service;
 }
 
+bool __is_daemon_in_service(void)
+{
+	return open_access_count == 1;
+}
+
 static inline long check_ioctl_command(unsigned int command)
 {
 	/* Check for valid ioctl codes */