Whamcloud - gitweb
LU-6910 osp: add procfs values for OST reserved size
[fs/lustre-release.git] / lustre / osp / osp_internal.h
index d6cf452..012cff9 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -94,6 +94,13 @@ struct osp_precreate {
        int                              osp_pre_recovering;
 };
 
+struct osp_update_request_sub {
+       struct object_update_request    *ours_req;
+       size_t                          ours_req_size;
+       /* Linked to osp_update_request->our_req_list */
+       struct list_head                ours_list;
+};
+
 /**
  * Tracking the updates being executed on this dt_device.
  */
@@ -102,9 +109,10 @@ struct osp_update_request {
        /* update request result */
        int                             our_rc;
 
-       /* Holding object updates sent to the remote target */
-       struct object_update_request    *our_req;
-       size_t                          our_req_size;
+       /* List of osp_update_request_sub */
+       struct list_head                our_req_list;
+       int                             our_req_nr;
+       int                             our_update_nr;
 
        struct list_head                our_cb_items;
 
@@ -112,6 +120,7 @@ struct osp_update_request {
        struct osp_thandle              *our_th;
        /* linked to the list(ou_list) in osp_updates */
        struct list_head                our_list;
+       __u32                           our_batchid;
        __u32                           our_req_sent:1;
 };
 
@@ -189,6 +198,8 @@ struct osp_device {
        /* found records */
        struct ptlrpc_thread             opd_syn_thread;
        wait_queue_head_t                opd_syn_waitq;
+       /* list of inflight rpc */
+       struct list_head                 opd_syn_inflight_list;
        /* list of remotely committed rpc */
        struct list_head                 opd_syn_committed_there;
        /* number of changes being under sync */
@@ -237,6 +248,12 @@ struct osp_device {
        struct list_head                 opd_async_updates;
        struct rw_semaphore              opd_async_updates_rwsem;
        atomic_t                         opd_async_updates_count;
+
+       /**
+        * Limit the object allocation using ENOSPC for opd_pre_status
+        */
+       int                             opd_reserved_mb_high;
+       int                             opd_reserved_mb_low;
 };
 
 #define opd_pre_lock                   opd_pre->osp_pre_lock
@@ -583,36 +600,50 @@ update_buffer_get_update(struct object_update_request *request,
 int osp_extend_update_buffer(const struct lu_env *env,
                             struct osp_update_request *our);
 
-#define osp_update_rpc_pack(env, name, update, op, ...)                \
-({                                                             \
-       struct object_update    *object_update;                 \
-       size_t                  max_update_length;              \
-       struct object_update_request *ureq;                     \
-       int                     ret;                            \
-                                                               \
+struct osp_update_request_sub *
+osp_current_object_update_request(struct osp_update_request *our);
+
+int osp_object_update_request_create(struct osp_update_request *our,
+                                    size_t size);
+
+#define osp_update_rpc_pack(env, name, our, op, ...)                   \
+({                                                                     \
+       struct object_update    *object_update;                         \
+       size_t                  max_update_length;                      \
+       struct osp_update_request_sub *ours;                            \
+       int ret;                                                        \
+                                                                       \
        while (1) {                                                     \
-               ureq = update->our_req;                                 \
-               max_update_length = update->our_req_size -              \
-                                   object_update_request_size(ureq);   \
+               ours = osp_current_object_update_request(our);          \
+               LASSERT(ours != NULL);                                  \
+               max_update_length = ours->ours_req_size -               \
+                           object_update_request_size(ours->ours_req); \
                                                                        \
-               object_update = update_buffer_get_update(ureq,          \
-                                                ureq->ourq_count);     \
+               object_update = update_buffer_get_update(ours->ours_req,\
+                                        ours->ours_req->ourq_count);   \
                ret = out_##name##_pack(env, object_update,             \
-                                       max_update_length,              \
+                                       &max_update_length,             \
                                       __VA_ARGS__);                    \
                if (ret == -E2BIG) {                                    \
                        int rc1;                                        \
-                       /* extend the buffer and retry */               \
-                       rc1 = osp_extend_update_buffer(env, update);    \
+                       /* Create new object update request */          \
+                       rc1 = osp_object_update_request_create(our,     \
+                               max_update_length  +                    \
+                               offsetof(struct object_update_request,  \
+                                        ourq_updates[0]) + 1);         \
                        if (rc1 != 0) {                                 \
                                ret = rc1;                              \
                                break;                                  \
                        }                                               \
+                       continue;                                       \
                } else {                                                \
                        if (ret == 0) {                                 \
+                               ours->ours_req->ourq_count++;           \
+                               (our)->our_update_nr++;                 \
+                               object_update->ou_batchid =             \
+                                                    (our)->our_batchid;\
                                object_update->ou_flags |=              \
-                                                    update->our_flags; \
-                               ureq->ourq_count++;                     \
+                                                    (our)->our_flags;  \
                        }                                               \
                        break;                                          \
                }                                                       \
@@ -643,7 +674,7 @@ extern struct llog_operations osp_mds_ost_orig_logops;
 /* osp_trans.c */
 int osp_insert_async_request(const struct lu_env *env, enum update_type op,
                             struct osp_object *obj, int count, __u16 *lens,
-                            const void **bufs, void *data,
+                            const void **bufs, void *data, __u32 repsize,
                             osp_update_interpreter_t interpreter);
 
 int osp_unplug_async_request(const struct lu_env *env,
@@ -678,7 +709,7 @@ static inline void osp_thandle_put(struct osp_thandle *oth)
 }
 
 int osp_prep_update_req(const struct lu_env *env, struct obd_import *imp,
-                       const struct object_update_request *ureq,
+                       struct osp_update_request *our,
                        struct ptlrpc_request **reqp);
 int osp_remote_sync(const struct lu_env *env, struct osp_device *osp,
                    struct osp_update_request *update,