Whamcloud - gitweb
LU-6587 obdclass: use OBD_FREE_LARGE with OBD_ALLOC_LARGE 34/18034/4
authorAndreas Dilger <andreas.dilger@intel.com>
Mon, 18 Jan 2016 19:54:46 +0000 (12:54 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 5 Feb 2016 15:07:03 +0000 (15:07 +0000)
The change to use is_vmalloc_addr() instead of checking the allocation
size was introduced in commit 919b85d796f8, which allows using trying
kmalloc() before vmalloc(), but the deprecation of OBD_FREE_LARGE()
should not have happened since this adds needless overhead.

Use OBD_FREE_LARGE() for memory allocated with OBD_ALLOC_LARGE() so
that we only need to check is_vmalloc_addr() in OBD_FREE_LARGE()
instead of every call to OBD_FREE().

Add comments to data structures using OBD_ALLOC_LARGE() memory so
that it is clear to the users that OBD_FREE_LARGE() must be used
when freeing that memory.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Ief38142f6f777eec4ec0dae4ec64bfbf78b804ed
Reviewed-on: http://review.whamcloud.com/18034
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
27 files changed:
contrib/scripts/checkpatch.pl
lustre/include/lu_target.h
lustre/include/lustre_dlm.h
lustre/include/lustre_log.h
lustre/include/lustre_net.h
lustre/include/lustre_update.h
lustre/include/obd_support.h
lustre/lfsck/lfsck_internal.h
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/rw26.c
lustre/lod/lod_internal.h
lustre/lod/lod_lov.c
lustre/lov/lov_cl_internal.h
lustre/lov/lov_ea.c
lustre/lov/lov_io.c
lustre/lov/lov_object.c
lustre/mdt/mdt_internal.h
lustre/obdecho/echo_client.c
lustre/osp/osp_internal.h
lustre/osp/osp_trans.c
lustre/ptlrpc/client.c
lustre/ptlrpc/sec_bulk.c
lustre/ptlrpc/sec_null.c
lustre/ptlrpc/sec_plain.c
lustre/ptlrpc/service.c
lustre/target/update_recovery.c

index ecb711b..dc85c7c 100755 (executable)
@@ -471,7 +471,6 @@ my %dep_functions = (
        'strcpy',                       'strncpy',
        'strcat',                       'strncat',
        'tempnam',                      'mkstemp',
        'strcpy',                       'strncpy',
        'strcat',                       'strncat',
        'tempnam',                      'mkstemp',
-       'OBD_FREE_LARGE',               'OBD_FREE',
        'f_dentry',                     'f_path.dentry',
 );
 
        'f_dentry',                     'f_path.dentry',
 );
 
