Whamcloud - gitweb
LU-8837 lustre: move lu_tgt_pool out of obd_target.h
[fs/lustre-release.git] / lustre / include / lu_object.h
index 0448b79..01a3e0d 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #ifndef __LUSTRE_LU_OBJECT_H
@@ -40,7 +39,6 @@
 #include <linux/percpu_counter.h>
 #include <linux/rhashtable.h>
 #include <linux/ctype.h>
-#include <obd_target.h>
 
 struct seq_file;
 struct proc_dir_entry;
@@ -934,6 +932,7 @@ enum lu_xattr_flags {
        LU_XATTR_CREATE  = BIT(1),
        LU_XATTR_MERGE   = BIT(2),
        LU_XATTR_SPLIT   = BIT(3),
+       LU_XATTR_PURGE   = BIT(4),
 };
 
 /** @} helpers */
@@ -1519,6 +1518,23 @@ static inline bool lu_object_is_cl(const struct lu_object *o)
        return lu_device_is_cl(o->lo_dev);
 }
 
+/* Generic subset of tgts */
+struct lu_tgt_pool {
+       __u32              *op_array;   /* array of index of
+                                        * lov_obd->lov_tgts
+                                        */
+       unsigned int        op_count;   /* number of tgts in the array */
+       unsigned int        op_size;    /* allocated size of op_array */
+       struct rw_semaphore op_rw_sem;  /* to protect lu_tgt_pool use */
+};
+
+int tgt_pool_init(struct lu_tgt_pool *op, unsigned int count);
+int tgt_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count);
+int tgt_pool_remove(struct lu_tgt_pool *op, __u32 idx);
+int tgt_pool_free(struct lu_tgt_pool *op);
+int tgt_check_index(int idx, struct lu_tgt_pool *osts);
+int tgt_pool_extend(struct lu_tgt_pool *op, unsigned int min_count);
+
 /* bitflags used in rr / qos allocation */
 enum lq_flag {
        LQ_DIRTY        = 0, /* recalc qos data */
@@ -1527,6 +1543,7 @@ enum lq_flag {
        LQ_RESET,            /* zero current penalties */
 };
 
+#ifdef HAVE_SERVER_SUPPORT
 /* round-robin QoS data for LOD/LMV */
 struct lu_qos_rr {
        spinlock_t               lqr_alloc;     /* protect allocation index */
@@ -1537,6 +1554,14 @@ struct lu_qos_rr {
        unsigned long            lqr_flags;
 };
 
+static inline void lu_qos_rr_init(struct lu_qos_rr *lqr)
+{
+       spin_lock_init(&lqr->lqr_alloc);
+       set_bit(LQ_DIRTY, &lqr->lqr_flags);
+}
+
+#endif /* HAVE_SERVER_SUPPORT */
+
 /* QoS data per MDS/OSS */
 struct lu_svr_qos {
        struct obd_uuid          lsq_uuid;      /* ptlrpc's c_remote_uuid */
@@ -1585,10 +1610,10 @@ struct lu_tgt_desc {
                           ltd_connecting:1; /* target is connecting */
 };
 
-/* number of pointers at 1st level */
-#define TGT_PTRS               (PAGE_SIZE / sizeof(void *))
 /* number of pointers at 2nd level */
 #define TGT_PTRS_PER_BLOCK     (PAGE_SIZE / sizeof(void *))
+/* number of pointers at 1st level - only need as many as max OST/MDT count */
+#define TGT_PTRS               ((LOV_ALL_STRIPES + 1) / TGT_PTRS_PER_BLOCK)
 
 struct lu_tgt_desc_idx {
        struct lu_tgt_desc *ldi_tgt[TGT_PTRS_PER_BLOCK];
@@ -1601,7 +1626,9 @@ struct lu_qos {
        __u32                    lq_active_svr_count;
        unsigned int             lq_prio_free;   /* priority for free space */
        unsigned int             lq_threshold_rr;/* priority for rr */
+#ifdef HAVE_SERVER_SUPPORT
        struct lu_qos_rr         lq_rr;          /* round robin qos data */
+#endif
        unsigned long            lq_flags;
 #if 0
        unsigned long            lq_dirty:1,     /* recalc qos data */
@@ -1639,11 +1666,10 @@ struct lu_tgt_descs {
 };
 
 #define LTD_TGT(ltd, index)                                            \
-        (ltd)->ltd_tgt_idx[(index) /                                   \
-        TGT_PTRS_PER_BLOCK]->ldi_tgt[(index) % TGT_PTRS_PER_BLOCK]
+        (ltd)->ltd_tgt_idx[(index) / TGT_PTRS_PER_BLOCK]->             \
+               ldi_tgt[(index) % TGT_PTRS_PER_BLOCK]
 
 u64 lu_prandom_u64_max(u64 ep_ro);
-void lu_qos_rr_init(struct lu_qos_rr *lqr);
 int lu_qos_add_tgt(struct lu_qos *qos, struct lu_tgt_desc *ltd);
 void lu_tgt_qos_weight_calc(struct lu_tgt_desc *tgt);