ceph: fix uid/gid on resent mds requests
[firefly-linux-kernel-4.4.55.git] / fs / ceph / mds_client.h
index 952410c60d093e7ba5c39ed630c6283664d90c5a..9341fd4f14320060a395c37f81b4a67b01c020d7 100644 (file)
@@ -8,9 +8,9 @@
 #include <linux/rbtree.h>
 #include <linux/spinlock.h>
 
-#include "types.h"
-#include "messenger.h"
-#include "mdsmap.h"
+#include <linux/ceph/types.h>
+#include <linux/ceph/messenger.h>
+#include <linux/ceph/mdsmap.h>
 
 /*
  * Some lock dependencies:
@@ -26,7 +26,7 @@
  *
  */
 
-struct ceph_client;
+struct ceph_fs_client;
 struct ceph_cap;
 
 /*
@@ -151,6 +151,7 @@ typedef void (*ceph_mds_request_callback_t) (struct ceph_mds_client *mdsc,
 struct ceph_mds_request {
        u64 r_tid;                   /* transaction id */
        struct rb_node r_node;
+       struct ceph_mds_client *r_mdsc;
 
        int r_op;                    /* mds op code */
        int r_mds;
@@ -169,6 +170,8 @@ struct ceph_mds_request {
 
        union ceph_mds_request_args r_args;
        int r_fmode;        /* file mode, if expecting cap */
+       uid_t r_uid;
+       gid_t r_gid;
 
        /* for choosing which mds to send this request to */
        int r_direct_mode;
@@ -207,8 +210,8 @@ struct ceph_mds_request {
 
        int               r_attempts;   /* resend attempts */
        int               r_num_fwd;    /* number of forward attempts */
-       int               r_num_stale;
        int               r_resend_mds; /* mds to resend to next, if any*/
+       u32               r_sent_on_mseq; /* cap mseq request was sent at*/
 
        struct kref       r_kref;
        struct list_head  r_wait;
@@ -229,11 +232,12 @@ struct ceph_mds_request {
  * mds client state
  */
 struct ceph_mds_client {
-       struct ceph_client      *client;
+       struct ceph_fs_client  *fsc;
        struct mutex            mutex;         /* all nested structures */
 
        struct ceph_mdsmap      *mdsmap;
-       struct completion       safe_umount_waiters, session_close_waiters;
+       struct completion       safe_umount_waiters;
+       wait_queue_head_t       session_close_wq;
        struct list_head        waiting_for_map;
 
        struct ceph_mds_session **sessions;    /* NULL for mds if no session */
@@ -267,10 +271,26 @@ struct ceph_mds_client {
        spinlock_t        cap_dirty_lock;   /* protects above items */
        wait_queue_head_t cap_flushing_wq;
 
-#ifdef CONFIG_DEBUG_FS
-       struct dentry     *debugfs_file;
-#endif
-
+       /*
+        * Cap reservations
+        *
+        * Maintain a global pool of preallocated struct ceph_caps, referenced
+        * by struct ceph_caps_reservations.  This ensures that we preallocate
+        * memory needed to successfully process an MDS response.  (If an MDS
+        * sends us cap information and we fail to process it, we will have
+        * problems due to the client and MDS being out of sync.)
+        *
+        * Reservations are 'owned' by a ceph_cap_reservation context.
+        */
+       spinlock_t      caps_list_lock;
+       struct          list_head caps_list; /* unused (reserved or
+                                               unreserved) */
+       int             caps_total_count;    /* total caps allocated */
+       int             caps_use_count;      /* in use */
+       int             caps_reserve_count;  /* unused, reserved */
+       int             caps_avail_count;    /* unused, unreserved */
+       int             caps_min_count;      /* keep at least this many
+                                               (unreserved) */
        spinlock_t        dentry_lru_lock;
        struct list_head  dentry_lru;
        int               num_dentry;
@@ -293,10 +313,9 @@ extern void ceph_put_mds_session(struct ceph_mds_session *s);
 extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc,
                             struct ceph_msg *msg, int mds);
 
-extern int ceph_mdsc_init(struct ceph_mds_client *mdsc,
-                          struct ceph_client *client);
+extern int ceph_mdsc_init(struct ceph_fs_client *fsc);
 extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc);
-extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc);
+extern void ceph_mdsc_destroy(struct ceph_fs_client *fsc);
 
 extern void ceph_mdsc_sync(struct ceph_mds_client *mdsc);
 
@@ -324,8 +343,7 @@ static inline void ceph_mdsc_put_request(struct ceph_mds_request *req)
 }
 
 extern int ceph_add_cap_releases(struct ceph_mds_client *mdsc,
-                                struct ceph_mds_session *session,
-                                int extra);
+                                struct ceph_mds_session *session);
 extern void ceph_send_cap_releases(struct ceph_mds_client *mdsc,
                                   struct ceph_mds_session *session);
 
@@ -343,4 +361,7 @@ extern void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
 extern void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc,
                                 struct ceph_msg *msg);
 
+extern void ceph_mdsc_open_export_target_sessions(struct ceph_mds_client *mdsc,
+                                         struct ceph_mds_session *session);
+
 #endif