index e831975..a64aa8e 100644 (file)
@@ -47,7 +47,7 @@
  * operation, and updates on each MDTs are linked to
  * dtr_sub_list */
 struct distribute_txn_replay_req {
  * operation, and updates on each MDTs are linked to
  * dtr_sub_list */
 struct distribute_txn_replay_req {
-       /* update record */
+       /* update record, may be vmalloc'd */
        struct llog_update_record *dtrq_lur;
        int                     dtrq_lur_size;
 
        struct llog_update_record *dtrq_lur;
        int                     dtrq_lur_size;
 
index 61728ea..5beb294 100644 (file)
@@ -813,6 +813,7 @@ struct ldlm_lock {
 
        /**
         * Temporary storage for a LVB received during an enqueue operation.
 
        /**
         * Temporary storage for a LVB received during an enqueue operation.
+        * May be vmalloc'd, so needs to be freed with OBD_FREE_LARGE().
         */
        __u32                   l_lvb_len;
        void                    *l_lvb_data;
         */
        __u32                   l_lvb_len;
        void                    *l_lvb_data;
index 71bff91..8a237b2 100644 (file)
@@ -263,7 +263,7 @@ struct llog_handle {
        struct rw_semaphore      lgh_lock;
        struct mutex             lgh_hdr_mutex; /* protect lgh_hdr data */
        struct llog_logid        lgh_id; /* id of this log */
        struct rw_semaphore      lgh_lock;
        struct mutex             lgh_hdr_mutex; /* protect lgh_hdr data */
        struct llog_logid        lgh_id; /* id of this log */
-       struct llog_log_hdr     *lgh_hdr;
+       struct llog_log_hdr     *lgh_hdr; /* may be vmalloc'd */
        size_t                  lgh_hdr_size;
        struct dt_object        *lgh_obj;
        /* For a Catalog, is the last/newest used index for a plain slot.
        size_t                  lgh_hdr_size;
        struct dt_object        *lgh_obj;
        /* For a Catalog, is the last/newest used index for a plain slot.
index 7512eaa..266105c 100644 (file)
@@ -912,7 +912,7 @@ struct ptlrpc_srv_req {
        struct ptlrpc_svc_ctx           *sr_svc_ctx;
        /** (server side), pointed directly into req buffer */
        struct ptlrpc_user_desc         *sr_user_desc;
        struct ptlrpc_svc_ctx           *sr_svc_ctx;
        /** (server side), pointed directly into req buffer */
        struct ptlrpc_user_desc         *sr_user_desc;
-       /** separated reply state */
+       /** separated reply state, may be vmalloc'd */
        struct ptlrpc_reply_state       *sr_reply_state;
        /** server-side hp handlers */
        struct ptlrpc_hpreq_ops         *sr_ops;
        struct ptlrpc_reply_state       *sr_reply_state;
        /** server-side hp handlers */
        struct ptlrpc_hpreq_ops         *sr_ops;
@@ -1073,9 +1073,9 @@ struct ptlrpc_request {
 
 
        /** various buffer pointers */
 
 
        /** various buffer pointers */
-       struct lustre_msg               *rq_reqbuf;      /**< req wrapper */
-       char                            *rq_repbuf;      /**< rep buffer */
-       struct lustre_msg               *rq_repdata;     /**< rep wrapper msg */
+       struct lustre_msg               *rq_reqbuf;  /**< req wrapper, vmalloc*/
+       char                            *rq_repbuf;  /**< rep buffer, vmalloc */
+       struct lustre_msg               *rq_repdata; /**< rep wrapper msg */
        /** only in priv mode */
        struct lustre_msg               *rq_clrbuf;
         int                      rq_reqbuf_len;  /* req wrapper buf len */
        /** only in priv mode */
        struct lustre_msg               *rq_clrbuf;
         int                      rq_reqbuf_len;  /* req wrapper buf len */
@@ -1501,30 +1501,30 @@ enum {
  * Definition of server service thread structure
  */
 struct ptlrpc_thread {
  * Definition of server service thread structure
  */
 struct ptlrpc_thread {
-        /**
-         * List of active threads in svc->srv_threads
-         */
+       /**
+        * List of active threads in svc->srv_threads
+        */
        struct list_head t_link;
        struct list_head t_link;
-        /**
-         * thread-private data (preallocated memory)
-         */
-        void *t_data;
-        __u32 t_flags;
-        /**
-         * service thread index, from ptlrpc_start_threads
-         */
-        unsigned int t_id;
-        /**
-         * service thread pid
-         */
+       /**
+        * thread-private data (preallocated vmalloc'd memory)
+        */
+       void *t_data;
+       __u32 t_flags;
+       /**
+        * service thread index, from ptlrpc_start_threads
+        */
+       unsigned int t_id;
+       /**
+        * service thread pid
+        */
        pid_t t_pid;
        pid_t t_pid;
-        /**
-         * put watchdog in the structure per thread b=14840
-         */
-        struct lc_watchdog *t_watchdog;
-        /**
-         * the svc this thread belonged to b=18582
-         */
+       /**
+        * put watchdog in the structure per thread b=14840
+        */
+       struct lc_watchdog *t_watchdog;
+       /**
+        * the svc this thread belonged to b=18582
+        */
        struct ptlrpc_service_part      *t_svcpt;
        wait_queue_head_t               t_ctl_waitq;
        struct lu_env                   *t_env;
        struct ptlrpc_service_part      *t_svcpt;
        wait_queue_head_t               t_ctl_waitq;
        struct lu_env                   *t_env;
index f6e1d2b..a5cd4a2 100644 (file)
@@ -269,11 +269,11 @@ object_update_result_data_get(const struct object_update_reply *reply,
  * distribution.
  */
 struct thandle_update_records {
  * distribution.
  */
 struct thandle_update_records {
-       /* All of updates for the cross-MDT operation. */
+       /* All of updates for the cross-MDT operation, vmalloc'd. */
        struct llog_update_record       *tur_update_records;
        size_t                          tur_update_records_buf_size;
 
        struct llog_update_record       *tur_update_records;
        size_t                          tur_update_records_buf_size;
 
-       /* All of parameters for the cross-MDT operation */
+       /* All of parameters for the cross-MDT operation, vmalloc'd */
        struct update_params    *tur_update_params;
        unsigned int            tur_update_param_count;
        size_t                  tur_update_params_buf_size;
        struct update_params    *tur_update_params;
        unsigned int            tur_update_param_count;
        size_t                  tur_update_params_buf_size;
index 61ebffc..5834cf3 100644 (file)
@@ -754,8 +754,6 @@ do {                                                                              \
                OBD_CPT_VMALLOC(ptr, cptab, cpt, size);                       \
 } while (0)
 
                OBD_CPT_VMALLOC(ptr, cptab, cpt, size);                       \
 } while (0)
 
-#define OBD_FREE_LARGE(ptr, size) OBD_FREE(ptr, size)
-
 #ifdef CONFIG_DEBUG_SLAB
 #define POISON(ptr, c, s) do {} while (0)
 #define POISON_PTR(ptr)  ((void)0)
 #ifdef CONFIG_DEBUG_SLAB
 #define POISON(ptr, c, s) do {} while (0)
 #define POISON_PTR(ptr)  ((void)0)
@@ -765,23 +763,29 @@ do {                                                                            \
 #endif
 
 #ifdef POISON_BULK
 #endif
 
 #ifdef POISON_BULK
-#define POISON_PAGE(page, val) do { memset(kmap(page), val, PAGE_CACHE_SIZE);   \
+#define POISON_PAGE(page, val) do { memset(kmap(page), val, PAGE_CACHE_SIZE); \
                                     kunmap(page); } while (0)
 #else
 #define POISON_PAGE(page, val) do { } while (0)
 #endif
 
                                     kunmap(page); } while (0)
 #else
 #define POISON_PAGE(page, val) do { } while (0)
 #endif
 
-#define OBD_FREE(ptr, size)                                                   \
-do {                                                                          \
-       if (is_vmalloc_addr(ptr)) {                                           \
+#define OBD_FREE(ptr, size)                                                  \
+do {                                                                         \
+       OBD_FREE_PRE(ptr, size, "kfreed");                                    \
+       kfree(ptr);                                                           \
+       POISON_PTR(ptr);                                                      \
+} while (0)
+
+#define OBD_FREE_LARGE(ptr, size)                                            \
+do {                                                                         \
+       if (is_vmalloc_addr(ptr)) {                                           \
                OBD_FREE_PRE(ptr, size, "vfreed");                            \
                OBD_FREE_PRE(ptr, size, "vfreed");                            \
-               vfree(ptr);                                                   \
-       } else {                                                              \
-               OBD_FREE_PRE(ptr, size, "kfreed");                            \
-               kfree(ptr);                                                   \
+               vfree(ptr);                                                   \
+               POISON_PTR(ptr);                                              \
+       } else {                                                              \
+               OBD_FREE(ptr, size);                                          \
        }                                                                     \
        }                                                                     \
-       POISON_PTR(ptr);                                                      \
-} while(0)
+} while (0)
 
 #define OBD_FREE_RCU(ptr, size, handle)                                              \
 do {                                                                         \
 
 #define OBD_FREE_RCU(ptr, size, handle)                                              \
 do {                                                                         \
index f04144e..281643e 100644 (file)
@@ -598,7 +598,7 @@ struct lfsck_lmv {
                                         ll_inline:1,
                                         ll_failed:1,
                                         ll_ignore:1;
                                         ll_inline:1,
                                         ll_failed:1,
                                         ll_ignore:1;
-       struct lfsck_slave_lmv_rec      *ll_lslr;
+       struct lfsck_slave_lmv_rec      *ll_lslr; /* may be vmalloc'd */
 };
 
 /* If the namespace LFSCK finds that the master MDT-object of a striped
 };
 
 /* If the namespace LFSCK finds that the master MDT-object of a striped
index de3f657..2ebad02 100644 (file)
@@ -1587,10 +1587,8 @@ out_rmdir:
                        RETURN(-ENOMEM);
 
                /* Copy the whole struct */
                        RETURN(-ENOMEM);
 
                /* Copy the whole struct */
-               if (copy_from_user(hur, (void __user *)arg, totalsize)) {
-                       OBD_FREE_LARGE(hur, totalsize);
-                       RETURN(-EFAULT);
-               }
+               if (copy_from_user(hur, (void __user *)arg, totalsize))
+                       GOTO(out_hur, rc = -EFAULT);
 
                if (hur->hur_request.hr_action == HUA_RELEASE) {
                        const struct lu_fid *fid;
 
                if (hur->hur_request.hr_action == HUA_RELEASE) {
                        const struct lu_fid *fid;
@@ -1615,6 +1613,7 @@ out_rmdir:
                                           hur, NULL);
                }
 
                                           hur, NULL);
                }
 
+out_hur:
                OBD_FREE_LARGE(hur, totalsize);
 
                RETURN(rc);
                OBD_FREE_LARGE(hur, totalsize);
 
                RETURN(rc);
index 0d13b13..8e6afbd 100644 (file)
@@ -1571,13 +1571,12 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
        if (lump == NULL)
                 RETURN(-ENOMEM);
 
        if (lump == NULL)
                 RETURN(-ENOMEM);
 
-       if (copy_from_user(lump, (struct lov_user_md __user *)arg, lum_size)) {
-               OBD_FREE_LARGE(lump, lum_size);
-               RETURN(-EFAULT);
-       }
+       if (copy_from_user(lump, (struct lov_user_md __user *)arg, lum_size))
+               GOTO(out_lump, rc = -EFAULT);
 
        rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size);
 
 
        rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size);
 
+out_lump:
        OBD_FREE_LARGE(lump, lum_size);
        RETURN(rc);
 }
        OBD_FREE_LARGE(lump, lum_size);
        RETURN(rc);
 }
@@ -3859,7 +3858,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
        }
        unlock_res_and_lock(lock);
 
        }
        unlock_res_and_lock(lock);
 
-       if (lvbdata != NULL)
+       if (lvbdata)
                OBD_FREE_LARGE(lvbdata, lmmsize);
 
        EXIT;
                OBD_FREE_LARGE(lvbdata, lmmsize);
 
        EXIT;
index b2d6e31..ee17a73 100644 (file)
@@ -324,7 +324,7 @@ static void ll_free_user_pages(struct page **pages, int npages, int do_dirty)
 #if defined(HAVE_DIRECTIO_ITER) || defined(HAVE_IOV_ITER_RW)
        kvfree(pages);
 #else
 #if defined(HAVE_DIRECTIO_ITER) || defined(HAVE_IOV_ITER_RW)
        kvfree(pages);
 #else
-       OBD_FREE(pages, npages * sizeof(*pages));
+       OBD_FREE_LARGE(pages, npages * sizeof(*pages));
 #endif
 }
 
 #endif
 }
 
@@ -477,7 +477,7 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr,
                                        NULL);
                up_read(&current->mm->mmap_sem);
                if (unlikely(result <= 0))
                                        NULL);
                up_read(&current->mm->mmap_sem);
                if (unlikely(result <= 0))
