Whamcloud - gitweb
LU-3680 osd: reduce osd_thread_info in ldiskfs osd 26/9726/26
authorAlex Zhuravlev <alexey.zhuravlev@intel.com>
Wed, 19 Mar 2014 08:20:16 +0000 (12:20 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 3 Mar 2015 02:17:12 +0000 (02:17 +0000)
by unioning few rarely used fields. now the structure should
fit a page:

(gdb) p sizeof(struct osd_thread_info)
$1 = 3296

Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Change-Id: I75d5c6fefa41884390ce155781e0963884a3ad2c
Reviewed-on: http://review.whamcloud.com/9726
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_quota.c

index 9e0c0d7..235fb0e 100644 (file)
@@ -664,7 +664,14 @@ static int osd_obj_add_entry(struct osd_thread_info *info,
        LASSERT(th != NULL);
        LASSERT(th->h_transaction != NULL);
 
        LASSERT(th != NULL);
        LASSERT(th->h_transaction != NULL);
 
-       inode = &info->oti_inode;
+       inode = info->oti_inode;
+       if (unlikely(inode == NULL)) {
+               OBD_ALLOC_PTR(inode);
+               if (inode == NULL)
+                       RETURN(-ENOMEM);
+               info->oti_inode = inode;
+       }
+
        inode->i_sb = osd_sb(osd);
        osd_id_to_inode(inode, id);
        inode->i_mode = S_IFREG; /* for type in ldiskfs dir entry */
        inode->i_sb = osd_sb(osd);
        osd_id_to_inode(inode, id);
        inode->i_mode = S_IFREG; /* for type in ldiskfs dir entry */
index 58a1e1a..bf2a227 100644 (file)
@@ -127,7 +127,6 @@ int osd_trans_declare_op2rb[] = {
        [OSD_OT_WRITE]          = OSD_OT_WRITE,
        [OSD_OT_INSERT]         = OSD_OT_DELETE,
        [OSD_OT_DELETE]         = OSD_OT_INSERT,
        [OSD_OT_WRITE]          = OSD_OT_WRITE,
        [OSD_OT_INSERT]         = OSD_OT_DELETE,
        [OSD_OT_DELETE]         = OSD_OT_INSERT,
-       [OSD_OT_UPDATE]         = OSD_OT_MAX,
        [OSD_OT_QUOTA]          = OSD_OT_MAX,
 };
 
        [OSD_OT_QUOTA]          = OSD_OT_MAX,
 };
 
@@ -985,7 +984,6 @@ static struct thandle *osd_trans_create(const struct lu_env *env,
                oh->ot_credits = 0;
                atomic_set(&th->th_refc, 1);
                th->th_alloc_size = sizeof(*oh);
                oh->ot_credits = 0;
                atomic_set(&th->th_refc, 1);
                th->th_alloc_size = sizeof(*oh);
-               oti->oti_dev = osd_dt_dev(d);
                INIT_LIST_HEAD(&oh->ot_dcb_list);
                osd_th_alloced(oh);
 
                INIT_LIST_HEAD(&oh->ot_dcb_list);
                osd_th_alloced(oh);
 
@@ -1132,7 +1130,8 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
        struct osd_thandle     *oh;
        struct osd_thread_info *oti = osd_oti_get(env);
        struct osd_iobuf       *iobuf = &oti->oti_iobuf;
        struct osd_thandle     *oh;
        struct osd_thread_info *oti = osd_oti_get(env);
        struct osd_iobuf       *iobuf = &oti->oti_iobuf;
-       struct qsd_instance    *qsd = oti->oti_dev->od_quota_slave;
+       struct osd_device      *osd = osd_dt_dev(th->th_dev);
+       struct qsd_instance    *qsd = osd->od_quota_slave;
        struct lquota_trans    *qtrans;
        ENTRY;
 
        struct lquota_trans    *qtrans;
        ENTRY;
 
@@ -1156,19 +1155,20 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
                 oti->oti_txns--;
                 rc = dt_txn_hook_stop(env, th);
                 if (rc != 0)
                 oti->oti_txns--;
                 rc = dt_txn_hook_stop(env, th);
                 if (rc != 0)
-                        CERROR("Failure in transaction hook: %d\n", rc);
+                       CERROR("%s: failed in transaction hook: rc = %d\n",
+                              osd_name(osd), rc);
 
                /* hook functions might modify th_sync */
                hdl->h_sync = th->th_sync;
 
 
                /* hook functions might modify th_sync */
                hdl->h_sync = th->th_sync;
 
-                oh->ot_handle = NULL;
-                OSD_CHECK_SLOW_TH(oh, oti->oti_dev,
-                                  rc = ldiskfs_journal_stop(hdl));
-                if (rc != 0)
-                        CERROR("Failure to stop transaction: %d\n", rc);
-        } else {
+               oh->ot_handle = NULL;
+               OSD_CHECK_SLOW_TH(oh, osd, rc = ldiskfs_journal_stop(hdl));
+               if (rc != 0)
+                       CERROR("%s: failed to stop transaction: rc = %d\n",
+                              osd_name(osd), rc);
+       } else {
                thandle_put(&oh->ot_super);
                thandle_put(&oh->ot_super);
-        }
+       }
 
        /* inform the quota slave device that the transaction is stopping */
        qsd_op_end(env, qsd, qtrans);
 
        /* inform the quota slave device that the transaction is stopping */
        qsd_op_end(env, qsd, qtrans);