-                       OBD_FREE(*pages, *max_pages * sizeof(**pages));
+                       OBD_FREE_LARGE(*pages, *max_pages * sizeof(**pages));
        }
 
        return result;
        }
 
        return result;
index 484ba8e..869a44e 100644 (file)
@@ -288,7 +288,7 @@ struct lod_it {
 };
 
 struct lod_thread_info {
 };
 
 struct lod_thread_info {
-       /* per-thread buffer for LOV EA */
+       /* per-thread buffer for LOV EA, may be vmalloc'd */
        void             *lti_ea_store;
        __u32             lti_ea_store_size;
        /* per-thread buffer for LMV EA */
        void             *lti_ea_store;
        __u32             lti_ea_store_size;
        /* per-thread buffer for LMV EA */
index 63054d8..ee19042 100644 (file)
@@ -613,6 +613,7 @@ int lod_ea_store_resize(struct lod_thread_info *info, size_t size)
        if (info->lti_ea_store == NULL)
                RETURN(-ENOMEM);
        info->lti_ea_store_size = round;
        if (info->lti_ea_store == NULL)
                RETURN(-ENOMEM);
        info->lti_ea_store_size = round;
+
        RETURN(0);
 }
 
        RETURN(0);
 }
 
index cde1ff4..65009f9 100644 (file)
@@ -242,6 +242,8 @@ struct lov_object {
                         * When top-object is destroyed (lov_delete_raid0())
                         * it releases its reference to a sub-object and waits
                         * until the latter is finally destroyed.
                         * When top-object is destroyed (lov_delete_raid0())
                         * it releases its reference to a sub-object and waits
                         * until the latter is finally destroyed.
+                        *
+                        * May be vmalloc'd, must be freed with OBD_FREE_LARGE.
                         */
                        struct lovsub_object **lo_sub;
                        /**
                         */
                        struct lovsub_object **lo_sub;
                        /**
@@ -442,30 +444,31 @@ struct lov_io {
          * (stripe), used by ci_io_loop().
          */
        loff_t                   lis_pos;
          * (stripe), used by ci_io_loop().
          */
        loff_t                   lis_pos;
-        /**
-         * end position with in a file, for the current stripe io. This is
-         * exclusive (i.e., next offset after last byte affected by io).
-         */
+       /**
+        * end position with in a file, for the current stripe io. This is
+        * exclusive (i.e., next offset after last byte affected by io).
+        */
        loff_t                   lis_endpos;
 
        loff_t                   lis_endpos;
 
-        int                lis_mem_frozen;
-        int                lis_stripe_count;
-        int                lis_active_subios;
+       int                     lis_mem_frozen;
+       int                     lis_stripe_count;
+       int                     lis_active_subios;
 
 
-        /**
-         * the index of ls_single_subio in ls_subios array
-         */
-        int                lis_single_subio_index;
-        struct cl_io       lis_single_subio;
+       /**
+        * the index of ls_single_subio in ls_subios array
+        */
+       int                     lis_single_subio_index;
+       struct cl_io            lis_single_subio;
 
 
-        /**
-         * size of ls_subios array, actually the highest stripe #
-         */
-        int                lis_nr_subios;
-        struct lov_io_sub *lis_subs;
-        /**
-         * List of active sub-io's.
-         */
+       /**
+        * size of ls_subios array, actually the highest stripe #
+        * May be vmalloc'd, must be freed with OBD_FREE_LARGE().
+        */
+       int                     lis_nr_subios;
+       struct lov_io_sub       *lis_subs;
+       /**
+        * List of active sub-io's.
+        */
        struct list_head        lis_active;
 };
 
        struct list_head        lis_active;
 };
 
index d4d2262..05bf270 100644 (file)
@@ -116,14 +116,14 @@ err:
 
 void lsm_free_plain(struct lov_stripe_md *lsm)
 {
 
 void lsm_free_plain(struct lov_stripe_md *lsm)
 {
-        __u16 stripe_count = lsm->lsm_stripe_count;
-        int i;
-
-        for (i = 0; i < stripe_count; i++)
-                OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab,
-                              sizeof(struct lov_oinfo));
-        OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
-                       stripe_count * sizeof(struct lov_oinfo *));
+       __u16 stripe_count = lsm->lsm_stripe_count;
+       int i;
+
+       for (i = 0; i < stripe_count; i++)
+               OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab,
+                             sizeof(struct lov_oinfo));
+       OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
+                      stripe_count * sizeof(struct lov_oinfo *));
 }
 
 /* Find minimum stripe maxbytes value.  For inactive or
 }
 
 /* Find minimum stripe maxbytes value.  For inactive or
index 4d5b777..7626987 100644 (file)
@@ -298,20 +298,21 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
        LASSERT(lio->lis_object != NULL);
        lsm = lio->lis_object->lo_lsm;
 
        LASSERT(lio->lis_object != NULL);
        lsm = lio->lis_object->lo_lsm;
 
-        /*
-         * Need to be optimized, we can't afford to allocate a piece of memory
-         * when writing a page. -jay
-         */
-        OBD_ALLOC_LARGE(lio->lis_subs,
-                        lsm->lsm_stripe_count * sizeof lio->lis_subs[0]);
-        if (lio->lis_subs != NULL) {
-                lio->lis_nr_subios = lio->lis_stripe_count;
-                lio->lis_single_subio_index = -1;
-                lio->lis_active_subios = 0;
-                result = 0;
-        } else
-                result = -ENOMEM;
-        RETURN(result);
+       /*
+        * Need to be optimized, we can't afford to allocate a piece of memory
+        * when writing a page. -jay
+        */
+       OBD_ALLOC_LARGE(lio->lis_subs,
+                       lsm->lsm_stripe_count * sizeof lio->lis_subs[0]);
+       if (lio->lis_subs != NULL) {
+               lio->lis_nr_subios = lio->lis_stripe_count;
+               lio->lis_single_subio_index = -1;
+               lio->lis_active_subios = 0;
+               result = 0;
+       } else
+               result = -ENOMEM;
+
+       RETURN(result);
 }
 
 static int lov_io_slice_init(struct lov_io *lio,
 }
 
 static int lov_io_slice_init(struct lov_io *lio,
index 1f2ccca..85243d1 100644 (file)
@@ -1208,7 +1208,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
         */
        if (lsm->lsm_stripe_count > 1 && !(fiemap->fm_flags &
                                           FIEMAP_FLAG_DEVICE_ORDER))
         */
        if (lsm->lsm_stripe_count > 1 && !(fiemap->fm_flags &
                                           FIEMAP_FLAG_DEVICE_ORDER))
-               GOTO(out, rc = -ENOTSUPP);
+               GOTO(out_lsm, rc = -ENOTSUPP);
 
        if (lsm_is_released(lsm)) {
                if (fiemap->fm_start < fmkey->lfik_oa.o_size) {
 
        if (lsm_is_released(lsm)) {
                if (fiemap->fm_start < fmkey->lfik_oa.o_size) {
@@ -1229,7 +1229,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
                        fiemap->fm_extents[0].fe_flags |=
                                FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_LAST;
                }
                        fiemap->fm_extents[0].fe_flags |=
                                FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_LAST;
                }
-               GOTO(out, rc = 0);
+               GOTO(out_lsm, rc = 0);
        }
 
        if (fiemap_count_to_size(fiemap->fm_extent_count) < buffer_size)
        }
 
        if (fiemap_count_to_size(fiemap->fm_extent_count) < buffer_size)
@@ -1237,7 +1237,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
 
        OBD_ALLOC_LARGE(fm_local, buffer_size);
        if (fm_local == NULL)
 
        OBD_ALLOC_LARGE(fm_local, buffer_size);
        if (fm_local == NULL)
-               GOTO(out, rc = -ENOMEM);
+               GOTO(out_lsm, rc = -ENOMEM);
        lcl_fm_ext = &fm_local->fm_extents[0];
        count_local = fiemap_size_to_count(buffer_size);
 
        lcl_fm_ext = &fm_local->fm_extents[0];
        count_local = fiemap_size_to_count(buffer_size);
 
@@ -1256,7 +1256,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
        fm_end_offset = fiemap_calc_fm_end_offset(fiemap, lsm, fm_start, fm_end,
                                                  &start_stripe);
        if (fm_end_offset == -EINVAL)
        fm_end_offset = fiemap_calc_fm_end_offset(fiemap, lsm, fm_start, fm_end,
                                                  &start_stripe);
        if (fm_end_offset == -EINVAL)
-               GOTO(out, rc = -EINVAL);
+               GOTO(out_fm_local, rc = -EINVAL);
 
        /**
         * Requested extent count exceeds the fiemap buffer size, shrink our
 
        /**
         * Requested extent count exceeds the fiemap buffer size, shrink our
@@ -1286,7 +1286,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
                        continue;
 
                if (lov_oinfo_is_dummy(lsm->lsm_oinfo[cur_stripe]))
                        continue;
 
                if (lov_oinfo_is_dummy(lsm->lsm_oinfo[cur_stripe]))
-                       GOTO(out, rc = -EIO);
+                       GOTO(out_fm_local, rc = -EIO);
 
                /* If this is a continuation FIEMAP call and we are on
                 * starting stripe then lun_start needs to be set to
 
                /* If this is a continuation FIEMAP call and we are on
                 * starting stripe then lun_start needs to be set to
@@ -1315,7 +1315,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
                subobj = lov_find_subobj(env, cl2lov(obj), lsm,
                                             cur_stripe);
                if (IS_ERR(subobj))
                subobj = lov_find_subobj(env, cl2lov(obj), lsm,
                                             cur_stripe);
                if (IS_ERR(subobj))
-                       GOTO(out, rc = PTR_ERR(subobj));
+                       GOTO(out_fm_local, rc = PTR_ERR(subobj));
                /* If the output buffer is very large and the objects have many
                 * extents we may need to loop on a single OST repeatedly */
                ost_eof = false;
                /* If the output buffer is very large and the objects have many
                 * extents we may need to loop on a single OST repeatedly */
                ost_eof = false;
@@ -1448,10 +1448,10 @@ skip_last_device_calc:
 obj_put:
        if (subobj != NULL)
                cl_object_put(env, subobj);
 obj_put:
        if (subobj != NULL)
                cl_object_put(env, subobj);
-out:
-       if (fm_local != NULL)
-               OBD_FREE_LARGE(fm_local, buffer_size);
+out_fm_local:
+       OBD_FREE_LARGE(fm_local, buffer_size);
 
 
+out_lsm:
        lov_lsm_put(lsm);
 
        return rc;
        lov_lsm_put(lsm);
 
        return rc;
index 95c8a24..310d484 100644 (file)
@@ -420,7 +420,7 @@ struct mdt_thread_info {
 
         /* Ops object filename */
         struct lu_name             mti_name;
 
         /* Ops object filename */
         struct lu_name             mti_name;
-       /* per-thread values, can be re-used */
+       /* per-thread values, can be re-used, may be vmalloc'd */
        void                      *mti_big_lmm;
        int                        mti_big_lmmsize;
        /* big_lmm buffer was used and must be used in reply */
        void                      *mti_big_lmm;
        int                        mti_big_lmmsize;
        /* big_lmm buffer was used and must be used in reply */
index d47bc16..40132a4 100644 (file)
@@ -230,7 +230,7 @@ struct echo_thread_info {
        struct md_attr          eti_ma;
        struct lu_name          eti_lname;
        /* per-thread values, can be re-used */
        struct md_attr          eti_ma;
        struct lu_name          eti_lname;
        /* per-thread values, can be re-used */
-       void                    *eti_big_lmm;
+       void                    *eti_big_lmm; /* may be vmalloc'd */
        int                     eti_big_lmmsize;
        char                    eti_name[20];
        struct lu_buf           eti_buf;
        int                     eti_big_lmmsize;
        char                    eti_name[20];
        struct lu_buf           eti_buf;
index 727cf6e..88e2777 100644 (file)
@@ -95,7 +95,7 @@ struct osp_precreate {
 };
 
 struct osp_update_request_sub {
 };
 
 struct osp_update_request_sub {
-       struct object_update_request    *ours_req;
+       struct object_update_request    *ours_req; /* may be vmalloc'd */
        size_t                          ours_req_size;
        /* Linked to osp_update_request->our_req_list */
        struct list_head                ours_list;
        size_t                          ours_req_size;
        /* Linked to osp_update_request->our_req_list */
        struct list_head                ours_list;
index 368bec5..ffcc382 100644 (file)
@@ -211,7 +211,7 @@ void osp_update_request_destroy(struct osp_update_request *our)
        list_for_each_entry_safe(ours, tmp, &our->our_req_list, ours_list) {
                list_del(&ours->ours_list);
                if (ours->ours_req != NULL)
        list_for_each_entry_safe(ours, tmp, &our->our_req_list, ours_list) {
                list_del(&ours->ours_list);
                if (ours->ours_req != NULL)
-                       OBD_FREE(ours->ours_req, ours->ours_req_size);
+                       OBD_FREE_LARGE(ours->ours_req, ours->ours_req_size);
                OBD_FREE_PTR(ours);
        }
        OBD_FREE_PTR(our);
                OBD_FREE_PTR(ours);
        }
        OBD_FREE_PTR(our);
index bb7fe52..2749d04 100644 (file)
@@ -553,10 +553,10 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
                if (!msg) {
                        ptlrpc_request_cache_free(req);
                        return i;
                if (!msg) {
                        ptlrpc_request_cache_free(req);
                        return i;
-                }
-                req->rq_reqbuf = msg;
-                req->rq_reqbuf_len = size;
-                req->rq_pool = pool;
+               }
+               req->rq_reqbuf = msg;
+               req->rq_reqbuf_len = size;
+               req->rq_pool = pool;
                spin_lock(&pool->prp_lock);
                list_add_tail(&req->rq_list, &pool->prp_req_list);
        }
                spin_lock(&pool->prp_lock);
                list_add_tail(&req->rq_list, &pool->prp_req_list);
        }
index be2c35d..c091dd6 100644 (file)
@@ -121,7 +121,7 @@ static struct ptlrpc_enc_page_pool {
         cfs_time_t       epp_st_max_wait;       /* in jeffies */
        unsigned long    epp_st_outofmem;       /* # of out of mem requests */
        /*
         cfs_time_t       epp_st_max_wait;       /* in jeffies */
        unsigned long    epp_st_outofmem;       /* # of out of mem requests */
        /*
-        * pointers to pools
+        * pointers to pools, may be vmalloc'd
         */
        struct page    ***epp_pools;
 } page_pools;
         */
        struct page    ***epp_pools;
 } page_pools;
@@ -764,20 +764,20 @@ EXPORT_SYMBOL(sptlrpc_enc_pool_del_user);
 
 static inline void enc_pools_alloc(void)
 {
 
 static inline void enc_pools_alloc(void)
 {
-        LASSERT(page_pools.epp_max_pools);
-        OBD_ALLOC_LARGE(page_pools.epp_pools,
-                        page_pools.epp_max_pools *
-                        sizeof(*page_pools.epp_pools));
+       LASSERT(page_pools.epp_max_pools);
+       OBD_ALLOC_LARGE(page_pools.epp_pools,
+                       page_pools.epp_max_pools *
+                       sizeof(*page_pools.epp_pools));
 }
 
 static inline void enc_pools_free(void)
 {
 }
 
 static inline void enc_pools_free(void)
 {
-        LASSERT(page_pools.epp_max_pools);
-        LASSERT(page_pools.epp_pools);
+       LASSERT(page_pools.epp_max_pools);
+       LASSERT(page_pools.epp_pools);
 
 
-        OBD_FREE_LARGE(page_pools.epp_pools,
-                       page_pools.epp_max_pools *
-                       sizeof(*page_pools.epp_pools));
+       OBD_FREE_LARGE(page_pools.epp_pools,
+                      page_pools.epp_max_pools *
+                      sizeof(*page_pools.epp_pools));
 }
 
 int sptlrpc_enc_pool_init(void)
 }
 
 int sptlrpc_enc_pool_init(void)
index e5e8771..a54a9d8 100644 (file)
@@ -158,23 +158,23 @@ int null_alloc_reqbuf(struct ptlrpc_sec *sec,
                       struct ptlrpc_request *req,
                       int msgsize)
 {
                       struct ptlrpc_request *req,
                       int msgsize)
 {
-        if (!req->rq_reqbuf) {
-                int alloc_size = size_roundup_power2(msgsize);
-
-                LASSERT(!req->rq_pool);
-                OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size);
-                if (!req->rq_reqbuf)
-                        return -ENOMEM;
-
-                req->rq_reqbuf_len = alloc_size;
-        } else {
-                LASSERT(req->rq_pool);
-                LASSERT(req->rq_reqbuf_len >= msgsize);
-                memset(req->rq_reqbuf, 0, msgsize);
-        }
+       if (!req->rq_reqbuf) {
+               int alloc_size = size_roundup_power2(msgsize);
+
+               LASSERT(!req->rq_pool);
+               OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size);
+               if (!req->rq_reqbuf)
+                       return -ENOMEM;
+
+               req->rq_reqbuf_len = alloc_size;
+       } else {
+               LASSERT(req->rq_pool);
+               LASSERT(req->rq_reqbuf_len >= msgsize);
+               memset(req->rq_reqbuf, 0, msgsize);
+       }
 
 
-        req->rq_reqmsg = req->rq_reqbuf;
-        return 0;
+       req->rq_reqmsg = req->rq_reqbuf;
+       return 0;
 }
 
 static
 }
 
 static