@@ -1184,7 +1184,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
         */
        wait_event(iobuf->dr_wait,
                       atomic_read(&iobuf->dr_numreqs) == 0);
         */
        wait_event(iobuf->dr_wait,
                       atomic_read(&iobuf->dr_numreqs) == 0);
-       osd_fini_iobuf(oti->oti_dev, iobuf);
+       osd_fini_iobuf(osd, iobuf);
        if (!rc)
                rc = iobuf->dr_error;
 
        if (!rc)
                rc = iobuf->dr_error;
 
@@ -5864,6 +5864,8 @@ static void osd_key_fini(const struct lu_context *ctx,
 {
        struct osd_thread_info *info = data;
 
 {
        struct osd_thread_info *info = data;
 
+       if (info->oti_inode != NULL)
+               OBD_FREE_PTR(info->oti_inode);
        if (info->oti_hlock != NULL)
                ldiskfs_htree_lock_free(info->oti_hlock);
        OBD_FREE(info->oti_it_ea_buf, OSD_IT_EA_BUFSIZE);
        if (info->oti_hlock != NULL)
                ldiskfs_htree_lock_free(info->oti_hlock);
        OBD_FREE(info->oti_it_ea_buf, OSD_IT_EA_BUFSIZE);
@@ -6450,6 +6452,9 @@ static int __init osd_mod_init(void)
 {
        int rc;
 
 {
        int rc;
 
+       /* please, try to keep osd_thread_info smaller than a page */
+       CLASSERT(sizeof(struct osd_thread_info) <= PAGE_SIZE);
+
        osd_oi_mod_init();
 
        rc = lu_kmem_init(ldiskfs_caches);
        osd_oi_mod_init();
 
        rc = lu_kmem_init(ldiskfs_caches);
index 8ee1865..0acde51 100644 (file)
@@ -327,9 +327,8 @@ enum {
        OSD_OT_WRITE            = 7,
        OSD_OT_INSERT           = 8,
        OSD_OT_DELETE           = 9,
        OSD_OT_WRITE            = 7,
        OSD_OT_INSERT           = 8,
        OSD_OT_DELETE           = 9,
-       OSD_OT_UPDATE           = 10,
-       OSD_OT_QUOTA            = 11,
-       OSD_OT_MAX              = 12
+       OSD_OT_QUOTA            = 10,
+       OSD_OT_MAX              = 11
 };
 
 struct osd_thandle {
 };
 
 struct osd_thandle {
@@ -495,18 +494,26 @@ struct osd_iobuf {
 };
 
 struct osd_thread_info {
 };
 
 struct osd_thread_info {
-        const struct lu_env   *oti_env;
-        /**
-         * used for index operations.
-         */
-        struct dentry          oti_obj_dentry;
-        struct dentry          oti_child_dentry;
+       const struct lu_env   *oti_env;
+       /**
+        * used for index operations.
+        */
+       struct dentry          oti_obj_dentry;
+       struct dentry          oti_child_dentry;
+
+       /** dentry for Iterator context. */
+       struct dentry           oti_it_dentry;
 
 
-        /** dentry for Iterator context. */
-        struct dentry          oti_it_dentry;
-        struct htree_lock     *oti_hlock;
+       union {
+               /* fake struct file for osd_object_sync */
+               struct file             oti_file;
+               /* osd_statfs() */
+               struct kstatfs          oti_ksfs;
+       };
 
 
-        struct lu_fid          oti_fid;
+       struct htree_lock     *oti_hlock;
+
+       struct lu_fid          oti_fid;
        struct lu_fid          oti_fid2;
        struct lu_fid          oti_fid3;
        struct osd_inode_id    oti_id;
        struct lu_fid          oti_fid2;
        struct lu_fid          oti_fid3;
        struct osd_inode_id    oti_id;
@@ -518,10 +525,6 @@ struct osd_thread_info {
          * XXX temporary: for ->i_op calls.
          */
         struct timespec        oti_time;
          * XXX temporary: for ->i_op calls.
          */
         struct timespec        oti_time;
-       /*
-        * XXX temporary: fake struct file for osd_object_sync
-        */
-       struct file            oti_file;
         /*
          * XXX temporary: for capa operations.
          */
         /*
          * XXX temporary: for capa operations.
          */
@@ -542,13 +545,12 @@ struct osd_thread_info {
        void                    *oti_it_ea_buf;
        unsigned int            oti_it_ea_buf_used:1;
 
        void                    *oti_it_ea_buf;
        unsigned int            oti_it_ea_buf_used:1;
 
-       struct kstatfs          oti_ksfs;
-
-        /** IAM iterator for index operation. */
-        struct iam_iterator    oti_idx_it;
+       /* IAM iterator for index operation. */
+       struct iam_iterator    oti_idx_it;
 
         /** union to guarantee that ->oti_ipd[] has proper alignment. */
         union {
 
         /** union to guarantee that ->oti_ipd[] has proper alignment. */
         union {
+               char           oti_name[48];
                 char           oti_it_ipd[DX_IPD_MAX_SIZE];
                 long long      oti_alignment_lieutenant;
         };
                 char           oti_it_ipd[DX_IPD_MAX_SIZE];
                 long long      oti_alignment_lieutenant;
         };
@@ -571,10 +573,13 @@ struct osd_thread_info {
                struct lustre_mdt_attrs oti_mdt_attrs;
                /* old LMA for compatibility */
                char                    oti_mdt_attrs_old[LMA_OLD_SIZE];
                struct lustre_mdt_attrs oti_mdt_attrs;
                /* old LMA for compatibility */
                char                    oti_mdt_attrs_old[LMA_OLD_SIZE];
+               struct filter_fid_old   oti_ff;
+               struct filter_fid       oti_ff_new;
        };
        /** 0-copy IO */
        struct osd_iobuf       oti_iobuf;
        };
        /** 0-copy IO */
        struct osd_iobuf       oti_iobuf;
-       struct inode           oti_inode;
+       /* used to access objects in /O */
+       struct inode          *oti_inode;
 #define OSD_FID_REC_SZ 32
        char                   oti_ldp[OSD_FID_REC_SZ];
        char                   oti_ldp2[OSD_FID_REC_SZ];
 #define OSD_FID_REC_SZ 32
        char                   oti_ldp[OSD_FID_REC_SZ];
        char                   oti_ldp2[OSD_FID_REC_SZ];
@@ -601,12 +606,6 @@ struct osd_thread_info {
        unsigned short          oti_declare_ops_rb[OSD_OT_MAX];
        unsigned short          oti_declare_ops_cred[OSD_OT_MAX];
        bool                    oti_rollback;
        unsigned short          oti_declare_ops_rb[OSD_OT_MAX];
        unsigned short          oti_declare_ops_cred[OSD_OT_MAX];
        bool                    oti_rollback;
-
-       char                    oti_name[48];
-       union {
-               struct filter_fid_old   oti_ff;
-               struct filter_fid       oti_ff_new;
-       };
 };
 
 extern int ldiskfs_pdo;
 };
 
 extern int ldiskfs_pdo;
@@ -957,7 +956,7 @@ static inline void osd_trans_declare_op(const struct lu_env *env,
                        LASSERT(op < OSD_OT_MAX);
                } else {
                        CWARN("%s: Invalid operation index %d\n",
                        LASSERT(op < OSD_OT_MAX);
                } else {
                        CWARN("%s: Invalid operation index %d\n",
-                             osd_name(oti->oti_dev), op);
+                             osd_name(osd_dt_dev(oh->ot_super.th_dev)), op);
                        libcfs_debug_dumpstack(NULL);
                }
        } else {
                        libcfs_debug_dumpstack(NULL);
                }
        } else {
@@ -981,7 +980,7 @@ static inline void osd_trans_exec_op(const struct lu_env *env,
                        LASSERT(op < OSD_OT_MAX);
                else {
                        CWARN("%s: Invalid operation index %d\n",
                        LASSERT(op < OSD_OT_MAX);
                else {
                        CWARN("%s: Invalid operation index %d\n",
-                             osd_name(oti->oti_dev), op);
+                             osd_name(osd_dt_dev(oh->ot_super.th_dev)), op);
                        libcfs_debug_dumpstack(NULL);
                        return;
                }
                        libcfs_debug_dumpstack(NULL);
                        return;
                }
@@ -999,7 +998,7 @@ static inline void osd_trans_exec_op(const struct lu_env *env,
                                LASSERTF(rb < OSD_OT_MAX, "rb = %u\n", rb);
                        else {
                                CWARN("%s: Invalid rollback index %d\n",
                                LASSERTF(rb < OSD_OT_MAX, "rb = %u\n", rb);
                        else {
                                CWARN("%s: Invalid rollback index %d\n",
-                                     osd_name(oti->oti_dev), rb);
+                                     osd_name(osd_dt_dev(th->th_dev)), rb);
                                libcfs_debug_dumpstack(NULL);
                                return;
                        }
                                libcfs_debug_dumpstack(NULL);
                                return;
                        }
@@ -1011,7 +1010,7 @@ static inline void osd_trans_exec_op(const struct lu_env *env,
                        else {
                                CWARN("%s: Overflow in tracking declares for "
                                      "index, rb = %d\n",
                        else {
                                CWARN("%s: Overflow in tracking declares for "
                                      "index, rb = %d\n",
-                                     osd_name(oti->oti_dev), rb);
+                                     osd_name(osd_dt_dev(th->th_dev)), rb);
                                libcfs_debug_dumpstack(NULL);
                                return;
                        }
                                libcfs_debug_dumpstack(NULL);
                                return;
                        }
@@ -1033,7 +1032,7 @@ static inline void osd_trans_declare_rb(const struct lu_env *env,
                        LASSERT(op < OSD_OT_MAX);
                else {
                        CWARN("%s: Invalid operation index %d\n",
                        LASSERT(op < OSD_OT_MAX);
                else {
                        CWARN("%s: Invalid operation index %d\n",
-                             osd_name(oti->oti_dev), op);
+                             osd_name(osd_dt_dev(th->th_dev)), op);
                        libcfs_debug_dumpstack(NULL);
                }
 
                        libcfs_debug_dumpstack(NULL);
                }
 
index 8b7281e..dbbf7a3 100644 (file)
@@ -509,8 +509,7 @@ int osd_declare_qid(const struct lu_env *env, struct osd_thandle *oh,
                    struct lquota_id_info *qi, struct osd_object *obj,
                    bool enforce, int *flags)
 {
                    struct lquota_id_info *qi, struct osd_object *obj,
                    bool enforce, int *flags)
 {
-       struct osd_thread_info  *info = osd_oti_get(env);
-       struct osd_device       *dev = info->oti_dev;
+       struct osd_device       *dev = osd_dt_dev(oh->ot_super.th_dev);
        struct qsd_instance     *qsd = dev->od_quota_slave;
        struct inode            *inode = NULL;
        int                      i, rc = 0, crd;
        struct qsd_instance     *qsd = dev->od_quota_slave;
        struct inode            *inode = NULL;
        int                      i, rc = 0, crd;