@@ -200,17 +200,17 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec,
                       struct ptlrpc_request *req,
                       int msgsize)
 {
                       struct ptlrpc_request *req,
                       int msgsize)
 {
-        /* add space for early replied */
-        msgsize += lustre_msg_early_size();
+       /* add space for early replied */
+       msgsize += lustre_msg_early_size();
 
 
-        msgsize = size_roundup_power2(msgsize);
+       msgsize = size_roundup_power2(msgsize);
 
 
-        OBD_ALLOC_LARGE(req->rq_repbuf, msgsize);
-        if (!req->rq_repbuf)
-                return -ENOMEM;
+       OBD_ALLOC_LARGE(req->rq_repbuf, msgsize);
+       if (!req->rq_repbuf)
+               return -ENOMEM;
 
 
-        req->rq_repbuf_len = msgsize;
-        return 0;
+       req->rq_repbuf_len = msgsize;
+       return 0;
 }
 
 static
 }
 
 static
@@ -247,12 +247,12 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
         /* request from pool should always have enough buffer */
         LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newmsg_size);
 
         /* request from pool should always have enough buffer */
         LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newmsg_size);
 
-        if (req->rq_reqbuf_len < newmsg_size) {
-                alloc_size = size_roundup_power2(newmsg_size);
+       if (req->rq_reqbuf_len < newmsg_size) {
+               alloc_size = size_roundup_power2(newmsg_size);
 
 
-                OBD_ALLOC_LARGE(newbuf, alloc_size);
-                if (newbuf == NULL)
-                        return -ENOMEM;
+               OBD_ALLOC_LARGE(newbuf, alloc_size);
+               if (newbuf == NULL)
+                       return -ENOMEM;
 
                /* Must lock this, so that otherwise unprotected change of
                 * rq_reqmsg is not racing with parallel processing of
 
                /* Must lock this, so that otherwise unprotected change of
                 * rq_reqmsg is not racing with parallel processing of
@@ -262,11 +262,11 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
                 * there */
                if (req->rq_import)
                        spin_lock(&req->rq_import->imp_lock);
                 * there */
                if (req->rq_import)
                        spin_lock(&req->rq_import->imp_lock);
-                memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
+               memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
 
 
-                OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
-                req->rq_reqbuf = req->rq_reqmsg = newbuf;
-                req->rq_reqbuf_len = alloc_size;
+               OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+               req->rq_reqbuf = req->rq_reqmsg = newbuf;
+               req->rq_reqbuf_len = alloc_size;
 
                if (req->rq_import)
                        spin_unlock(&req->rq_import->imp_lock);
 
                if (req->rq_import)
                        spin_unlock(&req->rq_import->imp_lock);
@@ -319,12 +319,12 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize)
                 /* pre-allocated */
                 LASSERT(rs->rs_size >= rs_size);
         } else {
                 /* pre-allocated */
                 LASSERT(rs->rs_size >= rs_size);
         } else {
-                OBD_ALLOC_LARGE(rs, rs_size);
-                if (rs == NULL)
-                        return -ENOMEM;
+               OBD_ALLOC_LARGE(rs, rs_size);
+               if (rs == NULL)
+                       return -ENOMEM;
 
 
-                rs->rs_size = rs_size;
-        }
+               rs->rs_size = rs_size;
+       }
 
        rs->rs_svc_ctx = req->rq_svc_ctx;
        atomic_inc(&req->rq_svc_ctx->sc_refcount);
 
        rs->rs_svc_ctx = req->rq_svc_ctx;
        atomic_inc(&req->rq_svc_ctx->sc_refcount);
index ad10a2f..510b3fd 100644 (file)
@@ -570,15 +570,15 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
 
         alloc_len = lustre_msg_size_v2(PLAIN_PACK_SEGMENTS, buflens);
 
 
         alloc_len = lustre_msg_size_v2(PLAIN_PACK_SEGMENTS, buflens);
 
-        if (!req->rq_reqbuf) {
-                LASSERT(!req->rq_pool);
+       if (!req->rq_reqbuf) {
+               LASSERT(!req->rq_pool);
 
 
-                alloc_len = size_roundup_power2(alloc_len);
-                OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len);
-                if (!req->rq_reqbuf)
-                        RETURN(-ENOMEM);
+               alloc_len = size_roundup_power2(alloc_len);
+               OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len);
+               if (!req->rq_reqbuf)
+                       RETURN(-ENOMEM);
 
 
-                req->rq_reqbuf_len = alloc_len;
+               req->rq_reqbuf_len = alloc_len;
         } else {
                 LASSERT(req->rq_pool);
                 LASSERT(req->rq_reqbuf_len >= alloc_len);
         } else {
                 LASSERT(req->rq_pool);
                 LASSERT(req->rq_reqbuf_len >= alloc_len);
@@ -598,13 +598,13 @@ static
 void plain_free_reqbuf(struct ptlrpc_sec *sec,
                        struct ptlrpc_request *req)
 {
 void plain_free_reqbuf(struct ptlrpc_sec *sec,
                        struct ptlrpc_request *req)
 {
-        ENTRY;
-        if (!req->rq_pool) {
-                OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
-                req->rq_reqbuf = NULL;
-                req->rq_reqbuf_len = 0;
-        }
-        EXIT;
+       ENTRY;
+       if (!req->rq_pool) {
+               OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+               req->rq_reqbuf = NULL;
+               req->rq_reqbuf_len = 0;
+       }
+       EXIT;
 }
 
 static
 }
 
 static
@@ -631,12 +631,12 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec,
 
         alloc_len = size_roundup_power2(alloc_len);
 
 
         alloc_len = size_roundup_power2(alloc_len);
 
-        OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len);
-        if (!req->rq_repbuf)
-                RETURN(-ENOMEM);
+       OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len);
+       if (!req->rq_repbuf)
+               RETURN(-ENOMEM);
 
 
-        req->rq_repbuf_len = alloc_len;
-        RETURN(0);
+       req->rq_repbuf_len = alloc_len;
+       RETURN(0);
 }
 
 static
 }
 
 static
@@ -682,12 +682,12 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
         /* request from pool should always have enough buffer */
         LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newbuf_size);
 
         /* request from pool should always have enough buffer */
         LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newbuf_size);
 
-        if (req->rq_reqbuf_len < newbuf_size) {
-                newbuf_size = size_roundup_power2(newbuf_size);
+       if (req->rq_reqbuf_len < newbuf_size) {
+               newbuf_size = size_roundup_power2(newbuf_size);
 
 
-                OBD_ALLOC_LARGE(newbuf, newbuf_size);
-                if (newbuf == NULL)
-                        RETURN(-ENOMEM);
+               OBD_ALLOC_LARGE(newbuf, newbuf_size);
+               if (newbuf == NULL)
+                       RETURN(-ENOMEM);
 
                /* Must lock this, so that otherwise unprotected change of
                 * rq_reqmsg is not racing with parallel processing of
 
                /* Must lock this, so that otherwise unprotected change of
                 * rq_reqmsg is not racing with parallel processing of
@@ -698,24 +698,24 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
                if (req->rq_import)
                        spin_lock(&req->rq_import->imp_lock);
 
                if (req->rq_import)
                        spin_lock(&req->rq_import->imp_lock);
 
-                memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
+               memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
 
 
-                OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
-                req->rq_reqbuf = newbuf;
-                req->rq_reqbuf_len = newbuf_size;
-                req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf,
-                                                PLAIN_PACK_MSG_OFF, 0);
+               OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+               req->rq_reqbuf = newbuf;
+               req->rq_reqbuf_len = newbuf_size;
+               req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf,
+                                               PLAIN_PACK_MSG_OFF, 0);
 
                if (req->rq_import)
                        spin_unlock(&req->rq_import->imp_lock);
 
                if (req->rq_import)
                        spin_unlock(&req->rq_import->imp_lock);
-        }
+       }
 
 
-        _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, PLAIN_PACK_MSG_OFF,
-                                     newmsg_size);
-        _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize);
+       _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, PLAIN_PACK_MSG_OFF,
+                                    newmsg_size);
+       _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize);
 
 
-        req->rq_reqlen = newmsg_size;
-        RETURN(0);
+       req->rq_reqlen = newmsg_size;
+       RETURN(0);
 }
 
 /****************************************
 }
 
 /****************************************
@@ -819,16 +819,16 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize)
 
         rs = req->rq_reply_state;
 
 
         rs = req->rq_reply_state;
 
-        if (rs) {
-                /* pre-allocated */
-                LASSERT(rs->rs_size >= rs_size);
-        } else {
-                OBD_ALLOC_LARGE(rs, rs_size);
-                if (rs == NULL)
-                        RETURN(-ENOMEM);
+       if (rs) {
+               /* pre-allocated */
+               LASSERT(rs->rs_size >= rs_size);
+       } else {
+               OBD_ALLOC_LARGE(rs, rs_size);
+               if (rs == NULL)
+                       RETURN(-ENOMEM);
 
 
-                rs->rs_size = rs_size;
-        }
+               rs->rs_size = rs_size;
+       }
 
        rs->rs_svc_ctx = req->rq_svc_ctx;
        atomic_inc(&req->rq_svc_ctx->sc_refcount);
 
        rs->rs_svc_ctx = req->rq_svc_ctx;
        atomic_inc(&req->rq_svc_ctx->sc_refcount);
index 6fa28d0..693391d 100644 (file)
@@ -2439,12 +2439,12 @@ static int ptlrpc_main(void *arg)
                goto out_srv_fini;
        }
 
                goto out_srv_fini;
        }
 
-        /* Alloc reply state structure for this one */
-        OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size);
-        if (!rs) {
-                rc = -ENOMEM;
-                goto out_srv_fini;
-        }
+       /* Alloc reply state structure for this one */
+       OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size);
+       if (!rs) {
+               rc = -ENOMEM;
+               goto out_srv_fini;
+       }
 
        spin_lock(&svcpt->scp_lock);
 
 
        spin_lock(&svcpt->scp_lock);
 
index 2e36524..40db87c 100644 (file)
@@ -443,7 +443,7 @@ again:
         * we do not need lock here */
        if (replace_record) {
                /* Replace the update record and master transno */
         * we do not need lock here */
        if (replace_record) {
                /* Replace the update record and master transno */
-               OBD_FREE(dtrq->dtrq_lur, dtrq->dtrq_lur_size);
+               OBD_FREE_LARGE(dtrq->dtrq_lur, dtrq->dtrq_lur_size);
                dtrq->dtrq_lur = NULL;
                dtrq->dtrq_lur_size = llog_update_record_size(lur);
                OBD_ALLOC_LARGE(dtrq->dtrq_lur, dtrq->dtrq_lur_size);
                dtrq->dtrq_lur = NULL;
                dtrq->dtrq_lur_size = llog_update_record_size(lur);
                OBD_ALLOC_LARGE(dtrq->dtrq_lur, dtrq->dtrq_lur_size);